neiam
/recourse
public · Issues · Pulls · Labels · Forks · Compare · Actions success · Badges · Packages
Log in to mark this repository.
Moderation: staff notes, locks, category posting rules, flags, sanctions, log
3d71adc · gmorell · 2026-12-03 02:53
Message
{commit_body(@commit)}
Files changed
modified
docs/api.md
+32
−7
| 59 | 59 | |---|---| |
| 60 | 60 | | 400 | `bad_request` (unreadable JSON or a malformed id; `details.reason`) | |
| 61 | 61 | | 401 | `unauthorized` | |
| 62 | −| 403 | `unverified`, `closed` (topic closed to replies), `not_author` (tags) | | |
| 62 | +| 403 | `unverified`, `silenced`, `locked` (topic locked by staff), `staff_only` / `trust_level` (the category's posting rule, or the trust needed to flag), `own_post` (flagging your own), `moderated` / `hidden` (a post staff moderated or that is hidden pending review), `not_author` (tags) | | |
| 63 | +| 409 | `already_flagged` | | |
| 63 | 64 | | 404 | `not_found` | |
| 64 | 65 | | 410 | `removed` (a deleted topic, for non-staff) | |
| 65 | 66 | | 422 | `invalid` (the message says what) | |
| 85 | 86 | |
| 86 | 87 | | Method | Path | Notes | |
| 87 | 88 | |---|---|---| |
| 88 | −| GET | `/categories` | `{categories: [{id, slug, name, colors, description, parent_id, depth, topic_count, watching}]}` in tree order | | |
| 89 | −| GET | `/categories/{slug}?sort=` | `{category, ancestors, subcategories, sort, topics, can_post}`. `topics` covers the category and its visible subcategories, pinned first. A given `sort` is saved as the account's, as on the web. | | |
| 89 | +| GET | `/categories` | `{categories: [{id, slug, name, colors, description, parent_id, depth, topic_count, watching, posting, can_create_topic, can_reply}]}` in tree order | | |
| 90 | +| GET | `/categories/{slug}?sort=` | `{category, ancestors, subcategories, sort, topics, can_create_topic, create_blocked, can_post}` (`can_post` = `can_create_topic`, kept for older apps). `topics` covers the category and its visible subcategories, pinned first. A given `sort` is saved as the account's, as on the web. | | |
| 90 | 91 | | PUT | `/categories/{slug}/watch` | `{watching}` → `{watching}` | |
| 91 | 92 | | POST | `/categories/{slug}/topics` | `{title, body, tags?: [..]}` → 201, as `GET /topics/{id}` | |
| 92 | −| GET | `/topics/{id}` | `{topic, posts, can_reply, can_edit_tags, watching}` | | |
| 93 | +| GET | `/topics/{id}` | `{topic, posts, can_reply, reply_blocked, can_react, can_flag, can_edit_tags, watching}` | | |
| 93 | 94 | | POST | `/topics/{id}/posts` | `{body}` (markdown) → 201, a post | |
| 94 | 95 | | PUT | `/topics/{id}/tags` | `{tags: [..]}` → `{tags}`. Replaces; up to five; new names need `may_create_tags` and are otherwise dropped. | |
| 95 | 96 | | PUT | `/posts/{id}/reaction` | `{key}` or `{key: null}` → `{reactions}` | |
| 96 | 97 | | PUT | `/posts/{id}/bookmark` | `{bookmarked}` → `{bookmarked}` | |
| 98 | +| POST | `/posts/{id}/flags` | `{reason, note?}` → 201 `{flagged: true}`. `reason` is `spam`, `abusive`, `off_topic` or `other`. Once per post (409), not your own, trust level `MIN_TRUST_TO_FLAG` and up. | | |
| 97 | 99 | |
| 98 | 100 | A **topic summary** (in every list) is `{id, title, category, author, |
| 99 | −is_pinned, is_closed, posts_count, replies, views, created_at, bumped_at, | |
| 101 | +is_pinned, is_locked, is_closed, posts_count, replies, views, created_at, bumped_at, | |
| 100 | 102 | tags, posters, reactions, is_new, unread, notes}` — what a Focus tile shows. |
| 101 | 103 | `category` is `{id, slug, name, colors}`; `colors` is the lineage, root |
| 102 | 104 | first, the web's category circle. |
| 103 | 105 | |
| 104 | 106 | A **post** is `{id, post_number, author, cooked, created_at, edited_at, |
| 105 | −deleted, bookmarked, reactions: [{key, emoji, count, reacted}], can_edit}`. | |
| 107 | +deleted, bookmarked, reactions: [{key, emoji, count, reacted}], can_edit, | |
| 108 | +moderated, hidden, can_react, can_flag, flagged}`. | |
| 109 | + | |
| 110 | +**Moderation, as the app sees it** | |
| 111 | + | |
| 112 | +- `posting` on a category is `{create_topic, reply}`, each `{kind, min_trust}` | |
| 113 | + with `kind` one of `everyone` (whoever can read the category), `min_trust` | |
| 114 | + or `staff`. `can_create_topic` / `can_reply` already apply it, the account | |
| 115 | + (verified, not silenced) and, for `can_reply` on a topic, the lock. | |
| 116 | +- `*_blocked` is `{code, message}` or null: the same codes as the errors | |
| 117 | + above, and the web's sentence, to show instead of the hidden control. | |
| 118 | +- A topic's `is_locked` (= `is_closed`) and `lock_reason`: only staff reply, | |
| 119 | + react or edit. | |
| 120 | +- A post's `moderated` is `{by, at}` or null. `cooked` is then the staff note, | |
| 121 | + to show as "staff: …"; the original is never sent. | |
| 122 | +- `hidden: true` means flagged past the threshold and waiting for staff: | |
| 123 | + `cooked` is empty unless you wrote it. | |
| 124 | +- `flagged` means you flagged it (`can_flag` is then false). | |
| 125 | +- `/me`'s `user.silenced` is `{until, reason, message}` or null; `may_write` | |
| 126 | + is false while it lasts. A suspended account's token is revoked and any | |
| 127 | + request is 401. | |
| 128 | +- Staff moderation (moderate, hide, lock, the flag queue, sanctions) is | |
| 129 | + web-only. | |
| 106 | 130 | |
| 107 | 131 | **Finding** |
| 108 | 132 |
| 119 | 143 | |
| 120 | 144 | ## Not in the API |
| 121 | 145 | |
| 122 | −Everything under `/admin` (categories, reaction types), invites, editing and | |
| 146 | +Everything under `/admin` (categories, reaction types, flags, users, the | |
| 147 | +moderation log), staff moderation of posts and topics, invites, editing and | |
| 123 | 148 | deleting posts and topics, sign-up and password sign-in stay on the web or |
| 124 | 149 | the `manage` CLI. There is no push (docs/android.md §2e). |
| 125 | 150 |
modified
migration/src/lib.rs
+2
−0
| 18 | 18 | mod m20240101_000016_visual_mode; |
| 19 | 19 | mod m20240101_000017_layout_names; |
| 20 | 20 | mod m20240101_000018_api_token_hash; |
| 21 | +mod m20240101_000019_moderation; | |
| 21 | 22 | |
| 22 | 23 | pub struct Migrator; |
| 23 | 24 |
| 47 | 48 | Box::new(m20240101_000016_visual_mode::Migration), |
| 48 | 49 | Box::new(m20240101_000017_layout_names::Migration), |
| 49 | 50 | Box::new(m20240101_000018_api_token_hash::Migration), |
| 51 | + Box::new(m20240101_000019_moderation::Migration), | |
| 50 | 52 | ] |
| 51 | 53 | } |
| 52 | 54 | } |
added
migration/src/m20240101_000019_moderation.rs
+114
−0
Click to load diff…
modified
src/actions.rs
+225
−23
Click to load diff…
modified
src/api/error.rs
+1
−0
Click to load diff…
modified
src/api/find.rs
+1
−1
Click to load diff…
modified
src/api/forum.rs
+95
−11
Click to load diff…
modified
src/api/mod.rs
+1
−0
Click to load diff…
modified
src/api/views.rs
+57
−3
Click to load diff…
modified
src/auth/api_tokens.rs
+1
−1
Click to load diff…
modified
src/auth/oidc.rs
+3
−0
Click to load diff…
modified
src/auth/tokens.rs
+5
−1
Click to load diff…
modified
src/auth/users.rs
+7
−0
Click to load diff…
modified
src/config.rs
+29
−0
Click to load diff…
modified
src/entities/categories.rs
+5
−0
Click to load diff…
modified
src/entities/mod.rs
+2
−0
Click to load diff…
added
src/entities/moderation_log.rs
+28
−0
Click to load diff…
added
src/entities/post_flags.rs
+55
−0
Click to load diff…
modified
src/entities/post_revisions.rs
+6
−0
Click to load diff…
modified
src/entities/posts.rs
+6
−0
Click to load diff…
modified
src/entities/topics.rs
+4
−0
Click to load diff…
modified
src/entities/users.rs
+13
−0
Click to load diff…
modified
src/handlers/auth.rs
+6
−0
Click to load diff…
modified
src/handlers/bookmarks.rs
+2
−1
Click to load diff…
modified
src/handlers/categories.rs
+132
−7
Click to load diff…
modified
src/handlers/focus.rs
+15
−12
Click to load diff…
modified
src/handlers/forum.rs
+178
−92
Click to load diff…
modified
src/handlers/mod.rs
+1
−0
Click to load diff…
added
src/handlers/moderation.rs
+751
−0
Click to load diff…
modified
src/handlers/posts.rs
+173
−114
Click to load diff…
modified
src/handlers/tags.rs
+1
−1
Click to load diff…
modified
src/lib.rs
+3
−0
Click to load diff…
modified
src/main.rs
+6
−114
Click to load diff…
added
src/moderation.rs
+736
−0
Click to load diff…
added
src/policy.rs
+464
−0
Click to load diff…
modified
src/seed.rs
+174
−6
Click to load diff…
added
src/web.rs
+159
−0
Click to load diff…
added
templates/admin/_author_glance.html
+7
−0
Click to load diff…
modified
templates/admin/_category_add.html
+14
−0
Click to load diff…
modified
templates/admin/_category_card.html
+1
−0
Click to load diff…
added
templates/admin/_flag_actions.html
+68
−0
Click to load diff…
added
templates/admin/_flag_card.html
+16
−0
Click to load diff…
added
templates/admin/_flag_counts.html
+8
−0
Click to load diff…
added
templates/admin/_flag_list.html
+22
−0
Click to load diff…
added
templates/admin/_flag_row.html
+14
−0
Click to load diff…
added
templates/admin/_mod_nav.html
+6
−0
Click to load diff…
added
templates/admin/_sanction_form.html
+19
−0
Click to load diff…
added
templates/admin/_shadow_form.html
+20
−0
Click to load diff…
added
templates/admin/_user_actions.html
+22
−0
Click to load diff…
added
templates/admin/_user_card.html
+11
−0
Click to load diff…
added
templates/admin/_user_row.html
+7
−0
Click to load diff…
added
templates/admin/_user_status.html
+4
−0
Click to load diff…
modified
templates/admin/categories.html
+2
−0
Click to load diff…
modified
templates/admin/category_form.html
+17
−0
Click to load diff…
added
templates/admin/flags.html
+36
−0
Click to load diff…
added
templates/admin/flags_focus.html
+33
−0
Click to load diff…
added
templates/admin/log.html
+32
−0
Click to load diff…
added
templates/admin/log_focus.html
+30
−0
Click to load diff…
added
templates/admin/user.html
+36
−0
Click to load diff…
added
templates/admin/users.html
+19
−0
Click to load diff…
added
templates/admin/users_focus.html
+18
−0
Click to load diff…
added
templates/forum/_flag.html
+26
−0
Click to load diff…
modified
templates/forum/_post.html
+50
−10
Click to load diff…
modified
templates/forum/_reader.html
+6
−5
Click to load diff…
modified
templates/forum/_topic_body.html
+11
−8
Click to load diff…
modified
templates/forum/_topic_head.html
+25
−3
Click to load diff…
modified
templates/forum/_topic_list.html
+1
−1
Click to load diff…
modified
templates/forum/_topic_square.html
+1
−1
Click to load diff…
modified
templates/forum/_topic_tile.html
+1
−1
Click to load diff…
modified
templates/forum/category.html
+5
−2
Click to load diff…
modified
templates/forum/focus.html
+5
−2
Click to load diff…
modified
templates/posts/history.html
+33
−4
Click to load diff…
added
templates/posts/moderate.html
+44
−0
Click to load diff…
modified
templates/root.html
+8
−0
Click to load diff…
modified
tests/api_db.rs
+2
−0
Click to load diff…
added
tests/moderation_db.rs
+670
−0
Click to load diff…
modified
tests/templates.rs
+45
−6
Click to load diff…
Parents: 6b4f785