diff --git a/plugins/chat/app/jobs/regular/chat/notify_mentioned.rb b/plugins/chat/app/jobs/regular/chat/notify_mentioned.rb index 5b472be3cd7..dc1defcd2a0 100644 --- a/plugins/chat/app/jobs/regular/chat/notify_mentioned.rb +++ b/plugins/chat/app/jobs/regular/chat/notify_mentioned.rb @@ -15,6 +15,7 @@ module Jobs @creator = @chat_message.user @chat_channel = @chat_message.chat_channel + @is_direct_message_channel = @chat_channel.direct_message_channel? @already_notified_user_ids = args[:already_notified_user_ids] || [] user_ids_to_notify = args[:to_notify_ids_map] || {} user_ids_to_notify.each { |mention_type, ids| process_mentions(ids, mention_type.to_sym) } @@ -37,7 +38,7 @@ module Jobs chat_message_id: @chat_message.id, chat_channel_id: @chat_channel.id, mentioned_by_username: @creator.username, - is_direct_message_channel: @chat_channel.direct_message_channel?, + is_direct_message_channel: @is_direct_message_channel, } data[:chat_thread_id] = @chat_message.thread_id if @chat_message.in_thread? @@ -76,6 +77,8 @@ module Jobs tag: ::Chat::Notifier.push_notification_tag(:mention, @chat_channel.id), excerpt: @chat_message.push_notification_excerpt, post_url: post_url, + channel_id: @chat_channel.id, + is_direct_message_channel: @is_direct_message_channel, } translation_prefix = diff --git a/plugins/chat/app/jobs/regular/chat/notify_watching.rb b/plugins/chat/app/jobs/regular/chat/notify_watching.rb index ac05cf1ccc2..c11afafefa5 100644 --- a/plugins/chat/app/jobs/regular/chat/notify_watching.rb +++ b/plugins/chat/app/jobs/regular/chat/notify_watching.rb @@ -81,6 +81,7 @@ module Jobs tag: ::Chat::Notifier.push_notification_tag(:message, @chat_channel.id), excerpt: @chat_message.push_notification_excerpt, channel_id: @chat_channel.id, + is_direct_message_channel: @is_direct_message_channel, } if @chat_message.in_thread? && !membership.muted? diff --git a/plugins/chat/assets/javascripts/discourse/initializers/chat-audio.js b/plugins/chat/assets/javascripts/discourse/initializers/chat-audio.js index 0decff95833..cd64b85c099 100644 --- a/plugins/chat/assets/javascripts/discourse/initializers/chat-audio.js +++ b/plugins/chat/assets/javascripts/discourse/initializers/chat-audio.js @@ -40,7 +40,7 @@ export default { if ( indicatorType === INDICATOR_PREFERENCES.dm_and_mentions && - !data.isDirectMessageChannel && + !data.is_direct_message_channel && !isMention ) { return; diff --git a/plugins/chat/assets/javascripts/discourse/services/chat-notification-manager.js b/plugins/chat/assets/javascripts/discourse/services/chat-notification-manager.js index 09ef8742a0a..8c253066d84 100644 --- a/plugins/chat/assets/javascripts/discourse/services/chat-notification-manager.js +++ b/plugins/chat/assets/javascripts/discourse/services/chat-notification-manager.js @@ -1,4 +1,3 @@ -import { action } from "@ember/object"; import Service, { service } from "@ember/service"; import { alertChannel, @@ -146,13 +145,6 @@ export default class ChatNotificationManager extends Service { } } - @action - async fetchChannel(channelId) { - return await this.chatChannelsManager.find(channelId, { - fetchIfNotFound: false, - }); - } - @bind async onMessage(data) { if (data.channel_id === this.chat.activeChannel?.id) { @@ -160,12 +152,6 @@ export default class ChatNotificationManager extends Service { } if (this.site.desktopView) { - const channel = await this.fetchChannel(data.channel_id); - - if (channel) { - data.isDirectMessageChannel = channel.isDirectMessageChannel ?? false; - } - return onDesktopNotification( data, this.siteSettings, diff --git a/plugins/chat/spec/jobs/regular/chat/notify_mentioned_spec.rb b/plugins/chat/spec/jobs/regular/chat/notify_mentioned_spec.rb index f1238562ecb..52bbc71a843 100644 --- a/plugins/chat/spec/jobs/regular/chat/notify_mentioned_spec.rb +++ b/plugins/chat/spec/jobs/regular/chat/notify_mentioned_spec.rb @@ -257,6 +257,8 @@ describe Jobs::Chat::NotifyMentioned do excerpt: message.push_notification_excerpt, post_url: "/chat/c/#{public_channel.slug}/#{public_channel.id}/#{message.id}", translated_title: payload_translated_title, + channel_id: public_channel.id, + is_direct_message_channel: false, }, ) diff --git a/plugins/chat/spec/system/user_menu_notifications/sidebar_spec.rb b/plugins/chat/spec/system/user_menu_notifications/sidebar_spec.rb index 3fa514dedd0..a46e881651b 100644 --- a/plugins/chat/spec/system/user_menu_notifications/sidebar_spec.rb +++ b/plugins/chat/spec/system/user_menu_notifications/sidebar_spec.rb @@ -63,7 +63,7 @@ RSpec.describe "User menu notifications | sidebar", type: :system do end expect(find("#quick-access-chat-notifications")).to have_link( I18n.t("js.notifications.popup.direct_message_chat_mention.direct"), - href: "/discuss/chat/c/#{other_user.username}/#{dm_channel_1.id}/#{message.id}", + href: "/discuss/chat/c/-/#{dm_channel_1.id}/#{message.id}", ) end end diff --git a/plugins/chat/test/javascripts/unit/lib/chat-audio-test.js b/plugins/chat/test/javascripts/unit/lib/chat-audio-test.js index da34453c83b..f51ade2eeaf 100644 --- a/plugins/chat/test/javascripts/unit/lib/chat-audio-test.js +++ b/plugins/chat/test/javascripts/unit/lib/chat-audio-test.js @@ -85,7 +85,7 @@ module("Discourse Chat | Unit | chat-audio", function (hooks) { this.currentUser.user_option.chat_header_indicator_preference = "dm_and_mentions"; - this.handleNotification({ isDirectMessageChannel: true }); + this.handleNotification({ is_direct_message_channel: true }); assert.ok(this.playStub.calledOnce); }); @@ -94,7 +94,7 @@ module("Discourse Chat | Unit | chat-audio", function (hooks) { this.currentUser.user_option.chat_header_indicator_preference = "dm_and_mentions"; - this.handleNotification({ isDirectMessageChannel: false }); + this.handleNotification({ is_direct_message_channel: false }); assert.ok(this.playStub.notCalled); });