summaryrefslogtreecommitdiff
path: root/src/message/app.rs
diff options
context:
space:
mode:
authorOwen Jacobson <owen@grimoire.ca>2026-02-27 16:41:37 -0500
committerOwen Jacobson <owen@grimoire.ca>2026-02-27 18:15:33 -0500
commitb32c7682f0a84619a6d1845516a6a1829fa0c59b (patch)
treefad8bf5bd8eb628253611f0b3d1a91febe3b9266 /src/message/app.rs
parent6ab0f42250294e38e8da6a48260ff83544a6be9a (diff)
Move failed push handling inside of the web push publisher.HEADmain
I want push publication to be "fire and forget," and ultimately also for it to be asynchronous and retriable. To facilitate that, the caller needs to be insulated from the final outcome of publishing a push message. I've opted to preserve the `Failure` possibility, but any delivery issues are now handled inside the publisher.
Diffstat (limited to 'src/message/app.rs')
-rw-r--r--src/message/app.rs32
1 files changed, 1 insertions, 31 deletions
diff --git a/src/message/app.rs b/src/message/app.rs
index b79dad0..4bf96bf 100644
--- a/src/message/app.rs
+++ b/src/message/app.rs
@@ -1,7 +1,6 @@
use chrono::TimeDelta;
use itertools::Itertools;
use sqlx::sqlite::SqlitePool;
-use web_push::WebPushError;
use super::{Body, History, Id, Message, history, repo::Provider as _};
use crate::{
@@ -184,39 +183,10 @@ where
self.events.broadcast_from(events.clone());
for event in events {
- let failures = self
- .publisher
+ self.publisher
.publish(Event::from(event), &signer, &push_recipients)
.await
.fail("Failed to publish push events")?;
-
- if !failures.is_empty() {
- let mut tx = self.db.begin().await.fail(db::failed::BEGIN)?;
- // Note that data integrity guarantees from the original transaction to read
- // subscriptions may no longer be valid now. Time has passed. Depending on how slow
- // delivering push notifications is, potentially a _lot_ of time has passed.
-
- for (sub, err) in failures {
- match err {
- // I _think_ this is the complete set of permanent failures. See
- // <https://docs.rs/web-push/latest/web_push/enum.WebPushError.html> for a complete
- // list.
- WebPushError::Unauthorized(_)
- | WebPushError::InvalidUri
- | WebPushError::EndpointNotValid(_)
- | WebPushError::EndpointNotFound(_)
- | WebPushError::InvalidCryptoKeys
- | WebPushError::MissingCryptoKeys => {
- tx.push().unsubscribe(sub).await.fail(
- "Failed to unsubscribe after permanent push message rejection",
- )?;
- }
- _ => (),
- }
- }
-
- tx.commit().await.fail(db::failed::COMMIT)?;
- }
}
Ok(message.as_sent())