From b2c5096744c99453856f7281251b3f0cb4b9baae Mon Sep 17 00:00:00 2001 From: tv Date: Mon, 9 Nov 2026 05:22:14 +0000 Subject: dashboard: a subscribed node's message written out, read from it when shown MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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. --- src/api/dashboard/mod.rs | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'src/api/dashboard/mod.rs') 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 { "/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>, + axum::extract::Path(seq): axum::extract::Path, +) -> 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, -- cgit v1.3.1