aboutsummaryrefslogtreecommitdiffstats
path: root/src/api
diff options
context:
space:
mode:
Diffstat (limited to 'src/api')
-rw-r--r--src/api/events.rs24
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<_>>(),
})
})