diff options
Diffstat (limited to 'src/push/repo.rs')
| -rw-r--r-- | src/push/repo.rs | 21 |
1 files changed, 21 insertions, 0 deletions
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<Vec<SubscriptionInfo>, 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, |
