FIX: Make chat tracking payload backwards compatible ()

Followup cab4b2cfba20ea03adb14e994c145e15c5ae8a2c,
this was causing client JS errors because the old version
of the client was expecting the old keys, but the new
ruby version of the app was sending different keys via
the MessageBus payload. We can remove this in a couple
of weeks.
This commit is contained in:
Martin Brennan 2023-03-28 12:56:32 +10:00 committed by GitHub
parent cb92ea3c2b
commit c912c58d6c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -129,7 +129,14 @@ module Chat
end
def self.publish_user_tracking_state(user, chat_channel_id, chat_message_id)
data = { channel_id: chat_channel_id, last_read_message_id: chat_message_id }.merge(
data = {
channel_id: chat_channel_id,
last_read_message_id: chat_message_id,
# TODO (martin) Remove old chat_channel_id and chat_message_id keys here once deploys have cycled,
# this will prevent JS errors from clients that are looking for the old payload.
chat_channel_id: chat_channel_id,
chat_message_id: chat_message_id,
}.merge(
Chat::ChannelUnreadsQuery.call(channel_ids: [chat_channel_id], user_id: user.id).first.to_h,
)