Skip to content

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

Open
pixlwave wants to merge 9 commits into
mainfrom
doug/profiles
Open

Sync: Add support for MSC4262 (Profile Updates Sliding Sync Extension).#6685
pixlwave wants to merge 9 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 and fetching global user profiles in the state stores.
  • Adds support for configuring the profiles sliding sync extension.

Note: get_global_profiles (bulk getter) isn't used yet, but was added for the next part of this work which is to include m.status/m.call fields on RoomMember and doing so in bulk should be more performant.

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 😄

  • 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 81.33333% with 28 lines in your changes missing coverage. Please review.
⚠️ Please upload report for BASE (main@023f5bd). Learn more about missing BASE report.
✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
crates/matrix-sdk-sqlite/src/state_store.rs 75.43% 1 Missing and 13 partials ⚠️
crates/matrix-sdk/src/sliding_sync/builder.rs 0.00% 8 Missing ⚠️
crates/matrix-sdk-base/src/store/traits.rs 62.50% 6 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##             main    #6685   +/-   ##
=======================================
  Coverage        ?   89.92%           
=======================================
  Files           ?      397           
  Lines           ?   110803           
  Branches        ?   110803           
=======================================
  Hits            ?    99641           
  Misses          ?     7371           
  Partials        ?     3791           

☔ 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 (4a9c430) with main (023f5bd)

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.

@pixlwave

pixlwave commented Jun 29, 2026

Copy link
Copy Markdown
Member Author

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.

Thanks, done as far as I can tell in 3e244e1

@pixlwave pixlwave marked this pull request as ready for review June 29, 2026 11:59
@pixlwave pixlwave requested a review from a team as a code owner June 29, 2026 11:59
@pixlwave pixlwave marked this pull request as draft June 29, 2026 15:30
@pixlwave

Copy link
Copy Markdown
Member Author

Converting back to draft until we have ruma/ruma#2518

@pixlwave pixlwave marked this pull request as ready for review June 30, 2026 10:20
@pixlwave

Copy link
Copy Markdown
Member Author

Alright, this is now ready for review. The first 3 commits are unchanged (but rebased on main). The rest are additions since #6685 (comment)

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