Skip to content
This repository was archived by the owner on Jul 22, 2025. It is now read-only.

Commit 54e0fe5

Browse files
DEV: Review fixes
1 parent 39dcfab commit 54e0fe5

File tree

6 files changed

+22
-3
lines changed

6 files changed

+22
-3
lines changed

app/models/ai_spam_log.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ class AiSpamLog < ActiveRecord::Base
1919
# payload :string(20000) default(""), not null
2020
# created_at :datetime not null
2121
# updated_at :datetime not null
22+
# error :string(3000)
2223
#
2324
# Indexes
2425
#
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# frozen_string_literal: true
2+
class AddErrorToAiSpamLog < ActiveRecord::Migration[7.2]
3+
def change
4+
add_column :ai_spam_logs, :error, :string, limit: 3000
5+
end
6+
end

lib/ai_moderation/spam_scanner.rb

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -414,6 +414,11 @@ def self.handle_spam(post, log)
414414

415415
# silencer will not hide tl1 posts, so we do this here
416416
hide_post(post)
417+
else
418+
log.update!(
419+
error:
420+
"unable to flag post as spam, post action failed for post #{post.id} with error: '#{result.errors.full_messages.join(", ")}'",
421+
)
417422
end
418423
end
419424

lib/automation/llm_triage.rb

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,8 +97,14 @@ def self.handle(
9797
queue_for_review: true,
9898
).perform
9999

100-
if flag_type == :spam_silence && result.success?
101-
SpamRule::AutoSilence.new(post.user, post).silence_user
100+
if flag_type == :spam_silence
101+
if result.success?
102+
SpamRule::AutoSilence.new(post.user, post).silence_user
103+
else
104+
Rails.logger.warn(
105+
"llm_triage: unable to flag post as spam, post action failed for #{post.id} with error: '#{result.errors.full_messages.join(",")}'",
106+
)
107+
end
102108
end
103109
else
104110
reviewable =

spec/lib/modules/ai_moderation/spam_scanner_spec.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -308,6 +308,7 @@
308308
log = AiSpamLog.find_by(post: post)
309309

310310
expect(log.reviewable).to be_nil
311+
expect(log.error).to match(/unable to flag post as spam/)
311312
expect(post.user.reload).not_to be_silenced
312313
expect(post.topic.reload).to be_visible
313314
end

spec/lib/modules/automation/llm_triage_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ def triage(**args)
147147
)
148148
end
149149

150-
expect(post.user).not_to be_silenced
150+
expect(post.user.reload).not_to be_silenced
151151
end
152152

153153
it "can handle garbled output from LLM" do

0 commit comments

Comments
 (0)