mirror of
https://github.com/discourse/discourse.git
synced 2025-01-30 23:30:45 +08:00
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:
parent
c5ac500181
commit
5d5e919530
|
@ -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
|
||||
|
||||
|
|
|
@ -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,
|
||||
|
|
Loading…
Reference in New Issue
Block a user