mirror of
https://github.com/discourse/discourse.git
synced 2025-06-03 02:48:28 +08:00
FIX: Don't publish PM archive events to acting user. (#14291)
When a user archives a personal message, they are redirected back to the inbox and will refresh the list of the topics for the given filter. Publishing an event to the user results in an incorrect incoming message because the list of topics has already been refreshed. This does mean that if a user has two tabs opened, the non-active tab will not receive the incoming message but at this point we do not think the technical trade-offs are worth it to support this feature. We basically have to somehow exclude a client from an incoming message which is not easy to do. Follow-up to fc1fd1b41689694b3916dc4e10605eb9b8bb89b7
This commit is contained in:

committed by
GitHub

parent
2215cc2547
commit
bc23dcd30b
@ -168,26 +168,17 @@ describe PrivateMessageTopicTrackingState do
|
||||
end
|
||||
end
|
||||
|
||||
describe '.publish_user_archived' do
|
||||
it 'should publish the right message_bus message' do
|
||||
message = MessageBus.track_publish(described_class.user_channel(user.id)) do
|
||||
described_class.publish_user_archived(private_message, user.id)
|
||||
end.first
|
||||
|
||||
data = message.data
|
||||
|
||||
expect(data['topic_id']).to eq(private_message.id)
|
||||
expect(data['message_type']).to eq(described_class::ARCHIVE_MESSAGE_TYPE)
|
||||
end
|
||||
end
|
||||
|
||||
describe '.publish_group_archived' do
|
||||
it 'should publish the right message_bus message' do
|
||||
user_3 = Fabricate(:user)
|
||||
group.add(user_3)
|
||||
|
||||
messages = MessageBus.track_publish do
|
||||
described_class.publish_group_archived(group_message, group.id)
|
||||
described_class.publish_group_archived(
|
||||
topic: group_message,
|
||||
group_id: group.id,
|
||||
acting_user_id: user_3.id
|
||||
)
|
||||
end
|
||||
|
||||
expect(messages.map(&:channel)).to contain_exactly(
|
||||
@ -201,6 +192,7 @@ describe PrivateMessageTopicTrackingState do
|
||||
expect(data['message_type']).to eq(described_class::GROUP_ARCHIVE_MESSAGE_TYPE)
|
||||
expect(data['topic_id']).to eq(group_message.id)
|
||||
expect(data['payload']['group_ids']).to contain_exactly(group.id)
|
||||
expect(data['payload']['acting_user_id']).to eq(user_3.id)
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -20,11 +20,7 @@ describe UserArchivedMessage do
|
||||
UserArchivedMessage.archive!(user.id, private_message)
|
||||
|
||||
expect do
|
||||
messages = MessageBus.track_publish(PrivateMessageTopicTrackingState.user_channel(user.id)) do
|
||||
UserArchivedMessage.move_to_inbox!(user.id, private_message)
|
||||
end
|
||||
|
||||
expect(messages.present?).to eq(true)
|
||||
UserArchivedMessage.move_to_inbox!(user.id, private_message)
|
||||
end.to change { private_message.message_archived?(user) }.from(true).to(false)
|
||||
end
|
||||
|
||||
@ -40,14 +36,4 @@ describe UserArchivedMessage do
|
||||
end
|
||||
end
|
||||
|
||||
describe '.archive' do
|
||||
it 'archives message correctly' do
|
||||
messages = MessageBus.track_publish(PrivateMessageTopicTrackingState.user_channel(user.id)) do
|
||||
UserArchivedMessage.archive!(user.id, private_message)
|
||||
end
|
||||
|
||||
expect(messages.present?).to eq(true)
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
Reference in New Issue
Block a user