feat(safety): report, block and hide, MODULE_API 1.21.0 #233

Merged
whitlocktech merged 1 commits from feature/user-safety into main 2026-10-30 07:24:39 -05:00
Member

What & why

Step 2 of docs/website/USER_SAFETY.md (the core): report, block and hide. This is account-deletion step 7, which comes before the Android M8 cutover. The design is the plan of record, plus four decisions the org lead made while this was being built (S11-S14, recorded in the docs PR):

  • S11 — chat is filtered on the server. The plan assumed the Rust chat feed was shared and cached. It is already read per viewer, so a module filters its own feed with ctx.safety.forViewer, and no client module-API member is needed.
  • S12 — a block lands on the RunicGateway account first. Only an unlinked speaker is blocked by Steam ID.
  • S13 — chat lines carry canBlock for signed-in readers.
  • S14 — a Steam-ID block becomes an account block once the ID is linked.

Server

  • POST /player/reports files a report on any target type: the forum's own types or a module's registered ones. One resolver (model/safety/targets.js) answers "what is this item, for this reader". An item the reader cannot see gets the same 404 as one that does not exist.
  • Every report now stores content_reports.snapshot, so the queue still shows what was said after a chat line is pruned or a post is edited.
  • POST /admin/moderation/reports/:id/hide is Hide for everyone. It hides the item through its own moderation (the forum's hide as a staff action, or the module's hide), then actions the report with actioned_with = 'hide' and an audit entry.
  • user_blocks and user_hidden_items tables, behind /auth/me/blocks and /auth/me/hidden. A block names an item, never a person. Staff cannot be blocked (403 staff). A block on someone who later becomes staff stops applying and says so.
  • Forum reads leave out blocked authors and hidden items, and carry canBlock on each thread and post.
  • MODULE_API 1.21.0 adds api.registerReportTargets, api.registerGameIdentities, ctx.safety.forViewer and ctx.safety.staffAmong.

Web

  • Hide for me and Block author in the forum menus. Block is offered only where canBlock is true, and asks for confirmation.
  • A Blocked section on /account and /admin/account.
  • Hide for everyone in the Reports queue, which also shows a module item from its snapshot.

Docs: RunicGateway/docs PR on branch docs/user-safety-core.

Not in this PR: team notifications and the team activity feed still include a blocked author's forum posts. The plan doesn't cover them, so I've left them for the org lead to decide.

How it was tested

  • npm test in server: 2381 tests, 0 failing. Run with an empty MODULES_DIR, because the local modules/rust install leaks its routes into the route manifests.
  • npm run build and npm test in client: 446 tests, 0 failing.
  • New tests: server/test/userSafety.test.js (S8, S12, S14, forViewer, the registry checks) and new cases in contentReports.test.js, teamForum.test.js and client/test/userSafety.test.js.
  • A live walk against a throwaway database (usafety) on the local MariaDB, with a core on :3291 and no modules, running the real routes with bearer logins. All 18 rows passed:
    • The schema was created on boot.
    • Hide for me removed a post from one member's view only.
    • Blocking a moderator was refused (403), and the moderator's post had canBlock: false.
    • Blocking a thread's author took the thread off the list and its link answered 404. Unblocking brought it back.
    • A report reached the queue with its snapshot, and a player got 403 on the queue.
    • Hide for everyone actioned the report. The post disappeared for members, and staff saw it marked hidden.
  • S14's SQL rewrite, including the merge when the member had also blocked the account directly, was checked against the same database.

Checklist

  • I have read CONTRIBUTING.md.
  • The change builds and existing tests/checks pass locally.
  • I have added or updated tests/docs where it makes sense.
  • My commits are reasonably scoped with clear messages.

AI-assisted contributions (required)

  • No AI tools were used to produce this contribution.
  • AI tools were used. Tool(s): Claude Code (Claude Opus 5.5). I have reviewed and understand
    every change, and take responsibility for it. AI-authored commits are
    marked with a Co-Authored-By / Assisted-By trailer.

License

  • I agree that my contribution is licensed under this project's license
    (GNU GPL v3.0 or later), and I have the right to contribute it.

🤖 Generated with Claude Code

https://claude.ai/code/session_01E14m6SuuY6i1vASFeGDBeY

## What & why Step 2 of `docs/website/USER_SAFETY.md` (the core): report, block and hide. This is account-deletion step 7, which comes before the Android M8 cutover. The design is the plan of record, plus four decisions the org lead made while this was being built (S11-S14, recorded in the docs PR): - **S11 — chat is filtered on the server.** The plan assumed the Rust chat feed was shared and cached. It is already read per viewer, so a module filters its own feed with `ctx.safety.forViewer`, and no client module-API member is needed. - **S12 — a block lands on the RunicGateway account first.** Only an unlinked speaker is blocked by Steam ID. - **S13 — chat lines carry `canBlock`** for signed-in readers. - **S14 — a Steam-ID block becomes an account block** once the ID is linked. **Server** - `POST /player/reports` files a report on any target type: the forum's own types or a module's registered ones. One resolver (`model/safety/targets.js`) answers "what is this item, for this reader". An item the reader cannot see gets the same 404 as one that does not exist. - Every report now stores `content_reports.snapshot`, so the queue still shows what was said after a chat line is pruned or a post is edited. - `POST /admin/moderation/reports/:id/hide` is *Hide for everyone*. It hides the item through its own moderation (the forum's hide as a staff action, or the module's `hide`), then actions the report with `actioned_with = 'hide'` and an audit entry. - `user_blocks` and `user_hidden_items` tables, behind `/auth/me/blocks` and `/auth/me/hidden`. A block names an item, never a person. Staff cannot be blocked (403 `staff`). A block on someone who later becomes staff stops applying and says so. - Forum reads leave out blocked authors and hidden items, and carry `canBlock` on each thread and post. - MODULE_API **1.21.0** adds `api.registerReportTargets`, `api.registerGameIdentities`, `ctx.safety.forViewer` and `ctx.safety.staffAmong`. **Web** - *Hide for me* and *Block author* in the forum menus. Block is offered only where `canBlock` is true, and asks for confirmation. - A *Blocked* section on `/account` and `/admin/account`. - *Hide for everyone* in the Reports queue, which also shows a module item from its snapshot. Docs: RunicGateway/docs PR on branch `docs/user-safety-core`. **Not in this PR:** team notifications and the team activity feed still include a blocked author's forum posts. The plan doesn't cover them, so I've left them for the org lead to decide. ## How it was tested - `npm test` in `server`: 2381 tests, 0 failing. Run with an empty `MODULES_DIR`, because the local `modules/rust` install leaks its routes into the route manifests. - `npm run build` and `npm test` in `client`: 446 tests, 0 failing. - New tests: `server/test/userSafety.test.js` (S8, S12, S14, `forViewer`, the registry checks) and new cases in `contentReports.test.js`, `teamForum.test.js` and `client/test/userSafety.test.js`. - A live walk against a throwaway database (`usafety`) on the local MariaDB, with a core on `:3291` and no modules, running the real routes with bearer logins. All 18 rows passed: - The schema was created on boot. - Hide for me removed a post from one member's view only. - Blocking a moderator was refused (403), and the moderator's post had `canBlock: false`. - Blocking a thread's author took the thread off the list and its link answered 404. Unblocking brought it back. - A report reached the queue with its snapshot, and a player got 403 on the queue. - Hide for everyone actioned the report. The post disappeared for members, and staff saw it marked hidden. - S14's SQL rewrite, including the merge when the member had also blocked the account directly, was checked against the same database. ## Checklist - [x] I have read [CONTRIBUTING.md](CONTRIBUTING.md). - [x] The change builds and existing tests/checks pass locally. - [x] I have added or updated tests/docs where it makes sense. - [x] My commits are reasonably scoped with clear messages. ## AI-assisted contributions (required) - [ ] No AI tools were used to produce this contribution. - [x] AI tools were used. Tool(s): `Claude Code (Claude Opus 5.5)`. I have reviewed and understand every change, and take responsibility for it. AI-authored commits are marked with a `Co-Authored-By` / `Assisted-By` trailer. ## License - [x] I agree that my contribution is licensed under this project's license (**GNU GPL v3.0 or later**), and I have the right to contribute it. 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_01E14m6SuuY6i1vASFeGDBeY
wtclaude added 1 commit 2026-10-30 05:41:56 -05:00
feat(safety): report, block and hide, MODULE_API 1.21.0
All checks were successful
PR Checks / bot-tests (pull_request) Successful in 36s
PR Checks / server-tests (pull_request) Successful in 6m11s
PR Checks / client-build (pull_request) Successful in 49s
41a1e84b51
USER_SAFETY.md step 2 (core), with S11-S14 decided while building it.

- Reports: POST /player/reports takes any target type, core's forum
  types or a module's registered ones. One resolver
  (model/safety/targets.js) answers "what is this item, for this
  reader" and 404s an item the reader cannot see. Every report stores
  content_reports.snapshot; the queue shows a module item from it.
- Hide for everyone: POST /admin/moderation/reports/:id/hide hides the
  item through its own moderation (forum hide as staff, or the module's
  hide) and actions the report with actioned_with = 'hide'.
- Blocks (user_blocks) name an item, never a person, and land on the
  author's account first (S12); an unlinked game identity is blocked as
  itself and becomes an account block once linked (S14). Staff cannot
  be blocked; a block on someone later promoted stops applying (S8).
- Hide for me (user_hidden_items), /auth/me/blocks and /auth/me/hidden.
- Forum reads filter blocked authors and hidden items on the server and
  carry canBlock per thread and post.
- MODULE_API 1.21.0: api.registerReportTargets,
  api.registerGameIdentities, ctx.safety.forViewer and
  ctx.safety.staffAmong, so a module filters its own per-viewer feeds on
  the server (S11) and marks lines canBlock (S13).
- Web: Hide for me / Block author in the forum menus, a Blocked section
  on both account pages, Hide for everyone in the Reports queue.
- Tests, OpenAPI, route/guard/engagement manifests regenerated.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01E14m6SuuY6i1vASFeGDBeY
whitlocktech approved these changes 2026-10-30 07:24:24 -05:00
whitlocktech scheduled this pull request to auto merge when all checks succeed 2026-10-30 07:24:31 -05:00
whitlocktech merged commit f13b8fe1fe into main 2026-10-30 07:24:39 -05:00
whitlocktech deleted branch feature/user-safety 2026-10-30 07:24:40 -05:00
Sign in to join this conversation.
No description provided.