Repeated /chat/new-channel notifications

While playing around with the message bus, I saw that every time I receive a chat message, I get a /chat/new-channel notification with it. This happens even when both users have the chat open.

[{"global_id":61583779,"message_id":134,"channel":"/chat/4","data":{"chat_message":{"id":6,"message":"nice to see you too","cooked":"<p>nice to see you too</p>","created_at":"2023-05-24T14:07:02.800Z","excerpt":"nice to see you too","available_flags":[],"thread_title":null,"chat_channel_id":4,"user":{"id":152,"username":"testuser","name":"testuser","avatar_template":"https://avatars.discourse-cdn.com/v4/letter/t/e495f1/{size}.png","moderator":false,"admin":false,"staff":false,"new_user":false,"primary_group_name":null,"assign_icon":"user-plus","assign_path":"/u/testuser/activity/assigned"},"chat_webhook_event":null,"uploads":[]},"type":"sent","staged_id":"66122c8d-ad8e-4754-b04a-e0ff75c4e898","staged_thread_id":null}}]
|
[{"global_id":61583780,"message_id":69,"channel":"/chat/4/new-messages","data":{"channel_id":4,"message_id":6,"user_id":152,"username":"testuser","thread_id":null}}]
|
[{"global_id":61583781,"message_id":20767,"channel":"/chat/new-channel","data":{"channel":{"id":4,"allow_channel_wide_mentions":true,"chatable":{"id":1,"users":[{"id":152,"username":"testuser","name":"testuser","avatar_template":"https://avatars.discourse-cdn.com/v4/letter/t/e495f1/{size}.png","custom_fields":{},"assign_icon":"user-plus","assign_path":"/u/testuser/activity/assigned"}]},"chatable_id":1,"chatable_type":"DirectMessage","chatable_url":null,"title":"@testuser","slug":null,"last_message_sent_at":"2023-05-24 14:07:02 UTC","status":"open","memberships_count":0,"current_user_membership":{"following":true,"muted":false,"desktop_notification_level":"always","mobile_notification_level":"always","chat_channel_id":4,"last_read_message_id":5},"meta":{"message_bus_last_ids":{"channel_message_bus_last_id":134,"new_messages":69,"new_mentions":0},"can_join_chat_channel":true},"threading_enabled":false}}}]
|

and then when another message is sent

[{"global_id":61583803,"message_id":135,"channel":"/chat/4","data":{"chat_message":{"id":7,"message":"and another message","cooked":"<p>and another message</p>","created_at":"2023-05-24T14:08:01.128Z","excerpt":"and another message","available_flags":[],"thread_title":null,"chat_channel_id":4,"user":{"id":152,"username":"testuser","name":"testuser","avatar_template":"https://avatars.discourse-cdn.com/v4/letter/t/e495f1/{size}.png","moderator":false,"admin":false,"staff":false,"new_user":false,"primary_group_name":null,"assign_icon":"user-plus","assign_path":"/u/testuser/activity/assigned"},"chat_webhook_event":null,"uploads":[]},"type":"sent","staged_id":"67a062f9-28de-42c8-a037-c3d272584c3d","staged_thread_id":null}}]
|
[{"global_id":61583804,"message_id":70,"channel":"/chat/4/new-messages","data":{"channel_id":4,"message_id":7,"user_id":152,"username":"testuser","thread_id":null}}]
|
[{"global_id":61583805,"message_id":20768,"channel":"/chat/new-channel","data":{"channel":{"id":4,"allow_channel_wide_mentions":true,"chatable":{"id":1,"users":[{"id":152,"username":"testuser","name":"testuser","avatar_template":"https://avatars.discourse-cdn.com/v4/letter/t/e495f1/{size}.png","custom_fields":{},"assign_icon":"user-plus","assign_path":"/u/testuser/activity/assigned"}]},"chatable_id":1,"chatable_type":"DirectMessage","chatable_url":null,"title":"@testuser","slug":null,"last_message_sent_at":"2023-05-24 14:08:01 UTC","status":"open","memberships_count":0,"current_user_membership":{"following":true,"muted":false,"desktop_notification_level":"always","mobile_notification_level":"always","chat_channel_id":4,"last_read_message_id":6},"meta":{"message_bus_last_ids":{"channel_message_bus_last_id":135,"new_messages":70,"new_mentions":0},"can_join_chat_channel":true},"threading_enabled":false}}}]
|

The source seems to imply that a new-channel event is sent every time when a message is created.

And of course, if this is a complete misunderstanding on my side on how things should work, feel free to laugh at me while you move this to support :wink:

5 Likes

I will investigate this tomorrow thanks. We have been movings lots of things around subscriptions lately, it’s possible we have regressed on this.

3 Likes

So I had a quick look already, I don’t think it’s a regression, however, this is now something we could probably get rid off as we have automatic logic to get the channel if not present (simply put: if not in your sidebar).

It would have been harder few months ago.

Will double check and try to finish this tomorrow, good call thanks :+1: This was on a list of things I have to check to allow stricter number of channels in the sidebar, so that’s one less thing :rocket:

4 Likes

Ok I just merged this, it should now only send the new channel event when the channel is not in your sidebar.

3 Likes