From eff129bc1f29bcb1b2b9d10c6b49ab886edc83d6 Mon Sep 17 00:00:00 2001 From: Owen Jacobson Date: Fri, 27 Sep 2024 18:17:02 -0400 Subject: Make `/api/events` a firehose endpoint. It now includes events for all channels. Clients are responsible for filtering. The schema for channel events has changed; it now includes a channel name and ID, in the same format as the sender's name and ID. They also now include a `"type"` field, whose only valid value (as of this writing) is `"message"`. This is groundwork for delivering message deletion (expiry) events to clients, and notifying clients of channel lifecycle events. --- src/channel/app.rs | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) (limited to 'src/channel/app.rs') diff --git a/src/channel/app.rs b/src/channel/app.rs index 793fa35..6bad158 100644 --- a/src/channel/app.rs +++ b/src/channel/app.rs @@ -1,18 +1,14 @@ use sqlx::sqlite::SqlitePool; -use crate::{ - events::broadcaster::Broadcaster, - repo::channel::{Channel, Provider as _}, -}; +use crate::repo::channel::{Channel, Provider as _}; pub struct Channels<'a> { db: &'a SqlitePool, - broadcaster: &'a Broadcaster, } impl<'a> Channels<'a> { - pub const fn new(db: &'a SqlitePool, broadcaster: &'a Broadcaster) -> Self { - Self { db, broadcaster } + pub const fn new(db: &'a SqlitePool) -> Self { + Self { db } } pub async fn create(&self, name: &str) -> Result { @@ -22,7 +18,6 @@ impl<'a> Channels<'a> { .create(name) .await .map_err(|err| CreateError::from_duplicate_name(err, name))?; - self.broadcaster.register_channel(&channel.id); tx.commit().await?; Ok(channel) -- cgit v1.2.3