FIX: Add MessageBust.last_id to chat channel subscriptions (#19255)
This commit adds variousMessageBus.last_ids to serializer payloads for chat channels and the chat view (for chat live pane) so we can use those IDs when subscribing to MessageBus channels from chat. This allows us to ensure that any messages created between the server being hit and the UI loaded and subscribing end up being delivered to the client, rather than just silently dropped. This commit also fixes an issue where we were subscribing to the new-messages and new-mentions MessageBus channels multiple times when following/unfollowing a channel multiple times.
This commit is contained in:
@@ -137,6 +137,11 @@ RSpec.describe Chat::ChatController do
|
||||
expect(reactions[smile_emoji]["reacted"]).to be false
|
||||
end
|
||||
|
||||
it "sends the last message bus id for the channel" do
|
||||
get "/chat/#{chat_channel.id}/messages.json", params: { page_size: page_size }
|
||||
expect(response.parsed_body["meta"]["channel_message_bus_last_id"]).not_to eq(nil)
|
||||
end
|
||||
|
||||
describe "scrolling to the past" do
|
||||
it "returns the correct messages in created_at, id order" do
|
||||
get "/chat/#{chat_channel.id}/messages.json",
|
||||
@@ -1030,7 +1035,8 @@ RSpec.describe Chat::ChatController do
|
||||
}.to change {
|
||||
user.notifications.where(notification_type: Notification.types[:chat_invitation]).count
|
||||
}.by(1)
|
||||
notification = user.notifications.where(notification_type: Notification.types[:chat_invitation]).last
|
||||
notification =
|
||||
user.notifications.where(notification_type: Notification.types[:chat_invitation]).last
|
||||
parsed_data = JSON.parse(notification[:data])
|
||||
expect(parsed_data["chat_channel_title"]).to eq(chat_channel.title(user))
|
||||
expect(parsed_data["chat_channel_slug"]).to eq(chat_channel.slug)
|
||||
|
||||
Reference in New Issue
Block a user