From 7352ba1fe8cdf1df31786aeb87153503a828f888 Mon Sep 17 00:00:00 2001 From: Joffrey JAFFEUX Date: Fri, 16 Jun 2023 03:04:59 +0200 Subject: [PATCH] FIX: direct message channels can be flagged (#22134) The events leading to this mistake are unclear but we decided few months ago to make direct messages NOT flaggable and even wrote a spec for this, when we actually support flagging of direct messages. This commit ensures it will show for direct messages channels and inverses the existing spec. --- .../javascripts/discourse/lib/chat-message-interactor.js | 1 - plugins/chat/spec/system/flag_message_spec.rb | 4 ++-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/plugins/chat/assets/javascripts/discourse/lib/chat-message-interactor.js b/plugins/chat/assets/javascripts/discourse/lib/chat-message-interactor.js index 9276cef9536..bc5da78b96a 100644 --- a/plugins/chat/assets/javascripts/discourse/lib/chat-message-interactor.js +++ b/plugins/chat/assets/javascripts/discourse/lib/chat-message-interactor.js @@ -122,7 +122,6 @@ export default class ChatMessageInteractor { get canFlagMessage() { return ( this.currentUser?.id !== this.message?.user?.id && - !this.message.channel?.isDirectMessageChannel && this.message?.userFlagStatus === undefined && this.message.channel?.canFlag && !this.message?.chatWebhookEvent && diff --git a/plugins/chat/spec/system/flag_message_spec.rb b/plugins/chat/spec/system/flag_message_spec.rb index 72fe229a818..f42bada31f7 100644 --- a/plugins/chat/spec/system/flag_message_spec.rb +++ b/plugins/chat/spec/system/flag_message_spec.rb @@ -34,11 +34,11 @@ RSpec.describe "Flag message", type: :system do fab!(:dm_channel_1) { Fabricate(:direct_message_channel, users: [current_user]) } fab!(:message_1) { Fabricate(:chat_message, chat_channel: dm_channel_1) } - it "doesn’t allow to flag a message" do + it "allows to flag a message" do chat.visit_channel(dm_channel_1) channel.expand_message_actions(message_1) - expect(page).to have_no_css("[data-value='flag']") + expect(page).to have_css("[data-value='flag']") end end end