Skip to content

Sync: Add support for MSC4262 (Profile Updates Sliding Sync Extension).#6685

Draft
pixlwave wants to merge 3 commits into
mainfrom
doug/profiles
Draft

Sync: Add support for MSC4262 (Profile Updates Sliding Sync Extension).#6685
pixlwave wants to merge 3 commits into
mainfrom
doug/profiles

Conversation

@pixlwave

@pixlwave pixlwave commented Jun 24, 2026

Copy link
Copy Markdown
Member

This PR makes the following additions:

  • Updates Ruma to a commit that supports MSC4262.
  • Adds support for storing global user profiles in the state stores.
  • Adds support for configuring the profiles sliding sync extension.

Full disclosure: I do not understand SQL, all of that code is LLM generated and I don't have any confidence to say whether or not it is valid/performant/good. ORMs ftw 😄

Draft whilst still a WIP.

  • I've documented the public API changes in the appropriate changelog files (see Writing changelog entries).
  • This PR was made with the help of AI.

@codecov

codecov Bot commented Jun 24, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 61.22449% with 38 lines in your changes missing coverage. Please review.
✅ Project coverage is 89.86%. Comparing base (d895344) to head (061e3ec).
✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
crates/matrix-sdk/src/sliding_sync/client.rs 0.00% 13 Missing ⚠️
crates/matrix-sdk-sqlite/src/state_store.rs 77.50% 1 Missing and 8 partials ⚠️
crates/matrix-sdk-base/src/store/traits.rs 69.23% 8 Missing ⚠️
crates/matrix-sdk/src/sliding_sync/builder.rs 0.00% 8 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #6685      +/-   ##
==========================================
- Coverage   89.86%   89.86%   -0.01%     
==========================================
  Files         396      396              
  Lines      110264   110359      +95     
  Branches   110264   110359      +95     
==========================================
+ Hits        99092    99170      +78     
- Misses       7394     7406      +12     
- Partials     3778     3783       +5     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

@codspeed-hq

codspeed-hq Bot commented Jun 24, 2026

Copy link
Copy Markdown

Merging this PR will not alter performance

✅ 50 untouched benchmarks


Comparing doug/profiles (061e3ec) with main (d895344)

Open in CodSpeed

@pixlwave pixlwave requested a review from poljar June 24, 2026 14:20
@poljar

poljar commented Jun 26, 2026

Copy link
Copy Markdown
Contributor

This all looks mostly sensible.

I thing I could spot, if we receive the profiles as part of the sync, then we should persist them in the store as part of a save_changes() call.

This ensures that all the changes a sync produces are persisted as part of a single DB transaction.

This means you'll need to extend this struct:

/// Store state changes and pass them to the StateStore.
#[derive(Clone, Debug, Default)]
pub struct StateChanges {
/// The sync token that relates to this update.
pub sync_token: Option<String>,
/// A mapping of event type string to `AnyBasicEvent`.
pub account_data: BTreeMap<GlobalAccountDataEventType, Raw<AnyGlobalAccountDataEvent>>,
/// A mapping of `UserId` to `PresenceEvent`.
pub presence: BTreeMap<OwnedUserId, Raw<PresenceEvent>>,
/// A mapping of `RoomId` to a map of users and their
/// `MinimalRoomMemberEvent`.
pub profiles: BTreeMap<OwnedRoomId, BTreeMap<OwnedUserId, MinimalRoomMemberEvent>>,
/// A mapping of room profiles to delete.
///
/// These are deleted *before* other room profiles are inserted.
pub profiles_to_delete: BTreeMap<OwnedRoomId, Vec<OwnedUserId>>,
/// A mapping of `RoomId` to a map of event type string to a state key and
/// `AnySyncStateEvent`.
pub state:
BTreeMap<OwnedRoomId, BTreeMap<StateEventType, BTreeMap<String, Raw<AnySyncStateEvent>>>>,
/// A mapping of `RoomId` to a map of event type string to `AnyBasicEvent`.
pub room_account_data:
BTreeMap<OwnedRoomId, BTreeMap<RoomAccountDataEventType, Raw<AnyRoomAccountDataEvent>>>,
/// A map of `OwnedRoomId` to `RoomInfo`.
pub room_infos: BTreeMap<OwnedRoomId, RoomInfo>,
/// A map of `RoomId` to `ReceiptEventContent`.
pub receipts: BTreeMap<OwnedRoomId, ReceiptEventContent>,
/// A map of `RoomId` to maps of `OwnedEventId` to be redacted by
/// `SyncRoomRedactionEvent`.
pub redactions: BTreeMap<OwnedRoomId, BTreeMap<OwnedEventId, Raw<SyncRoomRedactionEvent>>>,
/// A mapping of `RoomId` to a map of event type to a map of state key to
/// `StrippedState`.
pub stripped_state: BTreeMap<
OwnedRoomId,
BTreeMap<StateEventType, BTreeMap<String, Raw<AnyStrippedStateEvent>>>,
>,
/// A map from room id to a map of a display name and a set of user ids that
/// share that display name in the given room.
pub ambiguity_maps: BTreeMap<OwnedRoomId, HashMap<DisplayName, BTreeSet<OwnedUserId>>>,
}
.

And extend the logic which persists the changes from that struct.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants