summary refs log tree commit diff
path: root/tests (follow)
Commit message (Collapse)AuthorAgeFilesLines
* Persist CreateRoom events to DB in a batch (#13800)Shay2022-09-284-6/+20
|
* Prepatory work for batching events to send (#13487)Shay2022-09-281-2/+2
| | | This PR begins work on batching up events during the creation of a room. The PR splits out the creation and sending/persisting of the events. The first three events in the creation of the room-creating the room, joining the creator to the room, and the power levels event are sent sequentially, while the subsequent events are created and collected to be sent at the end of the function. This is currently done by appending them to a list and then iterating over the list to send, the next step (after this PR) would be to send and persist the collected events as a batch.
* Fix `have_seen_event` cache not being invalidated (#13863)Eric Eastwood2022-09-272-49/+136
| | | | | | | | | | | | | | | | | | | | | Fix https://github.com/matrix-org/synapse/issues/13856 Fix https://github.com/matrix-org/synapse/issues/13865 > Discovered while trying to make Synapse fast enough for [this MSC2716 test for importing many batches](https://github.com/matrix-org/complement/pull/214#discussion_r741678240). As an example, disabling the `have_seen_event` cache saves 10 seconds for each `/messages` request in that MSC2716 Complement test because we're not making as many federation requests for `/state` (speeding up `have_seen_event` itself is related to https://github.com/matrix-org/synapse/issues/13625) > > But this will also make `/messages` faster in general so we can include it in the [faster `/messages` milestone](https://github.com/matrix-org/synapse/milestone/11). > > *-- https://github.com/matrix-org/synapse/issues/13856* ### The problem `_invalidate_caches_for_event` doesn't run in monolith mode which means we never even tried to clear the `have_seen_event` and other caches. And even in worker mode, it only runs on the workers, not the master (AFAICT). Additionally there was bug with the key being wrong so `_invalidate_caches_for_event` never invalidates the `have_seen_event` cache even when it does run. Because we were using the `@cachedList` wrong, it was putting items in the cache under keys like `((room_id, event_id),)` with a `set` in a `set` (ex. `(('!TnCIJPKzdQdUlIyXdQ:test', '$Iu0eqEBN7qcyF1S9B3oNB3I91v2o5YOgRNPwi_78s-k'),)`) and we we're trying to invalidate with just `(room_id, event_id)` which did nothing.
* Support the stable dir parameter for /relations. (#13920)Patrick Cloke2022-09-271-4/+2
| | | | | | | Since MSC3715 has passed FCP, the stable parameter can be used. This currently falls back to the unstable parameter if the stable parameter is not provided (and MSC3715 support is enabled in the configuration).
* Improve tests for get_unread_push_actions_for_user_in_range_*. (#13893)Patrick Cloke2022-09-261-16/+72
| | | | | * Adds a docstring. * Reduces a small amount of duplicated code. * Improves tests.
* typing: check origin server of typing event against room's servers (#13830)Mathieu Velten2022-09-261-0/+4
| | | | | | | This is also using the partial state approximation if needed so we do not block here during a fast join. Signed-off-by: Mathieu Velten <mathieuv@matrix.org> Co-authored-by: Sean Quah <8349537+squahtx@users.noreply.github.com>
* Only try to backfill event if we haven't tried before recently (#13635)Eric Eastwood2022-09-231-4/+477
| | | | | | | | | | Only try to backfill event if we haven't tried before recently (exponential backoff). No need to keep trying the same backfill point that fails over and over. Fix https://github.com/matrix-org/synapse/issues/13622 Fix https://github.com/matrix-org/synapse/issues/8451 Follow-up to https://github.com/matrix-org/synapse/pull/13589 Part of https://github.com/matrix-org/synapse/issues/13356
* Accept & store thread IDs for receipts (implement MSC3771). (#13782)Patrick Cloke2022-09-236-14/+62
| | | | Updates the `/receipts` endpoint and receipt EDU handler to parse a `thread_id` from the body and insert it in the database.
* Faster Remote Room Joins: tell remote homeservers that we are unable to ↵reivilibre2022-09-231-1/+1
| | | | authorise them if they query a room which has partial state on our server. (#13823)
* Properly paginate forward in the /relations API. (#13840)Patrick Cloke2022-09-221-1/+28
| | | | | This fixes a bug where the `/relations` API with `dir=f` would skip the first item of each page (except the first page), causing incomplete data to be returned to the client.
* Track device IDs for pushers (#13831)Brendan Abolivier2022-09-211-5/+50
| | | Second half of the MSC3881 implementation
* Implementation of MSC3882 login token request (#13722)Hugh Nimmo-Smith2022-09-211-0/+132
|
* Support enabling/disabling pushers (from MSC3881) (#13799)Brendan Abolivier2022-09-214-17/+139
| | | Partial implementation of MSC3881
* Add cache invalidation across workers to module API (#13667)Mathieu Velten2022-09-211-0/+79
| | | Signed-off-by: Mathieu Velten <mathieuv@matrix.org>
* Improve the `synapse.api.auth.Auth` mock used in unit tests. (#13809)Quentin Gliech2022-09-211-26/+10
| | | To return the proper type (`Requester`) instead of a `dict`.
* Port the push rule classes to Rust. (#13768)Erik Johnston2022-09-201-15/+12
|
* Add an admin API endpoint to find a user based on its external ID in an auth ↵Quentin Gliech2022-09-161-0/+87
| | | | provider. (#13810)
* Avoid putting rejected events in room state (#13723)Sean Quah2022-09-161-0/+399
| | | Signed-off-by: Sean Quah <seanq@matrix.org>
* A third batch of Pydantic validation for rest/client/account.py (#13736)David Robertson2022-09-151-3/+26
|
* Add a `MXCUri` class to make working with mxc uri's easier. (#13162)Andrew Morgan2022-09-151-64/+38
|
* Keep track when we try and fail to process a pulled event (#13589)Eric Eastwood2022-09-141-0/+222
| | | | | | | | | | | | | | We can follow-up this PR with: 1. Only try to backfill from an event if we haven't tried recently -> https://github.com/matrix-org/synapse/issues/13622 1. When we decide to backfill that event again, process it in the background so it doesn't block and make `/messages` slow when we know it will probably fail again -> https://github.com/matrix-org/synapse/issues/13623 1. Generally track failures everywhere we try and fail to pull an event over federation -> https://github.com/matrix-org/synapse/issues/13700 Fix https://github.com/matrix-org/synapse/issues/13621 Part of https://github.com/matrix-org/synapse/issues/13356 Mentioned in [internal doc](https://docs.google.com/document/d/1lvUoVfYUiy6UaHB6Rb4HicjaJAU40-APue9Q4vzuW3c/edit#bookmark=id.qv7cj51sv9i5)
* Update event push action and receipt tables to support threads. (#13753)Patrick Cloke2022-09-141-0/+1
| | | | | | | | | | | | | | | Adds a `thread_id` column to the `event_push_actions`, `event_push_actions_staging`, and `event_push_summary` tables. This will notifications to be segmented by the thread in a future pull request. The `thread_id` column stores the root event ID or the special value `"main"`. The `thread_id` column for `event_push_actions` and `event_push_summary` is backfilled with `"main"` for all existing rows. New entries into `event_push_actions` and `event_push_actions_staging` will get the proper thread ID. `receipts_linearized` and `receipts_graph` also gain a `thread_id` column, which is similar, except `NULL` is a special value meaning the receipt is "unthreaded". See MSC3771 and MSC3773 for where this data will be useful.
* Fix bug in device list caching when remote users leave rooms (#13749)Sean Quah2022-09-141-1/+7
| | | | | | | | | | | | When a remote user leaves the last room shared with the homeserver, we have to mark their device list as unsubscribed, otherwise we would hold on to a stale device list in our cache. Crucially, the device list would remain cached even after the remote user rejoined the room, which could lead to E2EE failures until the next change to the remote user's device list. Fixes #13651. Signed-off-by: Sean Quah <seanq@matrix.org>
* Require SQLite >= 3.27.0 (#13760)David Robertson2022-09-091-1/+0
|
* Add timestamp to user's consent (#13741)Dirk Klimpel2022-09-082-7/+27
| | | Co-authored-by: reivilibre <olivier@librepush.net>
* Fix error in `is_mine_id` when encountering a malformed ID (#13746)Sean Quah2022-09-081-1/+25
| | | | | | | | | Previously, `is_mine_id` would raise an exception when passed an ID with no colons. Return `False` instead. Fixes #13040. Signed-off-by: Sean Quah <seanq@matrix.org>
* Cancel the processing of key query requests when they time out. (#13680)reivilibre2022-09-072-1/+38
|
* Rename the `EventFormatVersions` enum values so that they line up with room ↵reivilibre2022-09-073-4/+4
| | | | version numbers. (#13706)
* Add Admin API to Fetch Messages Within a Particular Window (#13672)Connor Davis2022-09-071-1/+157
| | | This adds two new admin APIs that allow us to fetch messages from a room within a particular time.
* Add a stub Rust crate (#12595)Erik Johnston2022-09-061-0/+11
|
* Remove configuration options for direct TCP replication. (#13647)Patrick Cloke2022-09-063-4/+3
| | | Removes the ability to configure legacy direct TCP replication. Workers now require Redis to run.
* Share some metrics between the Prometheus exporter and the phone home stats ↵Brendan Abolivier2022-09-051-1/+45
| | | | (#13671)
* Disable calculating unread counts unless the config flag is enabled. (#13694)Patrick Cloke2022-09-011-22/+20
| | | | | | | | This avoids doing work that will never be used (since the resulting unread counts will never be sent in a /sync response). The negative of doing this is that unread counts will be incorrect when the feature is initially enabled.
* Remove support for unstable private read receipts (#13653)Šimon Brandner2022-09-013-83/+36
| | | Signed-off-by: Šimon Brandner <simon.bra.ag@gmail.com>
* Drop support for calling `/_matrix/client/v3/rooms/{roomId}/invite` without ↵Jacek Kuśnierz2022-08-313-3/+25
| | | | | | | an `id_access_token` (#13241) Fixes #13206 Signed-off-by: Jacek Kusnierz jacek.kusnierz@tum.de
* Generalise the `@cancellable` annotation so it can be used on functions ↵reivilibre2022-08-314-4/+6
| | | | other than just servlet methods. (#13662)
* Fix admin List Room API return type on sqlite (#13509)David Robertson2022-08-311-5/+14
|
* Fix that user cannot `/forget` rooms after the last member has left (#13546)Dirk Klimpel2022-08-302-4/+93
|
* Update `get_users_in_room` mis-use to get hosts with dedicated ↵Eric Eastwood2022-08-241-5/+12
| | | | | `get_current_hosts_in_room` (#13605) See https://github.com/matrix-org/synapse/pull/13575#discussion_r953023755
* Directly lookup local membership instead of getting all members in a room ↵Eric Eastwood2022-08-241-6/+6
| | | | | first (`get_users_in_room` mis-use) (#13608) See https://github.com/matrix-org/synapse/pull/13575#discussion_r953023755
* Add experimental configuration option to allow disabling legacy Prometheus ↵reivilibre2022-08-241-0/+36
| | | | | metric names. (#13540) Co-authored-by: David Robertson <davidr@element.io>
* Drop support for delegating email validation, round 2 (#13596)David Robertson2022-08-231-1/+1
|
* Fix that sending server notices fail if avatar is `None` (#13566)Dirk Klimpel2022-08-232-3/+62
| | | Indroduced in #11846.
* `synapse.api.auth.Auth` cleanup: make permission-related methods use ↵Quentin Gliech2022-08-224-9/+17
| | | | | | | | | `Requester` instead of the `UserID` (#13024) Part of #13019 This changes all the permission-related methods to rely on the Requester instead of the UserID. This is a first step towards enabling scoped access tokens at some point, since I expect the Requester to have scope-related informations in it. It also changes methods which figure out the user/device/appservice out of the access token to return a Requester instead of something else. This avoids having store-related objects in the methods signatures.
* Implement MSC3852: Expose `last_seen_user_agent` to users for their own ↵Andrew Morgan2022-08-192-1/+106
| | | | devices; also expose to Admin API (#13549)
* Register homeserver modules when creating test homeserver (#13558)Andrew Morgan2022-08-194-22/+14
|
* Reduce the number of tests using TCP replication. (#13543)Patrick Cloke2022-08-195-77/+35
| | | | Uses Redis replication in additional test cases (instead of TCP replication). A small step towards dropping TCP replication.
* Fix validation problem that occurs when a user tries to deactivate their ↵reivilibre2022-08-191-0/+15
| | | | account or change their password. (#13563)
* Fix a bug in the `/event_reports` Admin API which meant that the total count ↵reivilibre2022-08-171-0/+27
| | | | | could be larger than the number of results you can actually query for. (#13525) Co-authored-by: Brendan Abolivier <babolivier@matrix.org>
* Add forgotten status to Room Details API (#13503)Dirk Klimpel2022-08-172-0/+71
|
* Make push rules use proper structures. (#13522)Erik Johnston2022-08-161-16/+17
| | | | | | | | | | | | This improves load times for push rules: | Version | Time per user | Time for 1k users | | -------------------- | ------------- | ----------------- | | Before | 138 µs | 138ms | | Now (with custom) | 2.11 µs | 2.11ms | | Now (without custom) | 49.7 ns | 0.05 ms | This therefore has a large impact on send times for rooms with large numbers of local users in the room.
* Use Pydantic to systematically validate a first batch of endpoints in ↵David Robertson2022-08-152-5/+58
| | | | `synapse.rest.client.account`. (#13188)
* Revert "Update locked versions of mypy and mypy-zope (#13521)"David Robertson2022-08-151-1/+3
| | | | | | | | This reverts commit f383b9b3eceaa082d5ae690550fe41460b711779. Other PRs were seeing mypy failures that looked to be related to mypy-zope. Confusingly, we didn't see this on #13521. Revert this for now and investigate later.
* Update locked versions of mypy and mypy-zope (#13521)David Robertson2022-08-151-3/+1
|
* Use literals in place of `HTTPStatus` constants in tests (#13488)Dirk Klimpel2022-08-1011-447/+176
| | | | | | | | | * Use literals in place of `HTTPStatus` constants in tests * newsfile * code style * code style
* Allow use of both `@trace` and `@tag_args` stacked on the same function (#13453)Eric Eastwood2022-08-091-0/+83
| | | | | | | | | | | | | ```py @trace @tag_args async def get_oldest_event_ids_with_depth_in_room(...) ... ``` Before this PR, you would see a warning in the logs and the span was not exported: ``` 2022-08-03 19:11:59,383 - synapse.logging.opentracing - 835 - ERROR - GET-0 - @trace may not have wrapped EventFederationWorkerStore.get_oldest_event_ids_with_depth_in_room correctly! The function is not async but returned a coroutine. ```
* Use literals in place of `HTTPStatus` constants in tests (#13479)Dirk Klimpel2022-08-0911-141/+140
| | | | | | | | | | Replace - `HTTPStatus.NOT_FOUND` - `HTTPStatus.FORBIDDEN` - `HTTPStatus.UNAUTHORIZED` - `HTTPStatus.CONFLICT` - `HTTPStatus.CREATED` Signed-off-by: Dirk Klimpel <dirk@klimpel.org>
* Strengthen tests about deleted old push actions. (#13471)Patrick Cloke2022-08-091-0/+15
|
* Use literals in place of `HTTPStatus` constants in tests (#13469)Dirk Klimpel2022-08-0812-331/+328
|
* Support stable identifiers for MSC2285: private read receipts. (#13273)Šimon Brandner2022-08-053-52/+119
| | | | | This adds support for the stable identifiers of MSC2285 while continuing to support the unstable identifiers behind the configuration flag. These will be removed in a future version.
* Use literals in place of `HTTPStatus` constants in tests (#13463)Dirk Klimpel2022-08-0517-191/+171
|
* Update module API "update room membership" method to allow for remote joins ↵Matt C2022-08-051-0/+29
| | | | | | (#13441) Co-authored-by: MattC <buffless-matt@users.noreply.github.com> Co-authored-by: Brendan Abolivier <babolivier@matrix.org>
* Add module API method to create a room (#13429)Matt C2022-08-041-0/+51
| | | | Co-authored-by: MattC <buffless-matt@users.noreply.github.com> Co-authored-by: Brendan Abolivier <babolivier@matrix.org>
* Fix rooms not being properly excluded from incremental sync (#13408)Brendan Abolivier2022-08-041-0/+21
|
* Return 404 or member list when getting joined_members after leaving (#13374)andrew do2022-08-031-0/+15
| | | | | | Signed-off-by: Andrew Doh <andrewddo@gmail.com> Co-authored-by: Patrick Cloke <clokep@users.noreply.github.com> Co-authored-by: Andrew Morgan <andrewm@element.io> Co-authored-by: Brendan Abolivier <babolivier@matrix.org>
* Add module API method to resolve a room alias to a room ID (#13428)Matt C2022-08-031-0/+19
| | | | Co-authored-by: MattC <buffless-matt@users.noreply.github.com> Co-authored-by: Brendan Abolivier <babolivier@matrix.org>
* Faster Room Joins: don't leave a stuck room partial state flag if the join ↵reivilibre2022-08-011-1/+121
| | | | fails. (#13403)
* Refactor `_resolve_state_at_missing_prevs` to return an `EventContext` (#13404)Sean Quah2022-08-011-4/+11
| | | | | | | | Previously, `_resolve_state_at_missing_prevs` returned the resolved state before an event and a partial state flag. These were unwieldy to carry around would only ever be used to build an event context. Build the event context directly instead. Signed-off-by: Sean Quah <seanq@matrix.org>
* Merge tag 'v1.64.0rc2' into developRichard van der Hoff2022-07-291-1/+1
|\ | | | | | | | | | | | | Synapse 1.64.0rc2 (2022-07-29) ============================== This RC reintroduces support for `account_threepid_delegates.email`, which was removed in 1.64.0rc1. It remains deprecated and will be removed altogether in a future release. ([\#13406](https://github.com/matrix-org/synapse/issues/13406))
| * Revert "Drop support for delegating email validation (#13192)" (#13406)3nprob2022-07-291-1/+1
| | | | | | | | | | Reverts commit fa71bb18b527d1a3e2629b48640ea67fff2f8c59, and tweaks documentation. Signed-off-by: 3nprob <git@3n.anonaddy.com>
* | Use stable prefixes for MSC3827: filtering of `/publicRooms` by room type ↵Šimon Brandner2022-07-271-3/+2
| | | | | | | | | | | | (#13370) Signed-off-by: Šimon Brandner <simon.bra.ag@gmail.com>
* | Add missing type hints for tests.unittest. (#13397)Patrick Cloke2022-07-275-52/+65
| |
* | Implement MSC3848: Introduce errcodes for specific event sending failures ↵Will Hunt2022-07-271-2/+3
| | | | | | | | | | (#13343) Implements MSC3848
* | Make minor clarifications to the error messages given when we fail to join a ↵reivilibre2022-07-271-1/+4
| | | | | | | | room via any server. (#13160)
* | Faster room joins: avoid blocking when pulling events with missing prevs ↵Sean Quah2022-07-263-1/+9
|/ | | | | | | | | (#13355) Avoid blocking on full state in `_resolve_state_at_missing_prevs` and return a new flag indicating whether the resolved state is partial. Thread that flag around so that it makes it into the event context. Co-authored-by: Richard van der Hoff <1389908+richvdh@users.noreply.github.com>
* Support Implicit TLS for sending emails (#13317)Jan Schär2022-07-251-1/+56
| | | | | | | | | | Previously, TLS could only be used with STARTTLS. Add a new option `force_tls`, where TLS is used from the start. Implicit TLS is recommended over STARTLS, see https://datatracker.ietf.org/doc/html/rfc8314 Fixes #8046. Signed-off-by: Jan Schär <jan@jschaer.ch>
* Remove old empty/redundant slaved stores. (#13349)Nick Mills-Barrett2022-07-212-72/+26
|
* Make DictionaryCache have better expiry properties (#13292)Erik Johnston2022-07-212-9/+36
|
* Add missing types to opentracing. (#13345)Patrick Cloke2022-07-211-9/+21
| | | After this change `synapse.logging` is fully typed.
* Update `get_pdu` to return the original, pristine `EventBase` (#13320)Eric Eastwood2022-07-201-12/+113
| | | | | | | | | | | | Update `get_pdu` to return the untouched, pristine `EventBase` as it was originally seen over federation (no metadata added). Previously, we returned the same `event` reference that we stored in the cache which downstream code modified in place and added metadata like setting it as an `outlier` and essentially poisoned our cache. Now we always return a copy of the `event` so the original can stay pristine in our cache and re-used for the next cache call. Split out from https://github.com/matrix-org/synapse/pull/13205 As discussed at: - https://github.com/matrix-org/synapse/pull/13205#discussion_r918365746 - https://github.com/matrix-org/synapse/pull/13205#discussion_r918366125 Related to https://github.com/matrix-org/synapse/issues/12584. This PR doesn't fix that issue because it hits [`get_event` which exists from the local database before it tries to `get_pdu`](https://github.com/matrix-org/synapse/blob/7864f33e286dec22368dc0b11c06eebb1462a51e/synapse/federation/federation_client.py#L581-L594).
* Validate federation destinations and log an error if server name is invalid. ↵Shay2022-07-201-2/+2
| | | | (#13318)
* Merge remote-tracking branch 'origin/master' into developErik Johnston2022-07-201-0/+85
|\
| * Don't include appservice users when calculating push rules (#13332)Erik Johnston2022-07-201-0/+85
| | | | | | This can cause a lot of extra load on servers with lots of appservice users. Introduced in #13078
* | Rate limit joins per-room (#13276)David Robertson2022-07-196-6/+358
| |
* | Update expected DB query count when creating a room (#13307)Andrew Morgan2022-07-181-2/+2
| |
* | Remove unnecessary `json.dumps` from tests (#13303)Dirk Klimpel2022-07-1712-200/+142
| |
* | Use HTTPStatus constants in place of literals in tests. (#13297)Dirk Klimpel2022-07-158-238/+307
| |
* | Provide more info why we don't have any thumbnails to serve (#13038)Eric Eastwood2022-07-151-8/+62
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Fix https://github.com/matrix-org/synapse/issues/13016 ## New error code and status ### Before Previously, we returned a `404` for `/thumbnail` which isn't even in the spec. ```json { "errcode": "M_NOT_FOUND", "error": "Not found [b'hs1', b'tefQeZhmVxoiBfuFQUKRzJxc']" } ``` ### After What does the spec say? > 400: The request does not make sense to the server, or the server cannot thumbnail the content. For example, the client requested non-integer dimensions or asked for negatively-sized images. > > *-- https://spec.matrix.org/v1.1/client-server-api/#get_matrixmediav3thumbnailservernamemediaid* Now with this PR, we respond with a `400` when we don't have thumbnails to serve and we explain why we might not have any thumbnails. ```json { "errcode": "M_UNKNOWN", "error": "Cannot find any thumbnails for the requested media ([b'example.com', b'12345']). This might mean the media is not a supported_media_format=(image/jpeg, image/jpg, image/webp, image/gif, image/png) or that thumbnailing failed for some other reason. (Dynamic thumbnails are disabled on this server.)", } ``` > Cannot find any thumbnails for the requested media ([b'example.com', b'12345']). This might mean the media is not a supported_media_format=(image/jpeg, image/jpg, image/webp, image/gif, image/png) or that thumbnailing failed for some other reason. (Dynamic thumbnails are disabled on this server.) --- We still respond with a 404 in many other places. But we can iterate on those later and maybe keep some in some specific places after spec updates/clarification: https://github.com/matrix-org/matrix-spec/issues/1122 We can also iterate on the bugs where Synapse doesn't thumbnail when it should in other issues/PRs.
* | Don't pull out the full state when storing state (#13274)Erik Johnston2022-07-152-2/+6
| |
* | Use a real room in the notification rotation tests. (#13260)Patrick Cloke2022-07-151-116/+79
| | | | | | | | Instead of manually inserting fake data. This fixes some issues with having to manually calculate stream orderings and other oddities.
* | Fix a bug which could lead to incorrect state (#13278)Erik Johnston2022-07-151-1/+41
| | | | | | | | | | There are two fixes here: 1. A long-standing bug where we incorrectly calculated `delta_ids`; and 2. A bug introduced in #13267 where we got current state incorrect.
* | Async get event cache prep (#13242)Nick Mills-Barrett2022-07-153-6/+6
| | | | | | | | | | Some experimental prep work to enable external event caching based on #9379 & #12955. Doesn't actually move the cache at all, just lays the groundwork for async implemented caches. Signed off by Nick @ Beeper (@Fizzadar)
* | Federation Sender & Appservice Pusher Stream Optimisations (#13251)Nick Mills-Barrett2022-07-151-8/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | * Replace `get_new_events_for_appservice` with `get_all_new_events_stream` The functions were near identical and this brings the AS worker closer to the way federation senders work which can allow for multiple workers to handle AS traffic. * Pull received TS alongside events when processing the stream This avoids an extra query -per event- when both federation sender and appservice pusher process events.
* | Rip out auth-event reconciliation code (#12943)Richard van der Hoff2022-07-143-154/+5
| | | | | | | | | | | | | | There is a corner in `_check_event_auth` (long known as "the weird corner") where, if we get an event with auth_events which don't match those we were expecting, we attempt to resolve the diffence between our state and the remote's with a state resolution. This isn't specced, and there's general agreement we shouldn't be doing it. However, it turns out that the faster-joins code was relying on it, so we need to introduce something similar (but rather simpler) for that.
* | Don't pull out state in `compute_event_context` for unconflicted state (#13267)Erik Johnston2022-07-141-55/+0
| |
* | Allow rate limiters to passively record actions they cannot limit (#13253)David Robertson2022-07-131-0/+74
| | | | | | Co-authored-by: Patrick Cloke <clokep@users.noreply.github.com>
* | Add support for room version 10 (#13220)Shay2022-07-131-1/+40
| |
* | Optimise room creation event lookups part 2 (#13224)Nick Mills-Barrett2022-07-131-4/+4
| |
* | Fix "add user" admin api error when request contains a "msisdn" threepid ↵Thomas Weston2022-07-131-0/+35
| | | | | | | | | | | | (#13263) Co-authored-by: Thomas Weston <thomas.weston@clearspancloud.com> Co-authored-by: David Robertson <david.m.robertson1@gmail.com>
* | Rename test case method to `add_hashes_and_signatures_from_other_server` ↵David Robertson2022-07-126-18/+13
| | | | | | | | (#13255)
* | Drop support for delegating email validation (#13192)Richard van der Hoff2022-07-121-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * Drop support for delegating email validation Delegating email validation to an IS is insecure (since it allows the owner of the IS to do a password reset on your HS), and has long been deprecated. It will now cause a config error at startup. * Update unit test which checks for email verification Give it an `email` config instead of a threepid delegate * Remove unused method `requestEmailToken` * Simplify config handling for email verification Rather than an enum and a boolean, all we need here is a single bool, which says whether we are or are not doing email verification. * update docs * changelog * upgrade.md: fix typo * update version number this will be in 1.64, not 1.63 * update version number this one too
* | expose whether a room is a space in the Admin API (#13208)andrew do2022-07-121-3/+10
|/
* Don't pull out the full state when calculating push actions (#13078)Erik Johnston2022-07-111-2/+2
|
* Reduce event lookups during room creation by passing known event IDs (#13210)Nick Mills-Barrett2022-07-111-0/+15
| | | | | | | | Inspired by the room batch handler, this uses previous event inserts to pre-populate prev events during room creation, reducing the number of queries required to create a room. Signed off by Nick @ Beeper (@Fizzadar)
* Uniformize spam-checker API, part 5: expand other spam-checker callbacks to ↵David Teller2022-07-113-10/+249
| | | | | | return `Tuple[Codes, dict]` (#13044) Signed-off-by: David Teller <davidt@element.io> Co-authored-by: Brendan Abolivier <babolivier@matrix.org>
* Fix notification count after a highlighted message (#13223)Erik Johnston2022-07-081-0/+7
| | | | | Fixes #13196 Broke by #13005
* Remove obsolete RoomEventsStoreTestCase (#13200)Petr Vaněk2022-07-071-69/+0
| | | | | | | | | | All tests are prefixed with `STALE_` and therefore they are silently skipped. They were moved to `STALE_` in version `v0.5.0` in commit 2fcce3b3c508 - `Remove stale tests`. Tests from `RoomEventsStoreTestCase` class are not used for last 8 years, I believe the best would be to remove them entirely. Signed-off-by: Petr Vaněk <arkamar@atlas.cz>
* Faster room joins: fix race in recalculation of current room state (#13151)Sean Quah2022-07-071-0/+2
| | | | | | | | | | | Bounce recalculation of current state to the correct event persister and move recalculation of current state into the event persistence queue, to avoid concurrent updates to a room's current state. Also give recalculation of a room's current state a real stream ordering. Signed-off-by: Sean Quah <seanq@matrix.org>
* Type `tests.utils` (#13028)David Robertson2022-07-051-44/+92
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * Cast to postgres types when handling postgres db * Remove unused method * Easy annotations * Annotate create_room * Use `ParamSpec` to annotate looping_call * Annotate `default_config` * Track `now` as a float `time_ms` returns an int like the proper Synapse `Clock` * Introduce a `Timer` dataclass * Introduce a Looper type * Suppress checking of a mock * tests.utils is typed * Changelog * Whoops, import ParamSpec from typing_extensions * ditch the psycopg2 casts
* annotate tests.server.FakeChannel (#13136)David Robertson2022-07-046-26/+35
|
* Merge tag 'v1.62.0rc3' into developAndrew Morgan2022-07-041-5/+5
|\ | | | | | | | | | | | | | | | | | | | | Synapse 1.62.0rc3 (2022-07-04) ============================== Bugfixes -------- - Update the version of the [ldap3 plugin](https://github.com/matrix-org/matrix-synapse-ldap3/) included in the `matrixdotorg/synapse` DockerHub images and the Debian packages hosted on `packages.matrix.org` to 0.2.1. This fixes [a bug](https://github.com/matrix-org/matrix-synapse-ldap3/pull/163) with usernames containing uppercase characters. ([\#13156](https://github.com/matrix-org/synapse/issues/13156)) - Fix a bug introduced in Synapse 1.62.0rc1 affecting unread counts for users on small servers. ([\#13168](https://github.com/matrix-org/synapse/issues/13168))
| * Fix stuck notification counts on small servers (#13168)Erik Johnston2022-07-041-5/+5
| |
* | Remove tests/utils.py from mypy's exclude list (#13159)Andrew Morgan2022-07-042-3/+2
| |
* | Skip waiting for full state for incoming events (#13144)Richard van der Hoff2022-07-011-1/+3
| | | | | | | | | | When we receive an event over federation during a faster join, there is no need to wait for full state, since we have a whole reconciliation process designed to take the partial state into account.
* | Merge remote-tracking branch 'origin/release-v1.62' into developPatrick Cloke2022-06-301-7/+5
|\|
| * Fix unread counts on large servers (#13140)Erik Johnston2022-06-301-7/+5
| |
* | More type hints for `synapse.logging` (#13103)Patrick Cloke2022-06-301-1/+1
| | | | | | | | Completes type hints for synapse.logging.scopecontextmanager and (partially) for synapse.logging.opentracing.
* | Implement MSC3827: Filtering of `/publicRooms` by room type (#13031)Šimon Brandner2022-06-292-3/+158
| | | | | | | | Signed-off-by: Šimon Brandner <simon.bra.ag@gmail.com>
* | Improve performance of getting unread counts in rooms (#13119)Erik Johnston2022-06-291-0/+2
|/
* Merge branch 'master' into developAndrew Morgan2022-06-281-0/+17
|\
| * Merge pull request from GHSA-22p3-qrh9-cx32reivilibre2022-06-281-0/+17
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * Make _iterate_over_text easier to read by using simple data structures * Prefer a set of tags to ignore In my tests, it's 4x faster to check for containment in a set of this size * Add a stack size limit to _iterate_over_text * Continue accepting the case where there is no body element * Use an early return instead for None Co-authored-by: Richard van der Hoff <richard@matrix.org>
* | Fix serialization errors when rotating notifications (#13118)Erik Johnston2022-06-281-5/+30
| |
* | Extra type annotations in `test_server` (#13124)David Robertson2022-06-281-37/+44
| |
* | Add Cross-Origin-Resource-Policy header to thumbnail and download media ↵Robert Long2022-06-271-0/+20
| | | | | | | | endpoints (#12944)
* | validate room alias before interacting with the room directory (#13106)santhoshivan232022-06-221-0/+13
| |
* | Fix inconsistencies in event validation (#13088)Richard van der Hoff2022-06-173-5/+96
| |
* | Fix inconsistencies in event validation for `m.room.create` events (#13087)Richard van der Hoff2022-06-171-2/+43
| | | | | | | | | | | | | | | | | | | | * Extend the auth rule checks for `m.room.create` events ... and move them up to the top of the function. Since the no auth_events are allowed for m.room.create events, we may as well get the m.room.create event checks out of the way first. * Add a test for create events with prev_events
* | Add type hints to event push actions tests. (#13099)Patrick Cloke2022-06-171-11/+17
| |
* | Simplify the alias deletion logic as an application service. (#13093)Quentin Gliech2022-06-171-0/+34
| |
* | Improve URL previews for sites with only Twitter card information. (#13056)Patrick Cloke2022-06-161-0/+41
| | | | | | | | | | | | Pull out `twitter:` meta tags when generating a preview and use it to augment any `og:` meta tags. Prefers Open Graph information over Twitter card information.
* | Add custom well-known (#13035)Jacek Kuśnierz2022-06-161-0/+22
| | | | | | Co-authored-by: David Robertson <david.m.robertson1@gmail.com>
* | Move some event auth checks out to a different method (#13065)Richard van der Hoff2022-06-151-54/+113
| | | | | | | | | | | | | | | | | | | | | | | | | | | | * Add auth events to events used in tests * Move some event auth checks out to a different method Some of the event auth checks apply to an event's auth_events, rather than the state at the event - which means they can play no part in state resolution. Move them out to a separate method. * Rename check_auth_rules_for_event Now it only checks the state-dependent auth rules, it needs a better name.
* | Add more tests for room upgrades (#13074)Sean Quah2022-06-151-5/+78
| | | | | | | | Signed-off-by: Sean Quah <seanq@element.io>
* | Change default `sync_response_cache_duration` (#13042)Erik Johnston2022-06-151-1/+1
| |
* | Replace pyjwt with authlib in `org.matrix.login.jwt` (#13011)Hannes Lerchl2022-06-151-21/+23
| |
* | Speed up `get_unread_event_push_actions_by_room` (#13005)Erik Johnston2022-06-153-17/+46
| | | | | | | | | | | | | | | | | | | | | | Fixes #11887 hopefully. The core change here is that `event_push_summary` now holds a summary of counts up until a much more recent point, meaning that the range of rows we need to count in `event_push_actions` is much smaller. This needs two major changes: 1. When we get a receipt we need to recalculate `event_push_summary` rather than just delete it 2. The logic for deleting `event_push_actions` is now divorced from calculating `event_push_summary`. In future it would be good to calculate `event_push_summary` while we persist a new event (it should just be a case of adding one to the relevant rows in `event_push_summary`), as that will further simplify the get counts logic and remove the need for us to periodically update `event_push_summary` in a background job.
* | Fix a long-standing bug which meant that rate limiting was not restrictive ↵reivilibre2022-06-151-11/+40
| | | | | | | | enough in some cases. (#13018)
* | Fix typechecks against twisted trunk (#13061)David Robertson2022-06-152-4/+5
| |
* | Fix `destination_is` errors seen in sentry. (#13041)David Robertson2022-06-143-1/+34
| | | | | | | | | | | | * Rename test_fedclient to match its source file * Require at least one destination to be truthy * Explicitly validate user ID in profile endpoint GETs Co-authored-by: Patrick Cloke <clokep@users.noreply.github.com>
* | Move the "email unsubscribe" resource, refactor the macaroon generator & ↵Quentin Gliech2022-06-145-17/+164
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | simplify the access token verification logic. (#12986) This simplifies the access token verification logic by removing the `rights` parameter which was only ever used for the unsubscribe link in email notifications. The latter has been moved under the `/_synapse` namespace, since it is not a standard API. This also makes the email verification link more secure, by embedding the app_id and pushkey in the macaroon and verifying it. This prevents the user from tampering the query parameters of that unsubscribe link. Macaroon generation is refactored: - Centralised all macaroon generation and verification logic to the `MacaroonGenerator` - Moved to `synapse.utils` - Changed the constructor to require only a `Clock`, hostname, and a secret key (instead of a full `Homeserver`). - Added tests for all methods.
* | Decouple `synapse.api.auth_blocking.AuthBlocking` from ↵Quentin Gliech2022-06-145-26/+44
| | | | | | | | `synapse.api.auth.Auth`. (#13021)
* | Uniformize spam-checker API, part 4: port other spam-checker callbacks to ↵David Teller2022-06-131-5/+170
| | | | | | | | | | return `Union[Allow, Codes]`. (#12857) Co-authored-by: Brendan Abolivier <babolivier@matrix.org>
* | Replace noop background updates with DELETE. (#12954)Patrick Cloke2022-06-131-28/+0
| | | | | | | | Removes the `register_noop_background_update` and deletes the background updates directly in a delta file.
* | Merge branch 'rav/simplify_event_auth_interface' into developRichard van der Hoff2022-06-131-155/+202
|\ \
| * | Remove `room_version` param from `check_auth_rules_for_event`Richard van der Hoff2022-06-121-41/+2
| | | | | | | | | | | | | | | | | | | | | Instead, use the `room_version` property of the event we're checking. The `room_version` was originally added as a parameter somewhere around #4482, but really it's been redundant since #6875 added a `room_version` field to `EventBase`.
| * | EventAuthTestCase: build events for the right room versionRichard van der Hoff2022-06-121-119/+205
| |/ | | | | | | | | | | In practice, when we run the auth rules, all of the events have the right room version. Let's stop building Room V1 events for these tests and use the right version.
* | Stop depending on `room_id` to be returned for children state in the ↵Patrick Cloke2022-06-101-1/+1
| | | | | | | | | | | | | | | | | | | | | | hierarchy response. (#12991) The `room_id` field was removed from MSC2946 before it was accepted. It was initially kept for backwards compatibility and should be removed now that the stable form of the API is used. This change only stops Synapse from validating that it is returned, a future PR will remove returning it as part of the response.
* | Type annotations for `test_v2` (#12985)David Robertson2022-06-091-42/+83
| |
* | Move the (unstable) `dir` parameter for /relations behind an experimental ↵Patrick Cloke2022-06-081-0/+1
| | | | | | | | | | | | flag. (#12984) MSC3715 defines this parameter, but the unstable version of it should be behind an experimental flag.
* | Clean up the test code for client disconnections (#12929)Sean Quah2022-06-075-88/+88
| | | | | | | | | | | | | | * Reword failure message about `await_result=False` * Use `reactor.advance()` instead of `reactor.pump()` * Raise `AssertionError`s ourselves * Un-instance method `_test_disconnect` * Replace `ThreadedMemoryReactorClock` with `MemoryReactorClock`
* | Test cancellation at every `await` during request handling (#12674)Sean Quah2022-06-072-2/+550
| | | | | | | | | | | | * Add tests for `/rooms/<room_id>/members` cancellation. * Add tests for `/rooms/<room_id>/state` cancellation. Signed-off-by: Sean Quah <seanq@element.io>
* | Consolidate the logic of delete_device/delete_devices. (#12970)Patrick Cloke2022-06-071-2/+2
|/ | | | | | | | By always using delete_devices and sometimes passing a list with a single device ID. Previously these methods had gotten out of sync with each other and it seems there's little benefit to the single-device variant.
* Prevent local quarantined media from being claimed by media retention (#12972)Andrew Morgan2022-06-071-13/+96
|
* Remove remaining pieces of groups code. (#12966)Patrick Cloke2022-06-061-2/+0
| | | | | * Remove an unused stream ID generator. * Remove the now unused remote profile cache.
* Reduce state pulled from DB due to sending typing and receipts over ↵Erik Johnston2022-06-062-9/+11
| | | | | federation (#12964) Reducing the amount of state we pull from the DB is useful as fetching state is expensive in terms of DB, CPU and memory.
* Do not break URL previews if an image is unreachable. (#12950)Patrick Cloke2022-06-061-0/+35
| | | | Avoid breaking a URL preview completely if the chosen image 404s or is unreachable for some other reason (e.g. DNS).
* Implement MSC3816, consider the root event for thread participation. (#12766)Patrick Cloke2022-06-061-26/+59
| | | | As opposed to only considering a user to have "participated" if they replied to the thread.
* Reduce the amount of state we pull from the DB (#12811)Erik Johnston2022-06-065-16/+27
|
* Improve URL previews for some pages (#12951)Patrick Cloke2022-06-031-1/+36
| | | | | * Skip `og` and `meta` tags where the value is empty. * Fallback to the favicon if there are no other images. * Ignore tags meant for navigation.
* Wait for lazy join to complete when getting current state (#12872)Erik Johnston2022-06-015-7/+72
|
* Remove remaining bits of groups code. (#12936)Patrick Cloke2022-06-0112-20/+0
| | | | | | * Update worker docs to remove group endpoints. * Removes an unused parameter to `ApplicationService`. * Break dependency between media repo and groups. * Avoid copying `m.room.related_groups` state events during room upgrades.
* Remove direct refeferences to PyNaCl (use signedjson instead). (#12902)Jacek Kuśnierz2022-06-012-13/+6
|
* Add config options for media retention (#12732)Andrew Morgan2022-05-311-0/+238
|
* Rename storage classes (#12913)Erik Johnston2022-05-3122-67/+115
|
* Fix invite notifications for users without pushers (#12840)DeepBlueV7.X2022-05-301-0/+91
| | | | Signed-off-by: Nicolas Werner <nicolas.werner@hotmail.de> Co-authored-by: Brendan Abolivier <github@brendanabolivier.com>
* Mutual rooms: Remove dependency on user directory (#12836)Jonathan de Jong2022-05-301-2/+0
|
* LockStore: fix acquiring a lock via `LockStore.try_acquire_lock` (#12832)Sumner Evans2022-05-301-0/+54
| | | Signed-off-by: Sumner Evans <sumner@beeper.com>
* Add a background job to automatically delete stale devices (#12855)Brendan Abolivier2022-05-271-0/+43
| | | Co-authored-by: Patrick Cloke <clokep@users.noreply.github.com>
* Additional constants for EDU types. (#12884)Patrick Cloke2022-05-2715-55/+81
| | | Instead of hard-coding strings in many places.
* Merge tag 'v1.60.0rc2' into developSean Quah2022-05-271-0/+41
|\ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Synapse 1.60.0rc2 (2022-05-27) ============================== This release of Synapse adds a unique index to the `state_group_edges` table, in order to prevent accidentally introducing duplicate information (for example, because a database backup was restored multiple times). If your Synapse database already has duplicate rows in this table, this could fail with an error and require manual remediation. Additionally, the signature of the `check_event_for_spam` module callback has changed. The previous signature has been deprecated and remains working for now. Module authors should update their modules to use the new signature where possible. See [the upgrade notes](https://github.com/matrix-org/synapse/blob/develop/docs/upgrade.md#upgrading-to-v1600) for more details. Features -------- - Add an option allowing users to use their password to reauthenticate for privileged actions even though password login is disabled. ([\#12883](https://github.com/matrix-org/synapse/issues/12883)) Bugfixes -------- - Explicitly close `ijson` coroutines once we are done with them, instead of leaving the garbage collector to close them. ([\#12875](https://github.com/matrix-org/synapse/issues/12875)) Internal Changes ---------------- - Improve URL previews by not including the content of media tags in the generated description. ([\#12887](https://github.com/matrix-org/synapse/issues/12887))
| * Add an option allowing users to use their password to reauthenticate even ↵reivilibre2022-05-271-0/+41
| | | | | | | | though password authentication is disabled. (#12883)
* | Add storage and module API methods to get monthly active users and their ↵Matt C2022-05-271-0/+83
| | | | | | | | appservices (#12838)
* | Remove backing code for groups/communities (#12558)Patrick Cloke2022-05-262-21/+2
| | | | | | | | Including handlers, configuration code, appservice support, and the GroupID construct.
* | Remove unstable APIs for /hierarchy. (#12851)Patrick Cloke2022-05-261-10/+10
| | | | | | | | Removes the unstable endpoint as well as a duplicated field which was modified during stabilization.
* | Pull out less state when handling gaps mk2 (#12852)Erik Johnston2022-05-263-18/+45
| |
* | Allow bigger responses to `/federation/v1/state` (#12877)Richard van der Hoff2022-05-251-3/+3
| | | | | | | | | | | | | | | | | | | | | | * Refactor HTTP response size limits Rather than passing a separate `max_response_size` down the stack, make it an attribute of the `parser`. * Allow bigger responses on `federation/v1/state` `/state` can return huge responses, so we need to handle that.
* | Fix up `state_store` naming (#12871)Erik Johnston2022-05-251-2/+2
| |
* | Remove user-visible groups/communities code (#12553)Patrick Cloke2022-05-252-145/+1
| | | | | | | | | | | | | | | | | | Makes it so that groups/communities no longer exist from a user-POV. E.g. we remove: * All API endpoints (including Client-Server, Server-Server, and admin). * Documented configuration options (and the experimental flag, which is now unused). * Special handling during room upgrades. * The `groups` section of the `/sync` response.
* | Add authentication to thirdparty bridge APIs (#12746)Will Hunt2022-05-241-0/+102
| | | | | | Co-authored-by: Brendan Abolivier <babolivier@matrix.org>
* | Experimental support for MSC3772 (#12740)Patrick Cloke2022-05-241-3/+81
|/ | | | | | | | | | Implements the following behind an experimental configuration flag: * A new push rule kind for mutually related events. * A new default push rule (`.m.rule.thread_reply`) under an unstable prefix. This is missing part of MSC3772: * The `.m.rule.thread_reply_to_me` push rule, this depends on MSC3664 / #11804.
* Prevent expired events from being filtered out when retention is disabled ↵Brendan Abolivier2022-05-232-8/+35
| | | | | | (#12611) Co-authored-by: Richard van der Hoff <1389908+richvdh@users.noreply.github.com> Co-authored-by: Patrick Cloke <clokep@users.noreply.github.com>
* Add some type hints to tests files (#12833)Dirk Klimpel2022-05-235-15/+18
| | | Co-authored-by: Andrew Morgan <1342360+anoadragon453@users.noreply.github.com>
* Update EventContext `get_current_event_ids` and `get_prev_event_ids` to ↵Shay2022-05-201-1/+1
| | | | accept state filters and update calls where possible (#12791)
* Add a unit test for copying over arbitrary room types when upgrading a room ↵Andrew Morgan2022-05-191-1/+31
| | | | (#12792)
* Lay some foundation work to allow workers to only subscribe to some kinds of ↵reivilibre2022-05-192-12/+115
| | | | messages, reducing replication traffic. (#12672)
* Refactor `resolve_state_groups_for_events` to not pull out full state when ↵Shay2022-05-181-0/+13
| | | | no state resolution happens. (#12775)
* Add some type hints to `event_federation` datastore (#12753)Dirk Klimpel2022-05-181-0/+1
| | | Co-authored-by: David Robertson <david.m.robertson1@gmail.com>
* Discard null-containing strings before updating the user directory (#12762)David Robertson2022-05-181-0/+28
|
* Make handling of federation Authorization header (more) compliant with ↵Hubert Chathi2022-05-181-1/+28
| | | | | | | | | | | | RFC7230 (#12774) The main differences are: - values with delimiters (such as colons) should be quoted, so always quote the origin, since it could contain a colon followed by a port number - should allow more than one space after "X-Matrix" - quoted values with backslash-escaped characters should be unescaped - names should be case insensitive
* Delete events from federation_inbound_events_staging table on purge (#12770)Mathieu Velten2022-05-171-0/+1
|
* Remove code which updates `application_services_state.last_txn` (#12680)Richard van der Hoff2022-05-172-31/+6
| | | | This column is unused as of #12209, so let's stop writing to it.
* Track in memory events using weakrefs (#10533)Erik Johnston2022-05-172-0/+26
|
* Avoid unnecessary copies when filtering private read receipts. (#12711)Šimon Brandner2022-05-161-38/+26
| | | | | | A minor optimization to avoid unnecessary copying/building identical dictionaries when filtering private read receipts. Also clarifies comments and cleans-up some tests.
* Fix room upgrades creating an empty room when auth fails (#12696)Sean Quah2022-05-161-13/+1
| | | | Signed-off-by: Sean Quah <seanq@element.io>
* Consolidate logic for parsing relations. (#12693)Patrick Cloke2022-05-161-2/+6
| | | | | | | | | | | | | Parse the `m.relates_to` event content field (which describes relations) in a single place, this is used during: * Event persistence. * Validation of the Client-Server API. * Fetching bundled aggregations. * Processing of push rules. Each of these separately implement the logic and each made slightly different assumptions about what was valid. Some had minor / potential bugs.
* Add config flags to allow for cache auto-tuning (#12701)Shay2022-05-131-1/+57
|
* Don't create an empty room when checking for MAU limits (#12713)Brendan Abolivier2022-05-131-1/+10
|
* SpamChecker metrics (#12513)Jess Porter2022-05-131-2/+4
| | | | | | | | | * add Measure blocks all over SpamChecker Signed-off-by: jesopo <github@lolnerd.net> * fix test_spam_checker_may_join_room and test_threepid_invite_spamcheck * better changelog entry
* add default_power_level_content_override config option. (#12618)Andy Balaam2022-05-121-0/+258
| | | Co-authored-by: Matthew Hodgson <matthew@matrix.org>
* No longer permit empty body when sending receipts (#12709)David Robertson2022-05-111-26/+4
|
* Complain if a federation endpoint has the `@cancellable` flag (#12705)Sean Quah2022-05-111-0/+2
| | | | | | | | `BaseFederationServlet` wraps its endpoints in a bunch of async code that has not been vetted for compatibility with cancellation. Fail CI if a `@cancellable` flag is applied to a federation endpoint. Signed-off-by: Sean Quah <seanq@element.io>
* Reload cache factors from disk on SIGHUP (#12673)David Robertson2022-05-112-0/+9
|
* Respect the `@cancellable` flag for `ReplicationEndpoint`s (#12700)Sean Quah2022-05-112-0/+119
| | | | | | | | | While `ReplicationEndpoint`s register themselves via `JsonResource`, they pass a method that calls the handler, instead of the handler itself, to `register_paths`. As a result, `JsonResource` will not correctly pick up the `@cancellable` flag and we have to apply it ourselves. Signed-off-by: Sean Quah <seanq@element.io>
* Respect the `@cancellable` flag for `RestServlet`s and ↵Sean Quah2022-05-114-2/+185
| | | | | | | | | | | | | | | `BaseFederationServlet`s (#12699) Both `RestServlet`s and `BaseFederationServlet`s register their handlers with `HttpServer.register_paths` / `JsonResource.register_paths`. Update `JsonResource` to respect the `@cancellable` flag on handlers registered in this way. Although `ReplicationEndpoint` also registers itself using `register_paths`, it does not pass the handler method that would have the `@cancellable` flag directly, and so needs separate handling. Signed-off-by: Sean Quah <seanq@element.io>
* Respect the `@cancellable` flag for `DirectServe{Html,Json}Resource`s (#12698)Sean Quah2022-05-111-2/+109
| | | | | | | | | | | | `DirectServeHtmlResource` and `DirectServeJsonResource` both inherit from `_AsyncResource`. These classes expect to be subclassed with `_async_render_*` methods. This commit has no effect on `JsonResource`, despite inheriting from `_AsyncResource`. `JsonResource` has its own `_async_render` override which will need to be updated separately. Signed-off-by: Sean Quah <seanq@element.io>
* Refactor `EventContext` (#12689)Erik Johnston2022-05-104-3/+10
| | | | | | | | | | Refactor how the `EventContext` class works, with the intention of reducing the amount of state we fetch from the DB during event processing. The idea here is to get rid of the cached `current_state_ids` and `prev_state_ids` that live in the `EventContext`, and instead defer straight to the database (and its caching). One change that may have a noticeable effect is that we now no longer prefill the `get_current_state_ids` cache on a state change. However, that query is relatively light, since its just a case of reading a table from the DB (unlike fetching state at an event which is more heavyweight). For deployments with workers this cache isn't even used. Part of #12684
* Stop writing to `event_reference_hashes` (#12679)Richard van der Hoff2022-05-101-9/+0
| | | | | This table is never read, since #11794. We stop writing to it; in future we can drop it altogether.
* Add helper class for testing request cancellation (#12630)Sean Quah2022-05-103-0/+126
| | | | | | | Also expose the `SynapseRequest` from `FakeChannel` in tests, so that we can call `Request.connectionLost` to simulate a client disconnecting. Signed-off-by: Sean Quah <seanq@element.io>
* Add the `update_user_directory_from_worker` configuration option ↵reivilibre2022-05-101-0/+27
| | | | | (superseding `update_user_directory`) to allow a generic worker to be designated as the worker to update the user directory. (#12654) Co-authored-by: Shay <hillerys@element.io>
* Immediately retry any requests that have backed off when a server comes back ↵Erik Johnston2022-05-101-0/+80
| | | | | online. (#12500) Otherwise it can take up to a minute for any in-flight `/send` requests to be retried.
* Convert stringy power levels to integers on room upgrade (#12657)David Robertson2022-05-072-2/+83
|
* Update mypy to 0.950 and fix complaints (#12650)David Robertson2022-05-061-5/+5
|
* Add the `notify_appservices_from_worker` configuration option (superseding ↵reivilibre2022-05-061-0/+288
| | | | `notify_appservices`) to allow a generic worker to be designated as the worker to send traffic to Application Services. (#12452)
* Support MSC3266 room summaries over federation (#11507)DeepBlueV7.X2022-05-051-0/+26
| | | | Signed-off-by: Nicolas Werner <nicolas.werner@hotmail.de>
* Use `private` instead of `hidden` in MSC2285 related code. (#12635)Šimon Brandner2022-05-052-18/+18
|
* Edits/annotations should not have any bundled aggregations calculated. (#12633)Patrick Cloke2022-05-051-0/+31
| | | | | | Fixes a regression from 8b309adb436c162510ed1402f33b8741d71fc058 (#11660) and b65acead428653b988351ae8d7b22127a22039cd (#11752) where events which themselves were an edit or an annotation could have bundled aggregations calculated, which is not allowed.
* Add `mau_appservice_trial_days` config (#12619)Will Hunt2022-05-041-0/+74
| | | | | | | | | | | | | | | | | | | | | * Add mau_appservice_trial_days * Add a test * Tweaks * changelog * Ensure we sync after the delay * Fix types * Add config statement * Fix test * Reinstate logging that got removed * Fix feature name
* Use `getClientAddress` instead of `getClientIP`. (#12599)Patrick Cloke2022-05-046-26/+33
| | | | | getClientIP was deprecated in Twisted 18.4.0, which also added getClientAddress. The Synapse minimum version for Twisted is currently 18.9.0, so all supported versions have the new API.
* Implement changes to MSC2285 (hidden read receipts) (#12168)Šimon Brandner2022-05-043-79/+449
| | | | | * Changes hidden read receipts to be a separate receipt type (instead of a field on `m.read`). * Updates the `/receipts` endpoint to accept `m.fully_read`.
* Remove unstable/unspecced login types. (#12597)Patrick Cloke2022-05-042-6/+2
| | | | | | * `m.login.jwt`, which was never specced and has been deprecated since Synapse 1.16.0. (`org.matrix.login.jwt` can be used instead.) * `uk.half-shot.msc2778.login.application_service`, which was stabilized as part of the Matrix spec v1.2 release.
* Include bundled aggregations for the latest event in a thread. (#12273)Patrick Cloke2022-05-041-1/+107
| | | | | | The `latest_event` field of the bundled aggregations for `m.thread` relations did not include bundled aggregations itself. This resulted in clients needing to immediately request the event from the server (and thus making it useless that the latest event itself was serialized instead of just including an event ID).
* Add a consistency check on events read from the database (#12620)Richard van der Hoff2022-05-031-22/+37
| | | | | | | I've seen a few errors which can only plausibly be explained by the calculated event id for an event being different from the ID of the event in the database. It should be cheap to check this, so let's do so and raise an exception.
* Remove unstable identifiers for MSC3069. (#12596)Patrick Cloke2022-05-031-6/+0
|
* Use constants for receipt types in tests. (#12582)Šimon Brandner2022-04-283-23/+29
|
* Fix logging of incorrect status codes for disconnected requests (#12580)Sean Quah2022-04-282-2/+26
| | | | | | | | | | | | | | The status code of requests must always be set, regardless of client disconnection, otherwise they will always be logged as 200!. Broken for `respond_with_json` in f48792eec43f893f4f893ffdcbf00f8958b6f6b5. Broken for `respond_with_json_bytes` in 3e58ce72b42f2ae473c1e76a967548cd6fa7e2e6. Broken for `respond_with_html_bytes` in ea26e9a98b0541fc886a1cb826a38352b7599dbe. Signed-off-by: Sean Quah <seanq@element.io>
* Prefer `make_awaitable` over `defer.succeed` in tests (#12505)Sean Quah2022-04-2712-60/+54
| | | | | | | | | | | When configuring the return values of mocks, prefer awaitables from `make_awaitable` over `defer.succeed`. `Deferred`s are only awaitable once, so it is inappropriate for a mock to return the same `Deferred` multiple times. Also update `run_in_background` to support functions that return arbitrary awaitables. Signed-off-by: Sean Quah <seanq@element.io>
* Add a module API to allow modules to edit push rule actions (#12406)Brendan Abolivier2022-04-271-1/+83
| | | Co-authored-by: Richard van der Hoff <1389908+richvdh@users.noreply.github.com>
* Remove unused `# type: ignore`s (#12531)David Robertson2022-04-275-21/+23
| | | | | | | | | | | | | | | | | | | | | | Over time we've begun to use newer versions of mypy, typeshed, stub packages---and of course we've improved our own annotations. This makes some type ignore comments no longer necessary. I have removed them. There was one exception: a module that imports `select.epoll`. The ignore is redundant on Linux, but I've kept it ignored for those of us who work on the source tree using not-Linux. (#11771) I'm more interested in the config line which enforces this. I want unused ignores to be reported, because I think it's useful feedback when annotating to know when you've fixed a problem you had to previously ignore. * Installing extras before typechecking Lacking an easy way to install all extras generically, let's bite the bullet and make install the hand-maintained `all` extra before typechecking. Now that https://github.com/matrix-org/backend-meta/pull/6 is merged to the release/v1 branch.
* Bound ephemeral events by key (#12544)Nick Mills-Barrett2022-04-261-0/+82
| | | | Co-authored-by: Brad Murray <bradtgmurray@gmail.com> Co-authored-by: Andrew Morgan <andrewm@element.io>
* Mark remote device list updates as already handled (#12557)Erik Johnston2022-04-261-1/+1
|
* Handle cancellation in `EventsWorkerStore._get_events_from_cache_or_db` (#12529)Sean Quah2022-04-251-2/+119
| | | | | | | | Multiple calls to `EventsWorkerStore._get_events_from_cache_or_db` can reuse the same database fetch, which is initiated by the first call. Ensure that cancelling the first call doesn't cancel the other calls sharing the same database fetch. Signed-off-by: Sean Quah <seanq@element.io>
* Misc. clean-ups to the relations code (#12519)Patrick Cloke2022-04-251-40/+34
| | | | | * Corrects some typos / copy & paste errors in tests. * Clarifies docstrings. * Removes an unnecessary method.
* Update `delay_cancellation` to accept any awaitable (#12468)Sean Quah2022-04-221-2/+31
| | | | | | | | This will mainly be useful when dealing with module callbacks, which are all typed as returning `Awaitable`s instead of coroutines or `Deferred`s. Signed-off-by: Sean Quah <seanq@element.io>
* Await un-partial-stating after a partial-state join (#12399)Richard van der Hoff2022-04-212-0/+130
| | | | | | When we join a room via the faster-joins mechanism, we end up with "partial state" at some points on the event DAG. Many parts of the codebase need to wait for the full state to load. So, we implement a mechanism to keep track of which events have partial state, and wait for them to be fully-populated.
* Remove unnecessary config overrides for MSC3666. (#12511)Patrick Cloke2022-04-201-4/+0
|
* Fix `/room/.../event/...` to return the *original* event after any edits ↵Richard van der Hoff2022-04-191-30/+62
| | | | | | (#12476) This is what the MSC (now) requires. Fixes https://github.com/matrix-org/synapse/issues/10310.
* Back out implementation of MSC2314 (#12474)Richard van der Hoff2022-04-191-39/+2
| | | | | | | | MSC2314 has now been closed, so we're backing out its implementation, which originally happened in #6176. Unfortunately it's not a direct revert, as that PR mixed in a bunch of unrelated changes to tests etc.
* Only send out device list updates for our own users (#12465)Erik Johnston2022-04-142-4/+45
| | | Broke in #12365
* Limit `device_id` size to 512B (#12454)Shay2022-04-131-1/+26
| | | *
* Prevent a sync request from removing a user's busy presence status (#12213)David Baker2022-04-131-0/+79
| | | | | | | | | | In trying to use the MSC3026 busy presence status, the user's status would be set back to 'online' next time they synced. This change makes it so that syncing does not affect a user's presence status if it is currently set to 'busy': it must be removed through the presence API. The MSC defers to implementations on the behaviour of busy presence, so this ought to remain compatible with the MSC.
* Fix missing sync events during historical batch imports (#12319)Nick Mills-Barrett2022-04-131-2/+123
| | | | | | | | Discovered after much in-depth investigation in #12281. Closes: #12281 Closes: #3305 Signed off by: Nick Mills-Barrett nick@beeper.com
* Process device list updates asynchronously (#12365)Erik Johnston2022-04-122-28/+27
|
* Disable groups/communities by default. (#12344)Patrick Cloke2022-04-121-0/+1
| | | | This disables the endpoints (and sync response fields) for groups/communities by default.
* Remove references to unstable identifiers from MSC3440. (#12382)Patrick Cloke2022-04-121-3/+1
| | | | | Removes references to unstable thread relation, unstable identifiers for filtering parameters, and the experimental config flag.
* Add missing type hints to config classes. (#12402)Patrick Cloke2022-04-112-10/+22
|
* Do not consider events by ignored users for bundled aggregations (#12235)Patrick Cloke2022-04-111-5/+68
| | | | | | | Consider the requester's ignored users when calculating the bundled aggregations. See #12285 / 4df10d32148ae29f792afc68ff774bcbd1915cea for corresponding changes for the `/relations` endpoint.
* Disallow untyped defs in synapse._scripts (#12422)David Robertson2022-04-111-31/+31
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Of note: * No untyped defs in `register_new_matrix_user` This one might be contraversial. `request_registration` has three dependency-injection arguments used for testing. I'm removing the injection of the `requests` module and using `unitest.mock.patch` in the test cases instead. Doing `reveal_type(requests)` and `reveal_type(requests.get)` before the change: ``` synapse/_scripts/register_new_matrix_user.py:45: note: Revealed type is "Any" synapse/_scripts/register_new_matrix_user.py:46: note: Revealed type is "Any" ``` And after: ``` synapse/_scripts/register_new_matrix_user.py:44: note: Revealed type is "types.ModuleType" synapse/_scripts/register_new_matrix_user.py:45: note: Revealed type is "def (url: Union[builtins.str, builtins.bytes], params: Union[Union[_typeshed.SupportsItems[Union[builtins.str, builtins.bytes, builtins.int, builtins.float], Union[builtins.str, builtins.bytes, builtins.int, builtins.float, typing.Iterable[Union[builtins.str, builtins.bytes, builtins.int, builtins.float]], None]], Tuple[Union[builtins.str, builtins.bytes, builtins.int, builtins.float], Union[builtins.str, builtins.bytes, builtins.int, builtins.float, typing.Iterable[Union[builtins.str, builtins.bytes, builtins.int, builtins.float]], None]], typing.Iterable[Tuple[Union[builtins.str, builtins.bytes, builtins.int, builtins.float], Union[builtins.str, builtins.bytes, builtins.int, builtins.float, typing.Iterable[Union[builtins.str, builtins.bytes, builtins.int, builtins.float]], None]]], builtins.str, builtins.bytes], None] =, data: Union[Any, None] =, headers: Union[Any, None] =, cookies: Union[Any, None] =, files: Union[Any, None] =, auth: Union[Any, None] =, timeout: Union[Any, None] =, allow_redirects: builtins.bool =, proxies: Union[Any, None] =, hooks: Union[Any, None] =, stream: Union[Any, None] =, verify: Union[Any, None] =, cert: Union[Any, None] =, json: Union[Any, None] =) -> requests.models.Response" ``` * Drive-by comment in `synapse.storage.types` * No untyped defs in `synapse_port_db` This was by far the most painful. I'm happy to break this up into smaller pieces for review if it's not managable as-is.
* Add Module API for reading and writing global account data. (#12391)reivilibre2022-04-111-0/+157
|
* Optimise `_update_client_ips_batch_txn` to batch together database ↵reivilibre2022-04-081-16/+57
| | | | | operations. (#12252) Co-authored-by: Patrick Cloke <clokep@users.noreply.github.com>
* Update the server notices user profile in room if changed. (#12115)Jorge Florian2022-04-081-0/+92
|