Repository navigation
feat(moderation): report and block resource - #20
Merged
Merged
Conversation
Client for /v1/moderation, added for Scaffald/SaaS#690 — the app carries user-generated content with no way to report or block anything, which Google Play's UGC policy and Apple Guideline 1.2 both require. Four calls: report(), listReports(), blockUser(), unblockUser(), listBlocks(). Two behaviours worth knowing at the call site, so they are in the doc comments: reporting the same subject twice while the first report is still open returns 409, which a UI should treat as "already done" rather than a failure; and blockUser is idempotent, returning the existing block rather than erroring.
thinkclay
added a commit
to Scaffald/SaaS
that referenced
this pull request
Sep 2, 2026
* feat(moderation): report and block — schema, API, and symmetric enforcement Backend half of #690. Scaffald carries UGC with no way to report content, report a person, or block anyone; Play's UGC policy and Apple Guideline 1.2 both require all three. Two tables, kept apart on purpose. A report is a request for moderator attention — queued, reviewed, resolved. A block is the user's own boundary — immediate, reversible, needs nobody's approval. Conflating them means either blocks wait on moderation or reports silently mute people. The constraints were tested by trying to break them, because #675 was a UNIQUE that never fired: self-block, self-report, duplicate block and a second open report on the same subject are all rejected, and reporting again after resolution is allowed. Enforcement is symmetric and is the half that matters. A block that is only recorded is worse than none — the user believes they are unreachable and they are not. RLS deliberately lets a user see only rows where they are the blocker, so a client cannot discover who blocked them; that is right for privacy and useless for filtering, hence core.blocked_user_ids() as SECURITY DEFINER. Applied to the inquiry thread and the community feed. The feed filters in the query rather than after it, so paging is not silently shortened. Three schema assumptions were wrong and checked rather than trusted: inquiry_comments uses sender_id not author_id, jobs uses created_by_user_id, and there is no shared getServiceClient to import. Wrong here is silent — the report still files, just with nobody attached. scripts/audit/test-moderation.mjs: 20/20 against the local stack. Still to come: SDK resource, hooks, and the UI surfaces. Nothing is user-reachable yet. * feat(moderation): make report and block reachable from the app App half of #690. The backend landed in the previous commit; nothing was user-reachable until now, and a store reviewer checks the UI. Three surfaces: community post report, in the author row so it is visible without opening the post inquiry message report, per message settings the list of people you have blocked, with unblock One ReportSheet and one ReportAction rather than a dialog per screen. Beyond tidiness: a reviewer is looking for whether reporting is FINDABLE, and an affordance that looks different everywhere reads as missing wherever they happen not to look. The sheet mounts only while open. Rendering it permanently-hidden made every message row in a thread instantiate two mutations and require a QueryClient to draw a flag icon — which is how this broke InquiryCommentThread's existing tests. Fixing the design fixed the tests; I did not touch them. Smaller decisions worth their comments: - `other` with no details is disabled rather than rejected, so nobody discovers the server rule by being refused - a 409 (already reported) shows as done, not as a failure — the user pressed the button and the outcome they wanted is true - the confirmation promises review, not removal or a timeline - blocking is offered after reporting, not instead of it - report controls are named per subject ("Report Alice Chen"), because a screen-reader user in a thread otherwise hears "Report" a dozen times - blocks list shows a short id: the API deliberately returns ids, since seeing someone you blocked should not require loading their profile. Joining the profile in is nicer and is a follow-up. SDK: Scaffald/sdk#20, pointer 2ae9506..4f6730a. typecheck 12/12, test:unit 7/7 --skip-nx-cache (1151/1151 in scf-core), lint 10/10, moderation API 20/20, and scripts/audit/smoke-report-block.mjs confirms the settings surface renders in the running app rather than only compiling.
5 tasks
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.
Client for
/v1/moderation, added for Scaffald/SaaS#690.The app carries user-generated content — community posts and comments, inquiry threads, profiles, job posts — with no way to report or block any of it. Google Play's UGC policy and Apple Guideline 1.2 both require reporting content, reporting a person, and blocking a person.
Surface
Two behaviours documented at the call site
blockUseris idempotent — blocking someone already blocked returns the existing block rather than erroring.Both are server behaviours a caller would otherwise discover by hitting them.
Builds clean (tsup, types emitted).
🤖 Generated with Claude Code