From 0bb17bd01640492db2685e67bacac12dd54a9f59 Mon Sep 17 00:00:00 2001 From: Owen Jacobson Date: Thu, 24 Oct 2024 22:37:22 -0400 Subject: 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. --- src/invite/app.rs | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'src/invite/app.rs') 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 { @@ -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::>()); + Ok((login.as_created(), secret)) } -- cgit v1.2.3