From 98ce341c5fe8403b9dc5654fe18e1ebba61e68e4 Mon Sep 17 00:00:00 2001 From: Owen Jacobson Date: Fri, 12 Dec 2025 10:23:59 -0500 Subject: Publish push messages when a message is sent to a conversation. --- src/push/repo.rs | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'src/push/repo.rs') diff --git a/src/push/repo.rs b/src/push/repo.rs index 4183489..8850059 100644 --- a/src/push/repo.rs +++ b/src/push/repo.rs @@ -83,6 +83,27 @@ impl Push<'_> { Ok(info) } + pub async fn broadcast_from( + &mut self, + originator: &Login, + ) -> Result, sqlx::Error> { + sqlx::query!( + r#" + select + sub.endpoint, + sub.p256dh, + sub.auth + from push_subscription as sub + join token on sub.token = token.id + where token.login <> $1 + "#, + originator.id, + ) + .map(|row| SubscriptionInfo::new(row.endpoint, row.p256dh, row.auth)) + .fetch_all(&mut *self.0) + .await + } + pub async fn unsubscribe( &mut self, subscription: &SubscriptionInfo, -- cgit v1.2.3