Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MSC3575: Sliding Sync (aka Sync v3) #3575

Open
wants to merge 81 commits into
base: main
Choose a base branch
from
Open

MSC3575: Sliding Sync (aka Sync v3) #3575

wants to merge 81 commits into from

Conversation

kegsay
Copy link
Member

@kegsay kegsay commented Dec 20, 2021

@kegsay kegsay marked this pull request as draft December 20, 2021 10:49
@ara4n ara4n added the proposal A matrix spec change proposal label Dec 20, 2021
@turt2live turt2live added needs-implementation This MSC does not have a qualifying implementation for the SCT to review. The MSC cannot enter FCP. kind:core MSC which is critical to the protocol's success client-server Client-Server API labels Dec 20, 2021
proposals/3575-sync.md Outdated Show resolved Hide resolved
proposals/3575-sync.md Outdated Show resolved Hide resolved
proposals/3575-sync.md Outdated Show resolved Hide resolved
proposals/3575-sync.md Outdated Show resolved Hide resolved
proposals/3575-sync.md Outdated Show resolved Hide resolved
proposals/3575-sync.md Outdated Show resolved Hide resolved
proposals/3575-sync.md Outdated Show resolved Hide resolved
proposals/3575-sync.md Outdated Show resolved Hide resolved
proposals/3575-sync.md Outdated Show resolved Hide resolved
proposals/3575-sync.md Outdated Show resolved Hide resolved
proposals/3575-sync.md Outdated Show resolved Hide resolved
proposals/3575-sync.md Outdated Show resolved Hide resolved
MadLittleMods added a commit to element-hq/synapse that referenced this pull request Jun 17, 2024
netbsd-srcmastr pushed a commit to NetBSD/pkgsrc that referenced this pull request Jun 18, 2024
# Synapse 1.109.0 (2024-06-18)

- Add the ability to auto-accept invites on the behalf of users. See
  the
  [`auto_accept_invites`](https://element-hq.github.io/synapse/latest/usage/configuration/config_documentation.html#auto-accept-invites)
  config option for
  details. ([\#17147](element-hq/synapse#17147))

- Add experimental
  [MSC3575](matrix-org/matrix-spec-proposals#3575)
  Sliding Sync `/sync/e2ee` endpoint for to-device messages and device
  encryption
  info. ([\#17167](element-hq/synapse#17167))

- Support
  [MSC3916](matrix-org/matrix-spec-proposals#3916)
  by adding unstable media endpoints to
  `/_matrix/client`. ([\#17213](element-hq/synapse#17213))

- Add logging to tasks managed by the task scheduler, showing CPU and
  database
  usage. ([\#17219](element-hq/synapse#17219))


# Synapse 1.108.0 (2024-05-28)

- Add a feature that allows clients to query the configured federation
  whitelist. Disabled by
  default. ([\#16848](element-hq/synapse#16848),
  [\#17199](element-hq/synapse#17199))

- Add the ability to allow numeric user IDs with a specific prefix
  when in the CAS flow. Contributed by Aurélien
  Grimpard. ([\#17098](element-hq/synapse#17098))


Synapse 1.107.0 (2024-05-14)

- Add preliminary support for [MSC3823: Account
  Suspension](matrix-org/matrix-spec-proposals#3823).
  ([\#17051](element-hq/synapse#17051))

- Declare support for [Matrix
  v1.10](https://matrix.org/blog/2024/03/22/matrix-v1.10-release/). Contributed
  by
  @clokep. ([\#17082](element-hq/synapse#17082))

- Add support for [MSC4115: membership metadata on
  events](matrix-org/matrix-spec-proposals#4115).
  ([\#17104](element-hq/synapse#17104),
  [\#17137](element-hq/synapse#17137))


# Synapse 1.106.0 (2024-04-30)

- Send an email if the address is already bound to an user
  account. ([\#16819](element-hq/synapse#16819))

- Implement the rendezvous mechanism described by
  [MSC4108](matrix-org/matrix-spec-proposals#4108).
  ([\#17056](element-hq/synapse#17056))

- Support delegating the rendezvous mechanism described
  [MSC4108](matrix-org/matrix-spec-proposals#4108)
  to an external
  implementation. ([\#17086](element-hq/synapse#17086))
MadLittleMods added a commit to element-hq/synapse that referenced this pull request Jun 19, 2024
@anoadragon453 anoadragon453 removed their request for review June 24, 2024 13:10
MadLittleMods added a commit to element-hq/synapse that referenced this pull request Jun 25, 2024
{"sender":"@alice:example.com","type":"m.room.message", "content":{"body":"B"}},
{"sender":"@alice:example.com","type":"m.room.message", "content":{"body":"C"}},
{"sender":"@alice:example.com","type":"m.room.message", "content":{"body":"D"}},
],
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What should happen for invite rooms?

If we copy Sync v2, then the invite room will only have invite_state (no timeline events, limited, prev_batch token, or required_state).

Perhaps we could make the rooms more uniform regardless of membership though. The hard case is how these fields should be set in cases where the user's room membership is invite with shared/joined history visibility where they can't see any timeline events until they join.

Where should the prev_batch token be pointing to? If we do it just like other rooms, we paginate up to the timeline_limit, then all of those events are filtered out (because we're not joined yet) and the prev_batch token points to a place before those events that we never saw. And then potentially when we join, we will miss those events depending on what the client does.

If we change the scenario to a room with world_readable or invited history visibility where timeline events would be returned when you are invited; The answer is timeline events are returned, limited is set respectively, and prev_batch points to the first event to continue paginating (no problems there).

For ban/leave, we can just query for timeline events up to the point where they were banned/left (no problem here either).


First discussed in element-hq/synapse#17320 (comment)

Copy link
Contributor

@MadLittleMods MadLittleMods Jul 9, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think I found the distinction for why we don't do this: local vs remote room

For a room where another local user is already in the room (which means we already have the info necessary on our local server), this kind of thing makes sense to me. Being invited to a room probably means you should have access to the room (access to the full state of the room and events based on history visibility) (no security concern). Stripped state makes more sense for knock rooms where you don't have access yet.

But the problem comes when you're the first one on your server to be invited to a new room over federation. When you receive a federated invite, you only have access to event.unsigned.invite_room_state so that's all that you can return to the client. You would have to go through the make_join/send_join process to start participating in the room and query more info.

So it makes sense just to do the same thing for all invite rooms, just return stripped state.

Copy link
Contributor

@MadLittleMods MadLittleMods Jul 9, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Related to matrix-org/matrix-spec#380. As an example, when someone is invited to a room, we don't even have the heroes necessary to calculate the room name if the room doesn't have m.room.name set.

This was solved for partial-joins via MSC3943

yingziwu added a commit to yingziwu/synapse that referenced this pull request Jun 26, 2024
- Fix the building of binary wheels for macOS by switching to macOS 12 CI runners. ([\#17319](element-hq/synapse#17319))

- When rolling back to a previous Synapse version and then forwards again to this release, don't require server operators to manually run SQL. ([\#17305](element-hq/synapse#17305), [\#17309](element-hq/synapse#17309))

- Use the release branch for sytest in release-branch PRs. ([\#17306](element-hq/synapse#17306))

- Fix bug where one-time-keys were not always included in `/sync` response when using workers. Introduced in v1.109.0rc1. ([\#17275](element-hq/synapse#17275))
- Fix bug where `/sync` could get stuck due to edge case in device lists handling. Introduced in v1.109.0rc1. ([\#17292](element-hq/synapse#17292))

- Add the ability to auto-accept invites on the behalf of users. See the [`auto_accept_invites`](https://element-hq.github.io/synapse/latest/usage/configuration/config_documentation.html#auto-accept-invites) config option for details. ([\#17147](element-hq/synapse#17147))
- Add experimental [MSC3575](matrix-org/matrix-spec-proposals#3575) Sliding Sync `/sync/e2ee` endpoint for to-device messages and device encryption info. ([\#17167](element-hq/synapse#17167))
- Support [MSC3916](matrix-org/matrix-spec-proposals#3916) by adding unstable media endpoints to `/_matrix/client`. ([\#17213](element-hq/synapse#17213))
- Add logging to tasks managed by the task scheduler, showing CPU and database usage. ([\#17219](element-hq/synapse#17219))

- Fix deduplicating of membership events to not create unused state groups. ([\#17164](element-hq/synapse#17164))
- Fix bug where duplicate events could be sent down sync when using workers that are overloaded. ([\#17215](element-hq/synapse#17215))
- Ignore attempts to send to-device messages to bad users, to avoid log spam when we try to connect to the bad server. ([\#17240](element-hq/synapse#17240))
- Fix handling of duplicate concurrent uploading of device one-time-keys. ([\#17241](element-hq/synapse#17241))
- Fix reporting of default tags to Sentry, such as worker name. Broke in v1.108.0. ([\#17251](element-hq/synapse#17251))
- Fix bug where typing updates would not be sent when using workers after a restart. ([\#17252](element-hq/synapse#17252))

- Update the LemonLDAP documentation to say that claims should be explicitly included in the returned `id_token`, as Synapse won't request them. ([\#17204](element-hq/synapse#17204))

- Improve DB usage when fetching related events. ([\#17083](element-hq/synapse#17083))
- Log exceptions when failing to auto-join new user according to the `auto_join_rooms` option. ([\#17176](element-hq/synapse#17176))
- Reduce work of calculating outbound device lists updates. ([\#17211](element-hq/synapse#17211))
- Improve performance of calculating device lists changes in `/sync`. ([\#17216](element-hq/synapse#17216))
- Move towards using `MultiWriterIdGenerator` everywhere. ([\#17226](element-hq/synapse#17226))
- Replaces all usages of `StreamIdGenerator` with `MultiWriterIdGenerator`. ([\#17229](element-hq/synapse#17229))
- Change the `allow_unsafe_locale` config option to also apply when setting up new databases. ([\#17238](element-hq/synapse#17238))
- Fix errors in logs about closing incorrect logging contexts when media gets rejected by a module. ([\#17239](element-hq/synapse#17239), [\#17246](element-hq/synapse#17246))
- Clean out invalid destinations from `device_federation_outbox` table. ([\#17242](element-hq/synapse#17242))
- Stop logging errors when receiving invalid User IDs in key querys requests. ([\#17250](element-hq/synapse#17250))

* Bump anyhow from 1.0.83 to 1.0.86. ([\#17220](element-hq/synapse#17220))
* Bump bcrypt from 4.1.2 to 4.1.3. ([\#17224](element-hq/synapse#17224))
* Bump lxml from 5.2.1 to 5.2.2. ([\#17261](element-hq/synapse#17261))
* Bump mypy-zope from 1.0.3 to 1.0.4. ([\#17262](element-hq/synapse#17262))
* Bump phonenumbers from 8.13.35 to 8.13.37. ([\#17235](element-hq/synapse#17235))
* Bump prometheus-client from 0.19.0 to 0.20.0. ([\#17233](element-hq/synapse#17233))
* Bump pyasn1 from 0.5.1 to 0.6.0. ([\#17223](element-hq/synapse#17223))
* Bump pyicu from 2.13 to 2.13.1. ([\#17236](element-hq/synapse#17236))
* Bump pyopenssl from 24.0.0 to 24.1.0. ([\#17234](element-hq/synapse#17234))
* Bump serde from 1.0.201 to 1.0.202. ([\#17221](element-hq/synapse#17221))
* Bump serde from 1.0.202 to 1.0.203. ([\#17232](element-hq/synapse#17232))
* Bump twine from 5.0.0 to 5.1.0. ([\#17225](element-hq/synapse#17225))
* Bump types-psycopg2 from 2.9.21.20240311 to 2.9.21.20240417. ([\#17222](element-hq/synapse#17222))
* Bump types-pyopenssl from 24.0.0.20240311 to 24.1.0.20240425. ([\#17260](element-hq/synapse#17260))
MadLittleMods added a commit to element-hq/synapse that referenced this pull request Jul 2, 2024
 - Timeline events
 - Stripped `invite_state`

Based on [MSC3575](matrix-org/matrix-spec-proposals#3575): Sliding Sync
MadLittleMods added a commit to element-hq/synapse that referenced this pull request Jul 2, 2024
yingziwu added a commit to yingziwu/synapse that referenced this pull request Jul 4, 2024
No significant changes since 1.110.0rc3.

- Fix bug where `/sync` requests could get blocked indefinitely after an upgrade from Synapse versions before v1.109.0. ([\#17386](element-hq/synapse#17386), [\#17391](element-hq/synapse#17391))

- Limit size of presence EDUs to 50 entries. ([\#17371](element-hq/synapse#17371))
- Fix building debian package for debian sid. ([\#17389](element-hq/synapse#17389))

- Fix uploading packages to PyPi. ([\#17363](element-hq/synapse#17363))

- Add initial implementation of an experimental [MSC3575](matrix-org/matrix-spec-proposals#3575) Sliding Sync `/sync` endpoint. ([\#17187](element-hq/synapse#17187))
- Add experimental support for [MSC3823](matrix-org/matrix-spec-proposals#3823) - Account suspension. ([\#17255](element-hq/synapse#17255))
- Improve ratelimiting in Synapse. ([\#17256](element-hq/synapse#17256))
- Add support for the unstable [MSC4151](matrix-org/matrix-spec-proposals#4151) report room API. ([\#17270](element-hq/synapse#17270), [\#17296](element-hq/synapse#17296))
- Filter for public and empty rooms added to Admin-API [List Room API](https://element-hq.github.io/synapse/latest/admin_api/rooms.html#list-room-api). ([\#17276](element-hq/synapse#17276))
- Add `is_dm` filtering to experimental [MSC3575](matrix-org/matrix-spec-proposals#3575) Sliding Sync `/sync` endpoint. ([\#17277](element-hq/synapse#17277))
- Add `is_encrypted` filtering to experimental [MSC3575](matrix-org/matrix-spec-proposals#3575) Sliding Sync `/sync` endpoint. ([\#17281](element-hq/synapse#17281))
- Include user membership in events served to clients, per [MSC4115](matrix-org/matrix-spec-proposals#4115). ([\#17282](element-hq/synapse#17282))
- Do not require user-interactive authentication for uploading cross-signing keys for the first time, per [MSC3967](matrix-org/matrix-spec-proposals#3967). ([\#17284](element-hq/synapse#17284))
- Add `stream_ordering` sort to experimental [MSC3575](matrix-org/matrix-spec-proposals#3575) Sliding Sync `/sync` endpoint. ([\#17293](element-hq/synapse#17293))
- `register_new_matrix_user` now supports a --password-file flag, which
  is useful for scripting. ([\#17294](element-hq/synapse#17294))
- `register_new_matrix_user` now supports a --exists-ok flag to allow registration of users that already exist in the database.
  This is useful for scripts that bootstrap user accounts with initial passwords. ([\#17304](element-hq/synapse#17304))
- Add support for via query parameter from [MSC4156](matrix-org/matrix-spec-proposals#4156). ([\#17322](element-hq/synapse#17322))
- Add `is_invite` filtering to experimental [MSC3575](matrix-org/matrix-spec-proposals#3575) Sliding Sync `/sync` endpoint. ([\#17335](element-hq/synapse#17335))
- Support [MSC3916](https://github.com/matrix-org/matrix-spec-proposals/blob/rav/authentication-for-media/proposals/3916-authentication-for-media.md) by adding a federation /download endpoint. ([\#17350](element-hq/synapse#17350))

- Fix searching for users with their exact localpart whose ID includes a hyphen. ([\#17254](element-hq/synapse#17254))
- Fix wrong retention policy being used when filtering events. ([\#17272](element-hq/synapse#17272))
- Fix bug where OTKs were not always included in `/sync` response when using workers. ([\#17275](element-hq/synapse#17275))
- Fix a long-standing bug where an invalid 'from' parameter to [`/notifications`](https://spec.matrix.org/v1.10/client-server-api/#get_matrixclientv3notifications) would result in an Internal Server Error. ([\#17283](element-hq/synapse#17283))
- Fix edge case in `/sync` returning the wrong the state when using sharded event persisters. ([\#17295](element-hq/synapse#17295))
- Add initial implementation of an experimental [MSC3575](matrix-org/matrix-spec-proposals#3575) Sliding Sync `/sync` endpoint. ([\#17301](element-hq/synapse#17301))
- Fix email notification subject when invited to a space. ([\#17336](element-hq/synapse#17336))

- Add missing quotes for example for `exclude_rooms_from_sync`. ([\#17308](element-hq/synapse#17308))
- Update header in the README to visually fix the the auto-generated table of contents. ([\#17329](element-hq/synapse#17329))
- Fix stale references to the Foundation's Security Disclosure Policy. ([\#17341](element-hq/synapse#17341))
- Add default values for `rc_invites.per_issuer` to docs. ([\#17347](element-hq/synapse#17347))
- Fix an error in the docs for `search_all_users` parameter under `user_directory`. ([\#17348](element-hq/synapse#17348))

- Remove unused `expire_access_token` option in the Synapse Docker config file. Contributed by @AaronDewes. ([\#17198](element-hq/synapse#17198))
- Use fully-qualified `PersistedEventPosition` when returning `RoomsForUser` to facilitate proper comparisons and `RoomStreamToken` generation. ([\#17265](element-hq/synapse#17265))
- Add debug logging for when room keys are uploaded, including whether they are replacing other room keys. ([\#17266](element-hq/synapse#17266))
- Handle OTK uploads off master. ([\#17271](element-hq/synapse#17271))
- Don't try and resync devices for remote users whose servers are marked as down. ([\#17273](element-hq/synapse#17273))
- Re-organize Pydantic models and types used in handlers. ([\#17279](element-hq/synapse#17279))
- Expose the worker instance that persisted the event on `event.internal_metadata.instance_name`. ([\#17300](element-hq/synapse#17300))
- Update the README with Element branding, improve headers and fix the #synapse:matrix.org support room link rendering. ([\#17324](element-hq/synapse#17324))
- Change path of the experimental [MSC3575](matrix-org/matrix-spec-proposals#3575) Sliding Sync implementation to `/org.matrix.simplified_msc3575/sync` since our simplified API is slightly incompatible with what's in the current MSC. ([\#17331](element-hq/synapse#17331))
- Handle device lists notifications for large accounts more efficiently in worker mode. ([\#17333](element-hq/synapse#17333), [\#17358](element-hq/synapse#17358))
- Do not block event sending/receiving while calculating large event auth chains. ([\#17338](element-hq/synapse#17338))
- Tidy up `parse_integer` docs and call sites to reflect the fact that they require non-negative integers by default, and bring `parse_integer_from_args` default in alignment. Contributed by Denis Kasak (@dkasak). ([\#17339](element-hq/synapse#17339))

* Bump authlib from 1.3.0 to 1.3.1. ([\#17343](element-hq/synapse#17343))
* Bump dawidd6/action-download-artifact from 3.1.4 to 5. ([\#17289](element-hq/synapse#17289))
* Bump dawidd6/action-download-artifact from 5 to 6. ([\#17313](element-hq/synapse#17313))
* Bump docker/build-push-action from 5 to 6. ([\#17312](element-hq/synapse#17312))
* Bump jinja2 from 3.1.3 to 3.1.4. ([\#17287](element-hq/synapse#17287))
* Bump lazy_static from 1.4.0 to 1.5.0. ([\#17355](element-hq/synapse#17355))
* Bump msgpack from 1.0.7 to 1.0.8. ([\#17317](element-hq/synapse#17317))
* Bump netaddr from 1.2.1 to 1.3.0. ([\#17353](element-hq/synapse#17353))
* Bump packaging from 24.0 to 24.1. ([\#17352](element-hq/synapse#17352))
* Bump phonenumbers from 8.13.37 to 8.13.39. ([\#17315](element-hq/synapse#17315))
* Bump regex from 1.10.4 to 1.10.5. ([\#17290](element-hq/synapse#17290))
* Bump requests from 2.31.0 to 2.32.2. ([\#17345](element-hq/synapse#17345))
* Bump sentry-sdk from 2.1.1 to 2.3.1. ([\#17263](element-hq/synapse#17263))
* Bump sentry-sdk from 2.3.1 to 2.6.0. ([\#17351](element-hq/synapse#17351))
* Bump tornado from 6.4 to 6.4.1. ([\#17344](element-hq/synapse#17344))
* Bump mypy from 1.8.0 to 1.9.0. ([\#17297](element-hq/synapse#17297))
* Bump types-jsonschema from 4.21.0.20240311 to 4.22.0.20240610. ([\#17288](element-hq/synapse#17288))
* Bump types-netaddr from 1.2.0.20240219 to 1.3.0.20240530. ([\#17314](element-hq/synapse#17314))
* Bump types-pillow from 10.2.0.20240423 to 10.2.0.20240520. ([\#17285](element-hq/synapse#17285))
* Bump types-pyyaml from 6.0.12.12 to 6.0.12.20240311. ([\#17316](element-hq/synapse#17316))
* Bump typing-extensions from 4.11.0 to 4.12.2. ([\#17354](element-hq/synapse#17354))
* Bump urllib3 from 2.0.7 to 2.2.2. ([\#17346](element-hq/synapse#17346))
MadLittleMods added a commit to element-hq/synapse that referenced this pull request Jul 8, 2024
… sorting (#17395)

`bump_stamp` corresponds to the `stream_ordering` of the latest `DEFAULT_BUMP_EVENT_TYPES` in the room. This helps clients sort more readily without them needing to pull in a bunch of the timeline to determine the last activity. `bump_event_types` is a thing because for example, we don't want display name changes to mark the room as unread and bump it to the top. For encrypted rooms, we just have to consider any activity as a bump because we can't see the content and the client has to figure it out for themselves.

Outside of Synapse, `bump_stamp` is just a free-form counter so other implementations could use `received_ts`or `origin_server_ts` (see the [*Security considerations* section in MSC3575 about the potential pitfalls of using `origin_server_ts`](https://github.com/matrix-org/matrix-spec-proposals/blob/kegan/sync-v3/proposals/3575-sync.md#security-considerations)). It doesn't have any guarantee about always going up. In the Synapse case, it could go down if an event was redacted/removed (or purged in cases of retention policies).

In the future, we could add `bump_event_types` as [MSC3575](matrix-org/matrix-spec-proposals#3575) mentions if people need to customize the event types.

---

In the Sliding Sync proxy, a similar [`timestamp` field was added](matrix-org/sliding-sync#247) for the same purpose but the name is not obvious what it pertains to or what it's for.

The `timestamp` field was also added to Ruma in ruma/ruma#1622
Comment on lines +518 to +520
"heroes": [
{"user_id":"@alice:example.com","displayname":"Alice","avatar_url":"mxc://..."},
],
Copy link
Contributor

@MadLittleMods MadLittleMods Jul 8, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of returning stripped state for heroes, we could simply return the User ID's of the heroes like Sync v2 (see m.heroes) and return the full membership event in required_state like we're already doing for $LAZY-loading room memberships.

Related to #3575 (comment) around making rooms more uniform regardless of membership.


// Sticky. Return a stripped variant of membership events (containing `user_id` and optionally `avatar_url` and `displayname`)
// for the users used to calculate the room name.
"include_heroes": true,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What use case is include_heroes useful for?

heroes will already be populated when the room doesn't have a m.room.name set. And you can specify $LAZY-loading room members to get relevant members in the room.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And you can specify $LAZY-loading room members to get relevant members in the room.

Ideally, the list of members used for heroes should be deterministic, i.e. not change from one initial response to another (assuming the list of members hasn't changed in the room, of course). Using $LAZY would give you a list of some members, but it's unclear it'd still be the same, all the time. For what it's worth, the Rust SDK just reflects the heroes when it gets them from the server-side with no extra computation, otherwise it'll try to use the room members' information (get the display name + avatar, etc.)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

heroes are used to calculate the room name so being deterministic is useful so the room name doesn't change that much. heroes are already automatically returned when the room doesn't have m.room.name set. Since this behavior is already built-in and automatic, this include_heroes option isn't necessary for room name calculation.

Are heroes used for anything else? If not, then this option isn't necessary


Displaying a few avatar bubbles to preview some of the room members could be useful:

A similar effect could be achieved by $LAZY-loading room members and fetching enough timeline events. heroes could also work but it will always only be up-to 5 members and won't reflect who's currently chatting if it's a big room. You could also fetch all members in the room by using required_state: [["m.room.member", "*"]] but can be a bit burdensome to parse in very large rooms. This use case might be better served by a specific extension to be able to specify the number of members you want to fetch and how you want them sorted.

Copy link
Member

@bnjbvr bnjbvr Jul 10, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are heroes used for anything else? If not, then this option isn't necessary

They're exposed to the EX apps at least, which use those to compute a hash that serves to determine a unique color for a room's visual entry in the room list. I think that color will also match what EW displays, since it's based on the same algorithm. That computation (be it done by the SDK or the EX apps themselves) requires the heroes to always be present.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for sharing another reference @bnjbvr 🙂

use those to compute a hash that serves to determine a unique color for a room's visual entry in the room list

Why not just hash against the room ID?

Feels like the room color would change over time as the heroes will shift around until 5 people are in the room and will shift as people leave the room.

As far as I can tell, Element Web just bases it off the Matrix ID (for users) and room ID (for rooms):

That computation (be it done by the SDK or the EX apps themselves) requires the heroes to always be present.

For Sync v2, heroes is only present for join rooms. And in Synapse, they are only returned when lazy-loading and (there are membership changes or initial sync).

So the color will change yet again based on membership if heroes was taken into account.

Can you share a link to the code in ElementX for this?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the extra clarification!

It appears that heroes are only necessary for DMs (or group chats), aligning perfectly with the server's automatic behavior of providing heroes when a room name is not specified.

This further supports the argument that a separate include_heroes option is unnecessary.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does that mean we wouldn't get the heroes for the "Soccer Club" example in the screenshot above?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@pixlwave Correct

Either, we could include m.room.avatar being set in the criteria for automatically including heroes or as I mentioned before, these kind of use cases might be better served by a specific extension to be able to specify the number of members you want to fetch and how you want them sorted. This would cover whatever people come up with and have a need for.

Calculating the display name for a room is a specced process whereas these other heroes usages are a lot more willy nilly and app specific.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(A small note: there are other clients than Element in the world, and we should also keep it flexible for these.)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let me see if I can find out actual product requirements for this on our side.

"rooms": {
// the room ID
"!foo:bar": {
"name": "The calculated room name",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To preface this: I'm on the side of not trying to calculate room names. Just leave it to clients to use the explicitly set room name or calculate it themselves via the heroes.

One thing, I'm not sure about is if the name field should strictly be the value from the m.room.name state event or whether we should also fallback to the m.room.canonical_alias. The existing spec currently says that heroes should be returned "if the room’s m.room.name or m.room.canonical_alias state events are unset or empty." so it might make sense to fallback.

Copy link
Member

@bnjbvr bnjbvr Jul 10, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed; calculing room names server-side is doomed to cause incorrect i10n (as a room name computed from heroes would look, for all languages, like "person A and person B"), and closes the door to customization options (even though that argument is feeble; the user value in being able to choose how many heroes are used for a fallback calculated room name would likely be quite low).

Re: fallback: I'd say no, let the clients implement this.

// Optional. If omitted there is no change to the heroes or the `name` was not
// calculated using room heroes. `avatar_url` and `displayname` are optional.
"heroes": [
{"user_id":"@alice:example.com","displayname":"Alice","avatar_url":"mxc://..."},
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we just use the existing definition of stripped state?

Stripped state events can only have the sender, type, state_key and content properties present.

MadLittleMods added a commit to element-hq/synapse that referenced this pull request Jul 9, 2024
Discussion tracking this: matrix-org/matrix-spec-proposals#3575 (comment)

It's also hard because we may not have any full membership events
when you're the first one on your server to be invited to a new room over federation.
MadLittleMods added a commit to element-hq/synapse that referenced this pull request Jul 11, 2024
Additional room summary fields: `joined_count`, `invited_count`

Based on
[MSC3575](matrix-org/matrix-spec-proposals#3575):
Sliding Sync
MadLittleMods added a commit to element-hq/synapse that referenced this pull request Jul 11, 2024
erikjohnston pushed a commit to element-hq/synapse that referenced this pull request Jul 15, 2024
Add room subscriptions to Sliding Sync `/sync`

Based on
[MSC3575](matrix-org/matrix-spec-proposals#3575):
Sliding Sync

Currently, you can only subscribe to rooms you have had *any* membership
in before.

In the future, we will allow `world_readable` rooms to be subscribed to
without joining.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
client-server Client-Server API kind:core MSC which is critical to the protocol's success matrix-2.0 Required for Matrix 2.0 proposal A matrix spec change proposal
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet