From 3193a30ebcf6bafdeaf463eda0e7e82082dfe4b5 Mon Sep 17 00:00:00 2001 From: Owen Jacobson Date: Fri, 13 Sep 2024 01:26:56 -0400 Subject: Embed the sender's whole login (id and name) in messages, drop the redundant channel ID. --- src/channel/routes.rs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'src/channel/routes.rs') diff --git a/src/channel/routes.rs b/src/channel/routes.rs index 83c733c..0f95c69 100644 --- a/src/channel/routes.rs +++ b/src/channel/routes.rs @@ -8,10 +8,13 @@ use axum::{ routing::{get, post}, Router, }; -use futures::stream::{StreamExt as _, TryStreamExt as _}; +use futures::{future, stream::TryStreamExt as _}; use super::repo::channels::Id as ChannelId; -use crate::{app::App, clock::RequestedAt, error::InternalError, login::repo::logins::Login}; +use crate::{ + app::App, clock::RequestedAt, error::BoxedError, error::InternalError, + login::repo::logins::Login, +}; pub fn router() -> Router { Router::new() @@ -63,10 +66,7 @@ async fn on_events( .channels() .events(&channel) .await? - .map(|msg| match msg { - Ok(msg) => Ok(serde_json::to_string(&msg)?), - Err(err) => Err(err), - }) + .and_then(|msg| future::ready(serde_json::to_string(&msg).map_err(BoxedError::from))) .map_ok(|msg| sse::Event::default().data(&msg)); Ok(Sse::new(stream).keep_alive(sse::KeepAlive::default())) -- cgit v1.2.3