diff options
| author | Owen Jacobson <owen@grimoire.ca> | 2024-10-24 22:37:22 -0400 |
|---|---|---|
| committer | Owen Jacobson <owen@grimoire.ca> | 2024-10-24 22:37:22 -0400 |
| commit | 0bb17bd01640492db2685e67bacac12dd54a9f59 (patch) | |
| tree | 5c8425b8e6a962e609f82a7b3f2498524d8d6c6f /src/invite/app.rs | |
| parent | d97f8ac1858fbd46b77b541a612cc37b07fc0b5d (diff) | |
Tests for channel, invite, setup, and message deletion events.
This also found a bug! No live event was being emitted during invite accept. The only way to find out about invites was to reconnect.
Diffstat (limited to 'src/invite/app.rs')
| -rw-r--r-- | src/invite/app.rs | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/src/invite/app.rs b/src/invite/app.rs index 65e7721..176075f 100644 --- a/src/invite/app.rs +++ b/src/invite/app.rs @@ -5,7 +5,7 @@ use super::{repo::Provider as _, Id, Invite, Summary}; use crate::{ clock::DateTime, db::{Duplicate as _, NotFound as _}, - event::repo::Provider as _, + event::{repo::Provider as _, Broadcaster, Event}, login::{repo::Provider as _, Login, Password}, name::Name, token::{repo::Provider as _, Secret}, @@ -13,11 +13,12 @@ use crate::{ pub struct Invites<'a> { db: &'a SqlitePool, + events: &'a Broadcaster, } impl<'a> Invites<'a> { - pub const fn new(db: &'a SqlitePool) -> Self { - Self { db } + pub const fn new(db: &'a SqlitePool, events: &'a Broadcaster) -> Self { + Self { db, events } } pub async fn issue(&self, issuer: &Login, issued_at: &DateTime) -> Result<Invite, sqlx::Error> { @@ -69,6 +70,9 @@ impl<'a> Invites<'a> { let secret = tx.tokens().issue(&login, accepted_at).await?; tx.commit().await?; + self.events + .broadcast(login.events().map(Event::from).collect::<Vec<_>>()); + Ok((login.as_created(), secret)) } |
