Repository navigation
fix: refuse new comments on the server when comments are turned off - #588
Merged
OXeu merged 1 commit intoNov 15, 2026
Merged
Conversation
Turning comments off only hid the form in the client. POST /comment/:feed never read comment.enabled, so bots kept posting through the API and every post still sent the comment webhook (openRin#585). The handler now answers 403 when comment.enabled is false, before it reads the body or touches the database, unless the caller is an admin. This is the same rule friend applications use (friend_apply_enable).
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.
Part of #585 (the part about turning comments off; the other requests in the issue stay open)
Problem
Turning comments off (
comment.enabledin the settings page) only hides the comment form in the client (client/src/page/feed.tsx).POST /comment/:feednever reads the setting, so anything that calls the API directly, such as a spam bot, can still post. Each post is stored and still triggers the comment webhook, which is why the reporter kept getting notification emails after turning comments off.Fix
server/src/services/comments.ts: the POST handler readscomment.enabledfromclientConfig(defaulttrue) and answers403 Comment Disabledwhen it is off, unless the caller is an admin. The check runs before the body is parsed, the feed lookup, the insert and the webhook, so a refused request changes nothing. It follows the existingfriend_apply_enablegate inserver/src/services/friends.ts, including the admin exemption.Tests
New
POST /:feed - Comments turned offblock inserver/src/services/__tests__/comments.test.ts:The two refusal tests fail without the change and pass with it.
bun run checkinserver/passes. Inbun run test:serverall comment tests pass. The only failures on my machine are RSS feed tests that hit bun's 5 s timeout on a slow disk; they fail the same way onmain, and they all pass with--timeout 30000.Not in this PR
The issue also asks for a moderation queue, custom spam filters, threaded replies and reply emails to guests. Those are features, so I kept this PR to closing the API when comments are off and did not close the issue. Happy to drop the admin exemption if you'd rather block everyone.