chore(sdk): Replace “simplified sliding sync” by “MSC4186”.
Simplified sliding sync finally has an MSC number: 4186. Let's use this name when possible to clarify the code.
This commit is contained in:
@@ -12,13 +12,12 @@
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
//! HTTP types for (Simplified) MSC3575.
|
||||
//! HTTP types for MSC4186 or MSC3585.
|
||||
//!
|
||||
//! This module provides unified namings for types from MSC3575 and
|
||||
//! Simplified MSC3575, in addition to provide conversion from one
|
||||
//! format to another.
|
||||
//! MSC4186.
|
||||
|
||||
/// HTTP types from MSC3575, renamed to match the Simplified MSC3575 namings.
|
||||
/// HTTP types from MSC3575, renamed to match the MSC4186 namings.
|
||||
pub mod msc3575 {
|
||||
use ruma::api::client::sync::sync_events::v4;
|
||||
pub use v4::{Request, Response};
|
||||
@@ -42,9 +41,9 @@ pub mod msc3575 {
|
||||
}
|
||||
}
|
||||
|
||||
/// HTTP types from Simplified MSC3575.
|
||||
pub mod simplified_msc3575 {
|
||||
/// HTTP types from MSC4186.
|
||||
pub mod msc4186 {
|
||||
pub use ruma::api::client::sync::sync_events::v5::*;
|
||||
}
|
||||
|
||||
pub use simplified_msc3575::*;
|
||||
pub use msc4186::*;
|
||||
|
||||
@@ -119,15 +119,14 @@ impl BaseClient {
|
||||
/// sync.
|
||||
/// * `previous_events_provider` - Timeline events prior to the current
|
||||
/// sync.
|
||||
/// * `from_simplified_sliding_sync` - Whether the `response` comes from
|
||||
/// simplified sliding sync (Simplified MSC3575), or sliding sync
|
||||
/// (MSC3575).
|
||||
/// * `from_msc4186` - Whether the `response` comes from simplified sliding
|
||||
/// sync (MSC4186) or sliding sync (MSC3575).
|
||||
#[instrument(skip_all, level = "trace")]
|
||||
pub async fn process_sliding_sync<PEP: PreviousEventsProvider>(
|
||||
&self,
|
||||
response: &http::Response,
|
||||
previous_events_provider: &PEP,
|
||||
from_simplified_sliding_sync: bool,
|
||||
from_msc4186: bool,
|
||||
) -> Result<SyncResponse> {
|
||||
let http::Response {
|
||||
// FIXME not yet supported by sliding sync. see
|
||||
@@ -181,7 +180,7 @@ impl BaseClient {
|
||||
&mut room_info_notable_updates,
|
||||
&mut notifications,
|
||||
&mut ambiguity_cache,
|
||||
from_simplified_sliding_sync,
|
||||
from_msc4186,
|
||||
)
|
||||
.await?;
|
||||
|
||||
@@ -353,7 +352,7 @@ impl BaseClient {
|
||||
room_info_notable_updates: &mut BTreeMap<OwnedRoomId, RoomInfoNotableUpdateReasons>,
|
||||
notifications: &mut BTreeMap<OwnedRoomId, Vec<Notification>>,
|
||||
ambiguity_cache: &mut AmbiguityCache,
|
||||
from_simplified_sliding_sync: bool,
|
||||
from_msc4186: bool,
|
||||
) -> Result<(RoomInfo, Option<JoinedRoomUpdate>, Option<LeftRoomUpdate>, Option<InvitedRoom>)>
|
||||
{
|
||||
// This method may change `room_data` (see the terrible hack describes below)
|
||||
@@ -381,10 +380,10 @@ impl BaseClient {
|
||||
// `timestamp` despites having `m.room.create` in `bump_event_types`. The result
|
||||
// of this is that an invite cannot be sorted. This horrible hack will fix that.
|
||||
//
|
||||
// The SDK manipulates Simplified MSC3575 `Request` and `Response` though. In
|
||||
// Simplified MSC3575, `bump_stamp` replaces `timestamp`, which does NOT
|
||||
// represent a time! This hack must really, only, apply to the proxy, so to
|
||||
// MSC3575 strictly (hence the `from_simplified_sliding_sync` argument).
|
||||
// The SDK manipulates MSC4186 `Request` and `Response` though. In MSC4186,
|
||||
// `bump_stamp` replaces `timestamp`, which does NOT represent a time! This
|
||||
// hack must really, only, apply to the proxy, so to MSC3575 strictly (hence
|
||||
// the `from_msc4186` argument).
|
||||
//
|
||||
// The proxy uses the `origin_server_ts` event's value to fill the `timestamp`
|
||||
// room's value (which is a bad idea[^1]). If `timestamp` is `None`, let's find
|
||||
@@ -392,9 +391,8 @@ impl BaseClient {
|
||||
//
|
||||
// [^1]: using `origin_server_ts` for `timestamp` is a bad idea because
|
||||
// this value can be forged by a malicious user. Anyway, that's how it works
|
||||
// in the proxy. Simplified MSC3575 has another mechanism which fixes the
|
||||
// problem.
|
||||
if !from_simplified_sliding_sync && room_data.bump_stamp.is_none() {
|
||||
// in the proxy. MSC4186 has another mechanism which fixes the problem.
|
||||
if !from_msc4186 && room_data.bump_stamp.is_none() {
|
||||
if let Some(invite_state) = &room_data.invite_state {
|
||||
room_data.to_mut().bump_stamp =
|
||||
invite_state.iter().rev().find_map(|invite_state| {
|
||||
@@ -1432,7 +1430,7 @@ mod tests {
|
||||
|
||||
#[async_test]
|
||||
async fn test_invitation_room_receive_a_default_timestamp_on_not_simplified_sliding_sync() {
|
||||
const NOT_SIMPLIFIED_SLIDING_SYNC: bool = false;
|
||||
const NOT_MSC4186: bool = false;
|
||||
|
||||
// Given a logged-in client
|
||||
let client = logged_in_base_client(None).await;
|
||||
@@ -1445,7 +1443,7 @@ mod tests {
|
||||
set_room_invited(&mut room, user_id, user_id);
|
||||
let response = response_with_room(room_id, room);
|
||||
let _sync_resp = client
|
||||
.process_sliding_sync(&response, &(), NOT_SIMPLIFIED_SLIDING_SYNC)
|
||||
.process_sliding_sync(&response, &(), NOT_MSC4186)
|
||||
.await
|
||||
.expect("Failed to process sync");
|
||||
|
||||
@@ -1491,7 +1489,7 @@ mod tests {
|
||||
|
||||
let response = response_with_room(room_id, room);
|
||||
let _sync_resp = client
|
||||
.process_sliding_sync(&response, &(), NOT_SIMPLIFIED_SLIDING_SYNC)
|
||||
.process_sliding_sync(&response, &(), NOT_MSC4186)
|
||||
.await
|
||||
.expect("Failed to process sync");
|
||||
|
||||
|
||||
@@ -32,7 +32,7 @@ pub enum Version {
|
||||
},
|
||||
|
||||
/// Use the version of the sliding sync implementation inside Synapse, i.e.
|
||||
/// Simplified MSC3575.
|
||||
/// MSC4186.
|
||||
Native,
|
||||
}
|
||||
|
||||
@@ -268,7 +268,7 @@ impl<'a> SlidingSyncResponseProcessor<'a> {
|
||||
pub async fn handle_room_response(
|
||||
&mut self,
|
||||
response: &http::Response,
|
||||
from_simplified_sliding_sync: bool,
|
||||
from_msc4186: bool,
|
||||
) -> Result<()> {
|
||||
self.response = Some(
|
||||
self.client
|
||||
@@ -276,7 +276,7 @@ impl<'a> SlidingSyncResponseProcessor<'a> {
|
||||
.process_sliding_sync(
|
||||
response,
|
||||
&SlidingSyncPreviousEventsProvider(self.rooms),
|
||||
from_simplified_sliding_sync,
|
||||
from_msc4186,
|
||||
)
|
||||
.await?,
|
||||
);
|
||||
|
||||
@@ -533,7 +533,7 @@ impl SlidingSync {
|
||||
/// Send a sliding sync request.
|
||||
///
|
||||
/// This method contains the sending logic. It takes a generic `Request`
|
||||
/// because it can be a Simplified MSC3575 or a MSC3575 `Request`.
|
||||
/// because it can be an MSC4186 or an MSC3575 `Request`.
|
||||
async fn send_sync_request<Request>(
|
||||
&self,
|
||||
request: Request,
|
||||
@@ -545,7 +545,7 @@ impl SlidingSync {
|
||||
Request::IncomingResponse: Send
|
||||
+ Sync
|
||||
+
|
||||
// This is required to get back a Simplified MSC3575 `Response` whatever the
|
||||
// This is required to get back an MSC4186 `Response` whatever the
|
||||
// `Request` type.
|
||||
Into<http::Response>,
|
||||
HttpError: From<ruma::api::error::FromHttpResponseError<Request::EndpointError>>,
|
||||
@@ -615,11 +615,10 @@ impl SlidingSync {
|
||||
#[cfg(not(feature = "e2e-encryption"))]
|
||||
let response = request.await?;
|
||||
|
||||
// The code manipulates `Request` and `Response` from Simplified MSC3575 because
|
||||
// it's the future standard. But this function may have received a `Request`
|
||||
// from Simplified MSC3575 or MSC3575. We need to get back a
|
||||
// Simplified MSC3575 `Response`.
|
||||
let response = Into::<http::simplified_msc3575::Response>::into(response);
|
||||
// The code manipulates `Request` and `Response` from MSC4186 because it's the
|
||||
// future standard. But this function may have received a `Request` from MSC4186
|
||||
// or MSC3575. We need to get back an MSC4186 `Response`.
|
||||
let response = Into::<http::msc4186::Response>::into(response);
|
||||
|
||||
debug!("Received response");
|
||||
|
||||
@@ -684,10 +683,9 @@ impl SlidingSync {
|
||||
let (request, request_config, position_guard) =
|
||||
self.generate_sync_request(&mut LazyTransactionId::new()).await?;
|
||||
|
||||
// The code manipulates `Request` and `Response` from Simplified MSC3575
|
||||
// because it's the future standard. If
|
||||
// `Client::is_simplified_sliding_sync_enabled` is turned off, the
|
||||
// Simplified MSC3575 `Request` must be transformed into a MSC3575 `Request`.
|
||||
// The code manipulates `Request` and `Response` from MSC4186 because it's
|
||||
// the future standard. Let's check if the generated request must be
|
||||
// transformed into an MSC3575 `Request`.
|
||||
if !self.inner.version.is_native() {
|
||||
self.send_sync_request(
|
||||
Into::<http::msc3575::Request>::into(request),
|
||||
|
||||
@@ -84,8 +84,8 @@ impl TestClientBuilder {
|
||||
let mut client_builder = Client::builder()
|
||||
.user_agent("matrix-sdk-integration-tests")
|
||||
.homeserver_url(homeserver_url)
|
||||
// Disable Simplified MSC3575 for the integration tests as, at the time of writing
|
||||
// (2024-07-15), we use a Synapse version that doesn't support Simplified MSC3575.
|
||||
// Disable MSC4186 for the integration tests as, at the time of writing
|
||||
// (2024-07-15), we use a Synapse version that doesn't support MSC4186.
|
||||
.sliding_sync_version_builder(VersionBuilder::Proxy {
|
||||
url: Url::parse(&sliding_sync_proxy_url)
|
||||
.expect("Sliding sync proxy URL is invalid"),
|
||||
|
||||
Reference in New Issue
Block a user