matrix_sdk_base: handle response.account_data events
"m.direct" events are not in room account data events but in main onemaster
parent
883183324f
commit
d858940342
|
@ -902,7 +902,11 @@ impl BaseClient {
|
||||||
/// * `room_id` - The unique id of the room the event belongs to.
|
/// * `room_id` - The unique id of the room the event belongs to.
|
||||||
///
|
///
|
||||||
/// * `event` - The presence event for a specified room member.
|
/// * `event` - The presence event for a specified room member.
|
||||||
pub async fn receive_account_data_event(&self, _: &RoomId, event: &AnyBasicEvent) -> bool {
|
pub async fn receive_account_data_event(
|
||||||
|
&self,
|
||||||
|
_: Option<&RoomId>,
|
||||||
|
event: &AnyBasicEvent,
|
||||||
|
) -> bool {
|
||||||
match event {
|
match event {
|
||||||
AnyBasicEvent::IgnoredUserList(event) => self.handle_ignored_users(event).await,
|
AnyBasicEvent::IgnoredUserList(event) => self.handle_ignored_users(event).await,
|
||||||
AnyBasicEvent::PushRules(event) => self.handle_push_rules(event).await,
|
AnyBasicEvent::PushRules(event) => self.handle_push_rules(event).await,
|
||||||
|
@ -971,6 +975,7 @@ impl BaseClient {
|
||||||
self.iter_joined_rooms(response).await?;
|
self.iter_joined_rooms(response).await?;
|
||||||
self.iter_invited_rooms(response).await?;
|
self.iter_invited_rooms(response).await?;
|
||||||
self.iter_left_rooms(response).await?;
|
self.iter_left_rooms(response).await?;
|
||||||
|
self.iter_account_data(response).await?;
|
||||||
|
|
||||||
let store = self.state_store.read().await;
|
let store = self.state_store.read().await;
|
||||||
|
|
||||||
|
@ -1071,7 +1076,7 @@ impl BaseClient {
|
||||||
// FIXME: receive_* and emit_* methods shouldn't be called in parallel. We
|
// FIXME: receive_* and emit_* methods shouldn't be called in parallel. We
|
||||||
// should only pass events to receive_* methods and then let *them* emit.
|
// should only pass events to receive_* methods and then let *them* emit.
|
||||||
if let Ok(e) = account_data.deserialize() {
|
if let Ok(e) = account_data.deserialize() {
|
||||||
if self.receive_account_data_event(&room_id, &e).await {
|
if self.receive_account_data_event(Some(&room_id), &e).await {
|
||||||
updated = true;
|
updated = true;
|
||||||
}
|
}
|
||||||
self.emit_account_data_event(room_id, &e, RoomStateType::Joined)
|
self.emit_account_data_event(room_id, &e, RoomStateType::Joined)
|
||||||
|
@ -1187,6 +1192,25 @@ impl BaseClient {
|
||||||
Ok(updated)
|
Ok(updated)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async fn iter_account_data(
|
||||||
|
&self,
|
||||||
|
response: &mut api::sync::sync_events::Response,
|
||||||
|
) -> Result<bool> {
|
||||||
|
let mut updated = false;
|
||||||
|
for account_data in &response.account_data.events {
|
||||||
|
{
|
||||||
|
// FIXME: emit_account_data_event assumes a room is given
|
||||||
|
if let Ok(e) = account_data.deserialize() {
|
||||||
|
if self.receive_account_data_event(None, &e).await {
|
||||||
|
updated = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// FIXME store all rooms if updated?
|
||||||
|
Ok(updated)
|
||||||
|
}
|
||||||
|
|
||||||
async fn iter_invited_rooms(
|
async fn iter_invited_rooms(
|
||||||
&self,
|
&self,
|
||||||
response: &api::sync::sync_events::Response,
|
response: &api::sync::sync_events::Response,
|
||||||
|
|
Loading…
Reference in New Issue