chadtmiller.com/group-host
atmosphere group host
0
0
The moderation queue names people by their handles
.claude/skills/ui/SKILL.md+3−0
| @@ -51,6 +51,9 @@ the rest, once per kept world: | ||
- `waiting`: bob asking to join Riders; carol invited to it. | ||
- `apps`: an app signed in to Riders with alice's app password | ||
"Phone", having posted as it, and taken a post down. | ||
- `reports`, after `full`: Lantern Hikers' moderation queue, with dan | ||
reported twice (once citing a rule), a post of frank's reported, erin | ||
escalated and bob resolved with a note. | ||
| ||
A state none of them makes is a seed of your own: a module that writes | ||
it, `--seed path/to/it.mjs` (the top of `harness/look/look.mjs` says | ||
crates/group-host/src/moderation.rs+27−6
| @@ -28,6 +28,7 @@ use axum::extract::{Query, State}; | ||
use axum::http::{HeaderMap, StatusCode}; | ||
use rusqlite::{OptionalExtension, Row, params}; | ||
use serde_json::{Value, json}; | ||
use std::collections::HashMap; | ||
use std::sync::Arc; | ||
| ||
type Answer = Result<Json<Value>, XrpcError>; | ||
| @@ -396,9 +397,19 @@ fn present(mut value: Value) -> Value { | ||
value | ||
} | ||
| ||
fn subject_view(s: &Subject) -> Value { | ||
/// The account a subject is, or whose record it is: a record's repo, as | ||
/// the queue keeps it, in a space. | ||
fn account_of<'a>(key: &'a str) -> &'a str { | ||
let repo = |path: &'a str| path.split('/').nth(4).expect("a record in a space"); | ||
key.strip_prefix("at://").map_or(key, repo) | ||
} | ||
| ||
/// A subject as the queue answers it, with `actors`, the people it names | ||
/// as a view names them. | ||
fn subject_view(s: &Subject, actors: &HashMap<String, Value>) -> Value { | ||
json!({ | ||
"subject": subject_ref(&s.subject), | ||
"actor": actors[account_of(&s.subject)], | ||
"status": s.status, | ||
"reportCount": s.reports, | ||
"createdAt": iso(s.created_at), | ||
| @@ -407,8 +418,9 @@ fn subject_view(s: &Subject) -> Value { | ||
} | ||
| ||
/// An event as the history answers it: one of the four kinds the union | ||
/// holds. A negation is the label taken back. | ||
fn event_view(e: &Event) -> Value { | ||
/// holds, with who did it as `actors` names them. A negation is the label | ||
/// taken back. | ||
fn event_view(e: &Event, actors: &HashMap<String, Value>) -> Value { | ||
let event = match e.kind.as_str() { | ||
"report" => json!({ | ||
"$type": "fyi.opensocial.defs#reportEvent", | ||
| @@ -433,6 +445,7 @@ fn event_view(e: &Event) -> Value { | ||
"id": e.seq.to_string(), | ||
"createdAt": iso(e.created_at), | ||
"createdBy": e.actor, | ||
"creator": e.actor.as_ref().map(|did| &actors[did]), | ||
"event": present(event), | ||
})) | ||
} | ||
| @@ -464,7 +477,10 @@ pub async fn list_subjects( | ||
.store | ||
.subjects(group, status, before, limit) | ||
.map_err(XrpcError::internal)?; | ||
let mut out = json!({"subjects": subjects.iter().map(subject_view).collect::<Vec<_>>()}); | ||
let actors = host.actor_views(subjects.iter().map(|s| account_of(&s.subject))); | ||
let actors = actors.await; | ||
let views: Vec<Value> = subjects.iter().map(|s| subject_view(s, &actors)).collect(); | ||
let mut out = json!({ "subjects": views }); | ||
if subjects.len() == limit as usize | ||
&& let Some(last) = subjects.last() | ||
{ | ||
| @@ -499,7 +515,10 @@ pub async fn get_subject_history( | ||
.store | ||
.events(group, subject, cid, after, limit) | ||
.map_err(XrpcError::internal)?; | ||
let mut out = json!({"events": events.iter().map(event_view).collect::<Vec<_>>()}); | ||
let actors = host.actor_views(events.iter().filter_map(|e| e.actor.as_deref())); | ||
let actors = actors.await; | ||
let views: Vec<Value> = events.iter().map(|e| event_view(e, &actors)).collect(); | ||
let mut out = json!({ "events": views }); | ||
if events.len() == limit as usize | ||
&& let Some(last) = events.last() | ||
{ | ||
| @@ -539,7 +558,9 @@ pub async fn resolve_subject( | ||
.map_err(XrpcError::internal)?; | ||
let now = host.store.subject(group, &subject); | ||
let now = now.map_err(XrpcError::internal)?; | ||
Ok(Json(subject_view(&now.expect("just kept")))) | ||
let now = now.expect("just kept"); | ||
let actors = host.actor_views([account_of(&now.subject)]).await; | ||
Ok(Json(subject_view(&now, &actors))) | ||
} | ||
| ||
/// Whether the group's labeler takes reports where it lists `key`: it | ||
crates/group-host/tests/moderation.rs+5−0
| @@ -124,6 +124,8 @@ async fn takes_a_report_from_one_who_reads_it() { | ||
assert_eq!(queue["subjects"][0]["subject"], record(uri)); | ||
assert_eq!(queue["subjects"][0]["status"], "open"); | ||
assert_eq!(queue["subjects"][0]["reportCount"], 2); | ||
// Whose record it is, as a view names them. | ||
assert_eq!(queue["subjects"][0]["actor"]["did"], bob.did.as_str()); | ||
| ||
// A rule the group's, cited. | ||
let rule = format!("{}/{did}/{NS}.rule/3mzjdd6rnfise", meta_space(&did)); | ||
| @@ -140,6 +142,7 @@ async fn takes_a_report_from_one_who_reads_it() { | ||
let event = &history["events"][0]; | ||
assert_eq!(event["id"], said["id"]); | ||
assert_eq!(event["createdBy"], bob.did.as_str()); | ||
assert_eq!(event["creator"]["did"], bob.did.as_str()); | ||
assert_eq!(event["event"]["$type"], "fyi.opensocial.defs#reportEvent"); | ||
assert_eq!( | ||
event["event"]["reasonType"], | ||
| @@ -149,6 +152,7 @@ async fn takes_a_report_from_one_who_reads_it() { | ||
// The account in the queue, as the union it was sent as. | ||
let (_, queue) = query(&h, &alice, "listSubjects", &format!("group={did}")).await; | ||
assert_eq!(queue["subjects"][0]["subject"], account(&alice.did)); | ||
assert_eq!(queue["subjects"][0]["actor"]["did"], alice.did.as_str()); | ||
| ||
let other = start_group( | ||
&h, | ||
| @@ -484,6 +488,7 @@ async fn resolves_and_escalates_with_a_note() { | ||
assert_eq!(view["status"], "escalated"); | ||
assert_eq!(view["subject"], record(uri)); | ||
assert_eq!(view["reportCount"], 1); | ||
assert!(view["actor"]["did"].is_string()); | ||
// Setting the status it has keeps a note. | ||
let (_, view) = call( | ||
&h, | ||
docs/design/moderation.md+6−1
| @@ -99,8 +99,13 @@ A subject is an account, sent and answered as | ||
the version a report or label names stays on that event. A subject has a | ||
status: `open`, `escalated` or `resolved`. | ||
| ||
Each subject in the queue comes with `actor`: the account it is, or whose | ||
record it is, by its DID and handle, so a moderator reads who it is about | ||
rather than a DID. | ||
| ||
Its history is a list of events, each with an `id`, `createdAt`, who did | ||
it as `createdBy`, and one of four kinds as `event`: | ||
it as `createdBy` and, by their DID and handle, as `creator`, and one of | ||
four kinds as `event`: | ||
| ||
- `reportEvent`: someone reported it, with a `reasonType`, an optional | ||
`reason` and the `rule` it cites, if any. | ||
docs/guides/shots/moderating-escalate-sent-dark.png+0−0
A binary file, not shown.
docs/guides/shots/moderating-escalate-sent.png+0−0
A binary file, not shown.
docs/guides/shots/moderating-escalate-sent.txt+4−4
| @@ -9,7 +9,7 @@ | ||
- heading "Subjects1" [level=2] | ||
- list: | ||
- listitem: | ||
- text: did:plc:<id> Reported once | ||
- button "Resolve" | ||
- list: | ||
- listitem: "<date> Reported: reasonSpam: Posts the same seed shop link in every thread." | ||
- text: maximilianaquinces.test Account · Reported on <date> Spam | ||
- button "Review maximilianaquinces.test": Review | ||
- paragraph: Posts the same seed shop link in every thread. | ||
- group: History | ||
docs/guides/shots/moderating-label-dialog-dark.png+0−0
A binary file, not shown.
docs/guides/shots/moderating-label-dialog.png+0−0
A binary file, not shown.
docs/guides/shots/moderating-labelled-dark.png+0−0
A binary file, not shown.
docs/guides/shots/moderating-labelled.png+0−0
A binary file, not shown.
docs/guides/shots/moderating-labelled.txt+13−16
| @@ -1,16 +1,13 @@ | ||
- main: | ||
- link "← Garden share": | ||
- heading "Moderation" [level=1] | ||
- button "Label someone" | ||
- navigation "The queue": | ||
- link "Open": | ||
- link "Escalated": | ||
- link "Resolved": | ||
- heading "Subjects1" [level=2] | ||
- list: | ||
- listitem: | ||
- text: did:plc:<id> Reported once | ||
- button "Resolve" | ||
- list: | ||
- listitem: "<date> Reported: reasonSpam: Posts the same seed shop link in every thread." | ||
- listitem: "<date> Labelled: spam" | ||
- listitem: | ||
- text: maximilianaquinces.test Account · Reported on <date> Spam | ||
- button "Review maximilianaquinces.test": Review | ||
- paragraph: Posts the same seed shop link in every thread. | ||
- group: | ||
- text: History | ||
- list: | ||
- listitem: | ||
- strong: Reported | ||
- text: by frank.test <date> Spam. Posts the same seed shop link in every thread. | ||
- listitem: | ||
- strong: Labelled | ||
- text: by dan.test <date> spam | ||
docs/guides/shots/moderating-queue-dark.png+0−0
A binary file, not shown.
docs/guides/shots/moderating-queue.png+0−0
A binary file, not shown.
docs/guides/shots/moderating-queue.txt+8−8
| @@ -9,12 +9,12 @@ | ||
- heading "Subjects2" [level=2] | ||
- list: | ||
- listitem: | ||
- text: did:plc:<id> Reported once | ||
- button "Resolve" | ||
- list: | ||
- listitem: "<date> Reported: reasonSpam: Posts the same seed shop link in every thread." | ||
- text: maximilianaquinces.test Account · Reported on <date> Spam | ||
- button "Review maximilianaquinces.test": Review | ||
- paragraph: Posts the same seed shop link in every thread. | ||
- group: History | ||
- listitem: | ||
- text: at://did:plc:<id>/space/com.example.board/swaps/did:plc:<id>/com.example.post/<rkey> Reported once | ||
- button "Resolve" | ||
- list: | ||
- listitem: "<date> Reported: reasonRude: Calls people names under every swap." | ||
- text: frank.test Post · Reported on <date> Rude | ||
- button "Review frank.test": Review | ||
- paragraph: Calls people names under every swap. | ||
- group: History | ||
docs/guides/shots/moderating-remove-dialog-dark.png+0−0
A binary file, not shown.
docs/guides/shots/moderating-remove-dialog.png+0−0
A binary file, not shown.
docs/guides/shots/moderating-removed-dark.png+0−0
A binary file, not shown.
docs/guides/shots/moderating-removed.png+0−0
A binary file, not shown.
docs/guides/shots/moderating-resolve-dialog-dark.png+0−0
A binary file, not shown.
docs/guides/shots/moderating-resolve-dialog.png+0−0
A binary file, not shown.
docs/guides/shots/moderating-resolve-dialog.txt+3−1
| @@ -1,8 +1,10 @@ | ||
- dialog "Resolve or escalate": | ||
- heading "Resolve or escalate" [level=2] | ||
- button "Close": × | ||
- paragraph: did:plc:<id> | ||
- paragraph: maximilianaquinces.test · Account | ||
- paragraph: Resolve it once it's dealt with, or escalate it for someone else to look at. | ||
- text: A note, if you like | ||
- textbox "A note, if you like": Taken down and removed from the group. | ||
- button "Cancel" | ||
- button "Escalate" | ||
- button "Resolve" | ||
docs/guides/shots/moderating-takedown-dark.png+0−0
A binary file, not shown.
docs/guides/shots/moderating-takedown.png+0−0
A binary file, not shown.
docs/guides/shots/moderating-takedown.txt+16−17
| @@ -1,17 +1,16 @@ | ||
- main: | ||
- link "← Garden share": | ||
- heading "Moderation" [level=1] | ||
- button "Label someone" | ||
- navigation "The queue": | ||
- link "Open": | ||
- link "Escalated": | ||
- link "Resolved": | ||
- heading "Subjects1" [level=2] | ||
- list: | ||
- listitem: | ||
- text: did:plc:<id> Reported once | ||
- button "Resolve" | ||
- list: | ||
- listitem: "<date> Reported: reasonSpam: Posts the same seed shop link in every thread." | ||
- listitem: "<date> Labelled: spam" | ||
- listitem: "<date> Labelled: !takedown" | ||
- listitem: | ||
- text: maximilianaquinces.test Account · Reported on <date> Spam | ||
- button "Review maximilianaquinces.test": Review | ||
- paragraph: Posts the same seed shop link in every thread. | ||
- group: | ||
- text: History | ||
- list: | ||
- listitem: | ||
- strong: Reported | ||
- text: by frank.test <date> Spam. Posts the same seed shop link in every thread. | ||
- listitem: | ||
- strong: Labelled | ||
- text: by dan.test <date> spam | ||
- listitem: | ||
- strong: Labelled | ||
- text: by dan.test <date> !takedown | ||
docs/guides/moderating.md+25−24
| @@ -40,16 +40,18 @@ is in the group, and a post only in a part of the group they can read. | ||
| ||
## What is on the Moderation page? | ||
| ||
1. Look at the **Open** tab. Each row is one subject: an account or a | ||
post that was reported. Under it, how often it was reported, then its | ||
history, one line per thing that happened, oldest first. | ||
1. Look at the **Open** tab. Each row is one subject: an account, or a | ||
post that was reported, under the handle of the account that posted | ||
it. Under the handle, whether it is an account or a post and when it | ||
was reported, then the reasons members chose, then what the latest | ||
report said. | ||
| ||
<!-- look /g/gardens.groups.test/moderation --as dan --element main --> | ||
 | ||
 | ||
| ||
The page names each account by its DID, the account's lasting ID, and | ||
each post by its full address. It shows the reason the member chose as | ||
one word, such as reasonSpam or reasonRude, then what they wrote. | ||
2. Press **History** under a row to see everything that happened to it, | ||
oldest first: each report, label, escalation or resolution, who did | ||
it, when, and what they wrote. | ||
| ||
The tabs sort subjects by where they are: | ||
| ||
| @@ -65,7 +67,7 @@ the tabs. | ||
| ||
When a report is not yours to decide, escalate it. | ||
| ||
1. Press **Resolve** on the post's row. The dialog **Resolve or escalate** | ||
1. Press **Review** on the post's row. The dialog **Resolve or escalate** | ||
opens. | ||
2. Under **A note, if you like**, type why, such as "Third time this | ||
month; over to the admins." | ||
| @@ -75,7 +77,7 @@ When a report is not yours to decide, escalate it. | ||
<!-- look /g/gardens.groups.test/moderation --as frank --click 'button[popovertarget=resolve-1]' --type '#resolve-1 [name=note]=Third time this month; over to the admins.' --click '#resolve-1 button[value=escalated]' --element main --> | ||
 | ||
| ||
The post now waits on the **Escalated** tab, your note under its report. | ||
The post now waits on the **Escalated** tab, your note in its history. | ||
| ||
## How do I label an account? | ||
| ||
| @@ -87,9 +89,7 @@ word is yours to choose. | ||
The console cannot take a label back. Only a terminal can, so check the | ||
label before you send it. | ||
| ||
The queue shows accounts by their DID, but the dialog asks for a handle. | ||
Find the handle in the app the report came from, or in the group's | ||
members list. | ||
The dialog asks for the account's handle, as the queue shows it. | ||
| ||
1. Press **Label someone**. | ||
2. Under **Their handle**, type the account's handle, such as | ||
| @@ -99,11 +99,11 @@ members list. | ||
<!-- look /g/gardens.groups.test/moderation --as dan --click 'button[popovertarget=label]' --type '#label-handle=maximilianaquinces.test' --type '[name=val]=spam' --element ':popover-open' --> | ||
 | ||
| ||
4. Press **Label them**. The dialog closes, and the account's row gains | ||
a line saying it was labelled. | ||
4. Press **Label them**. The dialog closes, and the account's history | ||
gains a line saying it was labelled. | ||
| ||
<!-- look /g/gardens.groups.test/moderation --as dan --click 'button[popovertarget=label]' --type '#label-handle=maximilianaquinces.test' --type '[name=val]=spam' --click ':popover-open button[type=submit]' --element main --> | ||
 | ||
<!-- look /g/gardens.groups.test/moderation --as dan --click 'button[popovertarget=label]' --type '#label-handle=maximilianaquinces.test' --type '[name=val]=spam' --click ':popover-open button[type=submit]' --click 'li.subject:has-text("maximilianaquinces.test") summary' --element 'li.subject:has-text("maximilianaquinces.test")' --> | ||
 | ||
| ||
If the handle is not found, the dialog stays open and says so. The | ||
dialog labels accounts only. | ||
| @@ -121,10 +121,11 @@ dialog, and it needs a role with `takedown`. | ||
1. Press **Label someone**. | ||
2. Under **Their handle**, type "maximilianaquinces.test". | ||
3. Under **Label**, type "!takedown". | ||
4. Press **Label them**. The account's row gains a line for the takedown. | ||
4. Press **Label them**. The account's history gains a line for the | ||
takedown. | ||
| ||
<!-- look /g/gardens.groups.test/moderation --as dan --click 'button[popovertarget=label]' --type '#label-handle=maximilianaquinces.test' --type '[name=val]=!takedown' --click ':popover-open button[type=submit]' --element main --> | ||
 | ||
<!-- look /g/gardens.groups.test/moderation --as dan --click 'button[popovertarget=label]' --type '#label-handle=maximilianaquinces.test' --type '[name=val]=!takedown' --click ':popover-open button[type=submit]' --click 'li.subject:has-text("maximilianaquinces.test") summary' --element 'li.subject:has-text("maximilianaquinces.test")' --> | ||
 | ||
| ||
The label `!hide` works the same way and needs the same permission. A | ||
moderator without it is refused, and the dialog stays open with the | ||
| @@ -149,23 +150,23 @@ a takedown does that. | ||
<!-- look /g/gardens.groups.test --as dan --click 'li.member:has-text("maximilianaquinces.test") .action-menu summary' --click 'li.member:has-text("maximilianaquinces.test") .menu button:has-text("Remove from the group")' --click ':popover-open button[type=submit]' --element 'section:has(.member) .section-head' --> | ||
 | ||
| ||
They lose access to what only members see, and their row on the | ||
They lose access to what only members see, and their history on the | ||
Moderation page notes that they were removed. Removing does not block them: | ||
they can ask to join again. | ||
| ||
## How do I resolve a report? | ||
| ||
1. On the Moderation page, press **Resolve** on the account's row. | ||
1. On the Moderation page, press **Review** on the account's row. | ||
2. Under **A note, if you like**, type what was done, such as "Taken down | ||
and removed from the group." | ||
| ||
<!-- look /g/gardens.groups.test/moderation --as dan --click 'button[popovertarget=resolve-0]' --type '#resolve-0 [name=note]=Taken down and removed from the group.' --element ':popover-open' --> | ||
 | ||
 | ||
| ||
3. Press **Resolve**. The subject moves to the **Resolved** tab, with | ||
all that was done and your note. | ||
all that was done and your note in its history. | ||
| ||
From **Resolved**, the row's button can still escalate a subject. | ||
From **Resolved**, the row's **Review** can still escalate a subject. | ||
| ||
## From a terminal | ||
| ||