replace unnecessary check when updating device keys

Signed-off-by: June Clementine Strawberry <june@3.dog>
This commit is contained in:
June Clementine Strawberry 2025-03-17 22:50:29 -04:00
parent 658c19d55e
commit 7bf92c8a37
No known key found for this signature in database
2 changed files with 17 additions and 5 deletions

View file

@ -290,7 +290,7 @@ pub(crate) async fn add_backup_keys_for_session_route(
new_forwarded_count < old_forwarded_count
},
};
};
}
}
if ok_to_replace {

View file

@ -80,14 +80,26 @@ pub(crate) async fn upload_keys_route(
)));
}
// TODO: merge this and the existing event?
// This check is needed to assure that signatures are kept
if services
if let Ok(existing_keys) = services
.users
.get_device_keys(sender_user, sender_device)
.await
.is_err()
{
if existing_keys.json().get() == device_keys.json().get() {
debug!(
?sender_user,
?sender_device,
?device_keys,
"Ignoring user uploaded keys as they are an exact copy already in the \
database"
);
} else {
services
.users
.add_device_keys(sender_user, sender_device, device_keys)
.await;
}
} else {
services
.users
.add_device_keys(sender_user, sender_device, device_keys)