Skip to content
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 .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ MATTERS_PASSPHRASES_SECRET=
MATTERS_SPAM_DETECTION_API_URL=
MATTERS_SHORT_CONTENT_SPAM_DETECTION_API_URL=
MATTERS_COMMENT_SPAM_DETECTION_API_URL=
MATTERS_MOMENT_SPAM_DETECTION_API_URL=
MATTERS_COMMENT_SPAM_AUTO_COLLAPSE=false
MATTERS_AWS_SPAM_SAMPLE_QUEUE_URL=
MATTERS_SPAM_SAMPLE_HASH_SALT=
Expand Down
5 changes: 5 additions & 0 deletions src/common/environment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,11 @@ export const environment = {
process.env.MATTERS_SHORT_CONTENT_SPAM_DETECTION_API_URL || '',
commentSpamDetectionApiUrl:
process.env.MATTERS_COMMENT_SPAM_DETECTION_API_URL || '',
// Dedicated moment spam model (label-fix retrain; fixes the shared short-content
// model's ~90% false-kill on Chinese moments). Falls back to the short-content
// model when unset, so this is a zero-downtime opt-in via env.
momentSpamDetectionApiUrl:
process.env.MATTERS_MOMENT_SPAM_DETECTION_API_URL || '',
// When true, a comment whose spam score reaches the system spam threshold is
// auto-collapsed (folded but still expandable in-thread — "不刪除,只是不再被
// 看見"). Default off so scoring stays observe-only until ops opts in.
Expand Down
5 changes: 4 additions & 1 deletion src/connectors/momentService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -461,8 +461,11 @@ export class MomentService {
id: string
content: string
}) => {
// Prefer the dedicated moment model; fall back to the shared short-content
// model when MATTERS_MOMENT_SPAM_DETECTION_API_URL is unset (zero-downtime).
const detector = new SpamDetector(
environment.shortContentSpamDetectionApiUrl
environment.momentSpamDetectionApiUrl ||
environment.shortContentSpamDetectionApiUrl
)
const score = await detector.detect(content)

Expand Down
Loading