From 491751e51a554d991d5066dbe968aa44f3d66f30 Mon Sep 17 00:00:00 2001 From: tv Date: Mon, 16 Nov 2026 21:46:03 +0000 Subject: 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. --- src/api/events.rs | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) (limited to 'src/api') 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) -> 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) -> Response { with_store(&state, |store| { let (own, dropped) = store.own(); @@ -172,7 +185,14 @@ async fn refused(State(state): State) -> 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::>(), }) }) -- cgit v1.3.1