SSS: refactor E2EE extension like other extensions

This commit is contained in:
Lambda 2025-05-31 17:31:36 +00:00
parent 30951cb611
commit f5ff294c3e

View file

@ -391,8 +391,20 @@ pub(crate) async fn sync_events_v5_route(
}
#[allow(clippy::if_then_some_else_none)]
let device_lists = if body.extensions.e2ee.enabled.unwrap_or(false) {
Some(get_e2ee_data(&sender_user, globalsince, &all_joined_rooms).await?)
let e2ee = if body.extensions.e2ee.enabled == Some(true) {
Some(sync_events::v5::response::E2EE {
device_lists: get_e2ee_data(
&sender_user,
globalsince,
&all_joined_rooms,
)
.await?,
device_one_time_keys_count: services()
.users
.count_one_time_keys(&sender_user, &sender_device)?,
// Fallback keys are not yet supported
device_unused_fallback_key_types: None,
})
} else {
None
};
@ -492,14 +504,7 @@ pub(crate) async fn sync_events_v5_route(
rooms,
extensions: sync_events::v5::response::Extensions {
to_device,
e2ee: sync_events::v5::response::E2EE {
device_lists: device_lists.unwrap_or_default(),
device_one_time_keys_count: services()
.users
.count_one_time_keys(&sender_user, &sender_device)?,
// Fallback keys are not yet supported
device_unused_fallback_key_types: None,
},
e2ee: e2ee.unwrap_or_default(),
account_data: sync_events::v5::response::AccountData {
global: if body.extensions.account_data.enabled.unwrap_or(false)
{