Page MenuHomePhabricator

D13970.diff
No OneTemporary

D13970.diff

diff --git a/services/tunnelbroker/src/notifs/apns/mod.rs b/services/tunnelbroker/src/notifs/apns/mod.rs
--- a/services/tunnelbroker/src/notifs/apns/mod.rs
+++ b/services/tunnelbroker/src/notifs/apns/mod.rs
@@ -1,4 +1,4 @@
-use crate::constants::PUSH_SERVICE_REQUEST_TIMEOUT;
+use crate::constants::{error_types, PUSH_SERVICE_REQUEST_TIMEOUT};
use crate::notifs::apns::config::APNsConfig;
use crate::notifs::apns::error::Error::ResponseError;
use crate::notifs::apns::headers::{NotificationHeaders, PushType};
@@ -8,7 +8,7 @@
use reqwest::StatusCode;
use serde::{Deserialize, Serialize};
use std::time::Duration;
-use tracing::debug;
+use tracing::{debug, error};
pub mod config;
pub mod error;
@@ -132,6 +132,16 @@
StatusCode::OK => Ok(()),
_ => {
let error_body: ErrorBody = response.json().await?;
+
+ if !error_body.reason.should_invalidate_token() {
+ error!(
+ errorType = error_types::APNS_ERROR,
+ "Failed sending APNs notification to: {}. Body: {}",
+ notif.device_token,
+ error_body,
+ );
+ }
+
Err(ResponseError(error_body))
}
}
diff --git a/services/tunnelbroker/src/notifs/apns/response.rs b/services/tunnelbroker/src/notifs/apns/response.rs
--- a/services/tunnelbroker/src/notifs/apns/response.rs
+++ b/services/tunnelbroker/src/notifs/apns/response.rs
@@ -117,3 +117,14 @@
/// The server is shutting down.
Shutdown,
}
+
+impl ErrorReason {
+ pub fn should_invalidate_token(&self) -> bool {
+ matches!(
+ self,
+ ErrorReason::BadDeviceToken
+ | ErrorReason::Unregistered
+ | ErrorReason::ExpiredToken
+ )
+ }
+}
diff --git a/services/tunnelbroker/src/websockets/session.rs b/services/tunnelbroker/src/websockets/session.rs
--- a/services/tunnelbroker/src/websockets/session.rs
+++ b/services/tunnelbroker/src/websockets/session.rs
@@ -34,8 +34,6 @@
};
use web_push::WebPushError;
-use crate::notifs::apns::response::ErrorReason;
-
use crate::database::{self, DatabaseClient, MessageToDeviceExt};
use crate::notifs::apns::headers::NotificationHeaders;
use crate::notifs::apns::APNsNotif;
@@ -527,12 +525,7 @@
if let Some(apns) = self.notif_client.apns.clone() {
let response = apns.send(apns_notif).await;
if let Err(apns::error::Error::ResponseError(body)) = &response {
- if matches!(
- body.reason,
- ErrorReason::BadDeviceToken
- | ErrorReason::Unregistered
- | ErrorReason::ExpiredToken
- ) {
+ if body.reason.should_invalidate_token() {
if let Err(e) = self
.invalidate_device_token(notif.device_id, device_token.clone())
.await
@@ -671,6 +664,13 @@
"Error invalidating device token {}: {:?}", device_token, e
);
};
+ } else {
+ error!(
+ errorType = error_types::WEB_PUSH_ERROR,
+ "Failed sending Web Push notification to: {}. Error: {}",
+ device_token,
+ web_push_error
+ );
}
}
Some(

File Metadata

Mime Type
text/plain
Expires
Sat, Nov 30, 6:19 AM (15 h, 30 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2599909
Default Alt Text
D13970.diff (3 KB)

Event Timeline