Skip to content

Add anti-spam moderation for first posts with links - #1482

Open
drusepth wants to merge 2 commits into
masterfrom
claude/forum-moderation-new-user-links-9rqnty
Open

Add anti-spam moderation for first posts with links#1482
drusepth wants to merge 2 commits into
masterfrom
claude/forum-moderation-new-user-links-9rqnty

Conversation

@drusepth

Copy link
Copy Markdown
Member

Fixes #

User-facing changes

  • First-time forum posters who include links in their initial post now have that post held for moderator review, along with their topic and user account
  • Forum staff (moderators and admins) are exempt from this automatic moderation
  • Moderators receive Discord notifications when posts are held for review, with one notification per user while they have pending posts in the queue
  • Topics held for moderation are announced on Discord once approved by a moderator, rather than at creation time

Implementation notes

  • Added contains_link? method to detect common link formats (http/https URLs, www links, and markdown-style links) in post content
  • Implemented hold_first_post_with_links_for_moderation callback that:
    • Checks if a post is a user's first post and contains a link
    • Holds the post, its topic, and the user's account for moderation
    • Ensures subsequent posts by a pending user are also held until approval
  • Added cascade_pending_moderation_to_topic to sync topic moderation state with its first post
  • Created NotifyDiscordOfPendingPostJob to ping the moderation Discord channel when posts enter the queue
  • Modified NotifyDiscordOfThreadJob to:
    • Skip announcing topics held for moderation at creation time
    • Announce them once a moderator approves them instead
    • Avoid duplicate announcements if approval happens within the 1-minute creation delay
  • Added logic to detect whether a thread went through the moderation queue using PostModerationRecord
  • Updated .gitignore to exclude locally-installed gems in /vendor/bundle

Testing

  • Added comprehensive test suite in test/models/forum_first_post_moderation_test.rb covering:
    • First posts with links are held for moderation
    • First posts without links are approved normally
    • Subsequent posts from users with existing posts are approved
    • Replies to others' topics don't affect the topic's moderation state
    • Subsequent posts by held users are also held
    • Forum staff bypass the moderation check
    • Approving a held post cascades approval to the topic and user
    • Link detection for various formats
    • Discord notification behavior (single ping per user, no duplicate pings)
  • Added test suite in test/jobs/notify_discord_of_thread_job_test.rb covering:
    • Approved threads are announced
    • Held threads are not announced at creation
    • Held threads are announced once when approved
    • No duplicate announcements within the 1-minute window

All new tests pass and cover the anti-spam workflow end-to-end.

https://claude.ai/code/session_01UxYdrUQipvTQzr9v2ENbhv

claude added 2 commits August 27, 2026 18:02
A user's first-ever forum post that contains a link (http/https URL,
www. link, or markdown link) is now held for moderation instead of
being auto-approved:

- The post, its topic (when it starts a new thread), and the author's
  thredded_user_detail are all set to pending_moderation, so any
  further posts they make before review are held too. Approving any of
  their posts from /forum/moderation approves the user again via
  Thredded::ModeratePost. Forum moderators/admins and site admins are
  exempt.
- Threads are only announced to the forums Discord webhook once
  approved: NotifyDiscordOfThreadJob now skips non-approved threads,
  and held threads are announced when a moderator approves them (with
  a guard so a thread approved within the 1-minute announce delay
  isn't posted twice).
- New NotifyDiscordOfPendingPostJob pings a moderator Discord channel
  (DISCORD_MODERATION_WEBHOOK) whenever a post enters the moderation
  queue - held first posts, reported posts, and posts by still-pending
  users - limited to one ping per user while they have posts waiting.

Pending posts remain publicly visible
(Thredded.content_visible_while_pending_moderation is unchanged).

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01UxYdrUQipvTQzr9v2ENbhv
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01UxYdrUQipvTQzr9v2ENbhv
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants