Skip to content

Report service

Purpose

The report domain (backend/internal/services/report/) is the member side of trust and safety. Members file reports on an account, a moment, a chat message, an event or a place's cover photo; reports on the same target collect into one report group that Tomoda accounts triage in Backstage (see Backstage service). The domain also applies the automatic hide rules at filing time and serves a member the enforcement actions taken on their own account or content.

Aggregates

Aggregate Table Holds
Report group report_groups One per target while open: target, a snapshot of the content, counts, top reason, priority, hide state, resolution
Report reports One reporter's report on a target: reason, optional details, the group it joined
Enforcement action enforcement_actions What Tomoda accounts did to a member (warn, hide_content, remove_content, suspend), the reason, its reversal and the member's review request (review_* columns)

Enums live in backend/internal/models/report.go (ReportTargetType, ReportReason, ReportStatus, ReportPriority, HideRule, EnforcementKind, ReviewOutcome) and are mirrored in frontend/services/reportService.ts.

HTTP endpoints

All routes need a JWT, sit behind the age gate, and share ReportLimit (20 per hour per account, filings and review requests together).

Method Path Description
POST /reports {target_type, target_id, reason, details}. 201 for a new report; 200 with the existing one when the reporter already has an open report on that target
POST /moderation/review-request Public. {token, note}: a suspended member's one review request, with the token from the refused sign-in
GET /me/moderation/{id} One of the caller's actions, opened from its notification
POST /me/moderation/{id}/review {note} (optional, 500 characters): ask staff to look again at a warning, hidden content or removed content, once. Suspensions have no review request

Refusals: SELF_REPORT (400) for the reporter's own content, 404 for a target the reporter can't see, REVIEW_CLOSED (409) when a review was already requested, the action was undone, or it is a suspension. Another member's action reads as 404.

Filing rules

  • Visibility first. A moment or event must pass privacy.CanView for the reporter; a message must be in a chat the reporter is in. A blocked author can still be reported from a shared chat. A target the reporter can't see, an expired moment and a Tomoda account are all not found.
  • One open report per reporter per target. A repeat returns the existing report and is not counted twice.
  • One open group per target. A new report joins the open group, or opens a new one when the last group was resolved.
  • Snapshots. The group stores the reported text (caption, message, event title, handle and name) at filing time, so triage sees what was reported even after an edit or delete.
  • Priority. A child_safety report makes the group urgent; urgent groups sort first in the queue. One such report never hides content by itself.

Automatic hide rules

Applied after each filing, only to moments, messages and events (accounts are never hidden automatically):

Rule Trigger Effect
child_safety ChildSafetyHideThreshold (2) distinct trusted reporters on a group whose top reason is child_safety Hide
threshold HideThreshold (3) distinct trusted reporters Hide

A trusted reporter is an established account: at least 7 days old, active, not suspended or deactivated, with at least one accepted friend, and not already behind 3 automatic hides in the last day or 2 automatic hides that staff later dismissed in the last 90 days. The trusted count only counts independent reporters: a reporter registered within a day of, or friends with, an earlier trusted reporter in the same group adds nothing, so a ring of related accounts counts once. A child safety report still marks the group urgent at once, so it sits at the top of the queue, and its lower threshold (2) uses the same independent count. The group keeps reporter_count (every distinct reporter, shown in triage) apart from trusted_reporter_count (the one the rules read), so new or throwaway accounts can add reports but cannot take content down on their own.

Moderation keeps its own state and never writes the owner's columns:

Target Hide Remove
Moment moderation_hidden_at: members see it as private (owner only) moderation_removed_at: gone for everyone, the owner too
Event moderation_hidden_at: private never removed
Message moderation_hidden_at: that one message leaves the room pending review, its content kept moderation_removed_at: gone

What members see is derived in the database (rows without a hold read the owner's state from the visible columns, so the migration backfills nothing): moments.visibility and events.visibility are recomputed by triggers from the owner's choice (owner_visibility) and the hold, and moments.deleted_at and chat_messages.deleted_at from the owner's or sender's own delete (owner_deleted_at, sender_deleted_at) and the moderation columns. A direct write to visibility or deleted_at from the previous release during a rollout counts as the owner's change. So every read path that already filters on visibility or deletion respects moderation, an owner can keep editing visibility without lifting a hold, and a restore clears only the moderation columns, never the owner's own delete. A message held pending review is never purged by the soft-delete retention job; after a message changes, the chat room's last-message preview moves to the newest visible message and open rooms drop it at once.

An automatic rule only hides a group that is still open, in the same transaction that marks it (for a message, only that message). A Tomoda decision applies its content change in the same transaction that closes the group, re-reading the group's hide there: a dismissal or an action that does not touch content (warn, suspend) restores what a rule hid, hide_content and remove_content hold the content. A suspension is applied just before the group closes and is safe to repeat, so a failed close leaves the group open to retry. A failed hide is logged and leaves the group for Tomoda; the report is still filed.

Place cover reports

A report with target_type geo_cover names its place as target_id <kind>:<key> (country:FR, region:<id>, city:<id>, place:<id>). The place must exist, and the group's target id is derived from <kind>:<key>, so every report on one place joins one group. The group has no target member and is never hidden automatically. Reasons are wrong_place, poor_quality, inappropriate and other; the member reasons are refused on a cover and the cover reasons on everything else. Triage can dismiss the group or clear the place's cover (see Backstage service), and a reviewer sees the open reports next to any pending photo for the same place (Geo cover service).

Member notices

Each enforcement action notifies its member (moderation.action, no actor named, suspensions included), and tapping the notification opens the notice at /me/moderation/{id}. Notifications are the only place a member finds a notice. For a warning, hidden content or removed content the member can ask for a review once, with an optional note. Staff decide it in Backstage: undo the action, or keep it. Either decision notifies the member (moderation.review_decided, outcome undone or kept). A suspension has no notice-screen request, since the member has no session: a suspended member asks at sign-in (below). Reporters are told the outcome of their report (moderation.report_outcome, actioned or dismissed) without detail. Tomoda identity and notes never reach the member.

Suspended members

A refused sign-in for a suspended account answers 403 ACCOUNT_SUSPENDED after the credential checked out, with the standing suspension (reason, suspended_at, review_requested_at) in error.details. While a request is still open to them it also carries review_token: 256 random bits, stored only as a SHA-256 hash in Redis for 15 minutes, bound to that member and that action, audited when issued and when used. POST /moderation/review-request (public, suspension_review_ip limit of 10 per hour per IP) spends it and files the one request on the suspension. The token opens nothing else: no route accepts it as a credential, and it never grants a session. People suspensions record an enforcement action like report suspensions do, so every suspension can be reviewed and undone. Staff decide it in the same Review requests list. Undo lifts the suspension and Keep leaves it, and either emails the member in their saved language (SendSuspensionReviewEmail), since they cannot see a notification.

Data lifecycle

  • Reports survive the reporter's deletion with reporter_id cleared; groups and actions survive the resolver's.
  • An action is deleted with the member it targets; a group keeps its snapshot with target_user_id cleared.
  • Data export includes the member's own reports (reports section, report.NewExporter).

Dependencies (deps.go)

Port Satisfied by Used for
privacy.Loader friend graph loader Visibility check on filing
AuditLogger platform/audit.Service Filing audit rows
CoverPlaces geocover.Service Resolving the place a cover report names

Where to look

Need File
Filing, hide rules service.go
Groups, hides, resolve, reverse transactions store.go, reportdb/queries.sql
Triage (Tomoda accounts) backend/internal/services/backstage/triage_service.go
Member screens frontend/components/report/ReportSheet.tsx, frontend/components/hub/moderation/