fix(broker): route all wakes through sqlite, remove transient ping buffer

This commit is contained in:
damocles 2026-07-05 11:55:40 +02:00
commit fac326aa35
9 changed files with 84 additions and 215 deletions

View file

@ -1082,7 +1082,7 @@ async fn dashboard_history(State(state): State<AppState>) -> Response {
messages.reverse();
let events: Vec<crate::dashboard_events::DashboardEvent> = messages
.into_iter()
.filter_map(|m| match m {
.map(|m| match m {
crate::broker::MessageEvent::Sent {
id,
from,
@ -1092,7 +1092,7 @@ async fn dashboard_history(State(state): State<AppState>) -> Response {
in_reply_to,
} => {
let file_refs = scan_validated_paths(&body);
Some(crate::dashboard_events::DashboardEvent::Sent {
crate::dashboard_events::DashboardEvent::Sent {
seq: 0,
id,
from,
@ -1101,7 +1101,7 @@ async fn dashboard_history(State(state): State<AppState>) -> Response {
at: hive_sh4re::wire_time::from_secs(at),
in_reply_to,
file_refs,
})
}
}
crate::broker::MessageEvent::Delivered {
id,
@ -1112,7 +1112,7 @@ async fn dashboard_history(State(state): State<AppState>) -> Response {
in_reply_to,
} => {
let file_refs = scan_validated_paths(&body);
Some(crate::dashboard_events::DashboardEvent::Delivered {
crate::dashboard_events::DashboardEvent::Delivered {
seq: 0,
id,
from,
@ -1121,11 +1121,8 @@ async fn dashboard_history(State(state): State<AppState>) -> Response {
at: hive_sh4re::wire_time::from_secs(at),
in_reply_to,
file_refs,
})
}
}
// Ping events are never persisted to sqlite — this arm is
// unreachable in practice but required for exhaustiveness.
crate::broker::MessageEvent::Ping { .. } => None,
})
.collect();
axum::Json(serde_json::json!({ "seq": seq, "events": events })).into_response()
@ -1359,27 +1356,27 @@ async fn api_operator_inbox(State(state): State<AppState>) -> Response {
Ok(messages) => {
let items: Vec<serde_json::Value> = messages
.into_iter()
.filter_map(|m| match m {
crate::broker::MessageEvent::Sent {
.filter_map(|m| {
let crate::broker::MessageEvent::Sent {
id,
from,
body,
at,
in_reply_to,
..
} => {
let file_refs = scan_validated_paths(&body);
Some(serde_json::json!({
"id": id,
"from": from,
"body": body,
"at": hive_sh4re::wire_time::from_secs(at),
"in_reply_to": in_reply_to,
"file_refs": file_refs,
}))
}
crate::broker::MessageEvent::Delivered { .. }
| crate::broker::MessageEvent::Ping { .. } => None,
} = m
else {
return None;
};
let file_refs = scan_validated_paths(&body);
Some(serde_json::json!({
"id": id,
"from": from,
"body": body,
"at": hive_sh4re::wire_time::from_secs(at),
"in_reply_to": in_reply_to,
"file_refs": file_refs,
}))
})
.collect();
axum::Json(serde_json::json!({ "messages": items })).into_response()