Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F3366266
D12951.id43003.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
3 KB
Referenced Files
None
Subscribers
None
D12951.id43003.diff
View Options
diff --git a/services/tunnelbroker/src/notifs/fcm/mod.rs b/services/tunnelbroker/src/notifs/fcm/mod.rs
--- a/services/tunnelbroker/src/notifs/fcm/mod.rs
+++ b/services/tunnelbroker/src/notifs/fcm/mod.rs
@@ -9,9 +9,9 @@
use tracing::{debug, error};
pub mod config;
-mod error;
+pub mod error;
pub mod firebase_message;
-mod response;
+pub mod response;
mod token;
#[derive(Clone)]
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
@@ -2,6 +2,7 @@
CLIENT_RMQ_MSG_PRIORITY, DDB_RMQ_MSG_PRIORITY, MAX_RMQ_MSG_PRIORITY,
RMQ_CONSUMER_TAG,
};
+use crate::notifs::fcm::response::FCMErrorResponse;
use comm_lib::aws::ddb::error::SdkError;
use comm_lib::aws::ddb::operation::put_item::PutItemError;
use derive_more;
@@ -16,6 +17,8 @@
};
use lapin::types::FieldTable;
use lapin::BasicProperties;
+use notifs::fcm::error::Error::FCMError as NotifsFCMError;
+use notifs::web_push::error::Error::WebPush as NotifsWebPushError;
use tokio::io::AsyncRead;
use tokio::io::AsyncWrite;
use tracing::{debug, error, info, trace};
@@ -26,6 +29,7 @@
DeviceToTunnelbrokerMessage, Heartbeat, MessageToDevice,
MessageToDeviceRequest, MessageToTunnelbroker,
};
+use web_push::WebPushError;
use crate::notifs::apns::response::ErrorReason;
@@ -472,7 +476,7 @@
};
let device_token = match self
- .get_device_token(notif.device_id, NotifClientType::FCM)
+ .get_device_token(notif.device_id.clone(), NotifClientType::FCM)
.await
{
Ok(token) => token,
@@ -491,10 +495,27 @@
};
if let Some(fcm) = self.notif_client.fcm.clone() {
- let response = fcm.send(fcm_message).await;
+ let result = fcm.send(fcm_message).await;
+
+ if let Err(NotifsFCMError(fcm_error)) = &result {
+ if matches!(
+ fcm_error,
+ FCMErrorResponse::Unregistered
+ | FCMErrorResponse::InvalidArgument(_)
+ ) {
+ if let Err(e) = self
+ .invalidate_device_token(notif.device_id, device_token.clone())
+ .await
+ {
+ error!(
+ "Error invalidating device token {}: {:?}",
+ device_token, e
+ );
+ };
+ }
+ }
return Some(
- self
- .get_message_to_device_status(¬if.client_message_id, response),
+ self.get_message_to_device_status(¬if.client_message_id, result),
);
}
@@ -540,13 +561,10 @@
};
let result = web_push_client.send(web_push_notif).await;
- if let Err(notifs::web_push::error::Error::WebPush(web_push_error)) =
- &result
- {
+ if let Err(NotifsWebPushError(web_push_error)) = &result {
if matches!(
web_push_error,
- web_push::WebPushError::EndpointNotValid
- | web_push::WebPushError::EndpointNotFound
+ WebPushError::EndpointNotValid | WebPushError::EndpointNotFound
) {
if let Err(e) = self
.invalidate_device_token(notif.device_id, device_token.clone())
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Tue, Nov 26, 10:28 AM (21 h, 8 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2584285
Default Alt Text
D12951.id43003.diff (3 KB)
Attached To
Mode
D12951: [Tunnelbroker] invalidate bad FCM tokens
Attached
Detach File
Event Timeline
Log In to Comment