Skip to content

Commit

Permalink
feat: Remove the experimental-sliding-sync feature flag.
Browse files Browse the repository at this point in the history
Sliding sync is no longer experimental. It has a solid MSC4186, along
with a solid implementation inside Synapse. It's time to consider it
mature.

The SDK continues to support the old MSC3575 in addition to MSC4186.
This patch only removes the `experimental-sliding-sync` feature flag.
  • Loading branch information
Hywan committed Jan 8, 2025
1 parent 62567ca commit 61dd560
Show file tree
Hide file tree
Showing 21 changed files with 112 additions and 150 deletions.
2 changes: 0 additions & 2 deletions bindings/matrix-sdk-ffi/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@ features = [
"anyhow",
"e2e-encryption",
"experimental-oidc",
"experimental-sliding-sync",
"experimental-widgets",
"markdown",
"rustls-tls", # note: differ from block below
Expand All @@ -71,7 +70,6 @@ features = [
"anyhow",
"e2e-encryption",
"experimental-oidc",
"experimental-sliding-sync",
"experimental-widgets",
"markdown",
"native-tls", # note: differ from block above
Expand Down
13 changes: 8 additions & 5 deletions crates/matrix-sdk-base/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,6 @@ e2e-encryption = ["dep:matrix-sdk-crypto"]
js = ["matrix-sdk-common/js", "matrix-sdk-crypto?/js", "ruma/js", "matrix-sdk-store-encryption/js"]
qrcode = ["matrix-sdk-crypto?/qrcode"]
automatic-room-key-forwarding = ["matrix-sdk-crypto?/automatic-room-key-forwarding"]
experimental-sliding-sync = [
"ruma/unstable-msc3575",
"ruma/unstable-msc4186",
]
uniffi = ["dep:uniffi", "matrix-sdk-crypto?/uniffi", "matrix-sdk-common/uniffi"]

# Private feature, see
Expand Down Expand Up @@ -65,7 +61,14 @@ matrix-sdk-store-encryption = { workspace = true }
matrix-sdk-test = { workspace = true, optional = true }
once_cell = { workspace = true }
regex = "1.11.1"
ruma = { workspace = true, features = ["canonical-json", "unstable-msc3381", "unstable-msc2867", "rand"] }
ruma = { workspace = true, features = [
"canonical-json",
"unstable-msc2867",
"unstable-msc3381",
"unstable-msc3575",
"unstable-msc4186",
"rand",
] }
unicode-normalization = { workspace = true }
serde = { workspace = true, features = ["rc"] }
serde_json = { workspace = true }
Expand Down
16 changes: 7 additions & 9 deletions crates/matrix-sdk-base/src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ use tokio::sync::{broadcast, Mutex};
use tokio::sync::{RwLock, RwLockReadGuard};
use tracing::{debug, error, info, instrument, trace, warn};

#[cfg(all(feature = "e2e-encryption", feature = "experimental-sliding-sync"))]
#[cfg(feature = "e2e-encryption")]
use crate::latest_event::{is_suitable_for_latest_event, LatestEvent, PossibleLatestEvent};
#[cfg(feature = "e2e-encryption")]
use crate::RoomMemberships;
Expand Down Expand Up @@ -766,16 +766,12 @@ impl BaseClient {
let (events, room_key_updates) =
o.receive_sync_changes(encryption_sync_changes).await?;

#[cfg(feature = "experimental-sliding-sync")]
for room_key_update in room_key_updates {
if let Some(room) = self.get_room(&room_key_update.room_id) {
self.decrypt_latest_events(&room, changes, room_info_notable_updates).await;
}
}

#[cfg(not(feature = "experimental-sliding-sync"))] // Silence unused variable warnings.
let _ = (room_key_updates, changes, room_info_notable_updates);

Ok(events)
} else {
// If we have no OlmMachine, just return the events that were passed in.
Expand All @@ -789,7 +785,7 @@ impl BaseClient {
/// that we can and if we can, change latest_event to reflect what we
/// found, and remove any older encrypted events from
/// latest_encrypted_events.
#[cfg(all(feature = "e2e-encryption", feature = "experimental-sliding-sync"))]
#[cfg(feature = "e2e-encryption")]
async fn decrypt_latest_events(
&self,
room: &Room,
Expand All @@ -810,7 +806,7 @@ impl BaseClient {
/// (i.e. we can usefully display it as a message preview). Returns the
/// decrypted event if we found one, along with its index in the
/// latest_encrypted_events list, or None if we didn't find one.
#[cfg(all(feature = "e2e-encryption", feature = "experimental-sliding-sync"))]
#[cfg(feature = "e2e-encryption")]
async fn decrypt_latest_suitable_event(
&self,
room: &Room,
Expand Down Expand Up @@ -1747,7 +1743,9 @@ mod tests {
async_test, ruma_response_from_json, sync_timeline_event, InvitedRoomBuilder,
LeftRoomBuilder, StateTestEvent, StrippedStateTestEvent, SyncResponseBuilder,
};
use ruma::{api::client as api, room_id, serde::Raw, user_id, UserId};
#[cfg(feature = "e2e-encryption")]
use ruma::UserId;
use ruma::{api::client as api, room_id, serde::Raw, user_id};
use serde_json::{json, value::to_raw_value};

use super::BaseClient;
Expand Down Expand Up @@ -1889,7 +1887,7 @@ mod tests {
);
}

#[cfg(all(feature = "e2e-encryption", feature = "experimental-sliding-sync"))]
#[cfg(feature = "e2e-encryption")]
#[async_test]
async fn test_when_there_are_no_latest_encrypted_events_decrypting_them_does_nothing() {
use std::collections::BTreeMap;
Expand Down
34 changes: 25 additions & 9 deletions crates/matrix-sdk-base/src/latest_event.rs
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
//! Utilities for working with events to decide whether they are suitable for
//! use as a [crate::Room::latest_event].
#![cfg(any(feature = "e2e-encryption", feature = "experimental-sliding-sync"))]

use matrix_sdk_common::deserialized_responses::SyncTimelineEvent;
#[cfg(feature = "e2e-encryption")]
use ruma::{
events::{
call::{invite::SyncCallInviteEvent, notify::SyncCallNotifyEvent},
poll::unstable_start::SyncUnstablePollStartEvent,
relation::RelationType,
room::member::{MembershipState, SyncRoomMemberEvent},
room::message::SyncRoomMessageEvent,
room::power_levels::RoomPowerLevels,
room::{
member::{MembershipState, SyncRoomMemberEvent},
message::SyncRoomMessageEvent,
power_levels::RoomPowerLevels,
},
sticker::SyncStickerEvent,
AnySyncMessageLikeEvent, AnySyncStateEvent, AnySyncTimelineEvent,
},
Expand Down Expand Up @@ -294,11 +294,16 @@ impl LatestEvent {

#[cfg(test)]
mod tests {
#[cfg(feature = "e2e-encryption")]
use std::collections::BTreeMap;

#[cfg(feature = "e2e-encryption")]
use assert_matches::assert_matches;
#[cfg(feature = "e2e-encryption")]
use assert_matches2::assert_let;
use matrix_sdk_common::deserialized_responses::SyncTimelineEvent;
use ruma::serde::Raw;
#[cfg(feature = "e2e-encryption")]
use ruma::{
events::{
call::{
Expand Down Expand Up @@ -336,14 +341,16 @@ mod tests {
RedactedSyncMessageLikeEvent, RedactedUnsigned, StateUnsigned, SyncMessageLikeEvent,
UnsignedRoomRedactionEvent,
},
owned_event_id, owned_mxc_uri, owned_user_id,
serde::Raw,
MilliSecondsSinceUnixEpoch, UInt, VoipVersionId,
owned_event_id, owned_mxc_uri, owned_user_id, MilliSecondsSinceUnixEpoch, UInt,
VoipVersionId,
};
use serde_json::json;

use crate::latest_event::{is_suitable_for_latest_event, LatestEvent, PossibleLatestEvent};
use super::LatestEvent;
#[cfg(feature = "e2e-encryption")]
use super::{is_suitable_for_latest_event, PossibleLatestEvent};

#[cfg(feature = "e2e-encryption")]
#[test]
fn test_room_messages_are_suitable() {
let event = AnySyncTimelineEvent::MessageLike(AnySyncMessageLikeEvent::RoomMessage(
Expand All @@ -368,6 +375,7 @@ mod tests {
assert_eq!(m.content.msgtype.msgtype(), "m.image");
}

#[cfg(feature = "e2e-encryption")]
#[test]
fn test_polls_are_suitable() {
let event = AnySyncTimelineEvent::MessageLike(AnySyncMessageLikeEvent::UnstablePollStart(
Expand All @@ -391,6 +399,7 @@ mod tests {
assert_eq!(m.content.poll_start().question.text, "do you like rust?");
}

#[cfg(feature = "e2e-encryption")]
#[test]
fn test_call_invites_are_suitable() {
let event = AnySyncTimelineEvent::MessageLike(AnySyncMessageLikeEvent::CallInvite(
Expand All @@ -413,6 +422,7 @@ mod tests {
);
}

#[cfg(feature = "e2e-encryption")]
#[test]
fn test_call_notifications_are_suitable() {
let event = AnySyncTimelineEvent::MessageLike(AnySyncMessageLikeEvent::CallNotify(
Expand All @@ -435,6 +445,7 @@ mod tests {
);
}

#[cfg(feature = "e2e-encryption")]
#[test]
fn test_stickers_are_suitable() {
let event = AnySyncTimelineEvent::MessageLike(AnySyncMessageLikeEvent::Sticker(
Expand All @@ -457,6 +468,7 @@ mod tests {
);
}

#[cfg(feature = "e2e-encryption")]
#[test]
fn test_different_types_of_messagelike_are_unsuitable() {
let event =
Expand All @@ -479,6 +491,7 @@ mod tests {
);
}

#[cfg(feature = "e2e-encryption")]
#[test]
fn test_redacted_messages_are_suitable() {
// Ruma does not allow constructing UnsignedRoomRedactionEvent instances.
Expand Down Expand Up @@ -507,6 +520,7 @@ mod tests {
);
}

#[cfg(feature = "e2e-encryption")]
#[test]
fn test_encrypted_messages_are_unsuitable() {
let event = AnySyncTimelineEvent::MessageLike(AnySyncMessageLikeEvent::RoomEncrypted(
Expand All @@ -530,6 +544,7 @@ mod tests {
);
}

#[cfg(feature = "e2e-encryption")]
#[test]
fn test_state_events_are_unsuitable() {
let event = AnySyncTimelineEvent::State(AnySyncStateEvent::RoomTopic(
Expand All @@ -549,6 +564,7 @@ mod tests {
);
}

#[cfg(feature = "e2e-encryption")]
#[test]
fn test_replacement_events_are_unsuitable() {
let mut event_content = RoomMessageEventContent::text_plain("Bye bye, world!");
Expand Down
1 change: 0 additions & 1 deletion crates/matrix-sdk-base/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ mod rooms;
pub mod read_receipts;
pub use read_receipts::PreviousEventsProvider;
pub use rooms::RoomMembersUpdate;
#[cfg(feature = "experimental-sliding-sync")]
pub mod sliding_sync;

pub mod store;
Expand Down
Loading

0 comments on commit 61dd560

Please sign in to comment.