base: Include the to-device events when returning the sync response

master
Damir Jelić 2021-01-14 13:35:21 +01:00
parent 43ea9a16a0
commit 508bf3b23d
2 changed files with 15 additions and 4 deletions

View File

@ -30,8 +30,8 @@ use matrix_sdk_common::{
events::{
presence::PresenceEvent,
room::member::{MemberEventContent, MembershipState},
AnyBasicEvent, AnyStrippedStateEvent, AnySyncRoomEvent, AnySyncStateEvent, EventContent,
StateEvent,
AnyBasicEvent, AnyStrippedStateEvent, AnySyncRoomEvent, AnySyncStateEvent,
AnyToDeviceEvent, EventContent, StateEvent,
},
identifiers::{RoomId, UserId},
locks::RwLock,
@ -868,14 +868,19 @@ impl BaseClient {
account_data: AccountData {
events: changes.account_data.into_iter().map(|(_, e)| e).collect(),
},
to_device: response
.to_device
.events
.into_iter()
.filter_map(|e| e.deserialize().ok())
.collect::<Vec<AnyToDeviceEvent>>()
.into(),
device_lists: response.device_lists,
device_one_time_keys_count: response
.device_one_time_keys_count
.into_iter()
.map(|(k, v)| (k, v.into()))
.collect(),
..Default::default()
};
if let Some(emitter) = self.event_emitter.read().await.as_ref() {

View File

@ -64,6 +64,12 @@ pub struct ToDevice {
pub events: Vec<AnyToDeviceEvent>,
}
impl From<Vec<AnyToDeviceEvent>> for ToDevice {
fn from(events: Vec<AnyToDeviceEvent>) -> Self {
Self { events }
}
}
#[derive(Clone, Debug, Default, Deserialize, Serialize)]
pub struct Rooms {
/// The rooms that the user has left or been banned from.