Skip to content

feat(moderation): report and block resource - #20

Merged
thinkclay merged 1 commit into
mainfrom
feat/moderation-resource
Sep 2, 2026
Merged

thinkclay merged 1 commit into
mainfrom
feat/moderation-resource

Conversation

@thinkclay

Copy link
Copy Markdown
Contributor

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

client.moderation.report({ subjectType, subjectId, reason, details? })
client.moderation.listReports({ limit?, offset? })
client.moderation.blockUser(userId)
client.moderation.unblockUser(userId)
client.moderation.listBlocks({ limit?, offset? })

Two behaviours documented at the call site

  • Reporting the same subject twice while the first report is still open returns 409. A UI should treat that as already done, not as a failure — the user pressed the button and the outcome they wanted is true.
  • blockUser is 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

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
thinkclay merged commit 4f6730a into main Sep 2, 2026
@thinkclay
thinkclay deleted the feat/moderation-resource branch September 2, 2026 05:09
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.
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.

1 participant