Skip to content

Commit 6a9d4b4

Browse files
authored
Don't delete devices marked as dehydrated devices (#4268)
2 parents 6dd5605 + 9b8a824 commit 6a9d4b4

File tree

1 file changed

+10
-2
lines changed
  • crates/matrix-synapse/src

1 file changed

+10
-2
lines changed

crates/matrix-synapse/src/lib.rs

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,9 @@ struct SynapseDeviceListResponse {
128128
#[derive(Serialize, Deserialize)]
129129
struct SynapseDevice {
130130
device_id: String,
131+
132+
#[serde(default, skip_serializing_if = "Option::is_none")]
133+
dehydrated: Option<bool>,
131134
}
132135

133136
#[derive(Serialize)]
@@ -316,6 +319,7 @@ impl HomeserverConnection for SynapseConnection {
316319
.post(&format!("_synapse/admin/v2/users/{mxid}/devices"))
317320
.json(&SynapseDevice {
318321
device_id: device_id.to_owned(),
322+
dehydrated: None,
319323
})
320324
.send_traced()
321325
.await
@@ -410,8 +414,12 @@ impl HomeserverConnection for SynapseConnection {
410414
.await
411415
.context("Failed to parse response while querying devices from Synapse")?;
412416

413-
let existing_devices: HashSet<String> =
414-
body.devices.into_iter().map(|d| d.device_id).collect();
417+
let existing_devices: HashSet<String> = body
418+
.devices
419+
.into_iter()
420+
.filter(|d| d.dehydrated != Some(true))
421+
.map(|d| d.device_id)
422+
.collect();
415423

416424
// First, delete all the devices that are not needed anymore
417425
let to_delete = existing_devices.difference(&devices).cloned().collect();

0 commit comments

Comments
 (0)