This repository was archived by the owner on Jul 22, 2025. It is now read-only.
generated from discourse/discourse-plugin-skeleton
-
Notifications
You must be signed in to change notification settings - Fork 40
FEATURE: allow llm triage to automatically hide posts #820
Merged
Merged
Changes from 1 commit
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -13,11 +13,12 @@ def self.handle( | |
| canned_reply: nil, | ||
| canned_reply_user: nil, | ||
| hide_topic: nil, | ||
| hide_post: nil, | ||
| flag_post: nil, | ||
| automation: nil | ||
| ) | ||
| if category_id.blank? && tags.blank? && canned_reply.blank? && hide_topic.blank? && | ||
| flag_post.blank? | ||
| flag_post.blank? && hide_post.blank? | ||
| raise ArgumentError, "llm_triage: no action specified!" | ||
| end | ||
|
|
||
|
|
@@ -82,6 +83,25 @@ def self.handle( | |
| force_review: true, | ||
| ) | ||
| end | ||
|
|
||
| # note this does not notify user of the action | ||
| # as it is mainly used for spam where notification | ||
| # is not needed. | ||
| # we will need another flag if we want to notify | ||
| if hide_post | ||
| reason ||= | ||
| ( | ||
| if post.hidden_at | ||
| Post.hidden_reasons[:flag_threshold_reached_again] | ||
| else | ||
| Post.hidden_reasons[:flag_threshold_reached] | ||
| end | ||
| ) | ||
|
|
||
| post.update!(hidden: true, hidden_at: Time.zone.now, hidden_reason_id: reason) | ||
|
|
||
| post.topic.update!(visible: false) if post.post_number == 1 | ||
|
||
| end | ||
| end | ||
| end | ||
| end | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I feel like you could lean on
post.hide!in core here https://github.com/discourse/discourse/blob/c446caa6e9f68be24bdc3d0ff0b33e0ddc2130c6/app/models/post.rb#L604-L604 since it's doing the same thing the code does here, and give itPostActionType.types[:spam]as thepost_action_type_id. I think the only thing you would need to do is your additional topic visibility update.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also generally I am not sure this with the
flag_post/needs_reviewpart above is quite the correct way to go, seems like going through thePostActionCreatorand indicating that it's for spam :This auto-hides if necessary and also does the
needs_review!on the flagged post. If we did this thehide_topicandhide_postoptions might not be necessary for the automation.It feels like we are not relying on the review queue logic to properly mark this as spam, and since this is the case if you mark the reviewable invalid / disagree the post might not get unhidden as you already indicated, and there is no testing for this.
The review queue logic is super hard to follow though so I understand the appeal of doing it in a more basic way here, I just think it may cause other problems doing it this way. This may solve the customer's immediate problem but I am not sure it's maintanable. Maybe we can do some further digging first and try out
PostActionCreatorbefore merging this?Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Might also be worth having 2 options:
And getting rid of hide_post and hide_topic options
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
its tricky cause hide_topic is used for automations that do not flag, we can not get rid of it. But I can try to see if I can get PostActionCreator going and allow people to select "send to review/mark as spam/don't involve review" ... its so complicated :(
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Worth mentioning that back on the old toxicity / nsfw days we used PostActionCreator and had problems because people don't always want the users to be aware that they were flagged / auto-hidden, which happens on both public topics and PMs.
This is the main reason we now only send to the queue without all the usual flag adjacent side effects. But that also means that if people now want it, it needs to be an option much like what @martin-brennan described.