Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F3341921
D13020.id43241.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
2 KB
Referenced Files
None
Subscribers
None
D13020.id43241.diff
View Options
diff --git a/services/tunnelbroker/src/notifs/wns/mod.rs b/services/tunnelbroker/src/notifs/wns/mod.rs
--- a/services/tunnelbroker/src/notifs/wns/mod.rs
+++ b/services/tunnelbroker/src/notifs/wns/mod.rs
@@ -8,8 +8,8 @@
};
pub mod config;
-mod error;
-mod response;
+pub mod error;
+pub mod response;
#[derive(Debug, Clone)]
pub struct WNSAccessToken {
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 @@
RMQ_CONSUMER_TAG,
};
use crate::notifs::fcm::response::FCMErrorResponse;
+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;
@@ -19,6 +20,7 @@
use lapin::BasicProperties;
use notifs::fcm::error::Error::FCMError as NotifsFCMError;
use notifs::web_push::error::Error::WebPush as NotifsWebPushError;
+use notifs::wns::error::Error::WNSNotification as NotifsWNSError;
use tokio::io::AsyncRead;
use tokio::io::AsyncWrite;
use tracing::{debug, error, info, trace};
@@ -601,7 +603,7 @@
};
let device_token = match self
- .get_device_token(notif.device_id, NotifClientType::WNS)
+ .get_device_token(notif.device_id.clone(), NotifClientType::WNS)
.await
{
Ok(token) => token,
@@ -614,11 +616,25 @@
};
let wns_notif = WNSNotif {
- device_token,
+ device_token: device_token.clone(),
payload: notif.payload,
};
let result = wns_client.send(wns_notif).await;
+ if let Err(NotifsWNSError(err)) = &result {
+ if matches!(err, WNSErrorResponse::NotFound | WNSErrorResponse::Gone)
+ {
+ if let Err(e) = self
+ .invalidate_device_token(notif.device_id, device_token.clone())
+ .await
+ {
+ error!(
+ "Error invalidating device token {}: {:?}",
+ device_token, e
+ );
+ };
+ }
+ }
Some(
self.get_message_to_device_status(¬if.client_message_id, result),
)
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Fri, Nov 22, 11:56 PM (17 h, 43 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2562790
Default Alt Text
D13020.id43241.diff (2 KB)
Attached To
Mode
D13020: [tunnelbroker] invalidate bad wns device tokens
Attached
Detach File
Event Timeline
Log In to Comment