summary refs log tree commit diff
path: root/tests (follow)
Commit message (Collapse)AuthorAgeFilesLines
* Merge remote-tracking branch 'origin/develop' into erikj/ss_hacksErik Johnston2024-07-302-100/+127
|\
| * Fix `failures` property in `/keys/query` (#17499)Richard van der Hoff2024-07-301-3/+56
| | | | | | | | Fixes: https://github.com/element-hq/synapse/issues/17498 Fixes: https://github.com/element-hq/element-web/issues/27867
| * Only send rooms with updates down sliding sync (#17479)Erik Johnston2024-07-301-27/+62
| | | | | | | | | | | | | | | | | | | | | | | | Rather than always including all rooms in range. Also adds a pre-filter to rooms that checks the stream change cache to see if anything might have happened. Based on #17447 --------- Co-authored-by: Eric Eastwood <eric.eastwood@beta.gouv.fr>
| * Sliding Sync: Track whether we have sent rooms down to clients (#17447)Erik Johnston2024-07-291-3/+449
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The basic idea is that we introduce a new token for a sliding sync connection, which stores the mapping of room to room "status" (i.e. have we sent the room down?). This token allows us to handle duplicate requests properly. In future it can be used to store more "per-connection" information safely. In future this should be migrated into the DB, so its important that we try to reduce the number of syncs where we need to update the per-connection information. In this PoC this only happens when we: a) send down a set of room for the first time, or b) we have previously sent down a room and there are updates but we are not sending the room down the sync (due to not falling in a list range) Co-authored-by: Eric Eastwood <eric.eastwood@beta.gouv.fr>
* | Merge remote-tracking branch ↵Erik Johnston2024-07-291-213/+675
|\ \ | | | | | | | | | 'origin/madlittlemods/sliding-sync-receipts-extension' into erikj/ss_hacks
| * | Fix nested quote syntaxEric Eastwood2024-07-251-1/+1
| | |
| * | Some clean-upEric Eastwood2024-07-251-15/+2
| | |
| * | Fix lintsEric Eastwood2024-07-251-5/+7
| | |
| * | Add testsEric Eastwood2024-07-251-181/+277
| | |
| * | Remove tests that aren't necessaryEric Eastwood2024-07-251-100/+0
| | |
| * | Merge branch 'develop' into madlittlemods/sliding-sync-receipts-extensionEric Eastwood2024-07-251-1249/+831
| |\|
| * | Use more up to date baseEric Eastwood2024-07-251-146/+348
| | |
| * | Generalize extension testEric Eastwood2024-07-251-17/+65
| | |
| * | Iterate moreEric Eastwood2024-07-251-238/+489
| | |
| * | Better standardize `find_relevant_room_ids_for_extension(...)`Eric Eastwood2024-07-241-62/+38
| | |
* | | REVERTErik Johnston2024-07-262-2/+2
| | |
* | | Merge branch 'erikj/ss_noop_rooms' into erikj/ss_hacksErik Johnston2024-07-262-1702/+2062
|\ \ \
| * \ \ Merge remote-tracking branch 'origin/erikj/ss_room_store' into ↵Erik Johnston2024-07-262-1664/+1990
| |\ \ \ | | | | | | | | | | | | | | | erikj/ss_noop_rooms
| | * | | Add never testErik Johnston2024-07-261-0/+70
| | | | |
| | * | | Previously state testErik Johnston2024-07-261-0/+111
| | | | |
| | * | | Review commentsErik Johnston2024-07-261-15/+18
| | | | |
| | * | | Move to integration testsErik Johnston2024-07-252-395/+116
| | | | |
| | * | | Use do_sync in testsErik Johnston2024-07-251-118/+50
| | | | |
| | * | | Merge remote-tracking branch 'origin/develop' into erikj/ss_room_storeErik Johnston2024-07-251-1170/+1658
| | |\ \ \ | | | | |/ | | | |/|
| | | * | Refactor Sliding Sync tests to better utilize the ↵Eric Eastwood2024-07-251-1021/+725
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | `SlidingSyncBase.do_sync(...)` (pt. 2) (#17482) `SlidingSyncBase.do_sync()` for tests was first introduced in https://github.com/element-hq/synapse/pull/17452 Part 1: https://github.com/element-hq/synapse/pull/17481
| | | * | Refactor Sliding Sync tests to better utilize the `SlidingSyncBase` (pt. 1) ↵Eric Eastwood2024-07-251-228/+106
| | | |/ | | | | | | | | | | | | | | | | | | | | | | | | | | | | (#17481) `SlidingSyncBase` for tests was first introduced in https://github.com/element-hq/synapse/pull/17452 Part 2: https://github.com/element-hq/synapse/pull/17482
| | | * Sliding Sync: Add Account Data extension (MSC3959) (#17477)Eric Eastwood2024-07-241-0/+786
| | | | | | | | | | | | | | | | | | | | | | | | Extensions based on [MSC3575](https://github.com/matrix-org/matrix-spec-proposals/pull/3575): Sliding Sync
| | | * Sliding Sync: ensure bump stamp ignores backfilled events (#17478)Erik Johnston2024-07-241-1/+121
| | | | | | | | | | | | | | | | | | | | | | | | Backfill events have a negative stream ordering, and so its not useful to use to compare with other (positive) stream orderings. Plus, the Rust SDK currently assumes `bump_stamp` is positive.
| * | | Don't send down rooms if nothing has happenedErik Johnston2024-07-261-26/+14
| | | |
| * | | Add test that empty room comes down initial syncErik Johnston2024-07-261-11/+29
| | | |
| * | | Review commentsErik Johnston2024-07-261-6/+1
| | | |
| * | | Only send rooms with updates down sliding syncErik Johnston2024-07-241-14/+49
| |/ /
* | | Merge branch 'erikj/ss_room_store' into erikj/ss_hacksErik Johnston2024-07-243-165/+1452
|\| |
| * | Merge remote-tracking branch 'origin/develop' into erikj/ss_room_storeErik Johnston2024-07-241-340/+189
| |\|
| | * Use a new token format for sliding sync (#17452)Erik Johnston2024-07-241-191/+225
| | | | | | | | | | | | | | | | | | | | | This is in preparation for adding per-connection state. --------- Co-authored-by: Eric Eastwood <eric.eastwood@beta.gouv.fr>
| * | Merge branch 'erikj/ss_tokens' into erikj/ss_room_storeErik Johnston2024-07-234-6/+1187
| |\ \
| | * | Fix testsErik Johnston2024-07-231-26/+106
| | | |
| | * | Merge remote-tracking branch 'origin/develop' into erikj/ss_tokensErik Johnston2024-07-234-6/+1107
| | |\|
| | | * Speed up SS room sorting (#17468)Erik Johnston2024-07-231-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | We do this by bulk fetching the latest stream ordering. --------- Co-authored-by: Andrew Morgan <1342360+anoadragon453@users.noreply.github.com>
| | | * Sliding Sync: Add E2EE extension (MSC3884) (#17454)Eric Eastwood2024-07-221-4/+821
| | | | | | | | | | | | | | | | | | | | Spec: [MSC3884](https://github.com/matrix-org/matrix-spec-proposals/pull/3884) Based on [MSC3575](https://github.com/matrix-org/matrix-spec-proposals/pull/3575): Sliding Sync
| | | * SS: Implement `$ME` support (#17469)Erik Johnston2024-07-221-0/+74
| | | | | | | | | | | | `$ME` can be used as a substitute for the requester's user ID.
| | * | Merge remote-tracking branch 'origin/develop' into erikj/ss_tokensErik Johnston2024-07-192-14/+410
| | |\ \
| * | | | Add test for cache being clearedErik Johnston2024-07-231-0/+71
| | | | |
| * | | | Fix linting in testsErik Johnston2024-07-181-4/+4
| | | | |
| * | | | Merge remote-tracking branch 'origin/develop' into erikj/ss_room_storeErik Johnston2024-07-182-14/+410
| |\ \ \ \ | | | |/ / | | |/| |
| * | | | Add some unit tests for 'get_room_sync_data'Erik Johnston2024-07-181-3/+396
| | | | |
| * | | | Apply suggestions from code reviewErik Johnston2024-07-181-1/+1
| | | | | | | | | | | | | | | Co-authored-by: Eric Eastwood <eric.eastwood@beta.gouv.fr>
* | | | | Merge branch 'erikj/ss_faster_sort' into erikj/ss_hacksErik Johnston2024-07-224-14/+620
|\ \ \ \ \ | | |_|_|/ | |/| | |
| * | | | Prepare for authenticated media freeze (#17433)Shay2024-07-221-0/+209
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | As part of the rollout of [MSC3916](https://github.com/matrix-org/matrix-spec-proposals/blob/main/proposals/3916-authentication-for-media.md) this PR adds support for designating authenticated media and ensuring that authenticated media is not served over unauthenticated endpoints.
| * | | | Add a cache on `get_rooms_for_local_user_where_membership_is` (#17460)Erik Johnston2024-07-191-0/+1
| | |/ / | |/| | | | | | | | | | | | | | | | | | | | | | As it gets used in sliding sync. We basically invalidate it in all the same places as `get_rooms_for_user`. Most of the changes are due to needing the arguments you pass in to be hashable (which lists aren't)
| * | | Order `heroes` by `stream_ordering` (as spec'ed) (#17435)Eric Eastwood2024-07-172-14/+410
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The spec specifically mentions `stream_ordering` but that's a Synapse specific concept. In any case, the essence of the spec is basically the first 5 members of the room which `stream_ordering` accomplishes. Split off from https://github.com/element-hq/synapse/pull/17419#discussion_r1671342794 ## Spec compliance > This should be the first 5 members of the room, **ordered by stream ordering**, which are joined or invited. The list must never include the client’s own user ID. When no joined or invited members are available, this should consist of the banned and left users. > > *-- https://spec.matrix.org/v1.10/client-server-api/#_matrixclientv3sync_roomsummary* Related to https://github.com/matrix-org/matrix-spec/issues/1334
* | | | Merge branch 'erikj/ss_incr_sync' into erikj/ss_hacksErik Johnston2024-07-171-2/+182
|\ \ \ \
| * | | | Only return changed rooms erikj/ss_incr_syncErik Johnston2024-07-171-2/+1
| | |/ / | |/| |
| * | | Add testsErik Johnston2024-07-171-0/+181
| | | |
* | | | Merge branch 'erikj/ss_room_store' into erikj/ss_hacksErik Johnston2024-07-176-56/+288
|\| | |
| * | | Fix testsErik Johnston2024-07-171-14/+2
| | |/ | |/|
| * | Fix to use new token formatErik Johnston2024-07-171-2/+9
| | |
| * | Don't create tokens manually in SSS testsErik Johnston2024-07-171-21/+119
| |/
| * Bump mypy from 1.9.0 to 1.10.1 (#17445)dependabot[bot]2024-07-161-1/+2
| |
| * Handle remote download responses with `UNKNOWN_LENGTH` more gracefully (#17439)Shay2024-07-162-14/+85
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Prior to this PR, remote downloads which did not provide a `content-length` were decremented from the remote download ratelimiter at the max allowable size, leading to excessive ratelimiting - see https://github.com/element-hq/synapse/issues/17394. This PR adds a linearizer to limit concurrent remote downloads to 6 per IP address, and decrements remote downloads without a `content-length` from the ratelimiter *after* the download is complete and the response length is known. Also adds logic to ensure that responses with a known length respect the `max_download_size`.
| * Remove unnecessary call to resume producing in fake channel (#17449)Shay2024-07-161-4/+0
| | | | | | | | | | This fell out of the authenticated media work - this bit of code masked a bug but does not break anything when removed, so probably should be removed.
| * Fix bug where sync could get stuck when using workers (#17438)Erik Johnston2024-07-151-0/+71
| | | | | | | | This is because we serialized the token wrong if the instance map contained entries from before the minimum token.
* | Merge remote-tracking branch 'origin/develop' into erikj/ss_hacksErik Johnston2024-07-153-243/+1200
|\|
| * Add room subscriptions to Sliding Sync `/sync` (#17432)Eric Eastwood2024-07-153-243/+1200
| | | | | | | | | | | | | | | | | | | | | | | | | | Add room subscriptions to Sliding Sync `/sync` Based on [MSC3575](https://github.com/matrix-org/matrix-spec-proposals/pull/3575): Sliding Sync Currently, you can only subscribe to rooms you have had *any* membership in before. In the future, we will allow `world_readable` rooms to be subscribed to without joining.
* | Merge remote-tracking branch 'origin/develop' into erikj/ss_hacksErik Johnston2024-07-122-12/+383
|\|
| * Add `is_dm` room field to Sliding Sync `/sync` (#17429)Eric Eastwood2024-07-111-0/+23
| | | | | | | | | | Based on [MSC3575](https://github.com/matrix-org/matrix-spec-proposals/pull/3575): Sliding Sync
| * Add `heroes` and room summary fields to Sliding Sync `/sync` (#17419)Eric Eastwood2024-07-111-12/+292
| | | | | | | | | | | | | | Additional room summary fields: `joined_count`, `invited_count` Based on [MSC3575](https://github.com/matrix-org/matrix-spec-proposals/pull/3575): Sliding Sync
| * Fix filtering room types on remote rooms (#17434)Erik Johnston2024-07-111-0/+68
| | | | | | | | | | | | We can only fetch room types for rooms the server is in, so we need to only filter rooms that we're joined to. Also includes a perf fix to bulk fetch room types.
* | Merge branch 'erikj/ss_sort' into erikj/ss_hacksErik Johnston2024-07-111-0/+1
|\ \
| * | Faster sliding sync sortingErik Johnston2024-07-111-0/+1
| |/
* / FIXUPErik Johnston2024-07-102-2/+2
|/
* Handle to-device extensions to Sliding Sync (#17416)Erik Johnston2024-07-101-2/+198
| | | | | | | Implements MSC3885 --------- Co-authored-by: Eric Eastwood <eric.eastwood@beta.gouv.fr>
* Add `rooms` `name` and `avatar` to Sliding Sync `/sync` (#17418)Eric Eastwood2024-07-091-0/+208
| | | Based on [MSC3575](https://github.com/matrix-org/matrix-spec-proposals/pull/3575): Sliding Sync
* Fix bug in sliding sync when using old DB. (#17398)Erik Johnston2024-07-082-124/+1
| | | | | | | | | We don't necessarily have `instance_name` for old events (before we support multiple event persisters). We treat those as if the `instance_name` was "master". --------- Co-authored-by: Eric Eastwood <eric.eastwood@beta.gouv.fr>
* Add `rooms.bump_stamp` to Sliding Sync `/sync` for easier client-side ↵Eric Eastwood2024-07-083-4/+201
| | | | | | | | | | | | | | | sorting (#17395) `bump_stamp` corresponds to the `stream_ordering` of the latest `DEFAULT_BUMP_EVENT_TYPES` in the room. This helps clients sort more readily without them needing to pull in a bunch of the timeline to determine the last activity. `bump_event_types` is a thing because for example, we don't want display name changes to mark the room as unread and bump it to the top. For encrypted rooms, we just have to consider any activity as a bump because we can't see the content and the client has to figure it out for themselves. Outside of Synapse, `bump_stamp` is just a free-form counter so other implementations could use `received_ts`or `origin_server_ts` (see the [*Security considerations* section in MSC3575 about the potential pitfalls of using `origin_server_ts`](https://github.com/matrix-org/matrix-spec-proposals/blob/kegan/sync-v3/proposals/3575-sync.md#security-considerations)). It doesn't have any guarantee about always going up. In the Synapse case, it could go down if an event was redacted/removed (or purged in cases of retention policies). In the future, we could add `bump_event_types` as [MSC3575](https://github.com/matrix-org/matrix-spec-proposals/pull/3575) mentions if people need to customize the event types. --- In the Sliding Sync proxy, a similar [`timestamp` field was added](https://github.com/matrix-org/sliding-sync/pull/247) for the same purpose but the name is not obvious what it pertains to or what it's for. The `timestamp` field was also added to Ruma in https://github.com/ruma/ruma/pull/1622
* Support MSC3916 by adding a federation /thumbnail endpoint and authenticated ↵Shay2024-07-083-84/+404
| | | | | | | | | | | | | | `_matrix/client/v1/media/thumbnail` endpoint (#17388) [MSC3916](https://github.com/matrix-org/matrix-spec-proposals/pull/3916) added the endpoints `_matrix/federation/v1/media/thumbnail` and the authenticated `_matrix/client/v1/media/thumbnail`. This PR implements those endpoints, along with stabilizing `_matrix/client/v1/media/config` and `_matrix/client/v1/media/preview_url`. Complement tests are at https://github.com/matrix-org/complement/pull/728
* Bump ruff from 0.3.7 to 0.5.0 (#17381)dependabot[bot]2024-07-051-1/+1
|
* Finish up work to allow per-user feature flags (#17392)Erik Johnston2024-07-052-12/+84
| | | | | | | Follows on from @H-Shay's great work at https://github.com/matrix-org/synapse/pull/15344 and MSC4026. Also enables its use for MSC3881, mainly as an easy but concrete example of how to use it.
* Upon deactivation, forget all of the user's rooms (#17400)Travis Ralston2024-07-051-0/+22
| | | | | | This can help ensure that the rooms are eventually purged if the other local users also forget them. Synapse already clears some of the room information as part of the `_background_remove_left_rooms` background task, but this doesn't catch `events`, `event_json`, etc.
* Add `rooms.required_state` to Sliding Sync `/sync` (#17342)Eric Eastwood2024-07-043-8/+1253
| | | Also handles excluding rooms with partial state when people are asking for room membership events unless it's `$LAZY` room membership.
* Add `room_types`/`not_room_types` filtering to Sliding Sync `/sync` (#17337)Eric Eastwood2024-07-021-1/+213
| | | | | Based on [MSC3575](https://github.com/matrix-org/matrix-spec-proposals/pull/3575): Sliding Sync
* Return some room data in Sliding Sync `/sync` (#17320)Eric Eastwood2024-07-024-57/+2672
| | | | | | - Timeline events - Stripped `invite_state` Based on [MSC3575](https://github.com/matrix-org/matrix-spec-proposals/pull/3575): Sliding Sync
* Merge remote-tracking branch 'origin/release-v1.110' into developErik Johnston2024-07-021-6/+31
|\
| * Limit size of presence EDUs (#17371)Erik Johnston2024-07-021-0/+119
| | | | | | | | | | | | | | Otherwise they are unbounded. --------- Co-authored-by: Andrew Morgan <1342360+anoadragon453@users.noreply.github.com>
| * Fix regression when bounding future tokens (#17391)Erik Johnston2024-07-021-6/+31
| | | | | | | | | | | | Fix bug added in #17386, where we accidentally used `room_key` for the receipts stream. See first commit. Reviewable commit-by-commit
| * Fix sync waiting for an invalid token from the "future" (#17386)Erik Johnston2024-07-022-2/+75
| | | | | | | | | | | | | | | | | | | | | | | | | | Fixes https://github.com/element-hq/synapse/issues/17274, hopefully. Basically, old versions of Synapse could advance streams without persisting anything in the DB (fixed in #17229). On restart those updates would get lost, and so the position of the stream would revert to an older position. If this happened across an upgrade to a later Synapse version which included #17215, then sync could get blocked indefinitely (until the stream advanced to the position in the token). We fix this by bounding the stream positions we'll wait for to the maximum position of the underlying stream ID generator.
* | Support MSC3916 by adding `_matrix/client/v1/media/download` endpoint (#17365)Shay2024-07-025-44/+991
| |
* | Fix sync waiting for an invalid token from the "future" (#17386)Erik Johnston2024-07-022-2/+75
| | | | | | | | | | | | | | | | | | | | | | | | | | Fixes https://github.com/element-hq/synapse/issues/17274, hopefully. Basically, old versions of Synapse could advance streams without persisting anything in the DB (fixed in #17229). On restart those updates would get lost, and so the position of the stream would revert to an older position. If this happened across an upgrade to a later Synapse version which included #17215, then sync could get blocked indefinitely (until the stream advanced to the position in the token). We fix this by bounding the stream positions we'll wait for to the maximum position of the underlying stream ID generator.
* | Limit size of presence EDUs (#17371)Erik Johnston2024-07-011-0/+119
|/ | | | | | | Otherwise they are unbounded. --------- Co-authored-by: Andrew Morgan <1342360+anoadragon453@users.noreply.github.com>
* Re-introduce federation /download endpoint (#17350)Shay2024-06-251-0/+173
|
* Reintroduce "Reduce device lists replication traffic."" (#17361)Erik Johnston2024-06-251-0/+8
| | | | | | Reintroduces https://github.com/element-hq/synapse/pull/17333 Turns out the reason for revert was down two master instances running
* Revert "Reduce device lists replication traffic." (#17360)Erik Johnston2024-06-251-8/+0
| | | | | | Reverts element-hq/synapse#17333 It looks like master was still sending out replication RDATA with the old format... somehow
* Add `is_invite` filtering to Sliding Sync `/sync` (#17335)Eric Eastwood2024-06-242-40/+182
| | | Based on [MSC3575](https://github.com/matrix-org/matrix-spec-proposals/pull/3575): Sliding Sync
* Reintroduce #17291. (#17338)Erik Johnston2024-06-243-12/+43
| | | | | | | This is #17291 (which got reverted), with some added fixups, and change so that tests actually pick up the error. The problem was that we were not calculating any new chain IDs due to a missing `not` in a condition.
* Add support for MSC3823 - Account Suspension Part 2 (#17255)Shay2024-06-242-0/+189
|
* Reduce device lists replication traffic. (#17333)Erik Johnston2024-06-241-0/+8
| | | | | | | | | | Reduce the replication traffic of device lists, by not sending every destination that needs to be sent the device list update over replication. Instead a "hosts to send to have been calculated" notification over replication, and then federation senders read the destinations from the DB. For non federation senders this should heavily reduce the impact of a user in many large rooms changing a device.
* Revert "Handle large chain calc better (#17291)" (#17334)Erik Johnston2024-06-192-38/+12
| | | | | | This reverts commit bdf82efea505c488953b46eb681b5a63c4e9655d (#17291) This seems to have stopped persisting auth chains for new events, and so is causing state res to fall back to the slow methods
* Register sliding sync under a different path (#17331)Erik Johnston2024-06-191-1/+3
| | | As the API is slightly incompatible.
* Filter added to Admin-API GET /rooms (#17276)Alexander Fechler2024-06-191-0/+77
|
* Handle large chain calc better (#17291)Erik Johnston2024-06-192-12/+38
| | | | | We calculate the auth chain links outside of the main persist event transaction to ensure that we do not block other event sending during the calculation.
* Require the 'from' parameter for `/notifications` be an integer (#17283)Andrew Morgan2024-06-192-19/+154
| | | | Co-authored-by: Erik Johnston <erikj@element.io>
* Revert "Support MSC3916 by adding a federation `/download` endpoint" (#17325)Andrew Morgan2024-06-182-246/+2
|
* Add `is_encrypted` filtering to Sliding Sync `/sync` (#17281)Eric Eastwood2024-06-171-0/+66
| | | | Based on [MSC3575](https://github.com/matrix-org/matrix-spec-proposals/pull/3575): Sliding Sync
* Add `stream_ordering` sort to Sliding Sync `/sync` (#17293)Eric Eastwood2024-06-173-58/+285
| | | Sort is no longer configurable and we always sort rooms by the `stream_ordering` of the last event in the room or the point where the user can see up to in cases of leave/ban/invite/knock.
* Merge branch 'release-v1.109' into developQuentin Gliech2024-06-171-180/+135
|\
| * Set our own stream position from the current sequence value on startup (#17309)Quentin Gliech2024-06-171-175/+126
| |
| * Automatically apply SQL for inconsistent sequence (#17305)Erik Johnston2024-06-141-5/+9
| | | | | | | | | | | | Rather than forcing the server operator to apply the SQL manually. This should be safe, as there should be only one writer for these sequences.
* | Enable cross-signing key upload without UIA (#17284)Richard van der Hoff2024-06-143-69/+2
| | | | | | | | | | | | Per MSC3967, which is now stable, we should not require UIA when uploading cross-signing keys for the first time. Fixes: #17227
* | Include user membership on events (#17282)Richard van der Hoff2024-06-132-8/+3
| | | | | | | | | | MSC4115 has now completed FCP, so we can enable it by default and switch to the stable identifier.
* | Add `is_dm` filtering to Sliding Sync `/sync` (#17277)Eric Eastwood2024-06-132-1/+256
| | | | | | Based on [MSC3575](https://github.com/matrix-org/matrix-spec-proposals/pull/3575): Sliding Sync
* | Fix `newly_left` rooms not appearing if we returned early (Sliding Sync) ↵Eric Eastwood2024-06-131-1/+1
| | | | | | | | | | | | | | | | | | | | | | (#17301) Fix `newly_left` rooms not appearing if we returned early when `membership_snapshot_token.is_before_or_eq(to_token.room_key)`. Introduced in https://github.com/element-hq/synapse/pull/17187 (part of Sliding Sync) The tests didn't catch it because they had a small typo in it `room_id1` vs `room_id2`. Found while working on https://github.com/element-hq/synapse/pull/17293
* | Add `event.internal_metadata.instance_name` (#17300)Eric Eastwood2024-06-133-3/+11
| | | | | | | | | | | | | | | | | | | | Add `event.internal_metadata.instance_name` (the worker instance that persisted the event) to go alongside the existing `event.internal_metadata.stream_ordering`. `instance_name` is useful to properly compare and query for events with a token since you need to compare both the `stream_ordering` and `instance_name` against the vector clock/`instance_map` in the `RoomStreamToken`. This is pre-requisite work and may be used in https://github.com/element-hq/synapse/pull/17293 Adding `event.internal_metadata.instance_name` was first mentioned in the initial Sliding Sync PR while pairing with @erikjohnston, see https://github.com/element-hq/synapse/pull/17187/commits/09609cb0dbca3a4cfd9fbf90cc962e765ec469c0#diff-5cd773fb307aa754bd3948871ba118b1ef0303f4d72d42a2d21e38242bf4e096R405-R410
* | Fix `get_last_event_in_room_before_stream_ordering(...)` finding the wrong ↵Eric Eastwood2024-06-131-2/+267
| | | | | | | | | | | | | | | | | | | | | | last event (#17295) PR where this was introduced: https://github.com/matrix-org/synapse/pull/14817 ### What does this affect? `get_last_event_in_room_before_stream_ordering(...)` is used in Sync v2 in a lot of different state calculations. `get_last_event_in_room_before_stream_ordering(...)` is also used in `/rooms/{roomId}/members`
* | Bump `mypy` from 1.8.0 to 1.9.0 (#17297)Andrew Morgan2024-06-132-12/+53
| | | | | | | | Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
* | Add report room API (MSC4151) (#17270)Travis Ralston2024-06-122-5/+94
| | | | | | | | | | | | | | | | https://github.com/matrix-org/matrix-spec-proposals/pull/4151 This is intended to be enabled by default for immediate use. When FCP is complete, the unstable endpoint will be dropped and stable endpoint supported instead - no backwards compatibility is expected for the unstable endpoint.
* | Reorganize Pydantic models and types used in handlers (#17279)Eric Eastwood2024-06-101-1/+1
| | | | | | | | | | | | Spawning from https://github.com/element-hq/synapse/pull/17187#discussion_r1619492779 around wanting to put `SlidingSyncBody` (parse the request in the rest layer), `SlidingSyncConfig` (from the rest layer, pass to the handler), `SlidingSyncResponse` (pass the response from the handler back to the rest layer to respond) somewhere that doesn't contaminate the imports and cause circular import issues. - Moved Pydantic parsing models to `synapse/types/rest` - Moved handler types to `synapse/types/handlers`
* | Support MSC3916 by adding a federation `/download` endpoint (#17172)Shay2024-06-072-2/+246
| |
* | Add Sliding Sync `/sync` endpoint (initial implementation) (#17187)Eric Eastwood2024-06-063-2/+1255
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Based on [MSC3575](https://github.com/matrix-org/matrix-spec-proposals/pull/3575): Sliding Sync This iteration only focuses on returning the list of room IDs in the sliding window API (without sorting/filtering). Rooms appear in the Sliding sync response based on: - `invite`, `join`, `knock`, `ban` membership events - Kicks (`leave` membership events where `sender` is different from the `user_id`/`state_key`) - `newly_left` (rooms that were left during the given token range, > `from_token` and <= `to_token`) - In order for bans/kicks to not show up, you need to `/forget` those rooms. This doesn't modify the event itself though and only adds the `forgotten` flag to `room_memberships` in Synapse. There isn't a way to tell when a room was forgotten at the moment so we can't factor it into the from/to range. ### Example request `POST http://localhost:8008/_matrix/client/unstable/org.matrix.msc3575/sync` ```json { "lists": { "foo-list": { "ranges": [ [0, 99] ], "sort": [ "by_notification_level", "by_recency", "by_name" ], "required_state": [ ["m.room.join_rules", ""], ["m.room.history_visibility", ""], ["m.space.child", "*"] ], "timeline_limit": 100 } } } ``` Response: ```json { "next_pos": "s58_224_0_13_10_1_1_16_0_1", "lists": { "foo-list": { "count": 1, "ops": [ { "op": "SYNC", "range": [0, 99], "room_ids": [ "!MmgikIyFzsuvtnbvVG:my.synapse.linux.server" ] } ] } }, "rooms": {}, "extensions": {} } ```
* | Ratelimiting of remote media downloads (#17256)Shay2024-06-051-2/+223
| |
* | Handle hyphens in user dir search porperly (#17254)Erik Johnston2024-06-052-0/+43
| | | | | | c.f. #16675
* | Use fully-qualified `PersistedEventPosition` when returning `RoomsForUser` ↵Eric Eastwood2024-06-041-1/+4
|/ | | | | | | (#17265) Use fully-qualified `PersistedEventPosition` (`instance_name` and `stream_ordering`) when returning `RoomsForUser` to facilitate proper comparisons and `RoomStreamToken` generation. Spawning from https://github.com/element-hq/synapse/pull/17187 where we want to utilize this change
* Fix bug where typing replication breaks (#17252)Erik Johnston2024-05-311-1/+52
| | | | This can happen on restarts of the service, due to old rooms being pruned.
* Fix deduplicating of membership events to not create unused state groups. ↵Erik Johnston2024-05-301-0/+21
| | | | | | | | | | | | | (#17164) We try and deduplicate in two places: 1) really early on, and 2) just before we persist the event. The first case was broken due to it occuring before the profile information was added, and so it thought the event contents were different. The second case did catch it and handle it correctly, however doing so creates a redundant state group leading to bloat. Fixes #3791
* Replaces all usages of `StreamIdGenerator` with `MultiWriterIdGenerator` ↵Erik Johnston2024-05-301-139/+1
| | | | | (#17229) Replaces all usages of `StreamIdGenerator` with `MultiWriterIdGenerator`, which is safer.
* Move towards using `MultiWriterIdGenerator` everywhere (#17226)Erik Johnston2024-05-291-164/+187
| | | | | | | | | | | | | | | There is a problem with `StreamIdGenerator` where it can go backwards over restarts when a stream ID is requested but then not inserted into the DB. This is problematic if we want to land #17215, and is generally a potential cause for all sorts of nastiness. Instead of trying to fix `StreamIdGenerator`, we may as well move to `MultiWriterIdGenerator` that does not suffer from this problem (the latest positions are stored in `stream_positions` table). This involves adding SQLite support to the class. This only changes id generators that were already using `MultiWriterIdGenerator` under postgres, a separate PR will move the rest of the uses of `StreamIdGenerator` over.
* Fix slipped logging context when media rejected (#17239)Erik Johnston2024-05-292-14/+14
| | | | | | | When a module rejects a piece of media we end up trying to close the same logging context twice. Instead of fixing the existing code we refactor to use an async context manager, which is easier to write correctly.
* Support MSC3916 by adding unstable media endpoints to `_matrix/client` (#17213)Shay2024-05-242-81/+1689
| | | | | | | | | | [MSC3916](https://github.com/matrix-org/matrix-spec-proposals/blob/rav/authentication-for-media/proposals/3916-authentication-for-media.md) adds new media endpoints under `_matrix/client`. This PR adds the `/preview_url`, `/config`, and `/thumbnail` endpoints. `/download` will be added in a follow-up PR once the work for the federation `/download` endpoint is complete (see https://github.com/element-hq/synapse/pull/17172). Should be reviewable commit-by-commit.
* Add Sliding Sync `/sync/e2ee` endpoint for To-Device messages (#17167)Eric Eastwood2024-05-233-165/+449
| | | | | | | | | | | This is being introduced as part of Sliding Sync but doesn't have any sliding window component. It's just a way to get E2EE events without having to sit through a big initial sync (`/sync` v2). And we can avoid encryption events being backed up by the main sync response or vice-versa. Part of some Sliding Sync simplification/experimentation. See [this discussion](https://github.com/element-hq/synapse/pull/17167#discussion_r1610495866) for why it may not be as useful as we thought. Based on: - https://github.com/matrix-org/matrix-spec-proposals/pull/3575 - https://github.com/matrix-org/matrix-spec-proposals/pull/3885 - https://github.com/matrix-org/matrix-spec-proposals/pull/3884
* Bring auto-accept invite logic into Synapse (#17147)devonh2024-05-213-0/+665
| | | | | | | | | | | | | | This PR ports the logic from the [synapse_auto_accept_invite](https://github.com/matrix-org/synapse-auto-accept-invite) module into synapse. I went with the naive approach of injecting the "module" next to where third party modules are currently loaded. If there is a better/preferred way to handle this, I'm all ears. It wasn't obvious to me if there was a better location to add this logic that would cleanly apply to all incoming invite events. Relies on https://github.com/element-hq/synapse/pull/17166 to fix linter errors.
* Add a short sleep if the request is rate-limited (#17210)Erik Johnston2024-05-184-4/+10
| | | This helps prevent clients from "tight-looping" retrying their request.
* Removed `request_key` from the `SyncConfig` (moved outside as its own ↵Eric Eastwood2024-05-162-10/+54
| | | | | | | | | function parameter) (#17201) Removed `request_key` from the `SyncConfig` (moved outside as its own function parameter) so it doesn't have to flow into `_generate_sync_entry_for_xxx` methods. This way we can separate the concerns of caching from generating the response and reuse the `_generate_sync_entry_for_xxx` functions as we see fit. Plus caching doesn't really have anything to do with the config of sync. Split from https://github.com/element-hq/synapse/pull/17167 Spawning from https://github.com/element-hq/synapse/pull/17167#discussion_r1601497279
* Fix bug where push rules would be empty in `/sync` (#17142)Erik Johnston2024-05-161-1/+28
| | | | | | Fixes #16987 Some old accounts seem to have an entry in global account data table for push rules, which we should ignore
* Refactor Sync handler to be able to return different sync responses ↵Eric Eastwood2024-05-162-18/+67
| | | | | | | | | | | | | | (`SyncVersion`) (#17200) Refactor Sync handler to be able to be able to return different sync responses (`SyncVersion`). Preparation to be able support sync v2 and a new Sliding Sync `/sync/e2ee` endpoint which returns a subset of sync v2. Split upon request: https://github.com/element-hq/synapse/pull/17167#discussion_r1601497279 Split from https://github.com/element-hq/synapse/pull/17167 where we will add `SyncVersion.E2EE_SYNC` and a new type of sync response.
* An federation whitelist query endpoint extension (#16848)Erik Johnston2024-05-133-0/+143
| | | | | | | | | | This is to allow clients to query the configured federation whitelist. Disabled by default. --------- Co-authored-by: Devon Hudson <devonhudson@librem.one> Co-authored-by: devonh <devon.dmytro@gmail.com> Co-authored-by: Andrew Morgan <1342360+anoadragon453@users.noreply.github.com>
* Optional whitespace support in Authorization (#1350) (#17145)Timshel2024-05-081-0/+7
| | | | Co-authored-by: Andrew Morgan <1342360+anoadragon453@users.noreply.github.com>
* Add optimisation to `StreamChangeCache` (#17130)Erik Johnston2024-05-061-3/+14
| | | | | | | When there have been lots of changes compared with the number of entities, we can do a fast(er) path. Locally I ran some benchmarking, and the comparison seems to give the best determination of which method we use.
* Add support for MSC3823 - Account Suspension (#17051)Shay2024-05-012-4/+67
|
* Apply user `email` & `picture` during OIDC registration if present & ↵devonh2024-04-291-14/+190
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | selected (#17120) This change will apply the `email` & `picture` provided by OIDC to the new user account when registering a new user via OIDC. If the user is directed to the account details form, this change makes sure they have been selected before applying them, otherwise they are omitted. In particular, this change ensures the values are carried through when Synapse has consent configured, and the redirect to the consent form/s are followed. I have tested everything manually. Including: - with/without consent configured - allowing/not allowing the use of email/avatar (via `sso_auth_account_details.html`) - with/without automatic account detail population (by un/commenting the `localpart_template` option in synapse config). ### 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 support for MSC4115 (#17104)Richard van der Hoff2024-04-293-93/+258
| | | | Co-authored-by: Andrew Morgan <1342360+anoadragon453@users.noreply.github.com>
* Ensure that incoming to-device messages are not dropped (#17127)Richard van der Hoff2024-04-292-1/+25
| | | | | | | | | | | | | | | | | | | | ... when workers are unreachable, etc. Fixes https://github.com/element-hq/synapse/issues/17117. The general principle is just to make sure that we propagate any exceptions to the JsonResource, so that we return an error code to the sending server. That means that the sending server no longer considers the message safely sent, so it will retry later. In the issue, Erik mentions that an alternative solution would be to persist the to-device messages into a table so that they can be retried. This might be an improvement for performance, but even if we did that, we still need this mechanism, since we might be unable to reach the database. So, if we want to do that, it can be a later follow-up. --------- Co-authored-by: Erik Johnston <erik@matrix.org>
* Fix filtering of rooms when supplying the `destination` query parameter to ↵Andrew Morgan2024-04-261-3/+64
| | | | `/_synapse/admin/v1/federation/destinations/<destination>/rooms` (#17077)
* Return the search terms as search highlights for SQLite instead of nothing ↵Melvyn Laïly2024-04-261-7/+6
| | | | | | | (#17000) Fixes https://github.com/element-hq/synapse/issues/16999 and https://github.com/element-hq/element-android/pull/8729 by returning the search terms as search highlights.
* Redact membership events if the user requested erasure upon deactivating ↵Till2024-04-251-0/+37
| | | | | (#17076) Fixes #15355 by redacting all membership events before leaving rooms.
* MSC4108 implementation (#17056)Quentin Gliech2024-04-253-2/+411
| | | | | | Co-authored-by: Hugh Nimmo-Smith <hughns@element.io> Co-authored-by: Hugh Nimmo-Smith <hughns@users.noreply.github.com> Co-authored-by: Andrew Morgan <1342360+anoadragon453@users.noreply.github.com>
* Merge branch 'master' into developErik Johnston2024-04-231-31/+73
|\
| * Fix GHSA-3h7q-rfh9-xm4vErik Johnston2024-04-231-31/+73
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Weakness in auth chain indexing allows DoS from remote room members through disk fill and high CPU usage. A remote Matrix user with malicious intent, sharing a room with Synapse instances before 1.104.1, can dispatch specially crafted events to exploit a weakness in how the auth chain cover index is calculated. This can induce high CPU consumption and accumulate excessive data in the database of such instances, resulting in a denial of service. Servers in private federations, or those that do not federate, are not affected.
* | Send an email if the address is already bound to an user account (#16819)mcalinghee2024-04-231-0/+9
| | | | | | | | Co-authored-by: Mathieu Velten <mathieu.velten@beta.gouv.fr> Co-authored-by: Olivier D <odelcroi@gmail.com>
* | Parse json validation (#16923)Gordan Trevis2024-04-182-0/+113
| | | | | | | | Co-authored-by: Andrew Morgan <1342360+anoadragon453@users.noreply.github.com>
* | Support for MSC4108 via delegation (#17086)Quentin Gliech2024-04-171-4/+30
| | | | | | | | | | | | | | This adds support for MSC4108 via delegation, similar to what has been done for MSC3886 --------- Co-authored-by: Hugh Nimmo-Smith <hughns@element.io>
* | Parse Integer negative value validation (#16920)Gordan Trevis2024-04-161-2/+3
| |
* | bugfix: make msc3967 idempotent (#16943)Kegan Dougal2024-04-151-0/+50
|/ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | MSC3967 was updated recently to make it more robust to network failures: > there is an existing cross-signing master key and it exactly matches the cross-signing master key provided in the request body. If there are any additional keys provided in the request (self signing key, user signing key) they MUST also match the existing keys stored on the server. In other words, the request contains no new keys. If there are new keys, UIA MUST be performed. https://github.com/matrix-org/matrix-spec-proposals/blob/hughns/device-signing-upload-uia/proposals/3967-device-signing-upload-uia.md#proposal This covers the case where the 200 OK is lost in transit so the client retries the upload, only to then get UIA'd. Complement tests: https://github.com/matrix-org/complement/pull/713 - passing example https://github.com/element-hq/synapse/actions/runs/7976948122/job/21778795094?pr=16943#step:7:8820 ### 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: reivilibre <oliverw@matrix.org>
* Stabliize support for MSC3981: recurse /relations (#17023)Patrick Cloke2024-04-091-6/+3
| | | | | | | See [MSC3981](https://github.com/matrix-org/matrix-spec-proposals/pull/3981), this pretty much just removes flags though. Part of #17021
* Also check if first event matches the last in prev batch (#17066)Erik Johnston2024-04-091-0/+95
| | | | | Refinement of #17064 cc @richvdh
* Fix bug in calculating state for non-gappy syncs (#16942)Richard van der Hoff2024-04-041-0/+105
| | | | | | | | | Unfortunately, the optimisation we applied here for non-gappy syncs is not actually valid. Fixes https://github.com/element-hq/synapse/issues/16941. ~~Based on https://github.com/element-hq/synapse/pull/16930.~~ Requires https://github.com/matrix-org/sytest/pull/1374.
* `/sync`: fix bug in calculating `state` response (#16930)Richard van der Hoff2024-04-041-0/+80
| | | | | | | Fix a long-standing issue which could cause state to be omitted from the sync response if the last event was filtered out. Fixes: https://github.com/element-hq/synapse/issues/16928
* Fix bug in `/sync` response for archived rooms (#16932)Richard van der Hoff2024-04-042-20/+206
| | | | | | | | | | | | This PR fixes a very, very niche edge-case, but I've got some more work coming which will otherwise make the problem worse. The bug happens when the syncing user leaves a room, and has a sync filter which includes "left" rooms, but sets the timeline limit to 0. In that case, the state returned in the `state` section is calculated incorrectly. The fix is to pass a token corresponding to the point that the user leaves the room through to `compute_state_delta`.
* Do not refuse to set read_marker if previous event_id is in wrong room (#16990)SpiritCroc2024-03-211-4/+4
|
* Fix reject knocks on deactivating account (#17010)Hanadi2024-03-211-2/+85
|
* Patch the db conn pool sooner in tests (#17017)Richard van der Hoff2024-03-211-53/+59
| | | | | | | | | When running unit tests, we patch the database connection pool so that it runs queries "synchronously". This is ok, except that if any queries are launched before we do the patching, those queries get left in limbo and never complete. To fix this, let's change the way we do the switcheroo, by patching out the method which creates the connection pool in the first place.
* Update power level default for public rooms (#16907)Shay2024-03-191-0/+18
|
* Improve event validation (#16908)Shay2024-03-192-2/+153
| | | As the title states.
* Specify IP subnet literals in canonical form (#16953)V024602024-03-191-2/+2
| | | | | This is needed, because the netaddr package removed support for the implicit prefix form in version 1.0.0: https://github.com/netaddr/netaddr/pull/360
* Improve lock performance when a lot of locks are waiting (#16840)Mathieu Velten2024-03-142-1/+64
| | | | | | | | | | | | When a lot of locks are waiting for a single lock, notifying all locks independently with `call_later` on each release is really costly and incurs some kind of async contention, where the CPU is spinning a lot for not much. The included test is taking around 30s before the change, and 0.5s after. It was found following failing tests with https://github.com/element-hq/synapse/pull/16827.
* Bump mypy from 1.5.1 to 1.8.0 (#16901)dependabot[bot]2024-03-131-1/+1
|
* Bump black from 23.10.1 to 24.2.0 (#16936)dependabot[bot]2024-03-138-36/+34
|
* deactivated flag refactored to filter deactivated users. (#16874)Alexander Fechler2024-03-111-3/+53
| | | | Co-authored-by: Andrew Morgan <1342360+anoadragon453@users.noreply.github.com>
* Stabilize support for Retry-After header (MSC4014) (#16947)Patrick Cloke2024-03-082-9/+2
|
* Don't invalidate the entire event cache when we purge history (#16905)Erik Johnston2024-02-131-0/+31
| | | | | We do this by adding support to the LRU cache for "extra indices" based on the cached value. This allows us to efficiently map from room ID to the cached events and only invalidate those.
* Correctly mention previous copyright (#16820)Erik Johnston2024-01-23242-0/+258
| | | | | During the migration the automated script to update the copyright headers accidentally got rid of some of the existing copyright lines. Reinstate them.
* Allow room creation but not publishing to continue if room publication rules ↵Shay2024-01-222-30/+58
| | | | | | | | | | | | | are violated when creating a new room. (#16811) Prior to this PR, if a request to create a public (public as in published to the rooms directory) room violated the room list publication rules set in the [config](https://matrix-org.github.io/synapse/latest/usage/configuration/config_documentation.html#room_list_publication_rules), the request to create the room was denied and the room was not created. This PR changes the behavior such that when a request to create a room published to the directory violates room list publication rules, the room is still created but the room is not published to the directory.
* Handle wildcard type filters properly (#14984)Mo Balaa2024-01-222-1/+29
|
* Filter out rooms from the room directory being served to other homeservers ↵reivilibre2024-01-081-0/+88
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | when those rooms block that homeserver by their Access Control Lists. (#16759) The idea here being that the directory server shouldn't advertise rooms to a requesting server is the requesting server would not be allowed to join or participate in the room. <!-- Fixes: # <!-- --> <!-- Supersedes: # <!-- --> <!-- Follows: # <!-- --> <!-- Part of: # <!-- --> Base: `develop` <!-- git-stack-base-branch:develop --> <!-- This pull request is commit-by-commit review friendly. <!-- --> <!-- This pull request is intended for commit-by-commit review. <!-- --> Original commit schedule, with full messages: <ol> <li> Pass `from_federation_origin` down into room list retrieval code </li> <li> Don't cache /publicRooms response for inbound federated requests </li> <li> fixup! Don't cache /publicRooms response for inbound federated requests </li> <li> Cap the number of /publicRooms entries to 100 </li> <li> Simplify code now that you can't request unlimited rooms </li> <li> Filter out rooms from federated requests that don't have the correct ACL </li> <li> Request a handful more when filtering ACLs so that we can try to avoid shortchanging the requester </li> </ol> --------- Signed-off-by: Olivier Wilkinson (reivilibre) <oliverw@matrix.org>
* Port `EventInternalMetadata` class to Rust (#16782)Erik Johnston2024-01-083-5/+7
| | | | | | | | | | | | | There are a couple of things we need to be careful of here: 1. The current python code does no validation when loading from the DB, so we need to be careful to ignore such errors (at least on jki.re there are some old events with internal metadata fields of the wrong type). 2. We want to be memory efficient, as we often have many hundreds of thousands of events in the cache at a time. --------- Co-authored-by: Quentin Gliech <quenting@element.io>
* Search non ASCII display names using Admin API (#16767)Adam Jędrzejewski2024-01-041-0/+23
| | | | | Closes #16370 Signed-off-by: Adam Jedrzejewski <adamjedrzejewski@icloud.com>
* Fix email verification redirection (#16761)FadhlanR2024-01-021-3/+40
| | | | | | Previously, the response status of `HTMLResource` was hardcoded as `200`. However, for proper redirection after the user verifies their email, we require the status to be `302`. This PR addresses that issue by using `code` as response status.
* Enable user without password (#16770)Dirk Klimpel2024-01-021-8/+23
| | | | | | | | | | | Closes: - https://github.com/matrix-org/synapse/issues/10397 - #10397 An administrator should know whether he wants to set a password or not. There are many uses cases where a blank password is required. - Use of only some users with SSO. - Use of bots with password, users with SSO
* Merge remote-tracking branch 'gitlab/clokep/license-license' into new_developErik Johnston2023-12-13293-2971/+4689
|\
| * Update license headersPatrick Cloke2023-11-21293-2971/+4689
| |
* | Add avatar and topic settings for server notice room (#16679)Mathieu Velten2023-12-121-0/+109
| |
* | Expose OIDC discovery information under the CSAPI (#16726)David Robertson2023-12-061-0/+59
| | | | | | | | Co-authored-by: Quentin Gliech <quenting@element.io>
* | Revert postgres logical replication deltaas v1.98.0rc1David Robertson2023-12-051-84/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | This reverts two commits: 0bb8e418a41c6f583ca9d705b400e37e2308a534 "Fix postgres schema after dropping old tables (#16730)" and 51e4e35653f98c3f61222fbdbdb1dcb8864f7fca "Add a Postgres `REPLICA IDENTITY` to tables that do not have an implicit one. This should allow use of Postgres logical replication. (take 2, now with no added deadlocks!) (#16658)" and also amends the changelog.
* | Fix upgrading a room without `events` field in power levels (#16725)David Robertson2023-12-051-0/+28
| |
* | Add a Postgres `REPLICA IDENTITY` to tables that do not have an implicit ↵reivilibre2023-12-041-1/+84
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | one. This should allow use of Postgres logical replication. (take 2, now with no added deadlocks!) (#16658) * Add `ALTER TABLE ... REPLICA IDENTITY ...` for individual tables We can't combine them into one file as it makes it likely to hit a deadlock if Synapse is running, as it only takes one other transaction to access two tables in a different order to the schema delta. * Add notes * Newsfile Signed-off-by: Olivier Wilkinson (reivilibre) <oliverw@matrix.org> * Re-introduce REPLICA IDENTITY test --------- Signed-off-by: Olivier Wilkinson (reivilibre) <oliverw@matrix.org>
* | Server notices: add an autojoin setting for the notices room (#16699)Mathieu Velten2023-12-041-0/+27
| | | | | | | | Co-authored-by: Patrick Cloke <clokep@users.noreply.github.com>
* | Implement MSC4069: Inhibit profile propagation (#16636)Travis Ralston2023-12-041-0/+160
| | | | | | MSC: https://github.com/matrix-org/matrix-spec-proposals/pull/4069
* | Request & follow redirects for /media/v3/download (#16701)Patrick Cloke2023-11-292-5/+59
| | | | | | | | | | | | Implement MSC3860 to follow redirects for federated media downloads. Note that the Client-Server API doesn't support this (yet) since the media repository in Synapse doesn't have a way of supporting redirects.
* | Move media retention tests out of rest tests (#16684)David Robertson2023-11-271-0/+0
| | | | | | | | | | | | | | | | * Move media retention tests out of rest tests AFAICS this doesn't make any HTTP requests and so it ought not to belong in `tests.rest`. * Changelog
* | Keep track of `user_ips` and `monthly_active_users` when delegating auth ↵David Robertson2023-11-236-44/+126
|/ | | | | | | | | | | | | (#16672) * Describe `insert_client_ip` * Pull out client_ips and MAU tracking to BaseAuth * Define HAS_AUTHLIB once in tests sick of copypasting * Track ips and token usage when delegating auth * Test that we track MAU and user_ips * Don't track `__oidc_admin`
* Revert "Add a Postgres `REPLICA IDENTITY` to tables that do not have an ↵Erik Johnston2023-11-161-84/+1
| | | | | implicit one. This should allow use of Postgres logical replication. (#16456)" (#16651) This reverts commit 69afe3f7a0d89f3422ddbd3aa16bc9bbc01056eb.
* Speed up persisting large number of outliers (#16649)Erik Johnston2023-11-161-1/+75
| | | Recalculating the roots tuple every iteration could be very expensive, so instead let's do a topological sort.
* Fix sending out of order `POSITION` over replication (#16639)Erik Johnston2023-11-161-0/+8
| | | | | If a worker reconnects to Redis we send out the current positions of all our streams. However, if we're also trying to send out a backlog of RDATA at the same time then we can end up sending a `POSITION` with the current token *before* we've sent all the RDATA before the current token. This doesn't cause actual bugs as the receiving servers see the POSITION, fetch the relevant rows from the DB, and then ignore the old RDATA as they come in. However, this is inefficient so it'd be better if we didn't send out-of-order positions
* Fix test not detecting tables with missing primary keys and missing replica ↵reivilibre2023-11-161-3/+4
| | | | | | | | | | | | | | | identities, then add more replica identities. (#16647) * Fix the CI query that did not detect all cases of missing primary keys * Add more missing REPLICA IDENTITY entries * Newsfile Signed-off-by: Olivier Wilkinson (reivilibre) <oliverw@matrix.org> --------- Signed-off-by: Olivier Wilkinson (reivilibre) <oliverw@matrix.org>
* Add an Admin API to temporarily grant the ability to update an existing ↵David Robertson2023-11-154-2/+410
| | | | cross-signing key without UIA (#16634)
* Asynchronous Uploads (#15503)Sumner Evans2023-11-151-1/+3
| | | Support asynchronous uploads as defined in MSC2246.
* Use full GitHub links instead of bare issue numbers. (#16637)Patrick Cloke2023-11-1515-29/+38
|
* Add a Postgres `REPLICA IDENTITY` to tables that do not have an implicit ↵reivilibre2023-11-131-1/+83
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | one. This should allow use of Postgres logical replication. (#16456) * Add Postgres replica identities to tables that don't have an implicit one Fixes #16224 * Newsfile Signed-off-by: Olivier Wilkinson (reivilibre) <oliverw@matrix.org> * Move the delta to version 83 as we missed the boat for 82 * Add a test that all tables have a REPLICA IDENTITY * Extend the test to include when indices are deleted * isort * black * Fully qualify `oid` as it is a 'hidden attribute' in Postgres 11 * Update tests/storage/test_database.py Co-authored-by: Patrick Cloke <clokep@users.noreply.github.com> * Add missed tables --------- Signed-off-by: Olivier Wilkinson (reivilibre) <oliverw@matrix.org> Co-authored-by: Patrick Cloke <clokep@users.noreply.github.com>
* Use attempt_to_set_autocommit everywhere. (#16615)Patrick Cloke2023-11-091-10/+5
| | | To avoid asserting the type of the database connection.
* Use dbname instead of database for Postgres config. (#16618)Patrick Cloke2023-11-092-4/+4
|
* Convert simple_select_one_txn and simple_select_one to return tuples. (#16612)Patrick Cloke2023-11-097-26/+21
|
* Return attrs for more media repo APIs. (#16611)Patrick Cloke2023-11-093-19/+19
|
* Bulk-invalidate e2e cached queries after claiming keys (#16613)David Robertson2023-11-091-0/+117
| | | | Co-authored-by: Patrick Cloke <patrickc@matrix.org>
* Avoid updating the same rows multiple times with simple_update_many_txn. ↵Patrick Cloke2023-11-071-2/+2
| | | | | | (#16609) simple_update_many_txn had a bug in it which would cause each update to be applied twice.
* Avoid executing no-op queries. (#16583)Patrick Cloke2023-11-071-20/+5
| | | | | | If simple_{insert,upsert,update}_many_txn is called without any data to modify then return instead of executing the query. This matches the behavior of simple_{select,delete}_many_txn.
* More tests for the simple_* methods. (#16596)Patrick Cloke2023-11-071-18/+628
| | | | Expand tests for the simple_* database methods, additionally test against both PostgreSQL and SQLite variants.
* Bump twisted from 23.8.0 to 23.10.0 (#16588)dependabot[bot]2023-11-012-2/+2
|
* Remove remaining usage of cursor_to_dict. (#16564)Patrick Cloke2023-10-313-21/+16
|
* Claim local one-time-keys in bulk (#16565)David Robertson2023-10-301-0/+158
| | | | Co-authored-by: Patrick Cloke <clokep@users.noreply.github.com>
* Claim fallback keys in bulk (#16570)David Robertson2023-10-301-0/+77
|
* Ensure local invited & knocking users leave before purge. (#16559)Patrick Cloke2023-10-271-1/+52
| | | | | This is mostly useful for federated rooms where some users would get stuck in the invite or knock state when the room was purged from their homeserver.
* Add new module API for adding custom fields to events `unsigned` section ↵Erik Johnston2023-10-272-1/+60
| | | | (#16549)
* Remove more usages of cursor_to_dict. (#16551)Patrick Cloke2023-10-264-11/+10
| | | Mostly to improve type safety.
* Add a new module API to update user presence state. (#16544)Patrick Cloke2023-10-262-11/+119
| | | | | | | | | | This adds a module API which allows a module to update a user's presence state/status message. This is useful for controlling presence from an external system. To fully control presence from the module the presence.enabled config parameter gains a new state of "untracked" which disables internal tracking of presence changes via user actions, etc. Only updates from the module will be persisted and sent down sync properly).
* Convert simple_select_list and simple_select_list_txn to return lists of ↵Patrick Cloke2023-10-269-240/+262
| | | | | tuples (#16505) This should use fewer allocations and improves type hints.
* Allow multiple workers to write to receipts stream. (#16432)Erik Johnston2023-10-252-4/+256
| | | Fixes #16417
* Fix tests on Twisted trunk. (#16528)Patrick Cloke2023-10-255-111/+94
| | | | | | | | | | | | | Twisted trunk makes a change to the `TLSMemoryBIOFactory` where the underlying protocol is changed from `TLSMemoryBIOProtocol` to `BufferingTLSTransport` to improve performance of TLS code (see https://github.com/twisted/twisted/issues/11989). In order to properly hook this code up in tests we need to pass the test reactor's clock into `TLSMemoryBIOFactory` to avoid the global (trial) reactor being used by default. Twisted does something similar internally for tests: https://github.com/twisted/twisted/blob/157cd8e659705940e895d321339d467e76ae9d0a/src/twisted/web/test/test_agent.py#L871-L874
* Fix http/s proxy authentication with long username/passwords (#16504)Richard Brežák2023-10-241-0/+21
|
* Revert "Add test case to detect dodgy b64 encoding"David Robertson2023-10-241-14/+0
| | | | | | | | | This reverts commit 5fe76b9434e22bb752c252dd9c66c3c2bfb90dfc. I think I had this accidentally commited on my local develop branch, and so it accidentally got merged into upstream develop. This should re-land with corrections in #16504.
* Merge branch 'develop' of github.com:matrix-org/synapse into developDavid Robertson2023-10-245-15/+129
|\
| * Fix type hint errors from Twisted trunk (#16526)Patrick Cloke2023-10-234-3/+5
| |
| * Fix bug where a new writer advances their token too quickly (#16473)Erik Johnston2023-10-231-12/+124
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * Fix bug where a new writer advances their token too quickly When starting a new writer (for e.g. persisting events), the `MultiWriterIdGenerator` doesn't have a minimum token for it as there are no rows matching that new writer in the DB. This results in the the first stream ID it acquired being announced as persisted *before* it actually finishes persisting, if another writer gets and persists a subsequent stream ID. This is due to the logic of setting the minimum persisted position to the minimum known position of across all writers, and the new writer starts off not being considered. * Fix sending out POSITIONs when our token advances without update Broke in #14820 * For replication HTTP requests, only wait for minimal position
* | Add test case to detect dodgy b64 encodingDavid Robertson2023-10-231-0/+14
|/
* Avoid sending massive replication updates when purging a room. (#16510)Patrick Cloke2023-10-181-29/+62
|
* Convert DeviceLastConnectionInfo to attrs. (#16507)Patrick Cloke2023-10-171-67/+70
| | | To improve type safety & memory usage.
* Fix a bug where servers could be marked as up when they were failing (#16506)Patrick Cloke2023-10-171-0/+75
| | | | After this change a server will only be reported as back online if they were previously having requests fail.
* Convert state delta processing from a dict to attrs. (#16469)Patrick Cloke2023-10-161-1/+1
| | | For improved type checking & memory usage.
* Convert user_get_threepids response to attrs. (#16468)Patrick Cloke2023-10-111-4/+4
| | | This improves type annotations by not having a dictionary of Any values.
* Convert simple_select_many_batch, simple_select_many_txn to tuples. (#16444)Patrick Cloke2023-10-111-26/+38
|
* Handle content types with parameters. (#16440)Patrick Cloke2023-10-111-1/+18
|
* Apply join rate limiter outside the lineariser (#16441)David Robertson2023-10-061-0/+24
|
* Return ThumbnailInfo in more places (#16438)Patrick Cloke2023-10-061-18/+18
| | | | Improves type hints by using concrete types instead of dictionaries.
* Stop sending incorrect knock_state_events. (#16403)Patrick Cloke2023-10-061-1/+1
| | | | | | | | | Synapse was incorrectly implemented with a knock_state_events property on some APIs (instead of knock_room_state). This was correct in Synapse 1.70.0, but *both* fields were sent to also be compatible with Synapse versions expecting the wrong field. Enough time has passed that only the correct field needs to be included/handled.
* Register media servlets via regex. (#16419)Patrick Cloke2023-10-0610-219/+193
| | | | | This converts the media servlet URLs in the same way as (most) of the rest of Synapse. This will give more flexibility in the versions each endpoint exists under.
* Factor out `MultiWriter` token from `RoomStreamToken` (#16427)Erik Johnston2023-10-051-4/+4
|
* Some refactors around receipts stream (#16426)Erik Johnston2023-10-042-11/+23
|
* Remove Python version from `/_synapse/admin/v1/server_version` (#16380)MomentQYC2023-10-021-3/+1
| | | | There's no reason to expose the full Python version over what is frequently a public API.
* Support rendering some media downloads as inline (#15988)Will Hunt2023-09-292-4/+65
| | | | | Use an `inline` Content-Disposition header when the media is "safe" to display inline (some known text, image, video, audio formats).
* Improve state types. (#16395)Patrick Cloke2023-09-281-5/+8
|
* Add a cache around server ACL checking (#16360)Patrick Cloke2023-09-261-13/+22
| | | | | * Pre-compiles the server ACLs onto an object per room and invalidates them when new events come in. * Converts the server ACL checking into Rust.
* Add support for pydantic v2 via pydantic.v1 compat module (#16332)Maxwell G2023-09-251-1/+7
| | | While maintaining support with pydantic v1.
* Convert more cached return values to immutable types (#16356)Patrick Cloke2023-09-201-16/+19
|
* Stop patching EventBase.__eq__ in tests. (#16349)Patrick Cloke2023-09-182-36/+30
| | | | It is clearer to directly test equality instead of doing indirect assertions via patching __eq__.
* Filter locked users in the admin API (#16328)Hanadi2023-09-181-0/+26
| | | | Co-authored-by: Hanadi Tamimi <hanadi.tamimi@sdui.de>
* Return an immutable value from get_latest_event_ids_in_room. (#16326)Patrick Cloke2023-09-186-25/+33
|
* Additional validation of receipts (#16327)Patrick Cloke2023-09-182-161/+214
| | | | Reject invalid receipts with a reasonable error message & expands tests for receipts.
* Add automatic purge after all users forget a room (#15488)Mathieu Velten2023-09-153-23/+162
| | | | | | Also add restore of purge/shutdown rooms after a synapse restart. Co-authored-by: Eric Eastwood <erice@matrix.org> Co-authored-by: Erik Johnston <erikj@matrix.org>
* Refactor `get_user_by_id` (#16316)Erik Johnston2023-09-142-27/+33
|
* Fix using dehydrated devices (MSC2697) & refresh tokens (#16288)Hanadi2023-09-131-1/+9
| | | | | Refresh tokens were not correctly moved to the rehydrated device (similar to how the access token is currently handled). This resulted in invalid refresh tokens after rehydration.
* Refactor storing of server keys (#16261)Erik Johnston2023-09-123-190/+26
|
* Add the List-Unsubscribe header for notification emails. (#16274)Patrick Cloke2023-09-111-0/+55
| | | | | | | | Adds both the List-Unsubscribe (RFC2369) and List-Unsubscribe-Post (RFC8058) headers to push notification emails, which together should: * Show an "Unsubscribe" link in the MUA UI when viewing Synapse notification emails. * Enable "one-click" unsubscribe (the user never leaves their MUA, which automatically makes a POST request to the specified endpoint).
* Update ruff config (#16283)Patrick Cloke2023-09-0816-38/+38
| | | Enable additional checks & clean-up unneeded configuration.