Page MenuHomePhabricator

D13020.id43241.diff
No OneTemporary

D13020.id43241.diff

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(&notif.client_message_id, result),
)

File Metadata

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)

Event Timeline