FIX: Update client lastReadMessageId on trashed message (#21697)

Followup ae3231e140, when a
message is trashed we already update the lastReadMessageId of
all users in the channel to the latest non-deleted message on
the server side. However we didn't propagate this to the client,
so in some cases when we did the following:

1. Delete the last message in the channel
2. Switch to another channel
3. Switch back to the original

We would get a 404 error from the target message ID being looked
up still being the old lastReadMessageId (now deleted) for the
user's channel membership.

All we need to do is send the last not-deleted message ID for
the channel (or thread) to all the member users.
This commit is contained in:
Martin Brennan
2023-05-23 18:32:19 +02:00
committed by GitHub
parent bce56d843c
commit c908eeacc9
9 changed files with 102 additions and 1 deletions
+13 -1
View File
@@ -137,10 +137,22 @@ module Chat
def self.publish_delete!(chat_channel, chat_message)
message_bus_targets = calculate_publish_targets(chat_channel, chat_message)
latest_not_deleted_message_id =
if chat_message.thread_reply? && chat_channel.threading_enabled &&
SiteSetting.enable_experimental_chat_threaded_discussions
chat_message.thread.latest_not_deleted_message_id
else
chat_channel.latest_not_deleted_message_id
end
publish_to_targets!(
message_bus_targets,
chat_channel,
{ type: "delete", deleted_id: chat_message.id, deleted_at: chat_message.deleted_at },
{
type: "delete",
deleted_id: chat_message.id,
deleted_at: chat_message.deleted_at,
latest_not_deleted_message_id: latest_not_deleted_message_id,
},
)
end