Commit Graph

25697 Commits

Author SHA1 Message Date
Erik Johnston 722cb29a6d WIP 2026-04-16 11:01:42 +01:00
Erik Johnston bf2fd53b4f WIP 2026-04-16 11:01:42 +01:00
Erik Johnston c03505bc8b Make room versions a diff 2026-04-16 11:01:42 +01:00
Erik Johnston 69eb374475 Delta room versions 2026-04-16 11:01:42 +01:00
Erik Johnston 8338077bf2 WIP 2026-04-16 11:01:42 +01:00
Erik Johnston c1cbd8cf40 WIP 2026-04-16 11:01:42 +01:00
Erik Johnston 9056570daa WIP 2026-04-16 11:01:42 +01:00
Erik Johnston a5121cdaed Fixup after rebase 2026-04-16 11:01:42 +01:00
Erik Johnston 665f108c82 Fixups 2026-04-16 11:01:42 +01:00
Erik Johnston 7eb485f8d6 Use assert_never for EventRedactBehaviour 2026-04-16 11:01:42 +01:00
Erik Johnston ee2c77dad8 WIP 2026-04-16 11:01:42 +01:00
Erik Johnston 34e6cbd1b8 WIP 2026-04-16 11:01:42 +01:00
Erik Johnston dd65e3f053 EventID 2026-04-16 11:01:42 +01:00
Erik Johnston f176bffb5c WIP 2026-04-16 11:01:42 +01:00
Erik Johnston fdc3d97e49 WIP 2026-04-16 11:01:42 +01:00
Erik Johnston 2631c7454f WIP 2026-04-16 11:01:42 +01:00
Erik Johnston 6de35a7ee8 WIP 2026-04-16 11:01:42 +01:00
Erik Johnston 0276c52ff4 WIP 2026-04-16 11:01:42 +01:00
Erik Johnston aeb99c65cc WIP 2026-04-16 11:01:42 +01:00
Erik Johnston 853734e30f WIP 2026-04-16 11:01:42 +01: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
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
Eric Eastwood 15662db095 Fix Docker image link typo in worker docs (#19645)
Fix https://github.com/element-hq/synapse/issues/19521
2026-04-08 10:14:58 -05:00
Quentin Gliech a778497acb Merge branch 'master' into develop 2026-04-07 15:43:26 +02:00
Quentin Gliech 4ea109aa5c Fix the changelog v1.151.0 2026-04-07 14:30:11 +02:00
Quentin Gliech cee606e590 Mention the rc in the bug fix in the changelog 2026-04-07 14:21:23 +02:00
Quentin Gliech 77b329a913 1.151.0 2026-04-07 14:15:50 +02:00
Quentin Gliech 09d83f3127 Fix KNOWN_ROOM_VERSIONS.__contains__ raising TypeError for non-string keys (#19649)
The Rust port of `KNOWN_ROOM_VERSIONS` (#19589) made `__contains__`
strict about key types, raising `TypeError` when called with `None`
instead of returning `False` like a Python dict would.
This broke `/sync` for rooms with a NULL `room_version` in the database.

```
  File "/home/synapse/src/synapse/handlers/sync.py", line 2628, in _get_room_changes_for_initial_sync
    if event.room_version_id not in KNOWN_ROOM_VERSIONS:
       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: argument 'key': 'NoneType' object cannot be cast as 'str'
```
2026-04-07 12:12:01 +00:00
Noah Markert 8291a493c7 resolves #19403 Report the rust compiler version used in the prometheus metrics (#19643)
# What is done?
- resolves #19403
- Adds build-time Rust compiler detection and captures the rustc
--version value during the build.
- Exposes the captured compiler version from the Rust extension via a
new Python-callable function.
- Exports a new Prometheus metric for rustc version.

# How to test?
- compile `poetry install`
- add `enable_metrics: true` and 
```yaml
    resources:
    - compress: false
      names:
      - client
      - federation
      - metrics
```
to homeserver.yaml
- start synapse
- find the rustc version at `http://localhost:8008/_synapse/metrics`

### 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: Quentin Gliech <quenting@element.io>
2026-04-03 11:21:23 +02:00
Neil Johnson 62f23fed27 include workaround for macos (#19615)
Co-authored-by: Andrew Morgan <1342360+anoadragon453@users.noreply.github.com>
2026-04-02 13:29:18 +00:00
dependabot[bot] cb6989514e Bump pygments from 2.19.2 to 2.20.0 (#19632)
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2026-04-02 11:47:54 +00:00
Eric Eastwood 2e9b8202f0 Document context for why increase timeout for policy server requests (#19633)
See https://github.com/element-hq/synapse/pull/19629#discussion_r3011377886
2026-03-31 14:10:36 -05:00
Eric Eastwood e1a429ae2e Run lint script to format Complement tests introduced in #19509 (#19636)
Run `poetry run ./scripts-dev/lint.sh` which exposed some formatted
Complement tests that were introduced in
https://github.com/element-hq/synapse/pull/19509

There is no CI for this so it's easy to miss.
2026-03-31 11:01:12 -05:00
Quentin Gliech 72711a3329 1.151.0rc1 v1.151.0rc1 2026-03-31 14:24:05 +02:00