Add anti-spam moderation for first posts with links - #1482
Open
drusepth wants to merge 2 commits into
Open
Conversation
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #
User-facing changes
Implementation notes
contains_link?method to detect common link formats (http/https URLs, www links, and markdown-style links) in post contenthold_first_post_with_links_for_moderationcallback that:cascade_pending_moderation_to_topicto sync topic moderation state with its first postNotifyDiscordOfPendingPostJobto ping the moderation Discord channel when posts enter the queueNotifyDiscordOfThreadJobto:PostModerationRecord.gitignoreto exclude locally-installed gems in/vendor/bundleTesting
test/models/forum_first_post_moderation_test.rbcovering:test/jobs/notify_discord_of_thread_job_test.rbcovering:All new tests pass and cover the anti-spam workflow end-to-end.
https://claude.ai/code/session_01UxYdrUQipvTQzr9v2ENbhv