Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F3332803
D12908.id42905.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
D12908.id42905.diff
View Options
diff --git a/services/tunnelbroker/src/constants.rs b/services/tunnelbroker/src/constants.rs
--- a/services/tunnelbroker/src/constants.rs
+++ b/services/tunnelbroker/src/constants.rs
@@ -43,13 +43,15 @@
// This table holds a device token associated with a device.
//
// - (primary key) = (deviceID: Partition Key)
- // - deviceID: The public key of a device's olm identity key
+ // - deviceID: The public key of a device's olm identity key.
// - deviceToken: Token to push services uploaded by device.
+ // - tokenInvalid: Information is token is invalid.
pub mod device_tokens {
pub const TABLE_NAME: &str = "tunnelbroker-device-tokens";
pub const PARTITION_KEY: &str = "deviceID";
pub const DEVICE_ID: &str = "deviceID";
pub const DEVICE_TOKEN: &str = "deviceToken";
+ pub const TOKEN_INVALID: &str = "tokenInvalid";
pub const DEVICE_TOKEN_INDEX_NAME: &str = "deviceToken-index";
}
diff --git a/services/tunnelbroker/src/database/mod.rs b/services/tunnelbroker/src/database/mod.rs
--- a/services/tunnelbroker/src/database/mod.rs
+++ b/services/tunnelbroker/src/database/mod.rs
@@ -36,6 +36,11 @@
}
}
+pub struct DeviceTokenEntry {
+ pub device_token: String,
+ pub token_invalid: bool,
+}
+
impl DatabaseClient {
pub fn new(aws_config: &AwsConfig) -> Self {
let client = DynamoDBClient::new(aws_config);
@@ -153,7 +158,7 @@
pub async fn get_device_token(
&self,
device_id: &str,
- ) -> Result<Option<String>, Error> {
+ ) -> Result<Option<DeviceTokenEntry>, Error> {
let get_response = self
.client
.get_item()
@@ -174,7 +179,13 @@
};
let device_token: String = item.take_attr(device_tokens::DEVICE_TOKEN)?;
- Ok(Some(device_token))
+ let token_invalid: Option<bool> =
+ item.take_attr(device_tokens::TOKEN_INVALID)?;
+
+ Ok(Some(DeviceTokenEntry {
+ device_token,
+ token_invalid: token_invalid.unwrap_or(false),
+ }))
}
pub async fn set_device_token(
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
@@ -69,6 +69,7 @@
MissingAPNsClient,
MissingFCMClient,
MissingDeviceToken,
+ InvalidDeviceToken,
}
// Parse a session request and retrieve the device information
@@ -530,6 +531,16 @@
.get_device_token(&device_id)
.await
.map_err(SessionError::DatabaseError)?;
- db_token.ok_or_else(|| SessionError::MissingDeviceToken)
+
+ match db_token {
+ Some(token) => {
+ if token.token_invalid {
+ Err(SessionError::InvalidDeviceToken)
+ } else {
+ Ok(token.device_token)
+ }
+ }
+ None => Err(SessionError::MissingDeviceToken),
+ }
}
}
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Fri, Nov 22, 1:50 AM (5 h, 15 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2559338
Default Alt Text
D12908.id42905.diff (2 KB)
Attached To
Mode
D12908: [Tunnelbroker] add DDB column with information about invalid device token
Attached
Detach File
Event Timeline
Log In to Comment