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

View File

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