Commit Graph

25709 Commits

Author SHA1 Message Date
Olivier 'reivilibre 5e7cbfe4ae Merge branch 'master' into develop 2026-04-28 17:16:24 +01:00
Olivier 'reivilibre 16863c87d5 Changelog tweaks v1.152.0 2026-04-28 13:45:53 +01:00
Olivier 'reivilibre fa52c62a89 1.152.0 2026-04-28 11:47:16 +01:00
FrenchGithubUser 449b1a4234 MSC4311: invites and knocks should contain the create event (#19722)
Part of MSC4311: invites and knocks should contain the create event
(stripped state for the client API)

Part of https://github.com/element-hq/synapse/issues/19414
2026-04-27 14:04:07 -05:00
dependabot[bot] 2e9d6f7f35 Bump attrs from 25.4.0 to 26.1.0 (#19684) 2026-04-27 11:38:23 +01:00
dependabot[bot] 811e69b6cd Bump go.opentelemetry.io/otel from 1.36.0 to 1.41.0 in /complement (#19728) 2026-04-27 11:37:05 +01:00
Devon Hudson 3a26806818 Ignore received EDUs if origin server in room ACL (MSC4163) (#18475)
Implements: [MSC4163: Make ACLs apply to
EDUs](https://github.com/matrix-org/matrix-spec-proposals/pull/4163)

Part of #18118 to declare support for Matrix v1.13

Complement PR: ~~https://github.com/matrix-org/complement/pull/783~~ ->
https://github.com/matrix-org/complement/pull/862


---------

Co-authored-by: Eric Eastwood <erice@element.io>
Co-authored-by: Quentin Gliech <quenting@element.io>
2026-04-24 19:31:44 -05:00
Eric Eastwood 22e1643359 Add warning about known problems when configuring use_frozen_dicts (#19711)
Known problems: https://github.com/element-hq/synapse/issues/18117

As a follow-up, we should consider removing this config option
altogether. It's "expensive" and claims to "prevent bugs" but actually
introduces a whole new class of bugs. It could be re-introduced with a
more holistic solution to the typing. Or a completely new approach (safe
mode that blows up when someone mutates the event content, always make
deep clones when handing out references, etc)

The `use_frozen_dict` config option was there [since
inception](https://github.com/element-hq/synapse/commit/a7b65bdedf512f646a3ca2478fb96a914856de35)
but was only recently
[documented](https://github.com/element-hq/synapse/pull/18122) for
completeness sake.
2026-04-24 12:00:13 -05:00
Erik Johnston ae242fd11d Do not mutate power levels on upgrade to v12 room (#19727)
When upgrading a room to v12, we accidentally ended up mutating the
content of the old power level. Since we cache events, this meant any
future usage of the old power level event would see the wrong content
(until it dropped from the cache).

This meant that the creator of the new room would not be able to perform
admin actions on the old room. Any federation requests for the event
would fail the hash checks, since the content had been changed.

All in all, quite a nasty bug.
2026-04-24 16:36:35 +00:00
dependabot[bot] 107029da92 Bump the minor-and-patches group across 1 directory with 2 updates (#19710)
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2026-04-24 10:35:00 +00:00
dasha-uwu 7fc937bac0 Stabilize MSC3266, support stable room_summary endpoint (#19720)
MSC3266 is merged in v1.15, let's stabilize it as part of #18731

1. Add support for the stable `/_matrix/client/v1/room_summary/`
endpoint, keeping both unstable endpoints for compat
2. Remove the experimental `msc3266_enabled` flag
2026-04-24 11:33:08 +01:00
dependabot[bot] a6b53209c3 Bump rustls-webpki from 0.103.10 to 0.103.13 (#19717)
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2026-04-24 10:24:01 +00:00
Benjamin Bouvier 2691d0b8b1 Send a SSS response immediately if the config has changed and there are new results to sync (#19714)
This fixes the bug described in #19713 (and double-checked against the
SDK integration test, which now passes with this change). A sync
response must be returned immediately if a room subscription
configuration change caused a new non-empty response (checked with `if
response` in the code) to be produced.

Fixes #19713.
Fixes #18844.

---------

Co-authored-by: Erik Johnston <erik@matrix.org>
2026-04-24 10:18:05 +00:00
dependabot[bot] 213b5a0e4d Bump python-multipart from 0.0.22 to 0.0.26 (#19700)
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Andrew Morgan <andrew@amorgan.xyz>
2026-04-24 09:04:36 +00:00
Jason Little 93e0497fc3 Avoid a M_FORBIDDEN response when a user tries to erase their account and profile updates are disabled (#19398)
Currently synapse returns `M_FORBIDDEN` when trying to use the account
deactivation API, if the server admin disabled displayname changes. This
is undesirable, since it prevents GDPR erasure without admin
interaction. The admin API seems to work fine though. This also only
seems to affect the deactivate API, when the erase flag is true.

Relevant endpoint:
https://spec.matrix.org/latest/client-server-api/#post_matrixclientv3accountdeactivate

This change only removes the checked for condition that the displayname
and profile avatar are allowed to be changed per the configuration
setting. If a user is deleting themselves, why is that denied?

There did not seem to be a basic test for this endpoint that checks the
`erase` usage, so that was added as well as checking the above mentioned
behavior.
2026-04-23 17:04:48 +01:00
Olivier 'reivilibre 613cb4df1c Pruning data is a feature v1.152.0rc1 2026-04-22 12:09:35 +01:00
Olivier 'reivilibre 2e0905e4c4 fixup! 1.152.0rc1 (3rd try) 2026-04-22 12:08:19 +01:00
Olivier 'reivilibre b07a7cc285 1.152.0rc1 (3rd try) 2026-04-22 12:05:39 +01:00
Olivier 'reivilibre fbaff67e1b Merge branch 'develop' into release-v1.152 2026-04-22 12:01:44 +01:00
Erik Johnston c8ce96f504 Reinstate removed EventBase methods (#19712)
Both `__getitem__` and `.user_id` were removed in #19680 to simplify the
event class. However, `EventBase` is exposed to modules who might also
make use of those methods, so let's reinstate them (but otherwise not
reinstate the usage of them in the code).
2026-04-22 11:43:59 +01:00
Erik Johnston 3cdae2e278 Fix race in new pruning of device lists tables. (#19709)
Follows on from #19473.

We should be recording where we have deleted up to in the same
transaction as we perform the delete, rather than at the end. This code
only starts deleting rows after a month (and the original PR isn't in a
release yet), so no server should have run into this problem yet.

Also let's log more regularly, as the initial set of deletions will
likely take a long time.
2026-04-21 11:39:39 +01:00
Andrew Morgan a9361c4f51 Bail out if admin_unsafely_bypass_quarantine was used by a non-admin (#19639) 2026-04-17 15:27:41 +00:00
Eric Eastwood 67b4d8e7e3 Add docs for what to document about a new stream (#19696)
Spawning from the follow-up necessary when adding a new stream
(https://github.com/element-hq/synapse/pull/19694)
2026-04-17 09:50:37 -05:00
Erik Johnston 2a8285931e Prune old rows in device_lists_changes_in_room table. (#19473)
Fixes #13043

The usages of the table mostly already correctly handled if we don't
have old entries, as that was needed when we first added the table.

I arbitrarily set the prune time to 30 days. The only use for old
entries is for sync streams that haven't synced since then, and we
should very rarely see sync streams that haven't been used in 30 days.

Reviewable commit-by-commit.

---------

Co-authored-by: Olivier 'reivilibre' <oliverw@element.io>
Co-authored-by: Olivier 'reivilibre' <olivier@librepush.net>
2026-04-17 11:54:22 +01:00
Shay 647fb59190 Add Admin API endpoints to manage user reports (#19657)
Adds [Admin
API](https://element-hq.github.io/synapse/latest/usage/administration/admin_api/index.html)
endpoints to list, fetch and delete user reports from the homeserver.
Follows on from #18120, which added the endpoints to report users.
2026-04-17 11:01:23 +01:00
dependabot[bot] bdb1cf7416 Bump authlib from 1.6.9 to 1.6.11 (#19703) 2026-04-17 10:57:38 +01:00
Kegan Dougal 15c03b9689 MSC4242: State DAGs (CSAPI) (#19424)
This implements [MSC4242: State
DAGs](https://github.com/matrix-org/matrix-spec-proposals/pull/4242),
without support for federation.

A general overview:
 - It adds a new room version and new event type.
 - It adds a new field `calculated_auth_event_ids` to internal metadata.
- It stores the state DAG via new state DAG edges / forward extremities
tables.
 - It adds new auth rules as per the MSC.
- It uses the new `prev_state_events` field instead of
`prev_event_ids()` when doing state resolution.

Complement tests: https://github.com/matrix-org/complement/pull/841

### Pull Request Checklist

<!-- Please read
https://element-hq.github.io/synapse/latest/development/contributing_guide.html
before submitting your pull request -->

* [x] Pull request is based on the develop branch
* [x] Pull request includes a [changelog
file](https://element-hq.github.io/synapse/latest/development/contributing_guide.html#changelog).
The entry should:
- Be a short description of your change which makes sense to users.
"Fixed a bug that prevented receiving messages from other servers."
instead of "Moved X method from `EventStore` to `EventWorkerStore`.".
  - Use markdown where necessary, mostly for `code blocks`.
  - End with either a period (.) or an exclamation mark (!).
  - Start with a capital letter.
- Feel free to credit yourself, by adding a sentence "Contributed by
@github_username." or "Contributed by [Your Name]." to the end of the
entry.
* [x] [Code
style](https://element-hq.github.io/synapse/latest/code_style.html) is
correct (run the
[linters](https://element-hq.github.io/synapse/latest/development/contributing_guide.html#run-the-linters))

---------

Co-authored-by: Eric Eastwood <erice@element.io>
2026-04-16 15:46:47 +00:00
Olivier 'reivilibre 09b48cf060 1.152.0rc1 (retry) 2026-04-16 14:23:45 +01:00
Olivier 'reivilibre 4252efa210 Merge branch 'develop' into release-v1.152 2026-04-16 14:16:46 +01:00
Olivier 'reivilibre 964ca65ebb Support MSC4450: Identity Provider selection for User-Interactive Authentication with Legacy Single Sign-On. (#19693)
Closes: #19688

Part of: MSC4450 whose Experimental Feature tracking issue is #19691


Add an unstable, namespaced `idp_id` query parameter to `fallback/web` \
This allows clients to specify the identity provider they'd like to log
in with for SSO when they have multiple upstream IdPs associated with
their account.

Previously, Synapse would just pick one arbitrarily. But this was
undesirable as you may want to use a different one at that point in
time. When logging in, the user is able to choose when IdP they use -
during UIA (which uses fallback auth mechanism) they should be able to
do the same.

-----

Signed-off-by: Olivier 'reivilibre <oliverw@matrix.org>
Co-authored-by: Andrew Morgan <andrew@amorgan.xyz>
Co-authored-by: Eric Eastwood <madlittlemods@gmail.com>
2026-04-16 12:19:28 +01:00
Travis Ralston e1b56313de Add upgrade notes for new quarantined_media_changes stream (#19694)
Fixes https://github.com/element-hq/synapse/issues/19692

Introduced by https://github.com/element-hq/synapse/pull/19558

---------

Co-authored-by: Eric Eastwood <madlittlemods@gmail.com>
2026-04-16 10:31:10 +00:00
Erik Johnston 2d015f78ea Convert EventInternalMetadata to use Arc<RwLock<_>> (#19669)
This moves the reference counting from PyO3 into standard Rust types,
allowing the class to be used natively from Rust without needing a
Python runtime.
2026-04-16 10:59:39 +01:00
Erik Johnston 71781de707 Add a FilteredEvent type to handle per-user data on events (#19640)
When we return events to clients we need to annotate them with the
membership of the user at the time of the event, in the `unsigned`
section. We already check the membership at the event during the
visibility checks, and so we annotate events there. However, since this
a per-user field we end up having to clone the event in question.

Instead, let's add a `FilteredEvent` class that is returned by the
visibility checks, which allows returning the membership without editing
the event. This has three benefits:
1. Avoids the clones of the event.
2. Allows us to statically check that we have filtered events before
returning them to clients.
3. We no longer edit `unsigned` data after event deserialization, this
makes it easier to port the event class to Rust.

The last benefit is why we're doing this *now*, however IMV it shouldn't
affect whether we want this change or not.

Reviewable commit-by-commit

---------

Co-authored-by: Olivier 'reivilibre' <oliverw@element.io>
2026-04-16 09:47:08 +01:00
Olivier 'reivilibre 943da0ace8 Fix database migrations failing on platforms where SQLite is configured with SQLITE_DBCONFIG_DEFENSIVE by default, such as macOS. (#19690)
Fixes: #19616

This caused 2+ people trouble now, so worth batting away with a
low-effort change if we can.

Only seen on macOS so far, but nothing stops SQLite being configured in
defensive mode by default on other platforms, so it is not necessarily
entirely specific to macOS.

We *could* also do this for Python < 3.12 but it'd be more effort and I
don't know if it's worth it.

(For context @kegsay says the interpreter with this problem was
installed through `pyenv install`.)

---------

Signed-off-by: Olivier 'reivilibre <oliverw@matrix.org>
2026-04-15 16:55:46 +01:00
Olivier 'reivilibre 52c05c5ca4 Introduce spam_checker_spammy internal event metadata. (#19453)
Follows: #19365

Part of: MSC4354 Sticky Events (experimental feature #19409)

This PR introduces a `spam_checker_spammy` flag, analogous to
`policy_server_spammy`, as an explicit flag
that an event was decided to be spammy by a spam-checker module.

The original Sticky Events PR (#18968) just reused
`policy_server_spammy`, but it didn't sit right with me
because we (at least appear to be experimenting with features that)
allow users to opt-in to seeing
`policy_server_spammy` events (presumably for moderation purposes).

Keeping these flags separate felt best, therefore.

As for why we need this flag: soon soft-failed status won't be
permanent, at least for sticky events.
The spam checker modules currently work by making events soft-failed.
We want to prevent spammy events from getting
reconsidered/un-soft-failed, so it seems like we need
a flag to track spam-checker spamminess *separately* from soft-failed.

Should be commit-by-commit friendly, but is also small.

---------

Signed-off-by: Olivier 'reivilibre <oliverw@matrix.org>
2026-04-15 16:53:23 +01:00
Quentin Gliech bed00bb766 Allow resigning of events with a new signing key (#19668)
This adds a way to re-sign all locally-created events with a new signing
key, which is useful when rotating server signing keys.

This doesn't trigger automatically, instead needs to be triggered when
needed via the admin API.

c.f.
https://github.com/matrix-org/internal-config/issues/1670#issuecomment-4206020126
for internal discussion.

---------

Co-authored-by: Kegan Dougall <kegan@element.io>
Co-authored-by: Erik Johnston <erikj@element.io>
2026-04-14 16:44:58 +00:00
Olivier 'reivilibre d4034c0cf8 1.152.0rc1 2026-04-14 13:16:25 +01:00
Eric Eastwood 1a949608d5 Re-usable Complement GitHub CI workflow (#19533)
Docs: https://docs.github.com/en/actions/how-tos/reuse-automations/reuse-workflows
2026-04-13 17:03:46 -05:00
Erik Johnston 8c1ac41cea Small simplifications to the events class (#19680)
This is to make it easier to port to Rust, as well as making things
conceptually simpler.

Two changes:
1. Remove the `__getitem__` interface on events
2. Remove `.user_id` as an alias of `.sender`.
2026-04-13 17:52:13 +01:00
Quentin Gliech 784a28bbc8 Reject device_keys: null in POST /keys/upload (#19637)
The spec says `device_keys` may be omitted, but not set to `null`.
This was temporarily allowed as a workaround for misbehaving clients
(see #19023), which have since been fixed.

Fixes #19030
2026-04-13 15:33:19 +02:00
Eric Eastwood 0e3e947bd6 Fix docstring for limit argument in _maybe_backfill_inner(...) (#19630)
Incorrectly labeled in https://github.com/matrix-org/synapse/pull/13535.

`maybe_backfill` already accurately describes `limit` (introduced in
https://github.com/matrix-org/synapse/pull/8349)

Spotted in
https://github.com/element-hq/synapse/pull/19611#discussion_r3011259710
2026-04-10 13:58:30 -05:00
dependabot[bot] 62523d89ba Bump cryptography from 46.0.6 to 46.0.7 (#19674) 2026-04-10 18:09:54 +01:00
dependabot[bot] 2390116e94 Bump sqlglot from 29.0.1 to 30.2.1 (#19656) 2026-04-10 18:09:21 +01:00
dependabot[bot] aceb081771 Bump actions/setup-go and actions/cache. (#19654) 2026-04-10 18:06:39 +01:00
dependabot[bot] 3a30ca66c7 Bump sentry-sdk, hiredis and pygithub (#19655) 2026-04-10 18:06:08 +01:00
Will Hunt 2439990efc Allow 'article' and 'profile' opengraph fields on URL previews. (#19659) 2026-04-10 18:04:11 +01:00
Travis Ralston a7b87e26ab Switch list quarantined media API to use max to_id instead of current (#19677)
Following up on
https://github.com/element-hq/synapse/pull/19558#discussion_r3054831510

Changelog for this PR is intended to overlap with the above PR.

`get_current_quarantined_media_stream_id` wasn't being used anywhere
else, so we can replace it like we do in this PR.

### Pull Request Checklist

<!-- Please read
https://element-hq.github.io/synapse/latest/development/contributing_guide.html
before submitting your pull request -->

* [x] Pull request is based on the develop branch
* [x] Pull request includes a [changelog
file](https://element-hq.github.io/synapse/latest/development/contributing_guide.html#changelog).
The entry should:
- Be a short description of your change which makes sense to users.
"Fixed a bug that prevented receiving messages from other servers."
instead of "Moved X method from `EventStore` to `EventWorkerStore`.".
  - Use markdown where necessary, mostly for `code blocks`.
  - End with either a period (.) or an exclamation mark (!).
  - Start with a capital letter.
- Feel free to credit yourself, by adding a sentence "Contributed by
@github_username." or "Contributed by [Your Name]." to the end of the
entry.
* [x] [Code
style](https://element-hq.github.io/synapse/latest/code_style.html) is
correct (run the
[linters](https://element-hq.github.io/synapse/latest/development/contributing_guide.html#run-the-linters))

---------

Co-authored-by: Eric Eastwood <erice@element.io>
Co-authored-by: Eric Eastwood <madlittlemods@gmail.com>
2026-04-09 22:06:28 +00:00
Travis Ralston fe742653ff Add an API to list changes to quarantine state of media (#19558)
Fixes https://github.com/element-hq/synapse/issues/19352

(See issue for history of this feature and previous PRs)

> First, a [naive
implementation](https://github.com/element-hq/synapse/pull/19268) of the
endpoint was introduced, but it quickly ran into [performance issues on
query](https://github.com/element-hq/synapse/pull/19312) and [long
startup times](https://github.com/element-hq/synapse/issues/19349),
leading to its
[removal](https://github.com/element-hq/synapse/pull/19351). It also
didn't actually work, and would fail to expose media when it was
"unquarantined", so a [partial
fix](https://github.com/element-hq/synapse/pull/19308) was attempted,
where the suggested direction is to use a
[stream](https://element-hq.github.io/synapse/latest/development/synapse_architecture/streams.html#cheatsheet-for-creating-a-new-stream)
instead of a timestamp column.

This PR re-introduces the API building on the previous feedback:
* Adds a stream which tracks when media becomes (un)quarantined.
* Runs a background update to capture already-quarantined media.
* Adds a new admin API to return rows from the stream table.

We track both quarantine and unquarantine actions in the stream to allow
downstream consumers to process the records appropriately. Namely, to
allow our Synapse exchange in HMA to remove hashes for unquarantined
media (use case further explained in the
[issue](https://github.com/element-hq/synapse/issues/19352)).

**Note**: This knowingly does not capture all cases of media being
quarantined. Other call sites are lower priority for T&S, and can be
addressed in a future PR. ~~An issue will be created after this PR is
merged to track those sites.~~
https://github.com/element-hq/synapse/issues/19672

### Pull Request Checklist

<!-- Please read
https://element-hq.github.io/synapse/latest/development/contributing_guide.html
before submitting your pull request -->

* [x] Pull request is based on the develop branch
* [x] Pull request includes a [changelog
file](https://element-hq.github.io/synapse/latest/development/contributing_guide.html#changelog).
The entry should:
- Be a short description of your change which makes sense to users.
"Fixed a bug that prevented receiving messages from other servers."
instead of "Moved X method from `EventStore` to `EventWorkerStore`.".
  - Use markdown where necessary, mostly for `code blocks`.
  - End with either a period (.) or an exclamation mark (!).
  - Start with a capital letter.
- Feel free to credit yourself, by adding a sentence "Contributed by
@github_username." or "Contributed by [Your Name]." to the end of the
entry.
* [x] [Code
style](https://element-hq.github.io/synapse/latest/code_style.html) is
correct (run the
[linters](https://element-hq.github.io/synapse/latest/development/contributing_guide.html#run-the-linters))

---------

Co-authored-by: turt2live <1190097+turt2live@users.noreply.github.com>
Co-authored-by: Eric Eastwood <madlittlemods@gmail.com>
Co-authored-by: Eric Eastwood <erice@element.io>
2026-04-09 11:41:31 -06:00
Eric Eastwood f7c8967604 Update developer stream docs to point out _setup_sequence(...) in portdb (#19675)
Part of https://github.com/element-hq/synapse/issues/19671

Spawning from [discussion in
`#synapse-dev:matrix.org`](https://matrix.to/#/!i5D5LLct_DYG-4hQprLzrxdbZ580U9UB6AEgFnk6rZQ/$Z3nqbH0Qy21FWC3qJOim6LSRCRpJ3pxV5DLXm98IA6I?via=element.io&via=matrix.org&via=beeper.com)
with roots in
https://github.com/element-hq/synapse/pull/19558#discussion_r3013184415.
As trialed/discovered by @turt2live alongside @reivilibre and @clokep
❤️


### Why is this necessary?

If you forget to add `_setup_sequence(...)`, you can run into the
following error if there is 1 row in SQLite and then you use the
`portdb` script to try to migrate to Postgres (as
[explained](https://matrix.to/#/!i5D5LLct_DYG-4hQprLzrxdbZ580U9UB6AEgFnk6rZQ/$mHU6dcTNL7NMfKBCJUekCh7vDj1lr1GDjriZQl7oeeU?via=element.io&via=matrix.org&via=beeper.com)
by @reivilibre)

```
Postgres sequence 'quarantined_media_id_seq' is inconsistent with associated stream position
of 'quarantined_media' in the 'stream_positions' table.
```
2026-04-09 09:49:25 -05:00
Eric Eastwood 35b55e962a Advertise MSC4445 sync timeline order (#19642)
Synapse uses topological ordering for initial sync (first time a room is
sent down `/sync`), https://github.com/element-hq/synapse/blob/2e9b8202f0a1a8ceba9f02bb5ec227498d51dcbd/synapse/handlers/sync.py#L768-L805
2026-04-08 10:47:13 -05:00