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, + #[serde(skip)] + pub platform_details: PlatformDetails, } #[derive(Clone, Debug)] @@ -61,26 +69,38 @@ pub last_primary_signature: Option, } -#[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, major_desktop_version: Option, } +fn serialize_device_type( + device_type: &DeviceType, + s: S, +) -> Result { + 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`]