FEATURE: Display the Watched Words that caused a post to be flagged. (#31435)

When a post is flagged due to matching watched words, it can be difficult to know what you're looking for, particularly if you have a lot of watched words built up over a long period of time.

This change stores the list of matched words, and later displays them in the review queue, listing which Watched Words were responsible for the flag. Because watched words can change, this is recorded at the time the post is flagged. For posts that were flagged prior to this feature landing, it tries to guess the relevant words based on the current Watched Words set.
This commit is contained in:
Gary Pendergast
2025-03-04 17:22:12 +11:00
committed by GitHub
parent b329eac79a
commit 9abeff460c
10 changed files with 137 additions and 8 deletions

View File

@ -14,7 +14,8 @@ class PostActionCreator
message: nil,
created_at: nil,
reason: nil,
silent: false
silent: false,
context: nil
)
new(
created_by,
@ -24,6 +25,7 @@ class PostActionCreator
created_at: created_at,
reason: reason,
silent: silent,
context: context,
).perform
end
@ -50,7 +52,8 @@ class PostActionCreator
created_at: nil,
queue_for_review: false,
reason: nil,
silent: false
silent: false,
context: nil
)
@created_by = created_by
@created_at = created_at || Time.zone.now
@ -73,6 +76,8 @@ class PostActionCreator
@reason = "queued_by_staff" if reason.nil? && @queue_for_review
@silent = silent
@context = context
end
def post_can_act?
@ -403,6 +408,7 @@ class PostActionCreator
meta_topic_id: @meta_post&.topic_id,
reason: @reason,
force_review: trusted_spam_flagger?,
context: @context,
)
end