Page MenuHomePhabricator

D11897.diff
No OneTemporary

D11897.diff

diff --git a/services/identity/src/constants.rs b/services/identity/src/constants.rs
--- a/services/identity/src/constants.rs
+++ b/services/identity/src/constants.rs
@@ -121,6 +121,8 @@
// device-list-specific attrs
pub const ATTR_TIMESTAMP: &str = "timestamp";
pub const ATTR_DEVICE_IDS: &str = "deviceIDs";
+ pub const ATTR_CURRENT_SIGNATURE: &str = "curPrimarySignature";
+ pub const ATTR_LAST_SIGNATURE: &str = "lastPrimarySignature";
// migration-specific attrs
pub const ATTR_CODE_VERSION: &str = "codeVersion";
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
@@ -53,6 +53,11 @@
pub user_id: String,
pub timestamp: DateTime<Utc>,
pub device_ids: Vec<String>,
+ /// Primary device signature. This is `None` for Identity-generated lists.
+ pub current_primary_signature: Option<String>,
+ /// Last primary device signature, in case the primary device has changed
+ /// since last device list update.
+ pub last_primary_signature: Option<String>,
}
#[derive(Clone, Debug)]
@@ -117,7 +122,8 @@
}
impl DeviceListRow {
- /// Generates new device list row from given devices
+ /// Generates new device list row from given devices.
+ /// Used only for Identity-generated (unsigned) device lists.
fn new(
user_id: impl Into<String>,
device_ids: Vec<String>,
@@ -127,6 +133,8 @@
user_id: user_id.into(),
device_ids,
timestamp: timestamp.unwrap_or_else(Utc::now),
+ current_primary_signature: None,
+ last_primary_signature: None,
}
}
}
@@ -383,10 +391,15 @@
let device_ids: Vec<String> = attrs.take_attr(ATTR_DEVICE_IDS)?;
+ let current_primary_signature = attrs.take_attr(ATTR_CURRENT_SIGNATURE)?;
+ let last_primary_signature = attrs.take_attr(ATTR_LAST_SIGNATURE)?;
+
Ok(Self {
user_id,
timestamp,
device_ids,
+ current_primary_signature,
+ last_primary_signature,
})
}
}
@@ -416,6 +429,18 @@
.collect(),
),
);
+ if let Some(current_signature) = device_list.current_primary_signature {
+ attrs.insert(
+ ATTR_CURRENT_SIGNATURE.to_string(),
+ AttributeValue::S(current_signature),
+ );
+ }
+ if let Some(last_signature) = device_list.last_primary_signature {
+ attrs.insert(
+ ATTR_CURRENT_SIGNATURE.to_string(),
+ AttributeValue::S(last_signature),
+ );
+ }
attrs
}
}

File Metadata

Mime Type
text/plain
Expires
Mon, Nov 18, 12:32 AM (19 h, 42 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2532445
Default Alt Text
D11897.diff (2 KB)

Event Timeline