summary refs log tree commit diff
path: root/synapse (follow)
Commit message (Collapse)AuthorAgeFilesLines
* Merge branch 'erikj/ss_unread_counts' into erikj/ss_hacks erikj/ss_hacksErik Johnston2024-08-091-5/+8
|\
| * SS: Hook up notification countsErik Johnston2024-08-091-5/+8
| |
* | Merge remote-tracking branch 'origin/develop' into erikj/ss_hacksErik Johnston2024-08-095-70/+131
|\ \
| * | Start handlers for new media endpoints when media resource configured (#17483)devonh2024-08-085-70/+131
| |/ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This is in response to issue #17473. Not all the necessary handlers to deal with media requests are started now when configuring synapse to use a media worker as per the [example config](https://element-hq.github.io/synapse/latest/workers.html#synapseappmedia_repository). The new media endpoints introduced with authenticated media fall under the `client` & `federation` handlers in synapse. This PR starts up handlers for the new media endpoints if a worker has been configured with only the `media` resource type. ### 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>
* | Merge remote-tracking branch 'origin/develop' into erikj/ss_hacksErik Johnston2024-08-0810-434/+736
|\|
| * SSS: Implement PREVIOUSLY room tracking (#17535)Erik Johnston2024-08-081-16/+52
| | | | | | | | | | | | Implement tracking of rooms that have had updates that have not been sent down to clients. Simplified Sliding Sync (SSS)
| * Sliding Sync: Use `stream_ordering` based timeline pagination for ↵Eric Eastwood2024-08-076-123/+305
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | incremental sync (#17510) Use `stream_ordering` based `timeline` pagination for incremental `/sync` in Sliding Sync. Previously, we were always using a `topological_ordering` but we should only be using that for historical scenarios (initial `/sync`, newly joined, or haven't sent the room down the connection before). This is slightly different than what the [spec suggests](https://spec.matrix.org/v1.10/client-server-api/#syncing) > Events are ordered in this API according to the arrival time of the event on the homeserver. This can conflict with other APIs which order events based on their partial ordering in the event graph. This can result in duplicate events being received (once per distinct API called). Clients SHOULD de-duplicate events based on the event ID when this happens. But we've had a [discussion below in this PR](https://github.com/element-hq/synapse/pull/17510#discussion_r1699105569) and this matches what Sync v2 already does and seems like it makes sense. Created a spec issue https://github.com/matrix-org/matrix-spec/issues/1917 to clarify this. Related issues: - https://github.com/matrix-org/matrix-spec/issues/1917 - https://github.com/matrix-org/matrix-spec/issues/852 - https://github.com/matrix-org/matrix-spec-proposals/pull/4033
| * Fixup sliding sync comment (#17531)Erik Johnston2024-08-071-1/+1
| | | | | | | | c.f. https://github.com/element-hq/synapse/pull/17529#discussion_r1705780925
| * Sliding Sync: Add more tracing (#17514)Eric Eastwood2024-08-065-240/+345
| | | | | | | | | | | | | | | | | | | | | | | | Spawning from looking at a couple traces and wanting a little more info. Follow-up to github.com/element-hq/synapse/pull/17501 The changes in this PR allow you to find slow Sliding Sync traces ignoring the `wait_for_events` time. In Jaeger, you can now filter for the `current_sync_for_user` operation with `RESULT.result=true` indicating that it actually returned non-empty results. If you want to find traces for your own user, you can use `RESULT.result=true ARG.sync_config.user="@madlittlemods:matrix.org"`
| * SS: Reset connection if token is unrecognized (#17529)Erik Johnston2024-08-062-0/+45
| | | | | | | | | | | | | | | | | | | | | | | | | | | | This triggers the client to start a new sliding sync connection. If we don't do this and the client asks for the full range of rooms, we end up sending down all rooms and their state from scratch (which can be very slow) This causes things like https://github.com/element-hq/element-x-ios/issues/3115 after we restart the server --------- Co-authored-by: Eric Eastwood <eric.eastwood@beta.gouv.fr>
* | Update log lineErik Johnston2024-08-051-1/+1
| |
* | Log what we send downErik Johnston2024-08-051-0/+11
| |
* | Don't send down list opsErik Johnston2024-08-051-1/+1
| |
* | Merge remote-tracking branch 'origin/develop' into erikj/ss_hacksErik Johnston2024-08-056-6/+140
|\|
| * Sliding Sync: Add typing notification extension (MSC3961) (#17505)Eric Eastwood2024-07-316-4/+138
| | | | | | | | | | | | | | [MSC3961](https://github.com/matrix-org/matrix-spec-proposals/pull/3961): Sliding Sync Extension: Typing Notifications Based on [MSC3575](https://github.com/matrix-org/matrix-spec-proposals/pull/3575): Sliding Sync
| * Sliding Sync: Fix `limited` response description (make accurate) (#17507)Eric Eastwood2024-07-311-2/+2
| |
* | Merge remote-tracking branch 'origin/develop' into erikj/ss_hacksErik Johnston2024-07-3112-90/+666
|\|
| * Sliding Sync: Update filters to be robust against remote invite rooms (#17450)Eric Eastwood2024-07-308-75/+611
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Update `filters.is_encrypted` and `filters.types`/`filters.not_types` to be robust when dealing with remote invite rooms in Sliding Sync. Part of [MSC3575](https://github.com/matrix-org/matrix-spec-proposals/pull/3575): Sliding Sync Follow-up to https://github.com/element-hq/synapse/pull/17434 We now take into account current state, fallback to stripped state for invite/knock rooms, then historical state. If we can't determine the info needed to filter a room (either from state or stripped state), it is filtered out.
| * Sliding Sync: Add receipts extension (MSC3960) (#17489)Eric Eastwood2024-07-305-63/+253
| | | | | | | | | | | | | | [MSC3960](https://github.com/matrix-org/matrix-spec-proposals/pull/3960): Receipts extension Based on [MSC3575](https://github.com/matrix-org/matrix-spec-proposals/pull/3575): Sliding Sync
| * Merge branch 'master' into developOlivier 'reivilibre2024-07-303-4/+14
| |\
| | * Upgrade locked dependency on Twisted to 24.7.0rc1. (#17502)reivilibre2024-07-303-4/+14
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | I also update the tests and HTTP Proxy code to fix it for this new Twisted release. Pulls in fix for https://github.com/twisted/twisted/security/advisories/GHSA-c8m8-j448-xjx7 Signed-off-by: Olivier 'reivilibre <oliverw@matrix.org>
* | | Merge branch 'erikj/ss_room_sub_timeline' into erikj/ss_hacksErik Johnston2024-07-301-22/+55
|\ \ \
| * | | Handle increases in timeline limitErik Johnston2024-07-301-2/+30
| | | |
| * | | Remember previous timeline limitErik Johnston2024-07-301-9/+18
| | | |
| * | | Only mark as updated if entry has changedErik Johnston2024-07-301-1/+3
| | | |
| * | | Add fast path if from_token is NoneErik Johnston2024-07-301-8/+11
| | | |
| * | | Refactor to make LIVE non-static valueErik Johnston2024-07-301-2/+5
| |/ /
* | | Merge remote-tracking branch 'origin/develop' into erikj/ss_hacksErik Johnston2024-07-305-46/+99
|\| |
| * | Add some more opentracing to sliding sync (#17501)Erik Johnston2024-07-302-5/+33
| | | | | | | | | This will make it easier to see what it is doing in jaeger.
| * | Fix `failures` property in `/keys/query` (#17499)Richard van der Hoff2024-07-301-8/+18
| | | | | | | | | | | | 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-303-3/+75
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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-296-40/+362
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* | | Don't set the initial flagErik Johnston2024-07-301-7/+8
| | |
* | | Trace stuffErik Johnston2024-07-291-0/+4
| | |
* | | Merge remote-tracking branch ↵Erik Johnston2024-07-295-57/+216
|\ \ \ | | | | | | | | | | | | 'origin/madlittlemods/sliding-sync-receipts-extension' into erikj/ss_hacks
| * | | Add testsEric Eastwood2024-07-251-1/+1
| | | |
| * | | Remove tests that aren't necessaryEric Eastwood2024-07-251-1/+0
| | | |
| * | | Generalize extension testEric Eastwood2024-07-252-1/+7
| | | |
| * | | Iterate moreEric Eastwood2024-07-254-21/+53
| | | |
| * | | Better standardize `find_relevant_room_ids_for_extension(...)`Eric Eastwood2024-07-243-54/+175
| |/ /
* | | TestErik Johnston2024-07-281-9/+24
| | |
* | | Revert room subsErik Johnston2024-07-281-8/+1
| | |
* | | fixupErik Johnston2024-07-281-1/+4
| | |
* | | UpdatesErik Johnston2024-07-282-3/+3
| | |
* | | Always initial on room subsErik Johnston2024-07-281-1/+5
| | |
* | | TagErik Johnston2024-07-261-1/+7
| | |
* | | log responseErik Johnston2024-07-261-0/+1
| | |
* | | LINTErik Johnston2024-07-261-0/+1
| | |
* | | REVERTErik Johnston2024-07-261-24/+0
| | |
* | | REVERTErik Johnston2024-07-261-2/+2
| | |
* | | REVERTErik Johnston2024-07-262-8/+9
| | |
* | | REVERTErik Johnston2024-07-262-26/+0
| | |
* | | Merge branch 'erikj/ss_noop_rooms' into erikj/ss_hacksErik Johnston2024-07-264-19/+257
|\ \ \
| * \ \ Merge remote-tracking branch 'origin/erikj/ss_room_store' into ↵Erik Johnston2024-07-264-8/+211
| |\ \ \ | | | | | | | | | | | | | | | erikj/ss_noop_rooms
| | * | | Review commentsErik Johnston2024-07-261-0/+3
| | | | |
| | * | | Merge remote-tracking branch 'origin/develop' into erikj/ss_room_storeErik Johnston2024-07-254-4/+203
| | |\| |
| | | * | Sliding Sync: Add Account Data extension (MSC3959) (#17477)Eric Eastwood2024-07-244-2/+195
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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-2/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
| | * | | Update commentsErik Johnston2024-07-252-4/+5
| | | | |
| * | | | Don't send down rooms if nothing has happenedErik Johnston2024-07-261-1/+1
| | | | |
| * | | | Make it clear we only filter out rooms in incremental syncErik Johnston2024-07-261-2/+2
| | | | |
| * | | | Review commentsErik Johnston2024-07-261-1/+3
| | | | |
| * | | | Only send rooms with updates down sliding syncErik Johnston2024-07-242-1/+36
| |/ / /
* | | | REVERTErik Johnston2024-07-265-5/+5
| | | |
* | | | FIXUPErik Johnston2024-07-261-2/+5
| | | |
* | | | Also log json requestErik Johnston2024-07-261-0/+2
| | | |
* | | | Merge branch 'erikj/ss_room_store' into erikj/ss_hacksErik Johnston2024-07-2415-135/+395
|\| | |
| * | | Merge remote-tracking branch 'origin/develop' into erikj/ss_room_storeErik Johnston2024-07-241-5/+5
| |\| |
| | * | Use a new token format for sliding sync (#17452)Erik Johnston2024-07-244-17/+75
| | | | | | | | | | | | | | | | | | | | | | | | | | | | 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-2327-104/+606
| |\ \ \
| | * | | Change token names againErik Johnston2024-07-232-12/+14
| | | | |
| | * | | Merge remote-tracking branch 'origin/develop' into erikj/ss_tokensErik Johnston2024-07-2327-88/+588
| | |\| |
| | | * | Speed up SS room sorting (#17468)Erik Johnston2024-07-234-27/+156
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | We do this by bulk fetching the latest stream ordering. --------- Co-authored-by: Andrew Morgan <1342360+anoadragon453@users.noreply.github.com>
| | | * | Reduce volume of 'Waiting for current token' logs, which were introduced in ↵reivilibre2024-07-232-5/+31
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | v1.109.0. (#17428) Introduced in: #17215 This caused us a minor bit of grief as the volume of logs produced was much higher than normal --------- Signed-off-by: Olivier 'reivilibre <oliverw@matrix.org>
| | | * | Fixed presence results not returning offline users on initial sync (#17231)Michael Hollister2024-07-232-1/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This is to address an issue in which `m.presence` results on initial sync are not returning entries of users who are currently offline. The original behaviour was from https://github.com/element-hq/synapse/issues/1535 This change is useful for applications that use the presence system for tracking user profile information/updates (e.g. https://github.com/element-hq/synapse/pull/16992 or for profile status messages). This is gated behind a new configuration option to avoid performance impact for applications that don't need this, as a pragmatic solution for now.
| | | * | Sliding Sync: Add E2EE extension (MSC3884) (#17454)Eric Eastwood2024-07-227-30/+201
| | | | | | | | | | | | | | | | | | | | | | | | | 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-1/+5
| | | | | | | | | | | | | | | `$ME` can be used as a substitute for the requester's user ID.
| | | * | Speed up room keys query by using read/write lock (#17461)Erik Johnston2024-07-221-9/+9
| | | | | | | | | | | | | | | | | | | | Linaerizing all access slows things down when devices try and fetch lots of keys on login
| * | | | Ensure there is only one SlidingSyncHandlerErik Johnston2024-07-231-0/+1
| | | | |
| * | | | Apply suggestions from code reviewErik Johnston2024-07-231-3/+4
| | | | | | | | | | | | | | | Co-authored-by: Eric Eastwood <eric.eastwood@beta.gouv.fr>
| * | | | Merge branch 'erikj/ss_tokens' into erikj/ss_room_storeErik Johnston2024-07-192-20/+32
| |\| | |
| | * | | Merge remote-tracking branch 'origin/develop' into erikj/ss_tokensErik Johnston2024-07-193-14/+58
| | |\ \ \
| | * | | | Remove '_token' prefixErik Johnston2024-07-182-15/+13
| | | | | |
| | * | | | Add docstringErik Johnston2024-07-181-0/+6
| | | | | |
| * | | | | Merge remote-tracking branch 'origin/develop' into erikj/ss_room_storeErik Johnston2024-07-183-12/+48
| |\ \ \ \ \
| * | | | | | Refactor to avoid SyncConfig.connection_id()Erik Johnston2024-07-182-47/+48
| | | | | | |
| * | | | | | Add context to conn_idErik Johnston2024-07-181-0/+5
| | | | | | |
| * | | | | | Rename boundsErik Johnston2024-07-181-10/+12
| | | | | | |
| * | | | | | Keyword argsErik Johnston2024-07-181-1/+3
| | | | | | |
| * | | | | | Reword docErik Johnston2024-07-182-4/+3
| | | | | | |
| * | | | | | Apply suggestions from code reviewErik Johnston2024-07-182-8/+9
| | | | | | | | | | | | | | | | | | | | | Co-authored-by: Eric Eastwood <eric.eastwood@beta.gouv.fr>
* | | | | | | Merge branch 'erikj/ss_faster_sort' into erikj/ss_hacksErik Johnston2024-07-2216-53/+326
|\ \ \ \ \ \ \
| * | | | | | | WIP faster sortErik Johnston2024-07-222-17/+106
| | |_|_|_|/ / | |/| | | | |
| * | | | | | Prepare for authenticated media freeze (#17433)Shay2024-07-229-12/+140
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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-194-4/+36
| | |_|_|/ / | |/| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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)
| * | | | | Generate room sync data concurrently (#17458)Erik Johnston2024-07-191-2/+10
| | |/ / / | |/| | | | | | | | This is also what we do for standard `/sync`.
| * | | | Improve default_power_level_content_override documentation (#17451)Ben Banfield-Zanin2024-07-181-0/+2
| | | | | | | | | | | | | | | | | | | | Co-authored-by: Andrew Morgan <1342360+anoadragon453@users.noreply.github.com>
| * | | | Add `m.room.create` to default bump event types (#17453)Eric Eastwood2024-07-181-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Add `m.room.create` to default bump event types This probably helps when no messages have been sent in the room and it was just created.
| * | | | Order `heroes` by `stream_ordering` (as spec'ed) (#17435)Eric Eastwood2024-07-171-12/+45
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* | | | | Remove fiddlingErik Johnston2024-07-221-2/+2
| | | | |
* | | | | Room keysgit checkout erikj/ss_hacksErik Johnston2024-07-191-9/+9
| | | | |
* | | | | Revert "Remove lists"Erik Johnston2024-07-192-4/+4
| | | | | | | | | | | | | | | | | | | | This reverts commit d8265b223f0ad96a47d4cb9a85d831c404008c6d.
* | | | | Remove listsErik Johnston2024-07-182-4/+4
| | | | |
* | | | | Merge branch 'erikj/ss_incr_sync' into erikj/ss_hacksErik Johnston2024-07-171-0/+25
|\ \ \ \ \
| * | | | | Only return changed rooms erikj/ss_incr_syncErik Johnston2024-07-171-0/+25
| | |/ / / | |/| | |
* | | | | FixupErik Johnston2024-07-171-1/+1
| | | | |
* | | | | Merge branch 'erikj/ss_room_store' into erikj/ss_hacksErik Johnston2024-07-1710-109/+547
|\| | | |
| * | | | Handle state deltas in non-initial roomsErik Johnston2024-07-172-3/+49
| | | | |
| * | | | Handle initial flag correctlyErik Johnston2024-07-171-35/+31
| | | | |
| * | | | Use new room store to track if we've sent a room downErik Johnston2024-07-171-11/+44
| | | | |
| * | | | Add conn_id fieldErik Johnston2024-07-174-5/+36
| | | | |
| * | | | WIP/PoC of storing whether we have sent rooms down to clientsErik Johnston2024-07-171-0/+197
| | |/ / | |/| |
| * | | Pass throught SlidingSyncStreamTokenErik Johnston2024-07-173-14/+28
| | | |
| * | | Add SlidingSyncStreamTokenErik Johnston2024-07-171-0/+37
| |/ /
| * | Handle remote download responses with `UNKNOWN_LENGTH` more gracefully (#17439)Shay2024-07-161-46/+80
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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`.
| * | Fix bug where sync could get stuck when using workers (#17438)Erik Johnston2024-07-152-10/+66
| | | | | | | | | | | | This is because we serialized the token wrong if the instance map contained entries from before the minimum token.
| * | Make sure we use the right logic for enabling the media repo. (#17424)Quentin Gliech2024-07-153-8/+2
| | | | | | | | | | | | | | | This removes the `enable_media_repo` attribute on the server config in favour of always using the `can_load_media_repo` in the media config. This should avoid issues like in #17420 in the future
* | | Merge remote-tracking branch 'origin/develop' into erikj/ss_hacksErik Johnston2024-07-151-123/+295
|\| |
| * | Add room subscriptions to Sliding Sync `/sync` (#17432)Eric Eastwood2024-07-151-115/+288
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
* | | Have more timeline events in incremental syncsErik Johnston2024-07-121-3/+7
| | |
* | | Merge remote-tracking branch 'origin/develop' into erikj/ss_hacksErik Johnston2024-07-126-138/+344
|\| |
| * | Add `is_dm` room field to Sliding Sync `/sync` (#17429)Eric Eastwood2024-07-111-29/+46
| | | | | | | | | | | | | | | 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-114-98/+236
| | | | | | | | | | | | | | | | | | | | | 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-112-13/+61
| | | | | | | | | | | | | | | | | | 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.
| * | Fix docs on `record_action` to clarify the actions are applied (#17426)Travis Ralston2024-07-111-3/+2
| | | | | | | | | | | | | | | This looks like a copy/paste error: the function doesn't reject anything, but instead allows the action count to go through regardless. The remainder of the function's documentation appears correct.
* | | FixupErik Johnston2024-07-122-2/+4
| | |
* | | FixupErik Johnston2024-07-121-1/+1
| | |
* | | FixupErik Johnston2024-07-111-1/+1
| | |
* | | Reduce log spamErik Johnston2024-07-111-12/+8
| | |
* | | Merge branch 'erikj/ss_sort' into erikj/ss_hacksErik Johnston2024-07-112-3/+4
|\ \ \
| * | | Faster sliding sync sorting erikj/ss_sortErik Johnston2024-07-115-23/+234
| |/ /
* | | Merge branch 'erikj/ss_sort' into erikj/ss_hacksErik Johnston2024-07-115-83/+126
|\ \ \
| * | | Faster sliding sync sortingErik Johnston2024-07-115-23/+231
| |/ /
* | | FixupErik Johnston2024-07-111-5/+8
| | |
* | | TracingErik Johnston2024-07-111-0/+3
| | |
* | | FixupErik Johnston2024-07-112-1/+5
| | |
* | | Fixup room typesErik Johnston2024-07-112-13/+36
| | |
* | | New tableErik Johnston2024-07-114-16/+101
| | |
* | | Handle $ME correctlyErik Johnston2024-07-111-1/+9
| | |
* | | FIXUPErik Johnston2024-07-111-7/+9
| | |
* | | FixupErik Johnston2024-07-111-7/+18
| | |
* | | FIXUPErik Johnston2024-07-101-1/+3
| | |
* | | FIXUPErik Johnston2024-07-102-10/+13
| | |
* | | FIXUPErik Johnston2024-07-108-9/+13
| | |
* | | tracingErik Johnston2024-07-101-1/+5
| | |
* | | ConcurrentErik Johnston2024-07-101-2/+6
| | |
* | | FixupErik Johnston2024-07-101-4/+6
| | |
* | | FixupErik Johnston2024-07-101-7/+3
| | |
* | | FixupErik Johnston2024-07-102-1/+2
| | |
* | | FixupErik Johnston2024-07-103-8/+52
| | |
* | | FixupErik Johnston2024-07-101-10/+1
| | |
* | | FixupErik Johnston2024-07-101-1/+21
| | |
* | | FixupErik Johnston2024-07-102-7/+13
| | |
* | | More fixupsErik Johnston2024-07-103-12/+22
| | |
* | | Faster room sortingErik Johnston2024-07-102-31/+28
|/ /
* | Handle to-device extensions to Sliding Sync (#17416)Erik Johnston2024-07-104-10/+193
| | | | | | | | | | | | | | Implements MSC3885 --------- Co-authored-by: Eric Eastwood <eric.eastwood@beta.gouv.fr>
* | Merge branch 'release-v1.111' into developQuentin Gliech2024-07-102-2/+2
|\|
| * Fix new media APIs when using synapse.app.media_repository (#17420)Erik Johnston2024-07-092-2/+2
| | | | | | Co-authored-by: Andrew Morgan <1342360+anoadragon453@users.noreply.github.com>
* | Add `rooms` `name` and `avatar` to Sliding Sync `/sync` (#17418)Eric Eastwood2024-07-091-55/+96
|/ | | Based on [MSC3575](https://github.com/matrix-org/matrix-spec-proposals/pull/3575): Sliding Sync
* Fix exception when failing to talk to remote server (#17411)Erik Johnston2024-07-091-1/+2
| | | Broke in #17381
* Fix `/versions` requests (#17410)Erik Johnston2024-07-092-1/+10
| | | | | We need it to work on workers and allow guest access. Broke by #17392
* Fix bug in sliding sync when using old DB. (#17398)Erik Johnston2024-07-085-88/+31
| | | | | | | | | 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-085-30/+93
| | | | | | | | | | | | | | | 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
* Declare support for Matrix 1.11 (#17403)Travis Ralston2024-07-081-0/+1
| | | | | | | | Previous: https://github.com/element-hq/synapse/pull/17082 Fixes https://github.com/element-hq/synapse/issues/17402 See https://github.com/element-hq/synapse/issues/17402 for context **Blocked on https://github.com/element-hq/synapse/pull/17388** (required for spec compliance)
* MSC3861: allow overriding the introspection endpoint (#17406)Quentin Gliech2024-07-082-2/+19
| | | | This makes it easier to go through an internal endpoint instead of the public facing URL when introspecting tokens, reducing latency.
* Support MSC3916 by adding a federation /thumbnail endpoint and authenticated ↵Shay2024-07-088-47/+178
| | | | | | | | | | | | | | `_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-057-12/+14
|
* Allow enabling sliding sync per-user (#17393)Erik Johnston2024-07-055-6/+87
| | | Based on #17392
* Finish up work to allow per-user feature flags (#17392)Erik Johnston2024-07-054-26/+98
| | | | | | | 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/+4
| | | | | | 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-045-81/+433
| | | 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-023-6/+34
| | | | | 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-029-202/+920
| | | | | | - 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-4/+22
|\
| * Limit size of presence EDUs (#17371)Erik Johnston2024-07-021-11/+20
| | | | | | | | | | | | | | 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-4/+22
| | | | | | | | | | | | 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-0214-29/+153
| | | | | | | | | | | | | | | | | | | | | | | | | | 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-0214-37/+689
| |
* | Fix sync waiting for an invalid token from the "future" (#17386)Erik Johnston2024-07-0214-29/+153
| | | | | | | | | | | | | | | | | | | | | | | | | | 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-11/+20
| | | | | | | | | | | | | | Otherwise they are unbounded. --------- Co-authored-by: Andrew Morgan <1342360+anoadragon453@users.noreply.github.com>
* | Handle multiple rows device inbox (#17362)Erik Johnston2024-06-271-3/+2
|/ | | | | | | | | | Fix bug where we don't get new to-device from remote if they resent a message we've already persisted and have recorded in the DB twice. `device_federation_inbox` table doesn't have a unique index, and so we can race and store an entry in there twice. If we do so then `simple_select_one_txn` will throw an error due to the query returning more than one row. We should add an unique index, but it doesn't really matter so lets just handle the case of multiple rows correctly for now.
* Re-introduce federation /download endpoint (#17350)Shay2024-06-256-11/+413
|
* Limit amount of replication we send (#17358)Erik Johnston2024-06-251-8/+7
| | | | | | | | | Fixes up #17333, where we failed to actually send less data (the `DISTINCT` didn't work due to `stream_id` being different). We fix this by making it so that every device list outbound poke for a given user ID has the same stream ID. We can't change the query to only return e.g. max stream ID as the receivers look up the destinations to send to by doing `SELECT WHERE stream_id = ?`
* Reintroduce "Reduce device lists replication traffic."" (#17361)Erik Johnston2024-06-254-48/+80
| | | | | | 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-254-80/+48
| | | | | | 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-241-3/+16
| | | Based on [MSC3575](https://github.com/matrix-org/matrix-spec-proposals/pull/3575): Sliding Sync
* Fix room `type` typo in mailer (#17336)Eric Eastwood2024-06-241-2/+3
| | | | | Correct event content field is `EventContentFields.ROOM_TYPE` (`type`) :white_check_mark: , not `room_type` :x: Spec: https://spec.matrix.org/v1.10/client-server-api/#mroomcreate
* Reintroduce #17291. (#17338)Erik Johnston2024-06-243-77/+206
| | | | | | | 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-246-0/+97
|
* Reduce device lists replication traffic. (#17333)Erik Johnston2024-06-244-48/+80
| | | | | | | | | | 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.
* Tidy up integer parsing (#17339)Denis Kasak2024-06-247-34/+24
| | | | | | | | | | The parse_integer function was previously made to reject negative values by default in https://github.com/element-hq/synapse/pull/16920, but the documentation stated otherwise. This fixes the documentation and also: - Removes explicit negative=False parameters from call sites. - Brings the negative default of parse_integer_from_args in alignment with parse_integer.
* Revert "Handle large chain calc better (#17291)" (#17334)Erik Johnston2024-06-192-191/+70
| | | | | | 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/+1
| | | As the API is slightly incompatible.
* register-new-matrix-user: add a flag to ignore already existing users (#17304)Jörg Thalheim2024-06-191-2/+28
| | | | Co-authored-by: Andrew Morgan <andrew@amorgan.xyz>
* Filter added to Admin-API GET /rooms (#17276)Alexander Fechler2024-06-192-15/+49
|
* Handle large chain calc better (#17291)Erik Johnston2024-06-192-70/+191
| | | | | 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-2/+18
| | | | Co-authored-by: Erik Johnston <erikj@element.io>
* Revert "Support MSC3916 by adding a federation `/download` endpoint" (#17325)Andrew Morgan2024-06-187-411/+22
|
* register_new_matrix_user: add password-file flag (#17294)Jörg Thalheim2024-06-181-5/+15
| | | | | Co-authored-by: Andrew Morgan <1342360+anoadragon453@users.noreply.github.com> Co-authored-by: Andrew Morgan <andrew@amorgan.xyz>
* Add support for via query parameter from MSC4156 (#17322)Johannes Marbach2024-06-183-0/+19
| | | | This adds support for the `via` query parameter from https://github.com/matrix-org/matrix-spec-proposals/pull/4156.
* Add `is_encrypted` filtering to Sliding Sync `/sync` (#17281)Eric Eastwood2024-06-173-100/+122
| | | | 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-175-63/+173
| | | 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-172-25/+35
|\
| * Set our own stream position from the current sequence value on startup (#17309)Quentin Gliech2024-06-171-3/+20
| |
| * Automatically apply SQL for inconsistent sequence (#17305)Erik Johnston2024-06-141-22/+15
| | | | | | | | | | | | 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-54/+29
| | | | | | | | | | | | 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-1313-34/+4
| | | | | | | | | | 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-6/+159
| | | | | | 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-13/+13
| | | | | | | | | | | | | | | | | | | | | | (#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-135-6/+16
| | | | | | | | | | | | | | | | | | | | 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-10/+22
| | | | | | | | | | | | | | | | | | | | | | 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`
* | Clarify that MSC4151 is enabled on matrix.org (#17296)Quentin Gliech2024-06-131-1/+9
| | | | | | | | | | This clarifies in the comments that the MSC is being used in matrix.org See #17270
* | Add report room API (MSC4151) (#17270)Travis Ralston2024-06-126-3/+115
| | | | | | | | | | | | | | | | 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.
* | Merge branch 'release-v1.109' into developQuentin Gliech2024-06-112-9/+35
|\|
| * Fix bug where device lists would break sync (#17292)Erik Johnston2024-06-102-9/+35
| | | | | | | | | | | | | | | | | | | | If the stream ID in the unconverted table is ahead of the device lists ID gen, then it can break all /sync requests that had an ID from ahead of the table. The fix is to make sure we add the unconverted table to the list of tables we check at start up. Broke in https://github.com/element-hq/synapse/pull/17229
| * Always return OTK counts (#17275)Erik Johnston2024-06-101-4/+29
| | | | | | Broke in https://github.com/element-hq/synapse/pull/17215
* | Reorganize Pydantic models and types used in handlers (#17279)Eric Eastwood2024-06-1013-243/+267
| | | | | | | | | | | | 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`
* | Wrong retention policy being used when filtering events (lint ↵Eric Eastwood2024-06-101-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | `ControlVarUsedAfterBlockViolation` `WPS441`) (#17272) Fix loop var being used outside block. Before this change, we were always using the last room_id's retention policy for all events being filtered. I found this bug with the [new lint rule, `ControlVarUsedAfterBlockViolation` `WPS441`](https://github.com/astral-sh/ruff/pull/11769), that I re-implemented in `ruff`. Shout-out to @reivilibre for all the help in the beginning! ### 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))
* | Support MSC3916 by adding a federation `/download` endpoint (#17172)Shay2024-06-077-22/+411
| |
* | Add debug logging for when room keys are uploaded, including whether they ↵reivilibre2024-06-071-0/+18
| | | | | | | | | | | | | | | | | | | | | | are replacing other room keys. (#17266) Fixes: #17013 Add logging for whether room keys are replaced This is motivated by the Crypto team who need to diagnose crypto issues. The existing opentracing logging is not enough because it is not enabled for all users.
* | Add Sliding Sync `/sync` endpoint (initial implementation) (#17187)Eric Eastwood2024-06-067-13/+1046
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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": {} } ```
* | Handle OTK uploads off master (#17271)Erik Johnston2024-06-062-38/+59
| | | | | | And fallback keys uploads. Only device keys need handling on master
* | Don't try and resync devices for down hosts (#17273)Erik Johnston2024-06-061-6/+18
| | | | | | | | It's just a waste of time if we won't even query the remote host as its marked as down.
* | Always return OTK counts (#17275)Erik Johnston2024-06-061-4/+29
| | | | | | Broke in https://github.com/element-hq/synapse/pull/17215
* | Ratelimiting of remote media downloads (#17256)Shay2024-06-059-12/+130
| |
* | Handle hyphens in user dir search porperly (#17254)Erik Johnston2024-06-051-6/+60
| | | | | | c.f. #16675
* | Use fully-qualified `PersistedEventPosition` when returning `RoomsForUser` ↵Eric Eastwood2024-06-049-74/+80
|/ | | | | | | (#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-3/+3
| | | | This can happen on restarts of the service, due to old rooms being pruned.
* Fix logging errors when receiving invalid User ID for key querys (#17250)Erik Johnston2024-05-311-0/+5
|
* Fix sentry default tags (#17251)Erik Johnston2024-05-311-10/+10
| | | | | This was broken by the sentry 2.0 upgrade Broke in v1.108.0
* In sync wait for worker to catch up since token (#17215)Erik Johnston2024-05-305-3/+131
| | | | | | | Otherwise things will get confused. An alternative would be to make sure that for lagging stream we don't return anything (and make sure the returned next_batch token doesn't go backwards). But that is a faff.
* Fix deduplicating of membership events to not create unused state groups. ↵Erik Johnston2024-05-302-35/+32
| | | | | | | | | | | | | (#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-308-224/+225
| | | | | (#17229) Replaces all usages of `StreamIdGenerator` with `MultiWriterIdGenerator`, which is safer.
* Clean out invalid destinations from outbox (#17242)Erik Johnston2024-05-302-0/+91
| | | | We started ensuring we only insert valid destinations: https://github.com/element-hq/synapse/pull/17240
* Ensure we delete media if we reject due to spam check (#17246)Erik Johnston2024-05-302-32/+32
| | | | | | | | Fixes up #17239 We need to keep the spam check within the `try/except` block. Also makes it so that we don't enter the top span twice. Also also ensures that we get the right thumbnail length.
* Move towards using `MultiWriterIdGenerator` everywhere (#17226)Erik Johnston2024-05-298-215/+153
| | | | | | | | | | | | | | | 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.
* Don't invalidate all `get_relations_for_event` on history purge (#17083)Erik Johnston2024-05-295-13/+40
| | | | This is a tree cache already, so may as well move the room ID to the front and use that
* Change allow_unsafe_locale to also apply on new databases (#17238)Erik Johnston2024-05-291-1/+7
| | | | We relax this as there are use cases where this is safe, though it is still highly recommended that people avoid using it.
* Ignore attempts to send to-device messages to bad users (#17240)Erik Johnston2024-05-291-0/+7
| | | | | | | | Currently sending a to-device message to a user ID with a dodgy destination is accepted, but then ends up spamming the logs when we try and send to the destination. An alternative would be to reject the request, but I'm slightly nervous that could break things.
* Handle duplicate OTK uploads racing (#17241)Erik Johnston2024-05-291-33/+45
| | | Currently this causes one of then to 500.
* Fix slipped logging context when media rejected (#17239)Erik Johnston2024-05-293-77/+40
| | | | | | | 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-244-468/+703
| | | | | | | | | | [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-10/+411
| | | | | | | | | | | 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
* Log exceptions when failing to auto-join new user according to the ↵reivilibre2024-05-221-1/+1
| | | | | | | `auto_join_rooms` option. (#17176) Would have been useful for tracking down #16878. Signed-off-by: Olivier 'reivilibre <oliverw@matrix.org>
* Add logging to tasks managed by the task scheduler, showing CPU and database ↵reivilibre2024-05-221-2/+67
| | | | | | | | | | | | | | | | | | | usage. (#17219) The log format is the same as the request log format, except: - fields that are specific to HTTP requests have been removed - the task's params are included at the end of the log line. These log lines are emitted: - when the task function finishes — both completion and failure (and I suppose it is possible for a task to become schedulable again?) - every 5 minutes whilst it is running Closes #17217. --------- Signed-off-by: Olivier 'reivilibre <oliverw@matrix.org>
* Reduce work of calculating outbound device pokes (#17211)Erik Johnston2024-05-222-0/+31
|
* Bring auto-accept invite logic into Synapse (#17147)devonh2024-05-216-1/+250
| | | | | | | | | | | | | | 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.
* Improve perf of sync device lists (#17216)Erik Johnston2024-05-214-62/+102
| | | | | | | | Re-introduces #17191, and includes #17197 and #17214 The basic idea is to stop calling `get_rooms_for_user` everywhere, and instead use the table `device_lists_changes_in_room`. Commits reviewable one-by-one.
* Add a short sleep if the request is rate-limited (#17210)Erik Johnston2024-05-181-0/+4
| | | This helps prevent clients from "tight-looping" retrying their request.
* Refactor `SyncResultBuilder` assembly to its own function (#17202)Eric Eastwood2024-05-161-116/+148
| | | | | | We will re-use `get_sync_result_builder(...)` in https://github.com/element-hq/synapse/pull/17167 Split out from https://github.com/element-hq/synapse/pull/17167