Backend/moderation: Restore author-visibility filtering for thread comments and replies#8649
Merged
aapeliv merged 1 commit intoMay 17, 2026
Conversation
…mments and replies The UMS moderation PRs for threads/replies replaced the where_users_column_visible() filter with where_moderated_content_visible(), which only checks moderation state and not whether the author is a deleted/banned/blocked/shadowed user. As a result, comments and replies by invisible users were no longer hidden. Apply both filters together (as done elsewhere in the codebase) across GetThread and total_num_responses, and switch the per-comment num_replies count to a correlated subquery so it only counts visible replies. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Contributor
📝 Release NotesThis PR should be included in the release notes. Suggested release note: 🤖 Bot Debug InformationModel: |
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.
The recent UMS moderation PRs for thread comments/replies (#8510) and discussions (#8511) introduced
where_moderated_content_visible(), which only checks an item's moderation state — not whether its author is a deleted, banned, blocked, or shadowed user.In
threads.pythe moderation PR replacedwhere_users_column_visible()withwhere_moderated_content_visible()instead of applying both. The two are orthogonal checks and are used together everywhere else in the codebase (references.py,api.py,requests.py, etc.). The regression: comments and replies authored by invisible users were no longer hidden from other users.This PR:
where_users_column_visible()alongsidewhere_moderated_content_visible()in allGetThreadqueries (comment list, reply list, parent-comment existence check) and intotal_num_responses().num_repliescount included replies regardless of moderation state or author visibility — it now uses a correlated subquery with both filters, matching the depth-1 reply list.Discussions are cluster-owned community content and were never filtered by creator visibility (before or after the moderation PR), so they are intentionally left unchanged.
Testing
test_comment_by_invisible_user_hiddenandtest_reply_by_invisible_user_hiddentotest_threads.py. Both approve the moderation state so they isolate the author-visibility check; the reply test also asserts the parent comment'snum_repliescount drops when the replier is deleted.uv run pytest src/tests/test_threads.py src/tests/test_discussions.py src/tests/test_events.py— all pass.make formatandmake mypyclean for the changed files.Backend checklist
developif necessary for linear migration historyFor maintainers
This PR was created with the Couchers PR skill.