mirror of
https://github.com/discourse/discourse-ai.git
synced 2025-06-26 09:32:40 +00:00
FEATURE: Triage can hide posts after adding them to the review queue (#1348)
This commit is contained in:
parent
de0625571b
commit
2fb691cba8
@ -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:
|
||||
|
@ -5,6 +5,10 @@ module DiscourseAi
|
||||
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",
|
||||
|
@ -148,6 +148,11 @@ module DiscourseAi
|
||||
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
|
||||
|
@ -128,6 +128,26 @@ describe DiscourseAi::Automation::LlmTriage do
|
||||
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,
|
||||
|
Loading…
x
Reference in New Issue
Block a user