refactor(base): Centralise processors that require e2e-encryption.

This commit is contained in:
Ivan Enderlin
2025-04-04 17:47:34 +02:00
parent e94fd64276
commit 90ce6e85ad
5 changed files with 19 additions and 12 deletions

View File

@@ -62,13 +62,11 @@ use tokio::sync::{broadcast, Mutex};
use tokio::sync::{RwLock, RwLockReadGuard};
use tracing::{debug, error, info, instrument, trace, warn};
#[cfg(feature = "e2e-encryption")]
use crate::RoomMemberships;
use crate::{
deserialized_responses::{DisplayName, RawAnySyncOrStrippedTimelineEvent, TimelineEvent},
error::{Error, Result},
event_cache::store::EventCacheStoreLock,
response_processors::{self as processors, account_data::AccountDataProcessor, Context},
response_processors::{account_data::AccountDataProcessor, Context},
rooms::{
normal::{RoomInfoNotableUpdate, RoomInfoNotableUpdateReasons, RoomMembersUpdate},
Room, RoomInfo, RoomState,
@@ -81,6 +79,11 @@ use crate::{
sync::{JoinedRoomUpdate, LeftRoomUpdate, Notification, RoomUpdates, SyncResponse, Timeline},
RoomStateFilter, SessionMeta,
};
#[cfg(feature = "e2e-encryption")]
use crate::{
response_processors::{self as processors},
RoomMemberships,
};
/// A no (network) IO client implementation.
///
@@ -466,6 +469,7 @@ impl BaseClient {
ambiguity_cache: &mut AmbiguityCache,
) -> Result<Timeline> {
// TODO: should receive `context` from an argument.
#[allow(unused)]
let mut context = Context::new(StateChanges::default(), Default::default());
let mut timeline = Timeline::new(limited, prev_batch);
let mut push_context = self.get_push_room_context(room, room_info, changes).await?;
@@ -938,6 +942,7 @@ impl BaseClient {
#[cfg(feature = "e2e-encryption")]
let olm_machine = self.olm_machine().await;
#[allow(unused_mut)]
let mut context =
Context::new(StateChanges::new(response.next_batch.clone()), Default::default());

View File

@@ -12,8 +12,6 @@
// See the License for the specific language governing permissions and
// limitations under the License.
#![cfg(feature = "e2e-encryption")]
use std::collections::BTreeMap;
use matrix_sdk_crypto::{store::RoomKeyInfo, EncryptionSyncChanges, OlmMachine};

View File

@@ -12,8 +12,6 @@
// See the License for the specific language governing permissions and
// limitations under the License.
#![cfg(feature = "e2e-encryption")]
use matrix_sdk_common::deserialized_responses::TimelineEvent;
use matrix_sdk_crypto::{
DecryptionSettings, OlmMachine, RoomEventDecryptionResult, TrustRequirement,

View File

@@ -13,16 +13,22 @@
// limitations under the License.
pub mod account_data;
#[cfg(feature = "e2e-encryption")]
pub mod e2ee;
#[cfg(feature = "e2e-encryption")]
pub mod latest_event;
#[cfg(feature = "e2e-encryption")]
pub mod verification;
use std::collections::BTreeMap;
pub use e2ee::e2ee;
pub use latest_event::decrypt_latest_events;
#[cfg(feature = "e2e-encryption")]
mod with_e2ee {
pub use super::{e2ee::e2ee, latest_event::decrypt_latest_events, verification::verification};
}
use ruma::OwnedRoomId;
pub use verification::verification;
#[cfg(feature = "e2e-encryption")]
pub use with_e2ee::*;
use crate::{RoomInfoNotableUpdateReasons, StateChanges};

View File

@@ -40,7 +40,7 @@ use super::BaseClient;
use crate::{
error::Result,
read_receipts::{compute_unread_counts, PreviousEventsProvider},
response_processors::{self as processors, account_data::AccountDataProcessor},
response_processors::account_data::AccountDataProcessor,
rooms::{
normal::{RoomHero, RoomInfoNotableUpdateReasons},
RoomState,
@@ -53,7 +53,7 @@ use crate::{
#[cfg(feature = "e2e-encryption")]
use crate::{
latest_event::{is_suitable_for_latest_event, LatestEvent, PossibleLatestEvent},
RoomMemberships,
response_processors as processors, RoomMemberships,
};
impl BaseClient {