summary refs log tree commit diff
path: root/synapse (follow)
Commit message (Collapse)AuthorAgeFilesLines
* Drop MSC3244 as it was rejected HEAD developRory&2025-06-293-46/+1
|
* Drop unsubscribe as its tied to emailRory&2025-06-283-108/+1
|
* Removed deprecated TCP replication errorRory&2025-06-282-14/+0
|
* Remove deprecated structured logging errorRory&2025-06-281-10/+0
|
* Remove log file errorRory&2025-06-281-9/+0
|
* Remove deprecated metrics settingRory&2025-06-281-22/+0
|
* Remove 3pid and identity serversRory&2025-06-2845-6077/+21
|
* TEMP: expose server error tracebacksRory&2025-06-281-1/+1
|
* Remove SAML/2 authRory&2025-06-2815-960/+21
|
* Remove CAS authRory&2025-06-287-576/+5
|
* Fix pagination with large gaps of rejected eventsNicolas Werner2025-06-271-2/+11
|
* fix: Always recheck `/messages` pagination data if a backfill might have ↵Jason Little2025-06-272-37/+34
| | | | been needed (#28)
* Expose tombstone in room admin apiRory&2025-06-273-2/+40
|
* Use parse_boolean for unredacted contentRory&2025-06-271-3/+2
|
* Log policy server rejected eventsRory&2025-06-271-0/+7
|
* Log entire room if accessibility check failsRory&2025-06-271-0/+4
| | | | Signed-off-by: Rory& <root@rory.gay>
* Add too much logging to room summary over federationRory&2025-06-271-4/+36
| | | | Signed-off-by: Rory& <root@rory.gay>
* Hotfix: ignore rejected events in delayed_eventsRory&2025-06-271-1/+6
|
* Default to `public` join rule in remote summary (#18493)nexy75742025-06-091-1/+1
| | | See: https://github.com/element-hq/synapse/issues/18358#issuecomment-2866119550
* Don't allow users to ignore themselves. (#18508)Will Hunt2025-06-061-0/+4
| | | | | | | | | | | Fixes the self-ignore issues we've being seeing of reports of by ignoring bad requests from clients. Fixes https://github.com/element-hq/synapse/issues/11963 Fix https://github.com/element-hq/element-web/issues/29969 although this should also be fixed on the client to avoid confusing errors popping up while rejecting invites. Related to https://github.com/matrix-org/matrix-rust-sdk/issues/5073
* Recover an appservice if a successful ping occurs. (#18521)Will Hunt2025-06-062-3/+40
| | | | | | | | | | | | | | Fixes https://github.com/element-hq/synapse/issues/14240 This scratches an itch that i've had for years. We regularly run into the issue where (especially in development) appservices can go down for a period and them come back up. The ping endpoint was introduced some time ago which means Synapse can determine if an AS is up more or less immediately, so we might as well use that to schedule transaction redelivery. I believe transaction scheduling logic is largely implementation specific, so we should be in the clear to do this without any spec changes.
* Remove destinations from sending if not whitelisted (#18484)Devon Hudson2025-06-062-8/+70
| | | | Co-authored-by: Andrew Morgan <andrew@amorgan.xyz>
* Export RatelimitOverride from ModuleApi (#18513)Hugh Nimmo-Smith2025-06-064-3/+19
|
* Reduce disk wastage by cleaning up `received_transactions` older than 1 day, ↵reivilibre2025-06-051-2/+2
| | | | | | | | | | | | rather than 30 days. (#18310) Clean up `received_transactions` older than 1 day, rather than 30 days \ Reduces disk waste by homeservers Closes #6437 --------- Signed-off-by: Olivier 'reivilibre <oliverw@matrix.org>
* Add support for MSC4155 Invite filtering (#18288)Will Hunt2025-06-0512-4/+205
| | | | | | | | | | This implements https://github.com/matrix-org/matrix-spec-proposals/pull/4155, which adds support for a new account data type that blocks an invite based on some conditions in the event contents. --------- Co-authored-by: Andrew Morgan <1342360+anoadragon453@users.noreply.github.com>
* Add ratelimit callbacks to module API to allow dynamic ratelimiting (#18458)Hugh Nimmo-Smith2025-06-046-3/+111
|
* Add user_may_send_state_event callback to spam checker module API (#18455)Hugh Nimmo-Smith2025-06-043-0/+80
|
* Add media repository callbacks to module API to control media upload size ↵Hugh Nimmo-Smith2025-06-046-9/+137
| | | | | | | | (#18457) Adds new callbacks for media related functionality: - `get_media_config_for_user` - `is_user_allowed_to_upload_media_of_size`
* Pass room_config argument to user_may_create_room spam checker module ↵Hugh Nimmo-Smith2025-06-042-28/+65
| | | | | | | | | | | | | | callback (#18486) This PR adds an additional `room_config` argument to the `user_may_create_room` spam checker module API callback. It will continue to work with implementations of `user_may_create_room` that do not expect the additional parameter. A side affect is that on a room upgrade the spam checker callback is called *after* doing some work to calculate the state rather than before. However, I hope that this is acceptable given the relative infrequency of room upgrades.
* Make user_type extensible and allow default user_type to be set (#18456)Hugh Nimmo-Smith2025-06-037-10/+75
|
* Mark dehydrated devices in admin get devices endpoint (#18252)Hubert Chathi2025-05-281-0/+11
| | | | Co-authored-by: Andrew Morgan <1342360+anoadragon453@users.noreply.github.com>
* Add option to limit key queries to users sharing rooms as per MSC4263 (#18180)Johannes Marbach2025-05-283-6/+104
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This implements https://github.com/matrix-org/matrix-spec-proposals/pull/4263. ### 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)) --------- Signed-off-by: Johannes Marbach <n0-0ne+github@mailbox.org>
* fix(device-handler): make _maybe_retry_device_resync thread-safe (#18391)3nprob2025-05-261-8/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | A race-condition may render concurrent retry loops. Use an actual `Lock` for guarding single access of device resyncing retrying. ### Pull Request Checklist * [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))
* Don't move invited users to new room when shutting down room (#18471)Shay2025-05-231-11/+12
| | | This is confusing to users who received unwanted invites.
* Policy server part 1: Actually call the policy server (#18387)Travis Ralston2025-05-217-1/+242
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Roughly reviewable commit-by-commit. This is the first part of adding policy server support to Synapse. Other parts (unordered), which may or may not be bundled into fewer PRs, include: * Implementation of a bulk API * Supporting a moderation server config (the `fallback_*` options of https://github.com/element-hq/policyserv_spam_checker ) * Adding an "early event hook" for appservices to receive federation transactions *before* events are processed formally * Performance and stability improvements ### 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: Devon Hudson <devon.dmytro@gmail.com>
* Include room ID in room deletion status response (#18318)Dagfinn Ilmari Mannsåker2025-05-201-0/+1
| | | | When querying by `delete_id` it's handy to see which room the delete pertains to.
* Merge branch 'master' into developDevon Hudson2025-05-205-3/+110
|\
| * Fix up the topological ordering for events above `MAX_DEPTH` (#18447)Erik Johnston2025-05-193-1/+100
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Synapse previously did not correctly cap the max depth of an event to the max canonical json int. This can cause ordering issues for any events that were sent locally at the time. This background update goes and correctly caps the topological ordering to the new `MAX_DEPTH`. c.f. GHSA-v56r-hwv5-mxg6 --------- Co-authored-by: Andrew Morgan <1342360+anoadragon453@users.noreply.github.com>
| * Move index creation to background update (#18439)Erik Johnston2025-05-152-2/+10
| | | | | | | | | | | | | | | | Follow on from #18375. This prevents blocking startup on creating the index, which can take a while --------- Co-authored-by: Devon Hudson <devon.dmytro@gmail.com>
* | Add a unit test for the phone home stats (#18463)Andrew Morgan2025-05-201-4/+29
| |
* | Bump ruff from 0.7.3 to 0.11.10 (#18451)dependabot[bot]2025-05-2040-142/+121
| | | | | | | | | | | | Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Andrew Morgan <andrew@amorgan.xyz> Co-authored-by: Andrew Morgan <1342360+anoadragon453@users.noreply.github.com>
* | Allow only requiring a field be present in an SSO response, rather than ↵Andrew Morgan2025-05-191-6/+1
| | | | | | | | specifying a required value (#18454)
* | Fix admin redaction endpoint not redacting encrypted messages (#18434)Shay2025-05-191-1/+1
| |
* | remove room without listeners from Notifier.room_to_user_streams (#18380)Stanislav Kazantsev2025-05-151-0/+3
| | | | | | | | Co-authored-by: Andrew Morgan <andrew@amorgan.xyz>
* | Add option to allow registrations that begin with '_' (#18262)_2025-05-152-1/+8
| | | | | | | | Co-authored-by: Andrew Morgan <1342360+anoadragon453@users.noreply.github.com>
* | Fix a couple type annotations in the `RootConfig`/`Config` (#18409)Eric Eastwood2025-05-135-11/+13
|/ | | | | | | | | Fix a couple type annotations in the `RootConfig`/`Config`. Discovered while cribbing this code for another project. It's really sucks that `mypy` type checking doesn't catch this. I assume this is because we also have a `synapse/config/_base.pyi` that overrides all of this. Still unclear to me why the `Iterable[str]` vs `StrSequence` issue wasn't caught as that's what `ConfigError` expects.
* Pass leave from remote invite rejection down Sliding Sync (#18375)Devon Hudson2025-05-084-1/+289
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Fixes #17753 ### Dev notes The `sliding_sync_membership_snapshots` and `sliding_sync_joined_rooms` database tables were added in https://github.com/element-hq/synapse/pull/17512 ### 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: Erik Johnston <erik@matrix.org> Co-authored-by: Olivier 'reivilibre <oliverw@matrix.org> Co-authored-by: Eric Eastwood <erice@element.io>
* Convert Sliding Sync tests to use higher-level `compute_interested_rooms` ↵Devon Hudson2025-05-075-41/+251
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | (#18399) Spawning from https://github.com/element-hq/synapse/pull/18375#discussion_r2071768635, This updates some sliding sync tests to use a higher level function in order to move test coverage to cover both fallback & new tables. Important when https://github.com/element-hq/synapse/pull/18375 is merged. In other words, adjust tests to target `compute_interested_room(...)` (relevant to both new and fallback path) instead of the lower level `get_room_membership_for_user_at_to_token(...)` that only applies to the fallback path. ### Dev notes ``` SYNAPSE_TEST_LOG_LEVEL=INFO poetry run trial tests.handlers.test_sliding_sync.ComputeInterestedRoomsTestCase_new ``` ``` SYNAPSE_TEST_LOG_LEVEL=INFO poetry run trial tests.rest.client.sliding_sync ``` ``` SYNAPSE_POSTGRES=1 SYNAPSE_POSTGRES_USER=postgres SYNAPSE_TEST_LOG_LEVEL=INFO poetry run trial tests.handlers.test_sliding_sync.ComputeInterestedRoomsTestCase_new.test_display_name_changes_leave_after_token_range ``` ### 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>
* Merge branch 'master' into developAndrew Morgan2025-05-066-93/+57
|\
| * Unschedule the background update scheduled in #18068. (#18372)Quentin Gliech2025-04-303-92/+18
| | | | | | Fixes #18356
| * Remove the trigger added in #18260 and then reverted (#18373)Quentin Gliech2025-04-303-1/+39
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | See #18260 This is useful for anyone who tried Synapse v1.129.0rc1 out Fixes #18349 To test: - checkout v1.129.0rc1 and start - check that the events table has the trigger (`\dS events` with postgres) - checkout this PR and start - check that the events table doesn't have the trigger anymore
* | Ensure the url previewer also hashes and quarantines media (#18297)Will Hunt2025-05-062-4/+14
| | | | | | | | Co-authored-by: Andrew Morgan <1342360+anoadragon453@users.noreply.github.com>
* | Return specific error code when email / phone not supported (#17578)David Baker2025-05-053-3/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Implements https://github.com/matrix-org/matrix-spec-proposals/pull/4178 If this would need tests, could you give some idea of what tests would be needed and how best to add them? ### Pull Request Checklist <!-- Please read https://element-hq.github.io/synapse/latest/development/contributing_guide.html before submitting your pull request --> * [ ] Pull request is based on the develop branch * [ ] 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. * [ ] [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))
* | Add the ability to exclude remote users in user directory search results ↵Will Lewis2025-05-023-4/+20
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | (#18300) This change adds a new configuration `user_directory.exclude_remote_users`, which defaults to False. When set to True, remote users will not appear in user directory search results. ### 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: Andrew Morgan <1342360+anoadragon453@users.noreply.github.com>
* | Allow a few admin APIs used by MAS to run on workers (#18313)Quentin Gliech2025-05-028-200/+239
| | | | | | | | | | | | | | | | | | | | | | | | This should be reviewed commit by commit. It adds a few admin servlets that are used by MAS when in delegation mode to workers --------- Co-authored-by: Olivier 'reivilibre <oliverw@matrix.org> Co-authored-by: Devon Hudson <devon.dmytro@gmail.com> Co-authored-by: Andrew Morgan <1342360+anoadragon453@users.noreply.github.com>
* | Apply `should_drop_federated_event` to federation invites (#18330)Shay2025-05-021-0/+6
| | | | | | Co-authored-by: Andrew Morgan <1342360+anoadragon453@users.noreply.github.com>
* | Fix lint which broke in #18374 (#18385)Quentin Gliech2025-05-021-1/+1
| | | | | | | | https://github.com/element-hq/synapse/pull/18374 did not pass linting but was merged
* | Don't check the `at_hash` (access token hash) in OIDC ID Tokens if we don't ↵Andrew Morgan2025-05-021-2/+27
| | | | | | | | | | | | use the access token (#18374) Co-authored-by: Eric Eastwood <erice@element.io>
* | Do not auto-provision missing users & devices when delegating auth to MAS ↵Quentin Gliech2025-05-021-28/+11
| | | | | | | | | | | | | | | | | | | | (#18181) Since MAS 0.13.0, the provisionning of devices and users is done synchronously and reliably enough that we don't need to auto-provision on the Synapse side anymore. It's important to remove this behaviour if we want to start caching token introspection results.
* | Add an Admin API endpoint to fetch scheduled tasks (#18214)Shay2025-05-012-0/+72
| |
* | Minor performance improvements to notifier/replication (#18367)Erik Johnston2025-04-291-30/+31
| | | | | | | | | | | | These are some improvements to `on_new_event` which is a hot path. Not sure how much this will save, but maybe like ~5%? Possibly easier to review commit-by-commit
* | Slight performance increase when using the ratelimiter (#18369)Erik Johnston2025-04-292-15/+11
| | | | | | See the commits.
* | Do not retry push during backoff period (#18363)Erik Johnston2025-04-291-0/+6
| | | | | | | | | | This fixes a bug where if a pusher gets told about a new event to push it will ignore the backoff and immediately retry sending any pending push.
* | Allow /rooms/ admin API to be on workers (#18360)Erik Johnston2025-04-252-3/+5
| | | | | | Tested by https://github.com/matrix-org/sytest/pull/1400
* | Move GET /devices/ off main process (#18355)Erik Johnston2025-04-251-2/+18
|/ | | | | | | | We can't move PUT/DELETE as they do need to happen on main process (due to notification of device changes). --------- Co-authored-by: Andrew Morgan <1342360+anoadragon453@users.noreply.github.com>
* Revert "Add total event, unencrypted message, and e2ee event counts to stats ↵Devon Hudson2025-04-166-405/+7
| | | | | | | | | | | reporting" (#18346) Reverts element-hq/synapse#18260 It is causing a failure when building release debs for `debian:bullseye` with the following error: ``` sqlite3.OperationalError: near "RETURNING": syntax error ```
* Fix query for room participation (#18345)Erik Johnston2025-04-161-12/+8
| | | | | | | | | | | Follow on from #18068 Currently the subquery in `UPDATE` is pointless, as it will still just update all `room_membership` rows. Instead, we should look at the current membership event ID (which is easily retrieved from `local_current_membership`). We also add a `AND NOT participant` to noop the `UPDATE` when the `participant` flag is already set. cc @H-Shay
* Fix ExternalIDReuse exception for concurrent transactions (#18342)Quentin Gliech2025-04-161-6/+23
|
* Don't cache introspection failures (#18339)Quentin Gliech2025-04-151-3/+9
|
* Fix `force_tracing_for_users` config when using MAS (#18334)Erik Johnston2025-04-151-0/+51
| | | | | | | This is a copy of what we do for internal auth, and we should figure out a way to deduplicate some of this stuff: https://github.com/element-hq/synapse/blob/dd05cc55eedbf086ae224a13c9ae9f0332d96b1f/synapse/api/auth/internal.py#L62-L110
* Fix the token introspection cache logging access tokens when MAS integration ↵reivilibre2025-04-152-10/+25
| | | | | | | | | | | is in use. (#18335) The `ResponseCache` logs keys by default. Let's not do that for access tokens. --------- Signed-off-by: Olivier 'reivilibre <oliverw@matrix.org>
* Add total event, unencrypted message, and e2ee event counts to stats ↵Andrew Morgan2025-04-156-7/+405
| | | | | | reporting (#18260) Co-authored-by: Eric Eastwood <erice@element.io>
* Add caches to new hot path functions (#18337)Erik Johnston2025-04-143-15/+22
| | | | We call these two functions for every authed request when using delegated auth.
* Add passthrough_authorization_parameters support to OIDC configuration (#18232)Olivier D2025-04-102-1/+17
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | # Add passthrough_authorization_parameters support to OIDC configuration This PR adds `the passthrough_authorization_parameters` option to OIDC configuration, allowing specific query parameters (like `login_hint`) to be passed from the redirect endpoint to the authorization grant URL. This enables clients to provide additional context to identity providers during authentication flows. # 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>
* Disable Postgres statement timeouts while purging room state (#18133)Jason Little2025-04-021-0/+7
|
* Make sure media hashes are not queried until the index is up (#18302)Quentin Gliech2025-04-012-3/+19
|
* Add an access token introspection cache to make Matrix Authentication ↵reivilibre2025-04-011-17/+96
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Service integration (MSC3861) more efficient. (#18231) Evolution of https://github.com/element-hq/synapse/commit/cd78f3d2ee15ccf3e8229a1f529e0e2c16e15c45 This cache does not have any explicit invalidation, but this is deemed acceptable (see code comment). We may still prefer to add it eventually, letting us bump up the Time-To-Live (TTL) on the cache as we currently set a 2 minute expiry to balance the fact that we have no explicit invalidation. This cache makes several things more efficient: - reduces number of outbound requests from Synapse, reducing CPU utilisation + network I/O - reduces request handling time in Synapse, which improves client-visible latency - reduces load on MAS and its database --- Other than that, this PR also introduces support for `expires_in` (seconds) on the introspection response. This lets the cached responses expire at the proper expiry time of the access token, whilst avoiding clock skew issues. Corresponds to: https://github.com/element-hq/matrix-authentication-service/pull/4241 --------- Signed-off-by: Olivier 'reivilibre <oliverw@matrix.org>
* Store hashes of media files, and allow quarantining by hash. (#18277)Will Hunt2025-03-276-45/+377
| | | | | | | | | | | | | | | | This PR makes a few radical changes to media. This now stores the SHA256 hash of each file stored in the database (excluding thumbnails, more on that later). If a set of media is quarantined, any additional uploads of the same file contents or any other files with the same hash will be quarantined at the same time. Currently this does NOT: - De-duplicate media, although a future extension could be to do that. - Run any background jobs to identify the hashes of older files. This could also be a future extension, though the value of doing so is limited to combat the abuse of recent media. - Hash thumbnails. It's assumed that thumbnails are parented to some form of media, so you'd likely be wanting to quarantine the media and the thumbnail at the same time.
* Add DB delta to remove the old state group deletion job (#18284)Devon Hudson2025-03-271-0/+15
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This background DB delta removes the old state group deletion background update from the `background_updates` table if it exists. The `delete_unreferenced_state_groups_bg_update` update should only exist in that table if a homeserver ran v1.126.0rc1/v1.126.0rc2, and rolled back or forward to any other version of Synapse before letting the update finish. ### 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))
* Merge branch 'master' into developAndrew Morgan2025-03-267-27/+63
|\
| * Fix GHSA-v56r-hwv5-mxg6 — Federation denialErik Johnston2025-03-267-27/+63
| | | | | | | | | | | | Fixes https://github.com/element-hq/synapse/security/advisories/GHSA-v56r-hwv5-mxg6 Federation denial of service via malformed events.
* | Delete unreferenced state groups in background (#18254)Devon Hudson2025-03-217-12/+338
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This PR fixes #18154 to avoid de-deltaing state groups which resulted in DB size temporarily increasing until the DB was `VACUUM`'ed. As a result, less state groups will get deleted now. It also attempts to improve performance by not duplicating work when processing state groups it has already processed in previous iterations. ### 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: Erik Johnston <erikj@element.io>
* | Add index to sliding sync membership snapshot table, to fix a performance ↵reivilibre2025-03-182-1/+23
| | | | | | | | | | | | | | | | | | | | | | | | issue. (#18074) To address a performance problem due to the foreign key on the same column. cc @erikjohnston --------- Signed-off-by: Olivier 'reivilibre <oliverw@matrix.org>
* | Add a column `participant` to `room_memberships` table (#18068)Shay2025-03-185-1/+179
|/
* Remove `SYNAPSE_USE_FROZEN_DICTS` environment variable (#18123)Eric Eastwood2025-03-181-10/+9
| | | | | | | | | | I got rid of the `SYNAPSE_USE_FROZEN_DICTS` environment variable because it will be overridden by the Synapse worker apps anyway and if we want to support `SYNAPSE_USE_FROZEN_DICTS`, it should be in `synapse/config/server.py`. It's also not documented so I'm assuming no one is using it anyway. Spawning from looking at the frozen dict stuff during the review of https://github.com/element-hq/synapse/pull/18103#discussion_r1935876168
* MSC4140: don't cancel delayed state on own state (#17810)Andrew Ferrazzutti2025-03-172-10/+40
| | | | | | | When a user sends a state event, do not cancel their own delayed events for the same piece of state. For context, see [the relevant section in the MSC](https://github.com/matrix-org/matrix-spec-proposals/blob/a09a883d9a013ac4b6ffddebd7ea87a827d211b9/proposals/4140-delayed-events-futures.md#delayed-state-events-are-cancelled-by-a-more-recent-state-event).
* Add caching support to media endpoints (#18235)Erik Johnston2025-03-133-7/+103
| | | | | | | | | | | | | | | | | We do a few things in this PR to better support caching: 1. Change `Cache-Control` header to allow intermediary proxies to cache media *only* if they revalidate on every request. This means that the intermediary cache will still send the request to Synapse but with a `If-None-Match` header, at which point Synapse can check auth and respond with a 304 and empty content. 2. Add `ETag` response header to all media responses. We hardcode this to `1` since all media is immutable (beyond being deleted). 3. Check for `If-None-Match` header (after checking for auth), and if it matches then respond with a 304 and empty body. --------- Co-authored-by: Andrew Morgan <1342360+anoadragon453@users.noreply.github.com>
* Revert the background job to clear unreferenced state groups (that was ↵reivilibre2025-03-077-276/+73
| | | | | | | | | | | | | | | | | introduced in v1.126.0rc1), due to a suspected issue that causes increased disk usage. (#18222) Revert "Add background job to clear unreferenced state groups (#18154)" This mechanism is suspected of inserting large numbers of rows into `state_groups_state`, thus unreasonably increasing disk usage. See: https://github.com/element-hq/synapse/issues/18217 This reverts commit 5121f9210c989fcc909e78195133876dff3bc9b9 (#18154). --------- Signed-off-by: Olivier 'reivilibre <oliverw@matrix.org>
* Support getting the device ID explicitly from MAS (#18174)Quentin Gliech2025-03-041-17/+32
| | | | | | | | | | | | | | | | | | | | | | | The context for this is that the Matrix spec allows basically anything in the device ID. With MSC3861, we're restricting this to strings that can be represented as scopes. Whilst this works well for next-gen auth sessions, compatibility/legacy sessions still can have characters that can't be encoded (mainly spaces) in them. To work around that, we added in MAS a behaviour where the device_id is given as an explicit property of the token introspection response, and remove it from the scope. Because we don't expect users to rollout new Synapse and MAS versions in sync, we needed a way to 'advertise' support for this behaviour: the easiest way to do that was through an extra header in the introspection response. On the longer term, I expect MAS and Synapse to move away from the introspection endpoint, and instead define a specific API for Synapse -> MAS communication. PR on the MAS side: https://github.com/element-hq/matrix-authentication-service/pull/4067
* Add `redirect_uri` option to `oidc_providers` entries (#18197)Andrew Morgan2025-03-032-1/+22
| | | | | | | | | | | | | | | | | | | | | Allows overriding the `redirect_uri` parameter sent to both the authorization and token endpoints of the IdP. Typically this parameter is hardcoded to `<public_baseurl>/_synapse/client/oidc/callback`. Yet it can be useful in certain contexts to allow a different callback URL. For instance, if you would like to intercept the authorization code returned from the IdP and do something with it, before eventually calling Synapse's OIDC callback URL yourself. This change enables enterprise use cases but does not change the default behaviour. --- Best reviewed commit-by-commit. --------- Co-authored-by: Eric Eastwood <erice@element.io>
* Add worker_replication_secret_path config option (#18191)V024602025-02-261-2/+19
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Workers now get their secrets from files, too! There are not many config options left to pathify :) Includes documentation and unit tests. ### 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: Devon Hudson <devon.dmytro@gmail.com>
* Add form_secret_path config option (#18090)V024602025-02-251-2/+14
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | I [was told](https://github.com/element-hq/synapse/pull/17983#issuecomment-2593370897) about another config option with a secret, so I got `form_secret` a companion: `form_secret_path` This PR makes NixOS and Kubernetes users a little bit happy. Includes docs and tests. ### 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))
* Define delayed event ratelimit category (#18019)Andrew Ferrazzutti2025-02-252-4/+34
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Apply ratelimiting on delayed event management separately from messages. ### 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. * [ ] [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: Andrew Morgan <1342360+anoadragon453@users.noreply.github.com>
* Add --no-secrets-in-config command line option (#18092)V024602025-02-259-13/+121
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Adds the `--no-secrets-in-config` command line option that makes Synapse reject all configurations containing keys with in-line secret values. Currently this rejects - `turn_shared_secret` - `registration_shared_secret` - `macaroon_secret_key` - `recaptcha_private_key` - `recaptcha_public_key` - `experimental_features.msc3861.client_secret` - `experimental_features.msc3861.jwk` - `experimental_features.msc3861.admin_token` - `form_secret` - `redis.password` - `worker_replication_secret` > [!TIP] > Hey, you! Yes, you! 😊 If you think this list is missing an item, please leave a comment below. Thanks :) This PR complements my other PRs[^1] that add the corresponding `_path` variants for this class of config options. It enables admins to enforce a policy of no secrets in configuration files and guards against accident and malice. Because I consider the flag `--no-secrets-in-config` to be security-relevant, I did not add a corresponding `--secrets-in-config` flag; this way, if Synapse command line options are appended at various places, there is no way to weaken the once-set setting with a succeeding flag. [^1]: [#17690](https://github.com/element-hq/synapse/pull/17690), [#17717](https://github.com/element-hq/synapse/pull/17717), [#17983](https://github.com/element-hq/synapse/pull/17983), [#17984](https://github.com/element-hq/synapse/pull/17984), [#18004](https://github.com/element-hq/synapse/pull/18004), [#18090](https://github.com/element-hq/synapse/pull/18090) ### 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))
* Add background job to clear unreferenced state groups (#18154)Devon Hudson2025-02-257-73/+276
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Fixes #18150 ### 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: Erik Johnston <erikj@element.io>
* Disable room list publication by default (#18175)Erik Johnston2025-02-241-3/+1
| | | | | | This is in line with our general policy of ensuring that the default config is reasonably locked down. SyTest PR to fix tests: https://github.com/matrix-org/sytest/pull/1396
* Prevent suspended users from sending encrypted messages (#18157)Shay2025-02-211-5/+27
| | | Missed in the first round.
* Add support for overriding `id_token_signing_alg_values_supported` for an ↵Eric Eastwood2025-02-202-0/+40
| | | | | | | | | | | | | OpenID identity provider (#18177) Normally, when `discovery` is enabled, `id_token_signing_alg_values_supported` comes from the OpenID Discovery Document (`/.well-known/openid-configuration`). If nothing was specified, we default to supporting `RS256` in the downstream usage. This PR just adds support for adding a default/overriding the the discovered value [just like we do for other things like the `token_endpoint`](https://github.com/element-hq/synapse/blob/1525a3b4d48a0f5657d61423e1f205bff9a77948/docs/usage/configuration/config_documentation.md#oidc_providers), etc.
* Make sure we advertise registration as disabled when MSC3861 is enabled (#17661)Quentin Gliech2025-02-181-4/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | This has been a problem with Element Web, as it will proble /register with an empty body, which gave this error: ``` curl -d '{}' -HContent-Type:application/json /_matrix/client/v3/register {"errcode": "M_UNKNOWN", "error": "Invalid username"} ``` And Element Web would choke on it. This changes that so we reply instead: ``` {"errcode": "M_FORBIDDEN", "error": "Registration has been disabled. Only m.login.application_service registrations are allowed."} ``` Also adds a test for this. See https://github.com/element-hq/element-web/issues/27993 --------- Co-authored-by: Andrew Morgan <andrew@amorgan.xyz>
* Cleanup deleted state group references (#18165)Devon Hudson2025-02-181-0/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | ### 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))
* Add method to get current server time in milliseconds in ModuleApi (#18144)qashlan2025-02-181-0/+4
| | | | | | | | | | - Add `get_current_time_msec()` method to the [module API](https://matrix-org.github.io/synapse/latest/modules/writing_a_module.html) for sound time comparisons with Synapse. - Fixes #18104 Signed-off-by: Ahmed Qashlan <ahmedelqashlan@gmail.com> Co-authored-by: Eric Eastwood <madlittlemods@gmail.com> Co-authored-by: Erik Johnston <erikj@jki.re>
* Add support to proxy outbound requests from Synapse in tests (#18158)Eric Eastwood2025-02-171-0/+6
| | | | | | | | | | | | | | | | | | | | Adds new environment variables that can be used with the Docker image (`SYNAPSE_HTTP_PROXY`/`SYNAPSE_HTTPS_PROXY`/`SYNAPSE_NO_PROXY`) Useful for things like the [Secure Border Gateway](https://element.io/server-suite/secure-border-gateways) ### Why is this necessary? You can already configure the `HTTP_PROXY`/`HTTPS_PROXY` environment variables to proxy outbound requests but setting this globally in the Docker image affects all processes which isn't always desirable or workable in the case where the proxy is running in the Docker image itself (because the Debian packages will fail to download because the proxy isn't up and running yet) . Adding Synapse specific environment variables (`SYNAPSE_HTTP_PROXY`/`SYNAPSE_HTTPS_PROXY`/`SYNAPSE_NO_PROXY`) makes things much more targetable.
* Limit size of user directory search queries (#18172)Erik Johnston2025-02-171-1/+7
| | | | | | | | If a user search has many words we can end up creating really large queries that take a long time for the database to process. Generally, such searches don't return any results anyway (due to limits on user ID and display name length). We "fix" this by cheating and only searching for the first ten words.
* Add log message when worker lock timeouts get large (#18124)Devon Hudson2025-02-121-0/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This is to help track down a possible, but very rare, worker deadlock that was seen on matrix.org. In theory, you could work back from an instance of these new logs to the approximate time when the lock was obtained and focus the diagnostic efforts there. ### 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))
* Fix internal server error when updating 3pid address with invalid email (#18125)qashlan2025-02-121-2/+8
| | | | | | | | When updating 3pid for a user email from admin api and sending invalid email the server throws 500 internal server error. changed to 400 Bad request and returned the error message Signed-off-by: qashlan <ahmedelqashlan@gmail.com> Signed-off-by: Ahmed Qashlan <ahmedelqashlan@gmail.com>
* Cleanup Python 3.8 leftovers (#17967)V024602025-02-1043-76/+90
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Some small cleanups after Python3.8 became EOL. - Move some type imports from `typing_extensions` to `typing` - Remove the `abi3-py38` feature from pyo3 ### 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>
* Overload "allow_none" on DB pool static method (#17616)Andrew Ferrazzutti2025-02-104-33/+44
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | ### 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>
* feat: Allow multiple values for SSO attribute_requirements via comma ↵meise2025-02-102-6/+20
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | separation (#17949) In the current `attribute_requirements` implementation it is only possible to allow exact matching attribute values. Multiple allowed values for one attribute are not possible as described in #13238. ### 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: Sebastian Neuser <pzkz@infra.run> Co-authored-by: Quentin Gliech <quenting@element.io>
* Don't log exceptions for obviously incorrect stream tokens (#18139)Erik Johnston2025-02-101-0/+5
| | | | | | | | We log incorrect ones as we want to catch bugs where Synapse returns bad tokens. However, sometimes clients just send tokens that are e.g. empty. --------- Co-authored-by: Eric Eastwood <erice@element.io>
* Merge branch 'release-v1.124' into developErik Johnston2025-02-072-15/+43
|\
| * Fix performance of `check_state_groups_and_bump_deletion` (#18141)Erik Johnston2025-02-072-15/+43
| | | | | | | | | | | | | | | | | | | | Regressed as part of https://github.com/element-hq/synapse/pull/18107 This does two things: 1. Only check if the state groups have been deleted when calculating the event context (as that's when we will insert them). This avoids lots of checks for read operations. 2. Don't lock the `state_groups` rows when doing the check. This adds overhead, and it doesn't prevent any races.
* | Merge branch 'release-v1.124' into developErik Johnston2025-02-051-2/+12
|\|
| * Fix bug where persisting some events fails after unclean shutdown. (#18137)Erik Johnston2025-02-051-2/+12
| | | | | | | | | | | | Introduced in #18107 `UniqueViolation: duplicate key value violates unique constraint "state_groups_persisting_pkey"`
* | Fix legacy modules `check_username_for_spam` (#18135)Erik Johnston2025-02-051-0/+2
| | | | | | | | | | Broke in #17916, as the signature inspection incorrectly looks at the wrapper function. We fix this by setting the signature on the wrapper function to that of the wrapped function via `@functools.wraps`.
* | Add MSC3861 config options admin_token_path and client_secret_path (#18004)V024602025-02-042-13/+104
|/ | | | | | | | | | | | | | Another PR on my quest to a `*_path` variant for every secret. Adds two config options `admin_token_path` and `client_secret_path` to the experimental config under `experimental_features.msc3861`. Also includes tests. I tried to be a good citizen here by following `attrs` conventions and not rewriting the corresponding non-path variants in the class, but instead adding methods to retrieve the value. Reading secrets from files has the security advantage of separating the secrets from the config. It also simplifies secrets management in Kubernetes. Also useful to NixOS users.
* Fix bug where purging history could lead to increase in disk space usage ↵Erik Johnston2025-02-032-1/+40
| | | | | | | | | | | | | | | | | | | | | | | | | | (#18131) When purging history, we try and delete any state groups that become unreferenced (i.e. there are no longer any events that directly reference them). When we delete a state group that is referenced by another state group, we "de-delta" that state group so that it no longer refers to the state group that is deleted. There are two bugs with this approach that we fix here: 1. There is a common pattern where we end up storing two state groups when persisting a state event: the state before and after the new state event, where the latter is stored as a delta to the former. When deleting state groups we only deleted the "new" state and left (and potentially de-deltaed) the old state. This was due to a bug/typo when trying to find referenced state groups. 2. There are times where we store unreferenced state groups in the DB, during the purging of history these would not get rechecked and instead always de-deltaed. Instead, we should check for this case and delete any unreferenced state groups rather than de-deltaing them. The effect of the above bugs is that when purging history we'd end up with lots of unreferenced state groups that had been de-deltaed (i.e. stored as the full state). This can lead to dramatic increases in storage space used.
* Add locking to more safely delete state groups: Part 2 (#18130)Erik Johnston2025-02-033-11/+162
| | | | | | This actually makes it so that deleting state groups goes via the new mechanism. c.f. #18107
* Add locking to more safely delete state groups: Part 1 (#18107)Erik Johnston2025-02-038-39/+611
| | | | | | | | | | | | | | | | Currently we don't really have anything that stops us from deleting state groups when an in-flight event references it. This is a fairly rare race currently, but we want to be able to more aggressively delete state groups so it is important to address this to ensure that the database remains valid. This implements the locking, but doesn't actually use it. See the class docstring of the new data store for an explanation for how this works. --------- Co-authored-by: Devon Hudson <devon.dmytro@gmail.com>
* Allow (un)block_room storage functions to be called on workers (#18119)Andrew Morgan2025-01-301-44/+44
| | | | | | | | | | | | This is so workers can call these functions. This was preventing the [Delete Room Admin API](https://element-hq.github.io/synapse/latest/admin_api/rooms.html#version-2-new-version) from succeeding when `block: true` was specified. This was because we had `run_background_tasks_on` configured to run on a separate worker. As workers weren't able to call the `block_room` storage function before this PR, the (delete room) task failed when taken off the queue by the worker.
* Raise an error if someone is using an incorrect suffix in a config duration ↵Eric Eastwood2025-01-291-2/+17
| | | | | | | string (#18112) Previously, a value like `5q` would be interpreted as 5 milliseconds. We should just raise an error instead of letting someone run with a misconfiguration.
* Never autojoin deactivated & suspended users. (#18073)Will Hunt2025-01-281-34/+51
| | | | | | | | | This PR changes the logic so that deactivated users are always ignored. Suspended users were already effectively ignored as Synapse forbids a join while suspended. --------- Co-authored-by: Devon Hudson <devon.dmytro@gmail.com>
* OIDC: increase length of generated `nonce` parameter from 30->32 chars (#18109)Andrew Morgan2025-01-271-1/+15
|
* Fix join being denied after being invited over federation (#18075)Eric Eastwood2025-01-275-7/+68
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This also happens for rejecting an invite. Basically, any out-of-band membership transition where we first get the membership as an `outlier` and then rely on federation filling us in to de-outlier it. This PR mainly addresses automated test flakiness, bots/scripts, and options within Synapse like [`auto_accept_invites`](https://element-hq.github.io/synapse/v1.122/usage/configuration/config_documentation.html#auto_accept_invites) that are able to react quickly (before federation is able to push us events), but also helps in generic scenarios where federation is lagging. I initially thought this might be a Synapse consistency issue (see issues labeled with [`Z-Read-After-Write`](https://github.com/matrix-org/synapse/labels/Z-Read-After-Write)) but it seems to be an event auth logic problem. Workers probably do increase the number of possible race condition scenarios that make this visible though (replication and cache invalidation lag). Fix https://github.com/element-hq/synapse/issues/15012 (probably fixes https://github.com/matrix-org/synapse/issues/15012 (https://github.com/element-hq/synapse/issues/15012)) Related to https://github.com/matrix-org/matrix-spec/issues/2062 Problems: 1. We don't consider [out-of-band membership](https://github.com/element-hq/synapse/blob/develop/docs/development/room-dag-concepts.md#out-of-band-membership-events) (outliers) in our `event_auth` logic even though we expose them in `/sync`. 1. (This PR doesn't address this point) Perhaps we should consider authing events in the persistence queue as events already in the queue could allow subsequent events to be allowed (events come through many channels: federation transaction, remote invite, remote join, local send). But this doesn't save us in the case where the event is more delayed over federation. ### What happened before? I wrote some Complement test that stresses this exact scenario and reproduces the problem: https://github.com/matrix-org/complement/pull/757 ``` COMPLEMENT_ALWAYS_PRINT_SERVER_LOGS=1 COMPLEMENT_DIR=../complement ./scripts-dev/complement.sh -run TestSynapseConsistency ``` We have `hs1` and `hs2` running in monolith mode (no workers): 1. `@charlie1:hs2` is invited and joins the room: 1. `hs1` invites `@charlie1:hs2` to a room which we receive on `hs2` as `PUT /_matrix/federation/v1/invite/{roomId}/{eventId}` (`on_invite_request(...)`) and the invite membership is persisted as an outlier. The `room_memberships` and `local_current_membership` database tables are also updated which means they are visible down `/sync` at this point. 1. `@charlie1:hs2` decides to join because it saw the invite down `/sync`. Because `hs2` is not yet in the room, this happens as a remote join `make_join`/`send_join` which comes back with all of the auth events needed to auth successfully and now `@charlie1:hs2` is successfully joined to the room. 1. `@charlie2:hs2` is invited and and tries to join the room: 1. `hs1` invites `@charlie2:hs2` to the room which we receive on `hs2` as `PUT /_matrix/federation/v1/invite/{roomId}/{eventId}` (`on_invite_request(...)`) and the invite membership is persisted as an outlier. The `room_memberships` and `local_current_membership` database tables are also updated which means they are visible down `/sync` at this point. 1. Because `hs2` is already participating in the room, we also see the invite come over federation in a transaction and we start processing it (not done yet, see below) 1. `@charlie2:hs2` decides to join because it saw the invite down `/sync`. Because `hs2`, is already in the room, this happens as a local join but we deny the event because our `event_auth` logic thinks that we have no membership in the room :x: (expected to be able to join because we saw the invite down `/sync`) 1. We finally finish processing the `@charlie2:hs2` invite event from and de-outlier it. - If this finished before we tried to join we would have been fine but this is the race condition that makes this situation visible. Logs for `hs2`: ``` 🗳️ on_invite_request: handling event <FrozenEventV3 event_id=$PRPCvdXdcqyjdUKP_NxGF2CcukmwOaoK0ZR1WiVOZVk, type=m.room.member, state_key=@user-2-charlie1:hs2, membership=invite, outlier=False> 🔦 _store_room_members_txn update room_memberships: <FrozenEventV3 event_id=$PRPCvdXdcqyjdUKP_NxGF2CcukmwOaoK0ZR1WiVOZVk, type=m.room.member, state_key=@user-2-charlie1:hs2, membership=invite, outlier=True> 🔦 _store_room_members_txn update local_current_membership: <FrozenEventV3 event_id=$PRPCvdXdcqyjdUKP_NxGF2CcukmwOaoK0ZR1WiVOZVk, type=m.room.member, state_key=@user-2-charlie1:hs2, membership=invite, outlier=True> 📨 Notifying about new event <FrozenEventV3 event_id=$PRPCvdXdcqyjdUKP_NxGF2CcukmwOaoK0ZR1WiVOZVk, type=m.room.member, state_key=@user-2-charlie1:hs2, membership=invite, outlier=True> ✅ on_invite_request: handled event <FrozenEventV3 event_id=$PRPCvdXdcqyjdUKP_NxGF2CcukmwOaoK0ZR1WiVOZVk, type=m.room.member, state_key=@user-2-charlie1:hs2, membership=invite, outlier=True> 🧲 do_invite_join for @user-2-charlie1:hs2 in !sfZVBdLUezpPWetrol:hs1 🔦 _store_room_members_txn update room_memberships: <FrozenEventV3 event_id=$bwv8LxFnqfpsw_rhR7OrTjtz09gaJ23MqstKOcs7ygA, type=m.room.member, state_key=@user-1-alice:hs1, membership=join, outlier=True> 🔦 _store_room_members_txn update room_memberships: <FrozenEventV3 event_id=$oju1ts3G3pz5O62IesrxX5is4LxAwU3WPr4xvid5ijI, type=m.room.member, state_key=@user-2-charlie1:hs2, membership=join, outlier=False> 📨 Notifying about new event <FrozenEventV3 event_id=$oju1ts3G3pz5O62IesrxX5is4LxAwU3WPr4xvid5ijI, type=m.room.member, state_key=@user-2-charlie1:hs2, membership=join, outlier=False> ... 🗳️ on_invite_request: handling event <FrozenEventV3 event_id=$O_54j7O--6xMsegY5EVZ9SA-mI4_iHJOIoRwYyeWIPY, type=m.room.member, state_key=@user-3-charlie2:hs2, membership=invite, outlier=False> 🔦 _store_room_members_txn update room_memberships: <FrozenEventV3 event_id=$O_54j7O--6xMsegY5EVZ9SA-mI4_iHJOIoRwYyeWIPY, type=m.room.member, state_key=@user-3-charlie2:hs2, membership=invite, outlier=True> 🔦 _store_room_members_txn update local_current_membership: <FrozenEventV3 event_id=$O_54j7O--6xMsegY5EVZ9SA-mI4_iHJOIoRwYyeWIPY, type=m.room.member, state_key=@user-3-charlie2:hs2, membership=invite, outlier=True> 📨 Notifying about new event <FrozenEventV3 event_id=$O_54j7O--6xMsegY5EVZ9SA-mI4_iHJOIoRwYyeWIPY, type=m.room.member, state_key=@user-3-charlie2:hs2, membership=invite, outlier=True> ✅ on_invite_request: handled event <FrozenEventV3 event_id=$O_54j7O--6xMsegY5EVZ9SA-mI4_iHJOIoRwYyeWIPY, type=m.room.member, state_key=@user-3-charlie2:hs2, membership=invite, outlier=True> 📬 handling received PDU in room !sfZVBdLUezpPWetrol:hs1: <FrozenEventV3 event_id=$O_54j7O--6xMsegY5EVZ9SA-mI4_iHJOIoRwYyeWIPY, type=m.room.member, state_key=@user-3-charlie2:hs2, membership=invite, outlier=False> 📮 handle_new_client_event: handling <FrozenEventV3 event_id=$WNVDTQrxy5tCdPQHMyHyIn7tE4NWqKsZ8Bn8R4WbBSA, type=m.room.member, state_key=@user-3-charlie2:hs2, membership=join, outlier=False> ❌ Denying new event <FrozenEventV3 event_id=$WNVDTQrxy5tCdPQHMyHyIn7tE4NWqKsZ8Bn8R4WbBSA, type=m.room.member, state_key=@user-3-charlie2:hs2, membership=join, outlier=False> because 403: You are not invited to this room. synapse.http.server - 130 - INFO - POST-16 - <SynapseRequest at 0x7f460c91fbf0 method='POST' uri='/_matrix/client/v3/join/%21sfZVBdLUezpPWetrol:hs1?server_name=hs1' clientproto='HTTP/1.0' site='8080'> SynapseError: 403 - You are not invited to this room. 📨 Notifying about new event <FrozenEventV3 event_id=$O_54j7O--6xMsegY5EVZ9SA-mI4_iHJOIoRwYyeWIPY, type=m.room.member, state_key=@user-3-charlie2:hs2, membership=invite, outlier=False> ✅ handled received PDU in room !sfZVBdLUezpPWetrol:hs1: <FrozenEventV3 event_id=$O_54j7O--6xMsegY5EVZ9SA-mI4_iHJOIoRwYyeWIPY, type=m.room.member, state_key=@user-3-charlie2:hs2, membership=invite, outlier=False> ```
* Ratelimit presence updates (#18000)Sven Mäder2025-01-244-6/+49
|
* Support the new `/auth_metadata` endpoint defined in MSC2965. (#18093)Quentin Gliech2025-01-213-3/+46
| | | | | | | See the updated MSC2965 --------- Co-authored-by: Andrew Morgan <1342360+anoadragon453@users.noreply.github.com>
* Implement MSC4133 to support custom profile fields. (#17488)Patrick Cloke2025-01-219-25/+671
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Implementation of [MSC4133](https://github.com/matrix-org/matrix-spec-proposals/pull/4133) to support custom profile fields. It is behind an experimental flag and includes tests. ### 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: Andrew Morgan <1342360+anoadragon453@users.noreply.github.com>
* Drop indices concurrently on background updates (#18091)Erik Johnston2025-01-201-2/+2
| | | | | | | | | | Otherwise these can race with other long running queries and lock out all other queries. This caused problems in v1.22.0 as we added an index to `events` table in #17948, but that got interrupted and so next time we ran the background update we needed to delete the half-finished index. However, that got blocked behind some long running queries and then locked other queries out (stopping workers from even starting).
* Bust `_membership_stream_cache` cache when current state changes (#17732)Eric Eastwood2025-01-084-2/+62
| | | | | | | | | | | | | | | | | | | | | | | This is particularly a problem in a state reset scenario where the membership might change without a corresponding event. This PR is targeting a scenario where a state reset happens which causes room membership to change. Previously, the cache would just hold onto stale data and now we properly bust the cache in this scenario. We have a few tests for these scenarios which you can see are now fixed because we can remove the `FIXME` where we were previously manually busting the cache in the test itself. This is a general Synapse thing so by it's nature it helps out Sliding Sync. Fix https://github.com/element-hq/synapse/issues/17368 Prerequisite for https://github.com/element-hq/synapse/issues/17929 --- Match when are busting `_curr_state_delta_stream_cache`
* Add the ability to filter by state event type on admin room state endpoint ↵Shay2025-01-081-1/+13
| | | | | | | | | | (#18035) Adds a query param `type` to `/_synapse/admin/v1/rooms/{room_id}/state` that filters the state event query by state event type. --------- Co-authored-by: Andrew Morgan <1342360+anoadragon453@users.noreply.github.com>
* Drop unstable MSC4151 implementation (#18052)Travis Ralston2025-01-073-17/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | It's been rotated out of known clients, and should be safe for removal now. Fixes https://github.com/element-hq/synapse/issues/17373 ### 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))
* Properly purge state groups tables when purging a room (#18024)Mathieu Velten2025-01-063-68/+32
| | | | | | | | | | | | | | | | | | | | | | | | | | Currently purging a complex room can lead to a lot of orphaned rows left behind in the state groups tables. It seems it is because we are loosing track of state groups sometimes. This change uses the `room_id` indexed column of `state_groups` table to decide what to delete instead of doing an indirection through `event_to_state_groups`. Related to https://github.com/element-hq/synapse/issues/3364. ### Pull Request Checklist * [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). * [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: Erik Johnston <erikj@jki.re>
* Refactor get_profile: do not return missing fields. (#18063)Patrick Cloke2025-01-036-28/+43
| | | | | | | | | | Refactor `get_profile` to avoid returning "empty" (`None` / `null`) fields. Currently this is not very important, but will be more useful once #17488 lands. It does update the servlet to use this now which has a minor change in behavior: additional fields served over federation will now be properly sent back to clients. It also adds constants for `avatar_url` / `displayname` although I did not attempt to use it everywhere possible.
* Make admin api redactions use the requester to send the redaction (#18029)morguldir2024-12-231-1/+1
|
* Stop using twisted.internet.defer.returnValue (#18020)Colin Watson2024-12-202-20/+3
| | | | | | | | | `defer.returnValue` was only needed in Python 2; in Python 3, a simple `return` is fine. `twisted.internet.defer.returnValue` is deprecated as of Twisted 24.7.0. Most uses of `returnValue` in synapse were removed a while back; this cleans up some remaining bits.
* Remove support for PostgreSQL 11 and 12 (#18034)Patrick Cloke2024-12-191-2/+2
| | | | | | | This is essentially matrix-org/synapse#14392. I didn't see anything in there about updating sytest or complement. The main driver of this is so that I can use `jsonb_path_exists` in #17488. 😄
* Disable statement timeout during room purge (#18017)Mathieu Velten2024-12-191-0/+5
| | | | This is already done for `purge_history` but seems to have been forgotten for `purge_room`.
* Fix mypy errors on Twisted 24.11.0 (#17998)Andrew Morgan2024-12-183-8/+16
| | | | | | | | | Fixes various `mypy` errors associated with Twisted `24.11.0`. Hopefully addresses https://github.com/element-hq/synapse/issues/17075, though I've yet to test against `trunk`. Changes should be compatible with our currently pinned Twisted version of `24.7.0`.
* Wording improvements for the `TaskScheduler` (#17992)Andrew Morgan2024-12-181-37/+53
| | | | As I found the current docstrings a bit unclear while trying to wrap my head around this class.
* Bump mypy from 1.11.2 to 1.12.1 and fix new typechecking errors (#17999)Andrew Morgan2024-12-184-11/+11
| | | | | | | Supersedes https://github.com/element-hq/synapse/pull/17958. Awkwardly, the changes made to fix the mypy errors in 1.12.1 cause errors in 1.11.2. So you'll need to update your mypy version to 1.12.1 to eliminate typechecking errors during developing.
* Add email.tlsname config option (#17849)cynhr2024-12-172-33/+61
| | | | | | | | | | | | | | | The existing `email.smtp_host` config option is used for two distinct purposes: it is resolved into the IP address to connect to, and used to (request via SNI and) validate the server's certificate if TLS is enabled. This new option allows specifying a different name for the second purpose. This is especially helpful, if `email.smtp_host` isn't a global FQDN, but something that resolves only locally (e.g. "localhost" to connect through the loopback interface, or some other internally routed name), that one cannot get a valid certificate for. Alternatives would of course be to specify a global FQDN as `email.smtp_host`, or to disable TLS entirely, both of which might be undesirable, depending on the SMTP server configuration.
* Add `macaroon_secret_key_path` config option (#17983)V024602024-12-161-5/+16
| | | | | | Another config option on my quest to a `*_path` variant for every secret. This time it’s `macaroon_secret_key_path`. Reading secrets from files has the security advantage of separating the secrets from the config. It also simplifies secrets management in Kubernetes. Also useful to NixOS users.
* Add some useful endpoints to Admin API (#17948)Shay2024-12-167-8/+169
| | | | | | | | | - Fetch the number of invites the provided user has sent after a given timestamp - Fetch the number of rooms the provided user has joined after a given timestamp, regardless if they have left/been banned from the rooms subsequently - Get report IDs of event reports where the provided user was the sender of the reported event
* forward requester id to check username for spam callbacks (#17916)Wilson2024-12-132-4/+28
|
* Fix bug when rejecting withdrew invite with a third_party_rules module (#17930)Mathieu Velten2024-12-101-5/+5
| | | | | | | | | | | | | | | | | | | When rejecting a withdrew invite through federation, an out of band event needs to be created. When doing so with a third_party_rules module installed, `get_prev_state_ids` [is called](https://github.com/element-hq/synapse/blob/e0fdb862cbbddc920a30233024eb99038ee2fb28/synapse/module_api/callbacks/third_party_event_rules_callbacks.py#L285) on the context to calculate the state to pass at `check_event_allowed` callbacks. The context for outliers is defined [here](https://github.com/element-hq/synapse/blob/e0fdb862cbbddc920a30233024eb99038ee2fb28/synapse/events/snapshot.py#L168), and `state_group_before_event` is None. This change makes the behavior of `get_prev_state_ids` and `get_current_state_ids` match the one presented in the docstring regarding null state_group.
* Promote account suspension to stable (#17964)Travis Ralston2024-12-043-8/+4
| | | MSC: https://github.com/matrix-org/matrix-spec-proposals/pull/3823
* Support for MSC4190: device management for application services (#17705)Quentin Gliech2024-12-046-25/+99
| | | | | | | | This is an implementation of MSC4190, which allows appservices to manage their user's devices without /login & /logout. --------- Co-authored-by: Andrew Morgan <1342360+anoadragon453@users.noreply.github.com>
* MSC4076: Add disable_badge_count to pusher configuration (#17975)manuroe2024-12-032-5/+14
| | | | | This PR implements [MSC4076: Let E2EE clients calculate app badge counts themselves (disable_badge_count)](https://github.com/matrix-org/matrix-spec-proposals/pull/4076).
* Merge branch 'master' into developQuentin Gliech2024-12-038-11/+144
|\
| * Restrict which image formats we will decode in order to generate thumbnailsOlivier 'reivilibre2024-12-031-1/+6
| |
| * Don't allow unsupported content-typeDevon Hudson2024-12-031-0/+36
| | | | | | | | Co-authored-by: Eric Eastwood <erice@element.io>
| * Handle null invite and knock room stateErik Johnston2024-12-035-9/+33
| |
| * Sliding Sync: Fix state leaking on incremental syncEric Eastwood2024-12-032-1/+69
| |
* | Be able to test `/login/sso/redirect` in Complement (#17986)Eric Eastwood2024-12-031-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | Be able to test `/login/sso/redirect` in Complement Spawning from https://github.com/element-hq/sbg/pull/421#discussion_r1854926218 where we have a proxy that intercepts responses to `/_matrix/client/v3/login/sso/redirect(/{idpId})` in order to upgrade them to use OAuth 2.0 Pushed Authorization Requests (PAR). We have some Complement tests in that codebase that go over this flow and these changes are required [in order for the URL's to line up](https://github.com/element-hq/synapse/blob/d648c8ce3f4cbf61191b9f5302e405f7b0288677/synapse/rest/client/login.py#L652-L673).
* | Sliding Sync: Include invite, ban, kick, targets when `$LAZY`-loading room ↵Eric Eastwood2024-12-023-8/+17
| | | | | | | | | | members (#17947) Part of https://github.com/element-hq/synapse/issues/17929
* | Use stable error code for account locking (#17965)Travis Ralston2024-12-021-2/+1
| |
* | Consolidate SSO redirects through ↵Eric Eastwood2024-11-294-17/+66
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | `/_matrix/client/v3/login/sso/redirect(/{idpId})` (#17972) Consolidate SSO redirects through `/_matrix/client/v3/login/sso/redirect(/{idpId})` Spawning from https://github.com/element-hq/sbg/pull/421#discussion_r1859497330 where we have a proxy that intercepts responses to `/_matrix/client/v3/login/sso/redirect(/{idpId})` in order to upgrade them to use OAuth 2.0 Pushed Authorization Requests (PAR). Instead of needing to intercept multiple endpoints that redirect to the authorization endpoint, it seems better to just have Synapse consolidate to a single flow. ### Testing strategy 1. Create a new OAuth application. I'll be using GitHub for example but there are [many options](https://github.com/matrix-org/synapse/blob/be65a8ec0195955c15fdb179c9158b187638e39a/docs/openid.md). Visit https://github.com/settings/developers -> **New OAuth App** - Application name: `Synapse local testing` - Homepage URL: `http://localhost:8008` - Authorization callback URL: `http://localhost:8008/_synapse/client/oidc/callback` 1. Update your Synapse `homeserver.yaml` ```yaml server_name: "my.synapse.server" public_baseurl: http://localhost:8008/ listeners: - port: 8008 bind_addresses: [ #'::1', '127.0.0.1' ] tls: false type: http x_forwarded: true resources: - names: [client, federation, metrics] compress: false # SSO login testing oidc_providers: - idp_id: github idp_name: Github idp_brand: "github" # optional: styling hint for clients discover: false issuer: "https://github.com/" client_id: "xxx" # TO BE FILLED client_secret: "xxx" # TO BE FILLED authorization_endpoint: "https://github.com/login/oauth/authorize" token_endpoint: "https://github.com/login/oauth/access_token" userinfo_endpoint: "https://api.github.com/user" scopes: ["read:user"] user_mapping_provider: config: subject_claim: "id" localpart_template: "{{ user.login }}" display_name_template: "{{ user.name }}" ``` 1. Start Synapse: `poetry run synapse_homeserver --config-path homeserver.yaml` 1. Visit `http://localhost:8008/_synapse/client/pick_idp?redirectUrl=http%3A%2F%2Fexample.com` 1. Choose GitHub 1. Notice that you're redirected to GitHub to sign in (`https://github.com/login/oauth/authorize?...`) Tested locally and works: 1. `http://localhost:8008/_synapse/client/pick_idp?idp=oidc-github&redirectUrl=http%3A//example.com` -> 1. `http://localhost:8008/_matrix/client/v3/login/sso/redirect/oidc-github?redirectUrl=http://example.com` -> 1. `https://github.com/login/oauth/authorize?response_type=code&client_id=xxx&redirect_uri=http%3A%2F%2Flocalhost%3A8008%2F_synapse%2Fclient%2Foidc%2Fcallback&scope=read%3Auser&state=xxx&nonce=xxx`
* | Fix new scheduled tasks jumping the queue (#17962)Richard van der Hoff2024-11-283-35/+34
| | | | | | | | | | | | | | | | | | | | | | | | Currently, when a new scheduled task is added and its scheduled time has already passed, we set it to ACTIVE. This is problematic, because it means it will jump the queue ahead of all other SCHEDULED tasks; furthermore, if the Synapse process gets restarted, it will jump ahead of any ACTIVE tasks which have been started but are taking a while to run. Instead, we leave it set to SCHEDULED, but kick off a call to `_launch_scheduled_tasks`, which will decide if we actually have capacity to start a new task, and start the newly-added task if so.
* | Merge branch 'master' into developQuentin Gliech2024-11-261-0/+1
|\|
| * Fix `delete_old_otks` job on worker deployments (#17960)Richard van der Hoff2024-11-261-0/+1
| | | | | | | | | | | | | | In a worker-mode deployment, the `E2eKeysHandler` is not necessarily loaded, which means the handler for the `delete_old_otks` task will not be registered. Make sure we load the handler. Introduced in https://github.com/element-hq/synapse/pull/17934
* | Fix up logic for delaying sending read receipts over federation. (#17933)Erik Johnston2024-11-254-99/+120
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | For context of why we delay read receipts, see https://github.com/matrix-org/synapse/issues/4730. Element Web often sends read receipts in quick succession, if it reloads the timeline it'll send one for the last message in the old timeline and again for the last message in the new timeline. This caused remote users to see a read receipt for older messages come through quickly, but then the second read receipt taking a while to arrive for the most recent message. There are two things going on in this PR: 1. There was a mismatch between seconds and milliseconds, and so we ended up delaying for far longer than intended. 2. Changing the logic to reuse the `DestinationWakeupQueue` (used for presence) The changes in logic are: - Treat the first receipt and subsequent receipts in a room in the same way - Whitelist certain classes of receipts to never delay being sent, i.e. receipts in small rooms, receipts for events that were sent within the last 60s, and sending receipts to the event sender's server. - The maximum delay a receipt can have before being sent to a server is 30s, and we'll send out receipts to remotes at least at 50Hz (by default) The upshot is that this should make receipts feel more snappy over federation. This new logic should send roughly between 10%–20% of transactions immediately on matrix.org.
* | Return suspended status when querying user account (#17952)Shay2024-11-221-0/+1
| |
* | Fix incorrect comment in new schema delta (#17936)Erik Johnston2024-11-201-2/+2
|/ | | Added in #17912, was a bad copy and paste.
* Enable authenticated media by default (#17889)Travis Ralston2024-11-201-3/+1
| | | Co-authored-by: Olivier 'reivilibre <oliverw@matrix.org>
* Support both import names of PyPI package `python-multipart`. (#17932)Renaud Allard2024-11-201-4/+17
|
* Speed up slow initial sliding syncs on large servers (#17946)Erik Johnston2024-11-193-1/+43
| | | | This was due to a missing index, which meant that deleting previous connections associated with the device and `conn_id` took a long time.
* Create one-off scheduled task to delete old OTKs (#17934)Richard van der Hoff2024-11-194-0/+132
| | | | | | | | | | To work around the fact that, pre-https://github.com/element-hq/synapse/pull/17903, our database may have old one-time-keys that the clients have long thrown away the private keys for, we want to delete OTKs that look like they came from libolm. To spread the load a bit, without holding up other background database updates, we use a scheduled task to do the work.
* Move server event filtering logic to rust (#17928)Devon Hudson2024-11-142-56/+38
| | | | | | | | | | | | | | | | | | | | | | | | | | ### 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))
* Removal: Remove support for experimental msc3886 (#17638)Poruri Sai Rahul2024-11-136-74/+0
|
* Fix typo in error message when a media ID isn't known (#17865)Benjamin Bouvier2024-11-122-2/+2
|
* Add index to `current_state_delta_stream` (#17912)Erik Johnston2024-11-112-2/+43
| | | | As we're now using it in the sync APIs to get state changes within a room
* Fix MSC4222 returning full state (#17915)Erik Johnston2024-11-087-31/+58
| | | | | | | | | | | There was a bug that meant we would return the full state of the room on incremental syncs when using lazy loaded members and there were no entries in the timeline. This was due to trying to use `state_filter or state_filter.all()` as a short hand for handling `None` case, however `state_filter` implements `__bool__` so if the state filter was empty it would be set to full. c.f. MSC4222 and #17888
* Fix other unit tests with latest twisted (#17907)Erik Johnston2024-11-071-2/+2
| | | There's also https://github.com/element-hq/synapse/pull/17906
* Issue one time keys in upload order (#17903)Richard van der Hoff2024-11-063-3/+42
| | | | | | | | Currently, one-time-keys are issued in a somewhat random order. (In practice, they are issued according to the lexicographical order of their key IDs.) That can lead to a situation where a client gives up hope of a given OTK ever being used, whilst it is still on the server. Related: https://github.com/element-hq/element-meta/issues/2356
* Remove support for python 3.8 (#17908)Devon Hudson2024-11-063-4/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | ### 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: Andrew Morgan <1342360+anoadragon453@users.noreply.github.com>
* Fix WheelTimer implementation that can expired timeout early (#17850)Alexander Udovichenko2024-11-051-4/+2
| | | | | When entries insert in the end of timer queue, then unnecessary entry inserted (with duplicated key). This can lead to some timeouts expired early and consume memory.
* Add experimental support for MSC4222 (#17888)Erik Johnston2024-11-054-12/+167
| | | | | | | | | | | Basically, if the client sets a special query param on `/sync` v2 instead of responding with `state` at the *start* of the timeline, we instead respond with `state_after` at the *end* of the timeline. We do this by using the `current_state_delta_stream` table, which is actually reliable, rather than messing around with "state at" points on the timeline. c.f. MSC4222
* Remove usage of internal header encoding API (#17894)Eric Eastwood2024-11-041-24/+16
| | | | | | | | | | | ```py from twisted.web.http_headers import Headers Headers()._canonicalNameCaps Headers()._encodeName ``` Introduced in https://github.com/matrix-org/synapse/pull/15913 <- https://github.com/matrix-org/synapse/pull/15773
* Sliding Sync: Lazy-loading room members on incremental sync (remember ↵Eric Eastwood2024-11-041-36/+132
| | | | | | | | memberships) (#17809) Lazy-loading room members on incremental sync and remember which memberships we've sent down the connection before (up-to 100) Fix https://github.com/element-hq/synapse/issues/17804
* Support & use stable endpoints for MSC4151 (#17374)Travis Ralston2024-10-311-13/+22
| | | | | | | | | | | https://github.com/matrix-org/matrix-spec-proposals/pull/4151 has finished FCP. See https://github.com/element-hq/synapse/issues/17373 for unstable endpoint removal --------- Co-authored-by: Andrew Morgan <andrew@amorgan.xyz>
* Remove `Generator` in `_prune_old_outbound_device_pokes` (#17814)Jason Little2024-10-301-1/+1
| | | | | | Context: https://github.com/matrix-org/synapse/issues/15439 (https://github.com/element-hq/synapse/issues/15439) Also see discussion in https://github.com/element-hq/synapse/pull/17813
* Remove `Generator` in `_purge_unreferenced_state_groups` twice (#17815)Jason Little2024-10-301-2/+2
| | | | | | Context: https://github.com/matrix-org/synapse/issues/15439 (https://github.com/element-hq/synapse/issues/15439) Also see discussion in https://github.com/element-hq/synapse/pull/17813
* Remove `Generator` in `update_cached_last_access_time` (#17816)Jason Little2024-10-301-3/+3
| | | | | | Context: https://github.com/matrix-org/synapse/issues/15439 (https://github.com/element-hq/synapse/issues/15439) Also see discussion in https://github.com/element-hq/synapse/pull/17813
* Remove `Generator` in `store_search_entries_txn` (#17817)Jason Little2024-10-301-2/+2
| | | | | | Context: https://github.com/matrix-org/synapse/issues/15439 (https://github.com/element-hq/synapse/issues/15439) Also see discussion in https://github.com/element-hq/synapse/pull/17813
* Remove `Generator` from 4 places in `PersistEventStore` (#17818)Jason Little2024-10-301-10/+10
| | | | | | Context: https://github.com/matrix-org/synapse/issues/15439 (https://github.com/element-hq/synapse/issues/15439) Also see discussion in https://github.com/element-hq/synapse/pull/17813
* Remove `Generator` in `_quarantine_media_txn()` (#17813)Jason Little2024-10-301-1/+1
|
* Check if user is in room before being able to tag it (#17839)Lama2024-10-302-0/+27
| | | Fix #17819
* Speed up sliding sync by computing extensions in parallel (#17884)Erik Johnston2024-10-303-12/+177
| | | | | | The main change here is to add a helper function `gather_optional_coroutines`, which works in a similar way as `yieldable_gather_results` but takes a set of coroutines rather than a function
* Add admin handler to list of handlers used for background tasks (#17847)Shay2024-10-292-1/+6
| | | | | | | Fixes #17823 While we're at it, makes a change where the redactions are sent as the admin if the user is not a member of the server (otherwise these fail with a "User must be our own" message).
* Fix check for outdated Rust library (#17861)Erik Johnston2024-10-291-22/+65
| | | | This failed when install with poetry, so let's properly try and detect what's going on.
* Include the destination in the error of 'Destination mismatch' (#17830)Erik Johnston2024-10-291-1/+1
| | | | To help debug problems such as https://github.com/element-hq/synapse/issues/17822
* Sliding Sync: Reset `forgotten` status when membership changes (like ↵Eric Eastwood2024-10-226-2/+154
| | | | | | | | | | | | | | | | rejoining a room) (#17835) Reset `sliding_sync_membership_snapshots` -> `forgotten` status when membership changes (like rejoining a room). Fix https://github.com/element-hq/synapse/issues/17781 ### What was the problem before? Previously, if someone used `/forget` on one of their rooms, it would update `sliding_sync_membership_snapshots` as expected but when someone rejoined the room (or had any membership change), the upsert didn't overwrite and reset the `forgotten` status so it remained `forgotten` and invisible down the Sliding Sync endpoint.
* Implement MSC4210: Remove legacy mentions (#17783)Tulir Asokan2024-10-144-0/+7
|
* Sliding Sync: Slight optimization when fetching state for the room ↵Eric Eastwood2024-10-142-9/+40
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | (`get_events_as_list(...)`) (#17718) Spawning from @kegsay [pointing out](https://matrix.to/#/!cnVVNLKqgUzNTOFQkz:matrix.org/$ExOO7J8uPUQSyH-9Uxc_QCa8jlXX9uK4VRtkSC0EI3o?via=element.io&via=matrix.org&via=jki.re) that the Sliding Sync endpoint doesn't handle a large room with a lot of state well on initial sync (requesting all state via `required_state: [ ["*","*"] ]`) (it just takes forever). After investigating further, the slow part is just `get_events_as_list(...)` fetching all of the current state ID's out for the room (which can be 100k+ events for rooms with a lot of membership). This is just a slow thing in Synapse in general and the same thing happens in Sync v2 or the `/state` endpoint. --- The only idea I had to improve things was to use `batch_iter` to only try fetching a fixed amount at a time instead of working with large maps, lists, and sets. This doesn't seem to have much effect though. There is already a `batch_iter(event_ids, 200)` in `_fetch_event_rows(...)` for when we actually have to touch the database and that's inside a queue to deduplicate work. I did notice one slight optimization to use `get_events_as_list(...)` directly instead of `get_events(...)`. `get_events(...)` just turns the result from `get_events_as_list(...)` into a dict and since we're just iterating over the events, we don't need the dict/map.
* Correctly changes to required state config in sliding sync (#17785)Erik Johnston2024-10-143-12/+233
| | | | | | | | | | | | | | | | | | Fixes https://github.com/element-hq/synapse/issues/17698 This handles `required_state` changes by checking if new state has been added to the config, and if so fetching and returning that from the current state. This also takes care to ensure that given a state entry S that is added, removed and then re-added that we do *not* send S down a second time if there have been no changes to S in the current state. This is fine for Rust SDK (as it just remembers all state), but we might decide not to do this behaviour in the MSC. If we decide to always send down S then its easy enough to rip out all the code. --------- Co-authored-by: Eric Eastwood <eric.eastwood@beta.gouv.fr>
* Added display_name_claim in jwt_config which sets the user's display name ↵Nathan2024-10-093-6/+21
| | | | upon registration (#17708)
* Fix saving of non-RGB thumbnails as PNG (#17736)Martin Weinelt2024-10-081-1/+1
|
* Improvements to admin redact api (#17792)Shay2024-10-083-25/+45
| | | | | | - better validation on user input - fix an early task completion - when checking membership in rooms, check for rooms user has been banned from as well
* Add missing license header (#17799)Andrew Ferrazzutti2024-10-087-2/+71
| | | | Co-authored-by: Erik Johnston <erik@matrix.org>
* Sliding sync: omit bump stamp when it is unchanged (#17788)Erik Johnston2024-10-083-12/+49
| | | This saves some DB lookups in rooms
* Sliding sync minor performance speed up using new table (#17787)Erik Johnston2024-10-082-9/+60
| | | | | | | Use the new tables to work out which rooms have changed. --------- Co-authored-by: Eric Eastwood <eric.eastwood@beta.gouv.fr>
* Speed up sliding sync when there are many active subscriptions (#17789)Erik Johnston2024-10-082-7/+62
| | | | | Two changes: a) use a batch lookup function instead of a loop, b) check existing data to see if we already have what we need and only fetch what we don't.
* Add config option redis.password_path (#17717)V024602024-10-071-1/+17
| | | | | | | | | | | Adds the option to load the Redis password from a file, instead of giving it in the config directly. The code is similar to how it’s done for `registration_shared_secret_path`. I changed the example in the documentation to represent the best practice regarding the handling of secrets. Reading secrets from files has the security advantage of separating the secrets from the config. It also simplifies secrets management in Kubernetes.
* Bump python-multipart from 0.0.10 to 0.0.12 (#17772)dependabot[bot]2024-10-071-3/+3
|
* Don't say MSC4140 is supported when it's disabled (#17780)Andrew Ferrazzutti2024-10-041-1/+1
|
* Fix NAME attribute of `ReplicationRemovePusherRestServlet` (#17779)Andrew Morgan2024-10-041-1/+1
|
* Fix perf when streams don't change often (#17767)Erik Johnston2024-09-301-7/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | There is a bug with the `StreamChangeCache` where it would incorrectly return that all entities had changed if asked for entities changed *since* the earliest stream position. Note that for streams we use the inequalities: `$min_stream_id < stream_id <= $max_stream_id`, i.e. when we ask the stream change cache for all things that have changed since `$stream_id` we don't care for events that happened *at* `$stream_id`. Specifically: `_earliest_known_stream_pos` is the position at which we know that we'll have entries for all changes since that point, we can use the cache for any stream IDs that equal `_earliest_known_stream_pos`. `_earliest_known_stream_pos` is set in three places: - On startup we set it either to: - the current maximum stream ID, with not prefilled values; or - the minimum of the latest N values we pulled from the DB - When we evict items from the bottom, we set it to the stream ID of the evicted items. This was changed in https://github.com/matrix-org/synapse/pull/14435, but I think we were overly conservative there. --------- Co-authored-by: Andrew Morgan <1342360+anoadragon453@users.noreply.github.com>
* Optimise notifier mk2 (#17766)Erik Johnston2024-09-301-35/+61
| | | | | | | | | | | | Based on #17765. Basically the idea is to reduce the overhead of calling `ObservableDeferred` in a loop. The two gains are: a) just using a list of deferreds rather than the machinery of `ObservableDeferred`, and b) only calling `PreseverLoggingContext` once. `PreseverLoggingContext` in particular is expensive to call a lot as each time it needs to call `get_thread_resource_usage` twice, so that it an update the CPU metrics of the log context.
* Reduce overhead of sliding sync E2EE loops (#17771)Erik Johnston2024-09-302-6/+7
| | | | Mainly toning down logging and only calling `get_membership_from_event_ids` if something has changed.
* Add fast path for sliding sync streams that only ask for extensions (#17768)Erik Johnston2024-09-301-0/+21
| | | Principally useful for EX e2ee sliding sync connections.
* Optimise notifier (#17765)Erik Johnston2024-09-301-25/+21
| | | | | | | The notifier is quite inefficient when it has to wake up many user streams all at once From a silly benchmark this takes the time to notify 1M user streams from ~30s to ~5s
* Minor perf speed up for large accounts on SSS (#17751)Erik Johnston2024-09-301-4/+6
| | | | | | | | | This works as instead of passing *all* rooms to `record_sent_rooms` we only need to pass rooms that were previously not in the LIVE state. This came from a py-spy where we were spending ~10% CPU calling these functions. Note that `record_sent_rooms` is a no-op for rooms that are already in the `LIVE` state, so we only need to call them for `PREVIOUSLY` or `INITIAL` rooms.
* Support MSC3757: Restricting who can overwrite a state event (#17513)Andrew Ferrazzutti2024-09-262-6/+89
| | | | | | | | Link to the MSC: https://github.com/matrix-org/matrix-spec-proposals/pull/3757 --------- Co-authored-by: Quentin Gliech <quenting@element.io>
* Bump treq from 23.11.0 to 24.9.1 (#17744)dependabot[bot]2024-09-251-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Bumps [treq](https://github.com/twisted/treq) from 23.11.0 to 24.9.1. <details> <summary>Release notes</summary> <p><em>Sourced from <a href="https://github.com/twisted/treq/releases">treq's releases</a>.</em></p> <blockquote> <h2>Treq 24.9.0</h2> <h2>Features</h2> <ul> <li>treq now ships type annotations. (<a href="https://redirect.github.com/twisted/treq/issues/366">#366</a>)</li> <li>The new <code>treq.cookies</code> module provides helper functions for working with <code>http.cookiejar.Cookie</code> and <code>CookieJar</code> objects. (<a href="https://redirect.github.com/twisted/treq/issues/384">#384</a>)</li> <li>Python 3.13 is now supported. (<a href="https://redirect.github.com/twisted/treq/issues/391">#391</a>)</li> </ul> <h2>Bugfixes</h2> <ul> <li><code>treq.content.text_content()</code> no longer generates deprecation warnings due to use of the <code>cgi</code> module. (<a href="https://redirect.github.com/twisted/treq/issues/355">#355</a>)</li> </ul> <h2>Deprecations and Removals</h2> <ul> <li>Mixing the <em>json</em> argument with <em>files</em> or <em>data</em> now raises <code>TypeError</code>. (<a href="https://redirect.github.com/twisted/treq/issues/297">#297</a>)</li> <li>Passing non-string (<code>str</code> or <code>bytes</code>) values as part of a dict to the <em>headers</em> argument now results in a <code>TypeError</code>, as does passing any collection other than a <code>dict</code> or <code>Headers</code> instance. (<a href="https://redirect.github.com/twisted/treq/issues/302">#302</a>)</li> <li>Support for Python 3.7 and PyPy 3.8, which have reached end of support, has been dropped. (<a href="https://redirect.github.com/twisted/treq/issues/378">#378</a>)</li> </ul> <h2>Misc</h2> <ul> <li><a href="https://redirect.github.com/twisted/treq/issues/336">#336</a>, <a href="https://redirect.github.com/twisted/treq/issues/382">#382</a>, <a href="https://redirect.github.com/twisted/treq/issues/395">#395</a></li> </ul> </blockquote> </details> <details> <summary>Changelog</summary> <p><em>Sourced from <a href="https://github.com/twisted/treq/blob/trunk/CHANGELOG.rst">treq's changelog</a>.</em></p> <blockquote> <h1>24.9.1 (2024-09-19)</h1> <h2>Bugfixes</h2> <ul> <li>treq has vendored its dependency on the <code>multipart</code> library to avoid import conflicts with <code>python-multipart</code>; it should now be installable alongside that library. (<code>[#399](https://github.com/twisted/treq/issues/399) &lt;https://github.com/twisted/treq/issues/399&gt;</code>__)</li> </ul> <h1>24.9.0 (2024-09-17)</h1> <h2>Features</h2> <ul> <li>treq now ships type annotations. (<code>[#366](https://github.com/twisted/treq/issues/366) &lt;https://github.com/twisted/treq/issues/366&gt;</code>__)</li> <li>The new :mod:<code>treq.cookies</code> module provides helper functions for working with <code>http.cookiejar.Cookie</code> and <code>CookieJar</code> objects. (<code>[#384](https://github.com/twisted/treq/issues/384) &lt;https://github.com/twisted/treq/issues/384&gt;</code>__)</li> <li>Python 3.13 is now supported. (<code>[#391](https://github.com/twisted/treq/issues/391) &lt;https://github.com/twisted/treq/issues/391&gt;</code>__)</li> </ul> <h2>Bugfixes</h2> <ul> <li>:mod:<code>treq.content.text_content()</code> no longer generates deprecation warnings due to use of the <code>cgi</code> module. (<code>[#355](https://github.com/twisted/treq/issues/355) &lt;https://github.com/twisted/treq/issues/355&gt;</code>__)</li> </ul> <h2>Deprecations and Removals</h2> <ul> <li>Mixing the <em>json</em> argument with <em>files</em> or <em>data</em> now raises <code>TypeError</code>. (<code>[#297](https://github.com/twisted/treq/issues/297) &lt;https://github.com/twisted/treq/issues/297&gt;</code>__)</li> <li>Passing non-string (<code>str</code> or <code>bytes</code>) values as part of a dict to the <em>headers</em> argument now results in a <code>TypeError</code>, as does passing any collection other than a <code>dict</code> or <code>Headers</code> instance. (<code>[#302](https://github.com/twisted/treq/issues/302) &lt;https://github.com/twisted/treq/issues/302&gt;</code>__)</li> <li>Support for Python 3.7 and PyPy 3.8, which have reached end of support, has been dropped. (<code>[#378](https://github.com/twisted/treq/issues/378) &lt;https://github.com/twisted/treq/issues/378&gt;</code>__)</li> </ul> <h2>Misc</h2> <ul> <li><code>[#336](https://github.com/twisted/treq/issues/336) &lt;https://github.com/twisted/treq/issues/336&gt;</code><strong>, <code>[#382](https://github.com/twisted/treq/issues/382) &lt;https://github.com/twisted/treq/issues/382&gt;</code></strong>, <code>[#395](https://github.com/twisted/treq/issues/395) &lt;https://github.com/twisted/treq/issues/395&gt;</code>__</li> </ul> </blockquote> </details> <details> <summary>Commits</summary> <ul> <li><a href="https://github.com/twisted/treq/commit/caaf9fcb62992de47ad5ebcb628cce5106b8d1b1"><code>caaf9fc</code></a> Release 24.9.1</li> <li><a href="https://github.com/twisted/treq/commit/9cedb088b40e5d756f1196defb46b5a7e41bf1c8"><code>9cedb08</code></a> Merge pull request <a href="https://redirect.github.com/twisted/treq/issues/400">#400</a> from twisted/vendor-multipart-for-now</li> <li><a href="https://github.com/twisted/treq/commit/4aa1ee8a3ca5461c165ea380b1cbd0ea5b41cce4"><code>4aa1ee8</code></a> news fragment</li> <li><a href="https://github.com/twisted/treq/commit/d7c16de8f522c5fc10cf2108371afce635d39e4e"><code>d7c16de</code></a> octothorpes rise up</li> <li><a href="https://github.com/twisted/treq/commit/4fd3c842c21a3fa45560dc7eb41767fcbb4e653a"><code>4fd3c84</code></a> try to make the linter happy</li> <li><a href="https://github.com/twisted/treq/commit/f0a5148cba2c983335758dd34ab78bff46f2dc6b"><code>f0a5148</code></a> fix import, switch to <code>from</code></li> <li><a href="https://github.com/twisted/treq/commit/7f16b87f0a2574a2ef67a50e6bf89ad9941fcf4c"><code>7f16b87</code></a> correct import</li> <li><a href="https://github.com/twisted/treq/commit/1526431a37745bb33982f79bb38d1d4e4554907d"><code>1526431</code></a> add a lightly-modified vendored version of <a href="https://github.com/defnull/multipa">https://github.com/defnull/multipa</a>...</li> <li><a href="https://github.com/twisted/treq/commit/7c52d4917f41291da271fd5cebf2e69e73dcee32"><code>7c52d49</code></a> remove dependency on <code>multipart</code> package</li> <li><a href="https://github.com/twisted/treq/commit/ca3966f57a34fa4a3c0b3eb1a90e3f1cc1951bf3"><code>ca3966f</code></a> Merge pull request <a href="https://redirect.github.com/twisted/treq/issues/398">#398</a> from twisted/397-release-24.9.0</li> <li>Additional commits viewable in <a href="https://github.com/twisted/treq/compare/release-23.11.0...treq-24.9.1">compare view</a></li> </ul> </details> <br /> [![Dependabot compatibility score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=treq&package-manager=pip&previous-version=23.11.0&new-version=24.9.1)](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores) Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting `@dependabot rebase`. [//]: # (dependabot-automerge-start) [//]: # (dependabot-automerge-end) --- <details> <summary>Dependabot commands and options</summary> <br /> You can trigger Dependabot actions by commenting on this PR: - `@dependabot rebase` will rebase this PR - `@dependabot recreate` will recreate this PR, overwriting any edits that have been made to it - `@dependabot merge` will merge this PR after your CI passes on it - `@dependabot squash and merge` will squash and merge this PR after your CI passes on it - `@dependabot cancel merge` will cancel a previously requested merge and block automerging - `@dependabot reopen` will reopen this PR if it is closed - `@dependabot close` will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually - `@dependabot show <dependency name> ignore conditions` will show all of the ignore conditions of the specified dependency - `@dependabot ignore this major version` will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself) - `@dependabot ignore this minor version` will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself) - `@dependabot ignore this dependency` will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself) </details> --------- Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Quentin Gliech <quenting@element.io>
* Remove the deprecated cgi module (#17741)V024602024-09-251-3/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Removes all uses of the `cgi` module from Synapse. It was deprecated in Python version 3.11 and removed in version 3.13 ([“dead battery”](https://docs.python.org/3.13/whatsnew/3.13.html#pep-594-remove-dead-batteries-from-the-standard-library)). ### 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>
* Never return negative bump stamp (#17748)Erik Johnston2024-09-241-0/+16
| | | Fixes #17737
* Support MSC4140: Delayed events (Futures) (#17326)Andrew Ferrazzutti2024-09-2314-12/+1306
|
* Speed up sorting of sliding sync rooms in initial request (#17734)Erik Johnston2024-09-201-2/+69
| | | | | | | We do this by using the event stream cache. --------- Co-authored-by: Devon Hudson <devon.dmytro@gmail.com>
* Sliding sync: Add connection tracking to the `account_data` extension (#17695)Erik Johnston2024-09-195-53/+270
| | | | | | | | | | | This is basically exactly the same logic as for receipts. Essentially we just need to track which room account data we have and haven't sent down to clients, and use that when we pull stuff out. I think this just needs a couple of extra tests written --------- Co-authored-by: Eric Eastwood <eric.eastwood@beta.gouv.fr>
* Sliding Sync: Avoid fetching left rooms and add back `newly_left` rooms (#17725)Eric Eastwood2024-09-195-107/+271
| | | | | | | | | | | | | | | Performance optimization: We can avoid fetching rooms that the user has left themselves (which could be a significant amount), then only add back rooms that the user has `newly_left` (left in the token range of an incremental sync). It's a lot faster to fetch less rooms than fetch them all and throw them away in most cases. Since the user only leaves a room (or is state reset out) once in a blue moon, we can avoid a lot of work. Based on @erikjohnston's branch, erikj/ss_perf --------- Co-authored-by: Erik Johnston <erik@matrix.org>
* Fix sliding sync for rooms with unknown room version (#17733)Erik Johnston2024-09-192-0/+15
| | | Follow on from #17727
* Sliding Sync: Add cache to `get_tags_for_room(...)` (#17730)Eric Eastwood2024-09-193-5/+19
| | | | | | | | | Add cache to `get_tags_for_room(...)` This helps Sliding Sync because `get_tags_for_room(...)` is going to be used in https://github.com/element-hq/synapse/pull/17695 Essentially, we're just trying to match `get_account_data_for_room(...)` which already has a tree cache.
* Sliding Sync: No need to sort if the range is large enough to cover all of ↵Eric Eastwood2024-09-191-2/+12
| | | | | | | | | the rooms (#17731) No need to sort if the range is large enough to cover all of the rooms in the list. Previously, we would only do this optimization if the range was exactly large enough. Follow-up to https://github.com/element-hq/synapse/pull/17672
* Sliding Sync: Fix `_bulk_get_max_event_pos(...)` being inefficient (#17728)Eric Eastwood2024-09-191-1/+1
| | | | | | | | | | | | Fix `_bulk_get_max_event_pos(...)` being inefficient. It kept adding all of the `batch_results` to the `results` over and over every time we checked a single room in the batch. I think we still ended up with the right answer before because we accumulate `recheck_rooms` and actually recheck them to overwrite the bad data we wrote to the `results` before. Introduced in https://github.com/element-hq/synapse/pull/17606/files#diff-cbd54e4b5a2a1646299d659a2d5884d6cb14e608efd2e1658e72b465bb66e31bR1481
* Sliding sync: Ignore invites from ignored users (#17729)Eric Eastwood2024-09-181-1/+29
| | | `m.ignored_user_list` in account data
* Sliding Sync: Shortcut for checking if certain background updates have ↵Eric Eastwood2024-09-181-0/+6
| | | | | | | | | | | | completed (#17724) Shortcut for checking if certain background updates have completed Pulling this change out from one of @erikjohnston's branches (https://github.com/element-hq/synapse/compare/develop...erikj/ss_perf) --------- Co-authored-by: Erik Johnston <erikj@element.io>
* Sliding Sync: bugfix: ensure we can sync with SSS even with missing rooms ↵Kegan Dougal2024-09-181-1/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | (#17727) Fixes https://github.com/element-hq/element-x-ios/issues/3300 Some rooms are missing from `sliding_sync_joined_rooms`. When this happens, the first call will succeed, but any subsequent calls for this room ID will cause the cache to return `None` for the room ID, rather than not having the key at all. This then causes the `<=` check to throw. Root cause: https://github.com/element-hq/synapse/issues/17726 ### 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 * [ ] 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. * [ ] [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))
* Add an Admin API endpoint to redact all a user's events (#17506)Shay2024-09-184-4/+359
|
* Sliding Sync: Short-circuit `have_finished_sliding_sync_background_jobs` ↵Eric Eastwood2024-09-171-2/+2
| | | | | | | | (#17723) We only need to check it if returned bump stamp is `None`, which is rare. Pulling this change out from one of @erikjohnston's branches (https://github.com/element-hq/synapse/compare/develop...erikj/ss_perf)
* Sliding Sync: Return room tags in account data extension (#17707)Eric Eastwood2024-09-163-27/+101
| | | | | | The account data extension was also updated to avoid copies when we pull the data out of the cache. Fix https://github.com/element-hq/synapse/issues/17694
* Sliding Sync: Support filtering by 'tags' / 'not_tags' in SSS (#17662)David Baker2024-09-121-2/+59
| | | | | | | | This appears to be enough to make Element Web work (or at least move it on to the next hurdle) --------- Co-authored-by: Eric Eastwood <eric.eastwood@beta.gouv.fr>
* Sliding Sync: Increase concurrency of sliding sync a bit (#17696)Erik Johnston2024-09-122-2/+10
| | | | | | For initial requests a typical page size is 20 rooms, so we may as well do the batching as 20. This should speed up bigger syncs a little bit.
* Sliding Sync: Move filters tests to rest layer (#17703)Eric Eastwood2024-09-124-4/+22
| | | | | | | | | | | | | Move filters tests to rest layer in order to test the new (with sliding sync tables) and fallback paths that Sliding Sync can use. Also found a bug in the new path because it's not being tested which is also fixed in this PR. We now take into account `has_known_state` when filtering. Spawning from https://github.com/element-hq/synapse/pull/17662#discussion_r1755574791. This should have been done when we started using the new sliding sync tables in https://github.com/element-hq/synapse/pull/17630
* import pydantic objects from the `_pydantic_compat` module (#17667)Éloi Rivard2024-09-1115-119/+105
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This PR changes `from pydantic import BaseModel` to `from synapse._pydantic_compat import BaseModel` (as well as `constr`, `conbytes`, `conint`, `confloat`). It allows `check_pydantic_models.py` to mock those pydantic objects only in the synapse module, and not interfere with pydantic objects in external dependencies. This should solve the CI problems for #17144, which breaks because `check_pydantic_models.py` patches pydantic models from [scim2-models](https://scim2-models.readthedocs.io/). /cc @DMRobertson @gotmax23 fixes #17659 ### 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))
* Sliding Sync: Use Sliding Sync tables for sorting (#17693)Eric Eastwood2024-09-116-104/+101
| | | | | Use Sliding Sync tables for sorting (`bulk_get_last_event_pos_in_room_before_stream_ordering(...)` -> `_bulk_get_max_event_pos(...)`)
* Sliding Sync: Make sure we get up-to-date information from ↵Eric Eastwood2024-09-113-1/+23
| | | | | | | | | | | | | | | | | `get_sliding_sync_rooms_for_user(...)` (#17692) We need to bust the `get_sliding_sync_rooms_for_user` cache when the room encryption is updated and any other field that is used in the query. Follow-up to https://github.com/element-hq/synapse/pull/17630 - Bust cache for membership change (cross-reference `get_rooms_for_user`) - Bust cache for room `encryption` (cross-reference `get_room_encryption`) - Bust cache for `forgotten` (cross-reference `did_forget`/`get_forgotten_rooms_for_user`)
* Sliding sync: various fixups to the background update (#17652)Erik Johnston2024-09-112-50/+185
|
* Sliding sync: don't fetch room summary for named rooms. (#17683)Erik Johnston2024-09-115-50/+94
| | | | | | | | | | For rooms with a name we can skip fetching a full room summary, as we don't need to calculate heroes, and instead just fetch the room counts directly. This also changes things to not return counts and heroes for non-joined rooms. For left/banned rooms we were returning zero values anyway, and for invite/knock rooms we don't really want to leak such information (even if some of is included in the stripped state).
* Enable guest access on new media endpoints, per MSC4189 (#17675)Travis Ralston2024-09-101-2/+2
|
* Add config option turn_shared_secret_path (#17690)V024602024-09-101-1/+13
| | | | Co-authored-by: Andrew Morgan <1342360+anoadragon453@users.noreply.github.com>
* Sliding sync: various fixups to the sliding sync joined room background job ↵Erik Johnston2024-09-101-9/+18
| | | | | | | | | (#17673) Follow-up to #17652, https://github.com/element-hq/synapse/pull/17641, https://github.com/element-hq/synapse/pull/17634, https://github.com/element-hq/synapse/pull/17631 and https://github.com/element-hq/synapse/pull/17632 to fix-up https://github.com/element-hq/synapse/pull/17512
* Sliding Sync: Look for `bump _stamp` in the room timeline (#17684)Erik Johnston2024-09-101-53/+95
| | | | | | | This allows us to skip checking the database a lot of the time. --------- Co-authored-by: Eric Eastwood <eric.eastwood@beta.gouv.fr>
* Sliding Sync: Retrieve fewer events from DB in sync (#17688)Erik Johnston2024-09-106-61/+68
| | | | When using timeline limit of 1 we end up fetching 2 events from the DB purely to tell if the response was "limited" or not. Lets not do that.
* Sliding Sync: Add comment to explain extra case where you can be invited -> ↵Eric Eastwood2024-09-091-3/+7
| | | | | | | | | banned -> unbanned (#17654) Add comment to explain extra case where you can be invited -> banned -> unbanned and we want to be able to find the invite event. Follow-up to https://github.com/element-hq/synapse/pull/17636#discussion_r1738993330
* Sliding Sync: Get `bump_stamp` from new sliding sync tables because it's ↵Eric Eastwood2024-09-093-47/+128
| | | | | | | | faster (#17658) Get `bump_stamp` from [new sliding sync tables](https://github.com/element-hq/synapse/pull/17512) which should be faster (performance) than flipping through the latest events in the room.
* Revert "Look for bump stamp in the room timeline"Erik Johnston2024-09-091-24/+12
| | | | This reverts commit a3c49565fff95cb332ef5f00b6faaf4803b34153.
* Look for bump stamp in the room timelineErik Johnston2024-09-091-12/+24
| | | | This allows us to skip checking the database a lot of the time.
* Sliding Sync: Speed up incremental sync by avoiding extra work (#17665)Eric Eastwood2024-09-093-41/+126
| | | | | Speed up incremental sync by avoiding extra work. We first look at the state delta changes and only fetch and calculate further derived things if they have changed.
* Fix bump stamp for non-joined rooms (#17674)Erik Johnston2024-09-061-19/+21
| | | | We should only look for bump stamps in joined rooms, otherwise we should just use the membership stream ordering.
* Small performance improvements for sliding sync (#17672)Erik Johnston2024-09-062-6/+17
| | | A couple of small performance improvements for sliding sync.
* Speed up fetching partial-state rooms on sliding sync (#17666)Erik Johnston2024-09-062-20/+34
| | | | | | | | | | Instead of having a large cache of `room_id -> bool` about whether a room is partially stated, replace with a "fetch rooms the user is which are partially-stated". This is a lot faster as the set of partially stated rooms at any point across the whole server is small, and so such a query is fast. The main issue with the bulk cache lookup is the CPU time looking all the rooms up in the cache.