summaryrefslogtreecommitdiff
path: root/src/push/app.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/push/app.rs')
-rw-r--r--src/push/app.rs48
1 files changed, 3 insertions, 45 deletions
diff --git a/src/push/app.rs b/src/push/app.rs
index f7846a6..1983055 100644
--- a/src/push/app.rs
+++ b/src/push/app.rs
@@ -1,6 +1,6 @@
use p256::ecdsa::VerifyingKey;
use sqlx::SqlitePool;
-use web_push::{SubscriptionInfo, WebPushError};
+use web_push::SubscriptionInfo;
use super::repo::Provider as _;
use crate::{
@@ -78,7 +78,7 @@ impl<P> Push<P>
where
P: Publish,
{
- pub async fn ping(&self, recipient: &Login) -> Result<(), PushError> {
+ pub async fn ping(&self, recipient: &Login) -> Result<(), Failed> {
let mut tx = self.db.begin().await.fail(db::failed::BEGIN)?;
let signer = tx
@@ -99,44 +99,10 @@ where
// we need to write.
tx.commit().await.fail(db::failed::COMMIT)?;
- let failures = self
- .publisher
+ self.publisher
.publish(Heartbeat::Heartbeat, &signer, &subscriptions)
.await
.fail("Failed to send push message")?;
-
- 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)?;
-
- return Err(PushError::Delivery(
- failures.into_iter().map(|(_, err)| err).collect(),
- ));
- }
Ok(())
}
}
@@ -153,11 +119,3 @@ pub enum SubscribeError {
#[error(transparent)]
Failed(#[from] Failed),
}
-
-#[derive(Debug, thiserror::Error)]
-pub enum PushError {
- #[error("push message delivery failures: {0:?}")]
- Delivery(Vec<WebPushError>),
- #[error(transparent)]
- Failed(#[from] Failed),
-}