From 9adb0deaa551898e8a67ddf9d45a2564e2f9991c Mon Sep 17 00:00:00 2001 From: Ivan Enderlin Date: Tue, 15 Apr 2025 09:32:24 +0200 Subject: [PATCH] refactor(base): `room::msc4186::update_any_room` uses `room::Room`. This patch uses the `room::Room` structure in `room::msc4186::update_any_room` to reduce its number of arguments. It results in the removal of te `allow(clippy::too_many_arguments)`. --- .../src/response_processors/room/msc4186.rs | 22 ++++++++++++------- crates/matrix-sdk-base/src/sliding_sync.rs | 10 +++++---- 2 files changed, 20 insertions(+), 12 deletions(-) diff --git a/crates/matrix-sdk-base/src/response_processors/room/msc4186.rs b/crates/matrix-sdk-base/src/response_processors/room/msc4186.rs index d358216d4..b7ceb0980 100644 --- a/crates/matrix-sdk-base/src/response_processors/room/msc4186.rs +++ b/crates/matrix-sdk-base/src/response_processors/room/msc4186.rs @@ -32,9 +32,12 @@ use tokio::sync::broadcast::Sender; #[cfg(feature = "e2e-encryption")] use super::super::e2ee; -use super::super::{notification, state_events, timeline, Context}; +use super::{ + super::{notification, state_events, timeline, Context}, + Room as RoomCreationData, +}; use crate::{ - store::{ambiguity_map::AmbiguityCache, BaseStateStore}, + store::BaseStateStore, sync::{InvitedRoomUpdate, JoinedRoomUpdate, KnockedRoomUpdate, LeftRoomUpdate}, Result, Room, RoomHero, RoomInfo, RoomInfoNotableUpdate, RoomInfoNotableUpdateReasons, RoomState, StateChanges, @@ -48,19 +51,22 @@ pub enum RoomUpdateKind { Knocked(KnockedRoomUpdate), } -#[allow(clippy::too_many_arguments)] pub async fn update_any_room( context: &mut Context, user_id: &UserId, - room_id: &RoomId, - requested_required_states: &[(StateEventType, String)], + room_creation_data: RoomCreationData<'_>, room_response: &http::response::Room, - room_info_notable_update_sender: Sender, rooms_account_data: &mut BTreeMap>>, #[cfg(feature = "e2e-encryption")] e2ee: e2ee::E2EE<'_>, mut notification: notification::Notification<'_>, - ambiguity_cache: &mut AmbiguityCache, ) -> Result> { + let RoomCreationData { + room_id, + room_info_notable_update_sender, + requested_required_states, + ambiguity_cache, + } = room_creation_data; + // Read state events from the `required_state` field. // // Don't read state events from the `timeline` field, because they might be @@ -91,7 +97,7 @@ pub async fn update_any_room( ); room_info.mark_state_partially_synced(); - room_info.handle_encryption_state(requested_required_states); + room_info.handle_encryption_state(requested_required_states.for_room(room_id)); #[cfg_attr(not(feature = "e2e-encryption"), allow(unused))] let new_user_ids = state_events::sync::dispatch_and_get_new_users( diff --git a/crates/matrix-sdk-base/src/sliding_sync.rs b/crates/matrix-sdk-base/src/sliding_sync.rs index 6ea2e39ba..25630f90e 100644 --- a/crates/matrix-sdk-base/src/sliding_sync.rs +++ b/crates/matrix-sdk-base/src/sliding_sync.rs @@ -149,10 +149,13 @@ impl BaseClient { let Some((room_info, room_update)) = processors::room::msc4186::update_any_room( &mut context, &user_id, - room_id, - requested_required_states.for_room(room_id), + processors::room::Room::new( + room_id, + self.room_info_notable_update_sender.clone(), + requested_required_states, + &mut ambiguity_cache, + ), room_response, - self.room_info_notable_update_sender.clone(), &mut rooms_account_data, #[cfg(feature = "e2e-encryption")] processors::e2ee::E2EE::new( @@ -165,7 +168,6 @@ impl BaseClient { &mut notifications, &self.state_store, ), - &mut ambiguity_cache, ) .await? else {