FIX: Don't notify of post deletion when agreeing with automatic flags. (#19241)

This commit is contained in:
Roman Rizzi
2022-11-29 14:18:07 -03:00
committed by GitHub
parent aab4ea1849
commit 88a0384d43
2 changed files with 18 additions and 4 deletions

View File

@@ -330,6 +330,12 @@ class PostDestroyer
allowed_user = @user.human? && @user.staff?
return unless allowed_user && rs = reviewable.reviewable_scores.order('created_at DESC').first
# ReviewableScore#types is a superset of PostActionType#flag_types.
# If the reviewable score type is not on the latter, it means it's not a flag by a user and
# must be an automated flag like `needs_approval`. There's no flag reason for these kind of types.
flag_type = PostActionType.flag_types[rs.reviewable_score_type]
return unless flag_type
notify_responders = options[:notify_responders]
Jobs.enqueue(
@@ -341,7 +347,7 @@ class PostDestroyer
flagged_post_response_raw_content: @post.raw,
url: notify_responders ? options[:parent_post].url : @post.url,
flag_reason: I18n.t(
"flag_reasons#{".responder" if notify_responders}.#{PostActionType.types[rs.reviewable_score_type]}",
"flag_reasons#{".responder" if notify_responders}.#{flag_type}",
locale: SiteSetting.default_locale,
base_path: Discourse.base_path
)