mirror of
https://gitlab.computer.surgery/matrix/grapevine.git
synced 2025-12-16 15:21:24 +01:00
SSS: factor out to_device
This commit is contained in:
parent
adff2ec637
commit
30951cb611
1 changed files with 21 additions and 16 deletions
|
|
@ -43,7 +43,7 @@ use crate::{
|
|||
},
|
||||
users::ConnectionKey,
|
||||
},
|
||||
services, Ar, Error, Ra, Result,
|
||||
services, utils, Ar, Error, Ra, Result,
|
||||
};
|
||||
|
||||
#[derive(Debug)]
|
||||
|
|
@ -443,6 +443,25 @@ pub(crate) async fn sync_events_v5_route(
|
|||
next_batch,
|
||||
);
|
||||
|
||||
let to_device = if body.extensions.to_device.enabled == Some(true) {
|
||||
let events = services()
|
||||
.users
|
||||
.get_to_device_events(&sender_user, &sender_device)?;
|
||||
if !events.is_empty() {
|
||||
debug!(
|
||||
events = utils::debug_slice_truncated(&events, 3),
|
||||
"Got new to-device events"
|
||||
);
|
||||
}
|
||||
|
||||
Some(sync_events::v5::response::ToDevice {
|
||||
events,
|
||||
next_batch: next_batch.to_string(),
|
||||
})
|
||||
} else {
|
||||
None
|
||||
};
|
||||
|
||||
let mut rooms = BTreeMap::new();
|
||||
for (room_id, todo_room) in todo_rooms {
|
||||
if let Some(room) = process_room(&sender_user, &room_id, &todo_room)? {
|
||||
|
|
@ -472,21 +491,7 @@ pub(crate) async fn sync_events_v5_route(
|
|||
lists,
|
||||
rooms,
|
||||
extensions: sync_events::v5::response::Extensions {
|
||||
to_device: body
|
||||
.extensions
|
||||
.to_device
|
||||
.enabled
|
||||
.unwrap_or(false)
|
||||
.then(|| {
|
||||
services()
|
||||
.users
|
||||
.get_to_device_events(&sender_user, &sender_device)
|
||||
.map(|events| sync_events::v5::response::ToDevice {
|
||||
events,
|
||||
next_batch: next_batch.to_string(),
|
||||
})
|
||||
})
|
||||
.transpose()?,
|
||||
to_device,
|
||||
e2ee: sync_events::v5::response::E2EE {
|
||||
device_lists: device_lists.unwrap_or_default(),
|
||||
device_one_time_keys_count: services()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue