Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F3359036
D12773.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
D12773.diff
View Options
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
@@ -369,24 +369,15 @@
return Some(MessageSentStatus::SerializationError(notif.headers));
};
- let device_token =
- match self.db_client.get_device_token(¬if.device_id).await {
- Ok(db_token) => {
- let Some(token) = db_token else {
- return Some(self.get_message_to_device_status(
- ¬if.client_message_id,
- Err(SessionError::MissingDeviceToken),
- ));
- };
- token
- }
- Err(e) => {
- return Some(self.get_message_to_device_status(
- ¬if.client_message_id,
- Err(SessionError::DatabaseError(e)),
- ));
- }
- };
+ let device_token = match self.get_device_token(notif.device_id).await {
+ Ok(token) => token,
+ Err(e) => {
+ return Some(
+ self
+ .get_message_to_device_status(¬if.client_message_id, Err(e)),
+ )
+ }
+ };
let apns_notif = APNsNotif {
device_token,
@@ -427,24 +418,15 @@
return Some(MessageSentStatus::SerializationError(notif.data));
};
- let device_token =
- match self.db_client.get_device_token(¬if.device_id).await {
- Ok(db_token) => {
- let Some(token) = db_token else {
- return Some(self.get_message_to_device_status(
- ¬if.client_message_id,
- Err(SessionError::MissingDeviceToken),
- ));
- };
- token
- }
- Err(e) => {
- return Some(self.get_message_to_device_status(
- ¬if.client_message_id,
- Err(SessionError::DatabaseError(e)),
- ));
- }
- };
+ let device_token = match self.get_device_token(notif.device_id).await {
+ Ok(token) => token,
+ Err(e) => {
+ return Some(
+ self
+ .get_message_to_device_status(¬if.client_message_id, Err(e)),
+ )
+ }
+ };
let fcm_message = FCMMessage {
data,
@@ -529,4 +511,16 @@
}),
}
}
+
+ async fn get_device_token(
+ &self,
+ device_id: String,
+ ) -> Result<String, SessionError> {
+ let db_token = self
+ .db_client
+ .get_device_token(&device_id)
+ .await
+ .map_err(SessionError::DatabaseError)?;
+ db_token.ok_or_else(|| SessionError::MissingDeviceToken)
+ }
}
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Mon, Nov 25, 6:48 AM (21 h, 15 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2578846
Default Alt Text
D12773.diff (2 KB)
Attached To
Mode
D12773: [Tunnelbroker] simplify retrieving device token
Attached
Detach File
Event Timeline
Log In to Comment