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:
Alan Guo Xiang Tan
2021-09-10 09:20:50 +08:00
committed by GitHub
parent 2215cc2547
commit bc23dcd30b
12 changed files with 117 additions and 114 deletions

View File

@ -1134,6 +1134,26 @@ describe PostCreator do
expect(target_user1.notifications.count).to eq(1)
expect(target_user2.notifications.count).to eq(1)
GroupArchivedMessage.create!(group: group, topic: post.topic)
message = MessageBus.track_publish(
PrivateMessageTopicTrackingState.group_channel(group.id)
) do
PostCreator.create!(user,
raw: "this is a reply to the group message",
topic_id: post.topic_id
)
end.first
expect(message.data["message_type"]).to eq(
PrivateMessageTopicTrackingState::GROUP_ARCHIVE_MESSAGE_TYPE
)
expect(message.data["payload"]["acting_user_id"]).to eq(user.id)
expect(GroupArchivedMessage.exists?(group: group, topic: post.topic))
.to eq(false)
end
end