Skip to content

Expose MSC4354 Sticky Events over the legacy (v3) /sync API.#19487

Merged
reivilibre merged 18 commits intodevelopfrom
rei/sticky_events_oldschool_sync
Mar 10, 2026
Merged

Expose MSC4354 Sticky Events over the legacy (v3) /sync API.#19487
reivilibre merged 18 commits intodevelopfrom
rei/sticky_events_oldschool_sync

Conversation

@reivilibre
Copy link
Copy Markdown
Contributor

Follows: #19365

Part of: MSC4354 whose experimental feature tracking issue is #19409

Partially supersedes: #18968 (commit history too long to point at specific commits)

This pull request is commit-by-commit review friendly.

@reivilibre reivilibre changed the title Expose [MSC4354 Sticky Events](https://github.com/matrix-org/matrix-spec-proposals/pull/4354) over the legacy (v3) /sync API. Expose MSC4354 Sticky Events over the legacy (v3) /sync API. Feb 20, 2026
@reivilibre reivilibre marked this pull request as ready for review February 20, 2026 16:34
@reivilibre reivilibre requested a review from a team as a code owner February 20, 2026 16:34
@reivilibre reivilibre force-pushed the rei/sticky_events_oldschool_sync branch from 7c4ca8e to 48a42e8 Compare February 27, 2026 20:15
@MadLittleMods MadLittleMods self-requested a review March 3, 2026 16:49
Comment thread synapse/handlers/sync.py Outdated
Comment thread synapse/handlers/sync.py Outdated
Comment on lines +2838 to +2841
# remove sticky events that are in the timeline, else we will needlessly duplicate
# events. This is particularly important given the risk of sticky events spam since
# anyone can send sticky events, so halving the bandwidth on average for each sticky
# event is helpful.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Is this part of the MSC?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Yes:

If a sticky event is in the timeline, it MAY be omitted from the sticky.events section. This ensures we minimise duplication in the /sync response JSON.

-- MSC4354 (permalink)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I'm also proposing we make this a MUST at matrix-org/matrix-spec-proposals#4354 (comment)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Feels like we should add some "as specced" or "As per MSC4354:" kind of comment in here. Still coming back to this after a second read

Comment thread synapse/handlers/sync.py Outdated
Comment thread synapse/handlers/sync.py
Comment thread synapse/storage/databases/main/sticky_events.py
Comment thread tests/rest/client/test_sync_sticky_events.py Outdated
Comment thread tests/rest/client/test_sync_sticky_events.py Outdated
Comment thread tests/rest/client/test_sync_sticky_events.py Outdated
Comment thread tests/rest/client/test_sync_sticky_events.py Outdated
Comment thread tests/rest/client/test_sync_sticky_events.py Outdated
@reivilibre reivilibre force-pushed the rei/sticky_events_oldschool_sync branch from ef5e852 to 005fcda Compare March 4, 2026 19:04
@reivilibre reivilibre force-pushed the rei/sticky_events_oldschool_sync branch from b98a932 to a4b09ab Compare March 4, 2026 19:52
Comment on lines +443 to +454
@patch.object(StickyEvent, "MAX_EVENTS_IN_SYNC", 3)
def test_pagination_with_many_sticky_events(self) -> None:
"""
Test that pagination works correctly when there are more sticky events than
the intended limit.

The MSC doesn't define a limit or how to set one.
See thread: https://github.com/matrix-org/matrix-spec-proposals/pull/4354#discussion_r2885670008

But Synapse currently emits 100 at a time, controlled by `MAX_EVENTS_IN_SYNC`.
In this test we patch it to 3 (as sending 100 events is not very efficient).
"""
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Heeere's a real pagination test.

Note this does a cheeky patch to set the Synapse limit to 3 events.

MSC4354 doesn't define a limit or a way for the client to set one.
The MSC thread to track: matrix-org/matrix-spec-proposals#4354 (comment)

@reivilibre reivilibre requested a review from MadLittleMods March 4, 2026 20:07
Comment thread tests/rest/client/test_sync_sticky_events.py
Comment thread tests/rest/client/test_sync_sticky_events.py Outdated
Comment thread synapse/handlers/sync.py
@@ -2225,6 +2284,7 @@ async def handle_room_entries(room_entry: "RoomSyncResultBuilder") -> None:
ephemeral=ephemeral_by_room.get(room_entry.room_id, []),
tags=tags_by_room.get(room_entry.room_id),
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

This async wasn't being used, so I thought it was enlightening/self-documenting to remove it.
Also renamed to may because it's just an approximation.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Just double-checking, the other manual checks here give us a definite answer?

@reivilibre reivilibre requested a review from MadLittleMods March 5, 2026 16:12
Comment thread synapse/handlers/sync.py Outdated
Comment on lines +2838 to +2841
# remove sticky events that are in the timeline, else we will needlessly duplicate
# events. This is particularly important given the risk of sticky events spam since
# anyone can send sticky events, so halving the bandwidth on average for each sticky
# event is helpful.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Feels like we should add some "as specced" or "As per MSC4354:" kind of comment in here. Still coming back to this after a second read

@reivilibre reivilibre merged commit 6e1ac55 into develop Mar 10, 2026
79 of 81 checks passed
@reivilibre reivilibre deleted the rei/sticky_events_oldschool_sync branch March 10, 2026 10:39
alexlebens pushed a commit to alexlebens/infrastructure that referenced this pull request Mar 24, 2026
This PR contains the following updates:

| Package | Update | Change |
|---|---|---|
| [element-hq/synapse](https://github.com/element-hq/synapse) | minor | `v1.149.1` → `v1.150.0` |

---

### Release Notes

<details>
<summary>element-hq/synapse (element-hq/synapse)</summary>

### [`v1.150.0`](https://github.com/element-hq/synapse/releases/tag/v1.150.0)

[Compare Source](element-hq/synapse@v1.149.1...v1.150.0)

### Synapse 1.150.0 (2026-03-24)

No significant changes since 1.150.0rc1.

### Synapse 1.150.0rc1 (2026-03-17)

#### Features

- Add experimental support for the [MSC4370](matrix-org/matrix-spec-proposals#4370) Federation API `GET /extremities` endpoint. ([#&#8203;19314](element-hq/synapse#19314))
- [MSC4140: Cancellable delayed events](matrix-org/matrix-spec-proposals#4140): When persisting a delayed event to the timeline, include its `delay_id` in the event's `unsigned` section in `/sync` responses to the event sender. ([#&#8203;19479](element-hq/synapse#19479))
- Expose [MSC4354 Sticky Events](matrix-org/matrix-spec-proposals#4354) over the legacy (v3) /sync API. ([#&#8203;19487](element-hq/synapse#19487))
- When Matrix Authentication Service (MAS) integration is enabled, allow MAS to set the user locked status in Synapse. ([#&#8203;19554](element-hq/synapse#19554))

#### Bugfixes

- Fix `Build and push complement image` CI job pointing to non-existent image. ([#&#8203;19523](element-hq/synapse#19523))
- Fix a bug introduced in v1.26.0 that caused deactivated, erased users to not be removed from the user directory. ([#&#8203;19542](element-hq/synapse#19542))

#### Improved Documentation

- In the Admin API documentation, always express path parameters as `/<param>` instead of as `/$param`. ([#&#8203;19307](element-hq/synapse#19307))
- Update docs to clarify `outbound_federation_restricted_to` can also be used with the [Secure Border Gateway (SBG)](https://element.io/en/server-suite/secure-border-gateways). ([#&#8203;19517](element-hq/synapse#19517))
- Unify Complement developer docs. ([#&#8203;19518](element-hq/synapse#19518))

#### Internal Changes

- Put membership updates in a background resumable task when changing the avatar or the display name. ([#&#8203;19311](element-hq/synapse#19311))
- Add in-repo Complement test to sanity check Synapse version matches git checkout (testing what we think we are). ([#&#8203;19476](element-hq/synapse#19476))
- Migrate `dev` dependencies to [PEP 735](https://peps.python.org/pep-0735/) dependency groups. ([#&#8203;19490](element-hq/synapse#19490))
- Remove the optional `systemd-python` dependency and the `systemd` extra on the `synapse` package. ([#&#8203;19491](element-hq/synapse#19491))
- Avoid re-computing the event ID when cloning events. ([#&#8203;19527](element-hq/synapse#19527))
- Allow caching of the `/versions` and `/auth_metadata` public endpoints. ([#&#8203;19530](element-hq/synapse#19530))
- Add a few labels to the number groupings in the `Processed request` logs. ([#&#8203;19548](element-hq/synapse#19548))

</details>

---

### Configuration

📅 **Schedule**: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined).

🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied.

♻ **Rebasing**: Whenever PR is behind base branch, or you tick the rebase/retry checkbox.

🔕 **Ignore**: Close this PR and you won't be reminded about this update again.

---

 - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box

---

This PR has been generated by [Renovate Bot](https://github.com/renovatebot/renovate).
<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiI0My44NC4yIiwidXBkYXRlZEluVmVyIjoiNDMuODQuMiIsInRhcmdldEJyYW5jaCI6Im1haW4iLCJsYWJlbHMiOlsiaW1hZ2UiXX0=-->

Reviewed-on: https://gitea.alexlebens.dev/alexlebens/infrastructure/pulls/5040
Co-authored-by: Renovate Bot <renovate-bot@alexlebens.net>
Co-committed-by: Renovate Bot <renovate-bot@alexlebens.net>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants