Page MenuHomePhorge

D13970.1765140720.diff
No OneTemporary

Size
3 KB
Referenced Files
None
Subscribers
None

D13970.1765140720.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
@@ -3,6 +3,7 @@
error_types, CLIENT_RMQ_MSG_PRIORITY, DDB_RMQ_MSG_PRIORITY,
MAX_RMQ_MSG_PRIORITY, RMQ_CONSUMER_TAG,
};
+use crate::notifs::wns::response::WNSErrorResponse;
use comm_lib::aws::ddb::error::SdkError;
use comm_lib::aws::ddb::operation::put_item::PutItemError;
use derive_more;
@@ -34,8 +35,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 +526,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 +665,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(
@@ -714,7 +715,8 @@
let result = wns_client.send(wns_notif).await;
if let Err(NotifsWNSError(err)) = &result {
- if err.should_invalidate_token() {
+ if matches!(err, WNSErrorResponse::NotFound | WNSErrorResponse::Gone)
+ {
if let Err(e) = self
.invalidate_device_token(notif.device_id, device_token.clone())
.await

File Metadata

Mime Type
text/plain
Expires
Sun, Dec 7, 8:52 PM (12 h, 29 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
5846005
Default Alt Text
D13970.1765140720.diff (3 KB)

Event Timeline