diff options
| author | tv <tv@krebsco.de> | 2026-11-09 05:22:14 +0000 |
|---|---|---|
| committer | tv <tv@krebsco.de> | 2026-11-09 06:30:44 +0100 |
| commit | b2c5096744c99453856f7281251b3f0cb4b9baae (patch) | |
| tree | cf1ff79be48513eda4b901c7197b452c557547d7 /src/api/dashboard/mod.rs | |
| parent | d7e3d9f8310aa40903f43272fbb30f37a1f68c2b (diff) | |
dashboard: a subscribed node's message written out, read from it when shown
A subscribed node's messages come without being written out (their stream leaves the
text out: up to 8 KiB each, 500 at a time), so the figures box said only when, both
ends, type and size of one. Now the node answers for one message by its number,
`GET /admin/dashboard/messages/own/{seq}` (`{"text": …}`, `404` once it isn't kept),
which pages of other origins may call as they do its streams (`cors::open`), and the
page reads it when the message is shown, with its narrow token, and keeps it on the
message. Where it can't be read, the box says why.
Diffstat (limited to 'src/api/dashboard/mod.rs')
| -rw-r--r-- | src/api/dashboard/mod.rs | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/src/api/dashboard/mod.rs b/src/api/dashboard/mod.rs index 7a643d0..3a50ca6 100644 --- a/src/api/dashboard/mod.rs +++ b/src/api/dashboard/mod.rs @@ -509,6 +509,7 @@ pub(crate) fn router(state: AppState) -> Router<AppState> { "/admin/dashboard/messages/own/events", get(own_messages_events), ) + .route("/admin/dashboard/messages/own/{seq}", get(own_message)) .layer(Extension(Hub::new(state, closing))) } @@ -573,6 +574,20 @@ impl Drop for Watching { } } +/// `GET /admin/dashboard/messages/own/{seq}`: the message `seq` of this node's +/// (`messages/own/events`, which leaves it out) written out, `{"text": …}`, for a page +/// subscribed to this node showing it; `404` once it isn't kept any more (the latest +/// 1000, while someone looks). +async fn own_message( + Extension(hub): Extension<Arc<Hub>>, + axum::extract::Path(seq): axum::extract::Path<u64>, +) -> axum::response::Response { + match hub.state.traffic.log.text_of(seq) { + Some(text) => axum::Json(json!({ "text": text })).into_response(), + None => super::error_response(axum::http::StatusCode::NOT_FOUND, "not kept any more", None), + } +} + /// `GET /admin/dashboard/messages/own/events`: server-sent events, `messages` with the /// messages this node sent and received since the last, as they come (gathered for /// `MESSAGES_GATHERED` after the first), as the page's own `messages` events have them, |
