FIX: Create a reviewable when flagging a chat message for 'something else' (#23264)

In #22914 we added a fix to stop creating reviewables in the review queue when flagging a chat message and choosing the "notify user" option. By mistake we also stopped creating it when selecting the "something else" option.

This change makes it so a "something else" flag once again creates a reviewable. (Same behaviour as posts.)
This commit is contained in:
Ted Johansson 2023-08-25 17:38:27 +08:00 committed by GitHub
parent c5ac500181
commit 5d5e919530
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 13 additions and 4 deletions

View File

@ -13,8 +13,10 @@ module Chat
def flag_message(chat_message, guardian, flag_type_id, opts = {})
result = { success: false, errors: [] }
is_notify_type =
ReviewableScore.types.slice(:notify_user, :notify_moderators).values.include?(flag_type_id)
is_notify_user_type = ReviewableScore.types.slice(:notify_user).values.include?(flag_type_id)
is_notify_moderators_type =
ReviewableScore.types.slice(:notify_moderators).values.include?(flag_type_id)
is_notify_type = is_notify_user_type || is_notify_moderators_type
is_dm = chat_message.chat_channel.direct_message_channel?
raise Discourse::InvalidParameters.new(:flag_type) if is_dm && is_notify_type
@ -46,7 +48,7 @@ module Chat
queued_for_review = !!ActiveRecord::Type::Boolean.new.deserialize(opts[:queue_for_review])
if !is_notify_type
if !is_notify_user_type
reviewable =
Chat::ReviewableMessage.needs_review!(
created_by: guardian.user,
@ -77,7 +79,7 @@ module Chat
result.tap do |r|
r[:success] = true
r[:reviewable] = reviewable if !is_notify_type
r[:reviewable] = reviewable if !is_notify_user_type
end
end

View File

@ -246,6 +246,13 @@ describe Chat::ReviewQueue do
)
end
it "creates a reviewable" do
queue.flag_message(message, guardian, ReviewableScore.types[:notify_moderators])
reviewable = Chat::ReviewableMessage.find_by(target: message)
expect(reviewable).to be_present
end
it "ignores the is_warning flag when notifying moderators" do
queue.flag_message(
message,