A platform for community discussion. Free, open, simple.
FIX: chat message bookmark title update (#35788)
David Battersby772d23faa392
diff --git a/plugins/chat/config/locales/server.en.yml b/plugins/chat/config/locales/server.en.ymlindex 577e519ab65..183c24eefef 100644--- a/plugins/chat/config/locales/server.en.yml+++ b/plugins/chat/config/locales/server.en.yml@@ -193,7 +193,8 @@ en:is_already_in_use: "is already in use"bookmarkable:- notification_title: "message in %{channel_name}"+ notification_title_channel: "message in %{channel_name}"+ notification_title_direct_message: "message with %{channel_name}"personal_chat: "personal chat"diff --git a/plugins/chat/lib/chat/message_bookmarkable.rb b/plugins/chat/lib/chat/message_bookmarkable.rbindex 8a779469b70..f603dc62ff3 100644--- a/plugins/chat/lib/chat/message_bookmarkable.rb+++ b/plugins/chat/lib/chat/message_bookmarkable.rb@@ -44,13 +44,23 @@ module Chatenddef self.reminder_handler(bookmark)+ channel = bookmark.bookmarkable.chat_channel+ channel_type =+ (+ if channel.direct_message_channel? && !channel.direct_message_group?+ "direct_message"+ else+ "channel"+ end+ )+send_reminder_notification(bookmark,data: {title:I18n.t(- "chat.bookmarkable.notification_title",- channel_name: bookmark.bookmarkable.chat_channel.title(bookmark.user),+ "chat.bookmarkable.notification_title_#{channel_type}",+ channel_name: channel.title(bookmark.user),),bookmarkable_url: bookmark.bookmarkable.url,},diff --git a/plugins/chat/spec/lib/chat/message_bookmarkable_spec.rb b/plugins/chat/spec/lib/chat/message_bookmarkable_spec.rbindex 49f57f0ff3d..da5e68d8250 100644--- a/plugins/chat/spec/lib/chat/message_bookmarkable_spec.rb+++ b/plugins/chat/spec/lib/chat/message_bookmarkable_spec.rb@@ -10,6 +10,8 @@ describe Chat::MessageBookmarkable dofab!(:category_channel) { Fabricate(:category_channel, chatable: other_category) }fab!(:private_category) { Fabricate(:private_category, group: Fabricate(:group)) }fab!(:channel, :category_channel)+ fab!(:direct_message)+ fab!(:direct_message_channel) { Fabricate(:direct_message_channel, chatable: direct_message) }before doregister_test_bookmarkable(described_class)@@ -47,7 +49,6 @@ describe Chat::MessageBookmarkable doendit "does not return bookmarks for messages inside direct message chat channels the user cannot access" do- direct_message = Fabricate(:direct_message)channel.update(chatable: direct_message)expect(registered_bookmarkable.perform_list_query(user, guardian)).to eq(nil)Chat::DirectMessageUser.create(user: user, direct_message: direct_message)@@ -137,7 +138,7 @@ describe Chat::MessageBookmarkable do{title:I18n.t(- "chat.bookmarkable.notification_title",+ "chat.bookmarkable.notification_title_channel",channel_name: bookmark1.bookmarkable.chat_channel.title(bookmark1.user),),bookmarkable_url: bookmark1.bookmarkable.url,@@ -149,6 +150,33 @@ describe Chat::MessageBookmarkable do}.to_json,)end++ it "returns the correct notification title for direct messages" do+ message = Fabricate(:chat_message, chat_channel: direct_message_channel)+ bookmark = Fabricate(:bookmark, user: user, bookmarkable: message)++ expect { registered_bookmarkable.send_reminder_notification(bookmark) }.to change {+ Notification.count+ }.by(1)+ notification = user.notifications.last+ expect(notification.notification_type).to eq(Notification.types[:bookmark_reminder])++ expect(notification.data).to eq(+ {+ title:+ I18n.t(+ "chat.bookmarkable.notification_title_direct_message",+ channel_name: direct_message_channel.title(user),+ ),+ bookmarkable_url: bookmark.bookmarkable.url,+ display_username: bookmark.user.username,+ bookmark_name: bookmark.name,+ bookmark_id: bookmark.id,+ bookmarkable_type: bookmark.bookmarkable_type,+ bookmarkable_id: bookmark.bookmarkable_id,+ }.to_json,+ )+ endenddescribe "#can_see?" do