Skip to content
This repository was archived by the owner on Jul 22, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions config/locales/server.en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ en:
ai:
flag_types:
review: "Add post to review queue"
review_hide: "Add post to review queue and hide post"
spam: "Flag as spam and hide post"
spam_silence: "Flag as spam, hide post and silence user"
scriptables:
Expand Down
4 changes: 4 additions & 0 deletions lib/automation.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ module Automation
def self.flag_types
[
{ id: "review", translated_name: I18n.t("discourse_automation.ai.flag_types.review") },
{
id: "review_hide",
translated_name: I18n.t("discourse_automation.ai.flag_types.review_hide"),
},
{ id: "spam", translated_name: I18n.t("discourse_automation.ai.flag_types.spam") },
{
id: "spam_silence",
Expand Down
5 changes: 5 additions & 0 deletions lib/automation/llm_triage.rb
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,11 @@ def self.handle(
reason: score_reason,
force_review: true,
)

# We cannot do this through the PostActionCreator because hiding a post is reserved for auto action flags.
# Those flags are off_topic, inappropiate, and spam. We want a more generic type for triage, so none of those
# fit here.
post.hide!(PostActionType.types[:notify_moderators]) if flag_type == :review_hide
end
end
end
Expand Down
20 changes: 20 additions & 0 deletions spec/lib/modules/automation/llm_triage_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,26 @@ def triage(**args)
expect(post.user.silenced?).to eq(true)
end

it "can handle flag + hide" do
DiscourseAi::Completions::Llm.with_prepared_responses(["bad"]) do
triage(
post: post,
model: "custom:#{llm_model.id}",
system_prompt: "test %%POST%%",
search_for_text: "bad",
flag_post: true,
flag_type: :review_hide,
automation: nil,
)
end

reviewable = ReviewablePost.last

expect(reviewable.target).to eq(post)
expect(reviewable.reviewable_scores.first.reason).to include("bad")
expect(post.reload).to be_hidden
end

it "does not silence the user if the flag fails" do
Fabricate(
:post_action,
Expand Down
Loading