Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F3392200
D12300.id41098.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
D12300.id41098.diff
View Options
diff --git a/services/identity/src/database/device_list.rs b/services/identity/src/database/device_list.rs
--- a/services/identity/src/database/device_list.rs
+++ b/services/identity/src/database/device_list.rs
@@ -14,6 +14,7 @@
DynamoDBError, TryFromAttribute,
},
};
+use serde::Serialize;
use tracing::{debug, error, trace, warn};
use crate::{
@@ -36,17 +37,24 @@
// We omit the content and notif one-time key count attributes from this struct
// because they are internal helpers and are not provided by users
-#[derive(Clone, Debug)]
+#[derive(Clone, Debug, Serialize)]
+#[serde(rename_all = "camelCase")]
pub struct DeviceRow {
+ #[serde(skip)]
pub user_id: String,
+ #[serde(skip)]
pub device_id: String,
+
+ #[serde(rename = "identityKeyInfo")]
pub device_key_info: IdentityKeyInfo,
pub content_prekey: Prekey,
pub notif_prekey: Prekey,
- pub platform_details: PlatformDetails,
/// Timestamp of last login (access token generation)
+ #[serde(skip)]
pub login_time: DateTime<Utc>,
+ #[serde(skip)]
+ pub platform_details: PlatformDetails,
}
#[derive(Clone, Debug)]
@@ -61,26 +69,38 @@
pub last_primary_signature: Option<String>,
}
-#[derive(Clone, Debug)]
+#[derive(Clone, Debug, Serialize)]
+#[serde(rename_all = "camelCase")]
pub struct IdentityKeyInfo {
pub key_payload: String,
pub key_payload_signature: String,
}
-#[derive(Clone, Debug)]
+#[derive(Clone, Debug, Serialize)]
+#[serde(rename_all = "camelCase")]
pub struct Prekey {
pub prekey: String,
pub prekey_signature: String,
}
-#[derive(Clone, Debug)]
+#[derive(Clone, Debug, Serialize)]
+#[serde(rename_all = "camelCase")]
pub struct PlatformDetails {
+ #[serde(serialize_with = "serialize_device_type")]
device_type: DeviceType,
code_version: u64,
state_version: Option<u64>,
major_desktop_version: Option<u64>,
}
+fn serialize_device_type<S: serde::Serializer>(
+ device_type: &DeviceType,
+ s: S,
+) -> Result<S::Ok, S::Error> {
+ let v = device_type.as_str_name().to_lowercase();
+ v.serialize(s)
+}
+
/// A struct representing device list update payload
/// issued by the primary device.
/// For the JSON payload, see [`crate::device_list::SignedDeviceList`]
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sun, Dec 1, 7:31 AM (21 h, 44 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2604208
Default Alt Text
D12300.id41098.diff (2 KB)
Attached To
Mode
D12300: [identity] Add Serialize trait for inbound keys types
Attached
Detach File
Event Timeline
Log In to Comment