From dd13fe6b4e42d4dcb6a3e12f2de13081ec84eaf4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jorge=20Mart=C3=ADn?= Date: Fri, 13 Sep 2024 14:33:43 +0200 Subject: [PATCH] sdk-base: use updated account data for processing direct rooms --- crates/matrix-sdk-base/src/client.rs | 7 ++++++- crates/matrix-sdk-base/src/sliding_sync/mod.rs | 14 ++++++++++---- 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/crates/matrix-sdk-base/src/client.rs b/crates/matrix-sdk-base/src/client.rs index d3838d8a1..c4ec7ba99 100644 --- a/crates/matrix-sdk-base/src/client.rs +++ b/crates/matrix-sdk-base/src/client.rs @@ -1169,7 +1169,12 @@ impl BaseClient { // because we want to have the push rules in place before we process // rooms and their events, but we want to create the rooms before we // process the `m.direct` account data event. - self.handle_account_data(&response.account_data.events, &mut changes).await; + if let Ok(Some(direct_account_data)) = + self.store.get_account_data_event(GlobalAccountDataEventType::Direct).await + { + debug!("Found direct room data in the Store, applying it"); + self.handle_account_data(&vec![direct_account_data], &mut changes).await; + } changes.presence = response .presence diff --git a/crates/matrix-sdk-base/src/sliding_sync/mod.rs b/crates/matrix-sdk-base/src/sliding_sync/mod.rs index 6f46e09a7..8ca60515e 100644 --- a/crates/matrix-sdk-base/src/sliding_sync/mod.rs +++ b/crates/matrix-sdk-base/src/sliding_sync/mod.rs @@ -26,11 +26,14 @@ use matrix_sdk_common::deserialized_responses::SyncTimelineEvent; use ruma::events::AnyToDeviceEvent; use ruma::{ api::client::sync::sync_events::v3::{self, InvitedRoom}, - events::{AnyRoomAccountDataEvent, AnySyncStateEvent, AnySyncTimelineEvent}, + events::{ + AnyRoomAccountDataEvent, AnySyncStateEvent, AnySyncTimelineEvent, + GlobalAccountDataEventType, + }, serde::Raw, JsOption, OwnedRoomId, RoomId, UInt, }; -use tracing::{debug, error, instrument, trace, warn}; +use tracing::{debug, error, info, instrument, trace, warn}; use super::BaseClient; #[cfg(feature = "e2e-encryption")] @@ -303,8 +306,11 @@ impl BaseClient { // because we want to have the push rules in place before we process // rooms and their events, but we want to create the rooms before we // process the `m.direct` account data event. - if !account_data.is_empty() { - self.handle_account_data(&account_data.global, &mut changes).await; + if let Ok(Some(direct_account_data)) = + self.store.get_account_data_event(GlobalAccountDataEventType::Direct).await + { + debug!("Found direct room data in the Store, applying it"); + self.handle_account_data(&vec![direct_account_data], &mut changes).await; } // FIXME not yet supported by sliding sync.