summaryrefslogtreecommitdiff
path: root/src/channel/routes.rs
diff options
context:
space:
mode:
authorOwen Jacobson <owen@grimoire.ca>2024-09-13 01:26:56 -0400
committerOwen Jacobson <owen@grimoire.ca>2024-09-13 02:42:27 -0400
commit3193a30ebcf6bafdeaf463eda0e7e82082dfe4b5 (patch)
tree2fb3ea84923aecf0ec1f820408bdc670b1247c95 /src/channel/routes.rs
parent067e3da1900d052a416c56e1c047640aa23441ae (diff)
Embed the sender's whole login (id and name) in messages, drop the redundant channel ID.
Diffstat (limited to 'src/channel/routes.rs')
-rw-r--r--src/channel/routes.rs12
1 files changed, 6 insertions, 6 deletions
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<App> {
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()))