diff options
| author | tv <tv@krebsco.de> | 2026-11-16 21:46:03 +0000 |
|---|---|---|
| committer | tv <tv@krebsco.de> | 2026-11-16 23:07:38 +0100 |
| commit | 491751e51a554d991d5066dbe968aa44f3d66f30 (patch) | |
| tree | 4840b910e8cec8014c7ce949e1f68d0c49a622ab /src/api/events.rs | |
| parent | 0c213626ba238fd6d8d69d08475d57e486f6f27a (diff) | |
api: what the store refused, by kind
`GET /events/refused` says of each refusal its kind (`none`, `judged`, `builtOn`, with
the event it builds on, or `notAbove`), apart from why: a party's client signs again
what a move refused, which it tells so.
Diffstat (limited to 'src/api/events.rs')
| -rw-r--r-- | src/api/events.rs | 24 |
1 files changed, 22 insertions, 2 deletions
diff --git a/src/api/events.rs b/src/api/events.rs index 2fa6719..65c6238 100644 --- a/src/api/events.rs +++ b/src/api/events.rs @@ -156,9 +156,22 @@ async fn counts(State(state): State<AppState>) -> Response { }) } +/// What kind of refusal it is, as a client tells them apart, and the event it builds on, +/// for one built on a refused one. +fn kind(refusal: &Refusal) -> (&'static str, Option<&Id>) { + match refusal { + Refusal::None => ("none", None), + Refusal::Judged(_) => ("judged", None), + Refusal::BuiltOn(id) => ("builtOn", Some(id)), + Refusal::NotAbove => ("notAbove", None), + Refusal::Own => ("own", None), + Refusal::Dropped => ("dropped", None), + } +} + /// `GET /events/refused`: what the store refused: of its own, by what it took before (the /// federation: a version changing another than the one it reads), apart; what its -/// operator had it drop; and the rest, each with why. +/// operator had it drop; and the rest, each with its kind and why. async fn refused(State(state): State<AppState>) -> Response { with_store(&state, |store| { let (own, dropped) = store.own(); @@ -172,7 +185,14 @@ async fn refused(State(state): State<AppState>) -> Response { "dropped": ids(dropped), "refused": rest .into_iter() - .map(|(id, refusal)| json!({"id": id.to_string(), "why": why(refusal)})) + .map(|(id, refusal)| { + let (kind, on) = kind(refusal); + let mut entry = json!({"id": id.to_string(), "kind": kind, "why": why(refusal)}); + if let Some(on) = on { + entry["on"] = json!(on.to_string()); + } + entry + }) .collect::<Vec<_>>(), }) }) |
