summary refs log tree commit diff
path: root/tests (follow)
Commit message (Collapse)AuthorAgeFilesLines
* 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
|
* Support the v1 endpoint for `/relations`. (#12403)Patrick Cloke2022-04-071-11/+11
| | | | Now that MSC2675 has passed FCP and the implementation is compliant with the final version.
* Generate historic pagination token for `/messages` when no `?from` token ↵Eric Eastwood2022-04-061-1/+3
| | | | provided (#12370)
* Fix edge case where a `Linearizer` could get stuck (#12358)Sean Quah2022-04-051-4/+47
| | | | | | | Just after a task acquires a contended `Linearizer` lock, it sleeps. If the task is cancelled during this sleep, we need to release the lock. Signed-off-by: Sean Quah <seanq@element.io>
* Update docstrings for `ReadWriteLock` tests (#12354)Sean Quah2022-04-051-6/+6
| | | Signed-off-by: Sean Quah <seanq@element.io>
* Refactor and convert `Linearizer` to async (#12357)Sean Quah2022-04-051-2/+2
| | | | | | | | | | | Refactor and convert `Linearizer` to async. This makes a `Linearizer` cancellation bug easier to fix. Also refactor to use an async context manager, which eliminates an unlikely footgun where code that doesn't immediately use the context manager could forget to release the lock. Signed-off-by: Sean Quah <seanq@element.io>
* Convert `Linearizer` tests from `inlineCallbacks` to async (#12353)Sean Quah2022-04-051-91/+133
| | | Signed-off-by: Sean Quah <seanq@element.io>
* Add type hints to some tests files (#12371)Dirk Klimpel2022-04-054-41/+57
|
* Allow specifying the Postgres database's port when running unit tests with ↵reivilibre2022-04-052-0/+12
| | | | Postgres. (#12376)
* Track device list updates per room. (#12321)Erik Johnston2022-04-042-10/+27
| | | | | | | | | | | | | | This is a first step in dealing with #7721. The idea is basically that rather than calculating the full set of users a device list update needs to be sent to up front, we instead simply record the rooms the user was in at the time of the change. This will allow a few things: 1. we can defer calculating the set of remote servers that need to be poked about the change; and 2. during `/sync` and `/keys/changes` we can avoid also avoid calculating users who share rooms with other users, and instead just look at the rooms that have changed. However, care needs to be taken to correctly handle server downgrades. As such this PR writes to both `device_lists_changes_in_room` and the `device_lists_outbound_pokes` table synchronously. In a future release we can then bump the database schema compat version to `69` and then we can assume that the new `device_lists_changes_in_room` exists and is handled. There is a temporary option to disable writing to `device_lists_outbound_pokes` synchronously, allowing us to test the new code path does work (and by implication upgrading to a future release and downgrading to this one will work correctly). Note: Ideally we'd do the calculation of room to servers on a worker (e.g. the background worker), but currently only master can write to the `device_list_outbound_pokes` table.
* Add type hints for `tests/unittest.py`. (#12347)Richard van der Hoff2022-04-0110-47/+96
| | | In particular, add type hints for get_success and friends, which are then helpful in a bunch of places.
* Remove redundant `get_success` calls in test code (#12346)Richard van der Hoff2022-04-0112-121/+73
| | | There are a bunch of places we call get_success on an immediate value, which is unnecessary. Let's rip them out, and remove the redundant functionality in get_success and friends.
* Default to `private` room visibility rather than `public` when a client does ↵reivilibre2022-04-013-6/+11
| | | | not specify one, according to spec. (#12350)
* Use a sequence to generate AS transaction IDs, drop `last_txn` AS state (#12209)Nick Mills-Barrett2022-04-011-69/+2
| | | | | | | | Switching to a sequence means there's no need to track `last_txn` on the AS state table to generate new TXN IDs. This also means that there is no longer contention between the AS scheduler and AS handler on updates to the `application_services_state` table, which will prevent serialization errors during the complete AS txn transaction.
* Move single-use methods out of `TestCase` (#12348)Richard van der Hoff2022-04-013-27/+27
| | | | These methods are only used by a single testcase, so they shouldn't be cluttering up the base `TestCase` class.
* Raise an exception when getting state at an outlier (#12191)Richard van der Hoff2022-04-011-18/+54
| | | | | | It seems like calling `_get_state_group_for_events` for an event where the state is unknown is an error. Accordingly, let's raise an exception rather than silently returning an empty result.
* Optimise `_get_state_after_missing_prev_event`: use `/state` (#12040)Richard van der Hoff2022-04-011-0/+225
| | | If we're missing most of the events in the room state, then we may as well call the /state endpoint, instead of individually requesting each and every event.
* Add a module callback to react to account data changes (#12327)Brendan Abolivier2022-04-011-0/+75
| | | | Co-authored-by: Sean Quah <8349537+squahtx@users.noreply.github.com> Co-authored-by: Andrew Morgan <1342360+anoadragon453@users.noreply.github.com>
* Add set_user_admin function to the module API (#12341)Amanda Graven2022-04-011-0/+14
|
* Move MSC2654 support behind an experimental configuration flag. (#12295)Patrick Cloke2022-03-311-0/+5
| | | To match the current thinking on disabling experimental features by default.
* Handle outliers in `/federation/v1/event` (#12332)Richard van der Hoff2022-03-311-0/+53
| | | | | | | The intention here is to avoid doing state lookups for outliers in `/_matrix/federation/v1/event`. Unfortunately that's expanded into something of a rewrite of `filter_events_for_server`, which ended up trying to do that operation in a couple of places.
* Add a callback to react to 3PID associations (#12302)Brendan Abolivier2022-03-311-0/+41
|
* Ensure the type of URL attributes is always str when matching against ↵Brendan Abolivier2022-03-311-2/+41
| | | | preview blacklist (#12333)
* Remove the unused and unstable `/aggregations` endpoint. (#12293)Patrick Cloke2022-03-301-207/+0
| | | | | | | | | This endpoint was removed from MSC2675 before it was approved. It is currently unspecified (even in any MSCs) and therefore subject to removal. It is not implemented by any known clients. This also changes the bundled aggregation format for `m.annotation`, which previously included pagination tokens for the `/aggregations` endpoint, which are no longer useful.
* Send device list updates to application services (MSC3202) - part 1 (#11881)Andrew Morgan2022-03-303-20/+172
| | | Co-authored-by: Patrick Cloke <clokep@users.noreply.github.com>
* Remove references to "msc2403" (#12165)Andrew Morgan2022-03-302-3/+1
|
* Start application service stream token tracking from 1 (#12193)Andrew Morgan2022-03-301-2/+2
| | | Co-authored-by: Erik Johnston <erik@matrix.org>
* Add a configuration to exclude rooms from sync response (#12310)Brendan Abolivier2022-03-301-0/+62
|
* Fix typechecker problems exposed by signedjson 1.1.2 (#12326)David Robertson2022-03-292-8/+14
|
* Bump `black` and `click` versions (#12320)David Robertson2022-03-292-4/+4
|
* Add restrictions by default to open registration in Synapse (#12091)Shay2022-03-251-2/+20
|
* Always allow the empty string as an avatar_url. (#12261)David Robertson2022-03-252-0/+25
| | | | | Hopefully this fixes #12257. Co-authored-by: Patrick Cloke <clokep@users.noreply.github.com>
* Remove unused test code. (#12291)Patrick Cloke2022-03-241-110/+0
| | | | The `MockHttpResource` and `MockKey` objects were unused since #9396 (74af356baf79de5d719fad6c32b981eedbdd950d).
* Do not consider events by ignored users for relations (#12285)Patrick Cloke2022-03-241-1/+79
| | | | Filter the events returned from `/relations` for the requester's ignored users in a similar way to `/messages` (and `/sync`).
* Optionally include account validity in MSC3720 account status responses (#12266)Brendan Abolivier2022-03-241-1/+57
|
* Refuse to start if DB has an unsafe locale (#12262)Shay2022-03-231-0/+46
|
* Allow registering admin users using the module API (#12250)Nicolas Werner2022-03-231-0/+10
| | | Signed-off-by: Nicolas Werner <n.werner@famedly.com>
* Rename shared_rooms to mutual_rooms (#12036)Jonathan de Jong2022-03-231-15/+15
| | | Co-authored-by: reivilibre <olivier@librepush.net>
* Add type hints to tests files. (#12256)Dirk Klimpel2022-03-214-86/+100
|
* Try to detect borked package installations. (#12244)David Robertson2022-03-181-1/+14
| | | | | | | * Try to detect borked package installations. Fixes #12223. Co-authored-by: Sean Quah <8349537+squahtx@users.noreply.github.com>
* Only fetch thread participation for events with threads. (#12228)Patrick Cloke2022-03-182-244/+285
| | | | | | | | | We fetch the thread summary in two phases: 1. The summary that is shared by all users (count of messages and latest event). 2. Whether the requesting user has participated in the thread. There's no use in attempting step 2 for events which did not return a summary from step 1.
* Add type hints to more tests files. (#12240)Dirk Klimpel2022-03-174-43/+65
|
* Merge branch 'release-v1.55' into developPatrick Cloke2022-03-161-0/+28
|\
| * Fix bundling aggregations if unsigned is not a returned event field. (#12234)Patrick Cloke2022-03-161-0/+28
| | | | | | | | | | | | | | An error occured if a filter was supplied with `event_fields` which did not include `unsigned`. In that case, bundled aggregations are still added as the spec states it is allowed for servers to add additional fields.
* | Handle cancellation in `DatabasePool.runInteraction()` (#12199)Sean Quah2022-03-161-0/+58
| | | | | | | | | | | | | | | | | | | | | | | | To handle cancellation, we ensure that `after_callback`s and `exception_callback`s are always run, since the transaction will complete on another thread regardless of cancellation. We also wait until everything is done before releasing the `CancelledError`, so that logging contexts won't get used after they have been finished. Signed-off-by: Sean Quah <seanq@element.io>
* | Refactor relations tests (#12232)Patrick Cloke2022-03-161-406/+363
| | | | | | | | | | * Moves the relation pagination tests to a separate class. * Move the assertion of the response code into the `_send_relation` helper. * Moves some helpers into the base-class.
* | Clean-up logic for rebasing URLs during URL preview. (#12219)Patrick Cloke2022-03-161-43/+11
| | | | | | | | By using urljoin from the standard library and reducing the number of places URLs are rebased.
* | Use the ignored_users table to test event visibility & sync. (#12225)Patrick Cloke2022-03-151-0/+17
| | | | | | | | | | Instead of fetching the raw account data and re-parsing it. The ignored_users table is a denormalised version of the account data for quick searching.
* | Add tests for database transaction callbacks (#12198)Sean Quah2022-03-151-1/+103
| | | | | | | | Signed-off-by: Sean Quah <seanq@element.io>
* | Add type hints to some tests/handlers files. (#12224)Dirk Klimpel2022-03-155-126/+155
|/
* Add cancellation support to `@cached` and `@cachedList` decorators (#12183)Sean Quah2022-03-141-2/+145
| | | | | | | | These decorators mostly support cancellation already. Add cancellation tests and fix use of finished logging contexts by delaying cancellation, as suggested by @erikjohnston. Signed-off-by: Sean Quah <seanq@element.io>
* Add cancellation support to `ReadWriteLock` (#12120)Sean Quah2022-03-141-58/+337
| | | | | | Also convert `ReadWriteLock` to use async context managers. Signed-off-by: Sean Quah <seanq@element.io>
* Add `delay_cancellation` utility function (#12180)Sean Quah2022-03-141-6/+118
| | | | | | | | | `delay_cancellation` behaves like `stop_cancellation`, except it delays `CancelledError`s until the original `Deferred` resolves. This is handy for unifying cleanup paths and ensuring that uncancelled coroutines don't use finished logcontexts. Signed-off-by: Sean Quah <seanq@element.io>
* Add config settings for background update parameters (#11980)Shay2022-03-113-20/+300
|
* Add an additional HTTP pusher + push rule tests. (#12188)Nick Mills-Barrett2022-03-111-3/+69
| | | And rename the field used for caching from _id to _cache_key.
* Add type hints to `tests/rest`. (#12208)Dirk Klimpel2022-03-113-84/+128
| | | Co-authored-by: Patrick Cloke <clokep@users.noreply.github.com>
* Add some type hints to the tests.handlers module. (#12207)Patrick Cloke2022-03-114-59/+71
|
* Remove unnecessary pass statements. (#12206)Patrick Cloke2022-03-111-1/+0
|
* Retention test: avoid relying on state at purged events (#12202)Richard van der Hoff2022-03-111-12/+17
| | | | This test was relying on poking events which weren't in the database into filter_events_for_client.
* Support stable identifiers for MSC3440: Threading (#12151)Patrick Cloke2022-03-103-27/+18
| | | | The unstable identifiers are still supported if the experimental configuration flag is enabled. The unstable identifiers will be removed in a future release.
* Allow retrieving the relations of a redacted event. (#12130)Patrick Cloke2022-03-101-5/+40
| | | | | | | | | This is allowed per MSC2675, although the original implementation did not allow for it and would return an empty chunk / not bundle aggregations. The main thing to improve is that the various caches get cleared properly when an event is redacted, and that edits must not leak if the original event is redacted (as that would presumably leak something similar to the original event content).
* Rename get_tcp_replication to get_replication_command_handler. (#12192)Patrick Cloke2022-03-104-5/+5
| | | | | | Since the object it returns is a ReplicationCommandHandler. This is clean-up from adding support to Redis where the command handler was added as an additional layer of abstraction from the TCP protocol.
* Remove dead code in `tests/storage/test_database.py` (#12197)Sean Quah2022-03-091-16/+0
| | | Signed-off-by: Sean Quah <seanq@element.io>
* Add third_party module callbacks to check if a user can delete a room and ↵Will Hunt2022-03-091-0/+121
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | deactivate a user (#12028) * Add check_can_deactivate_user * Add check_can_shutdown_rooms * Documentation * callbacks, not functions * Various suggested tweaks * Add tests for test_check_can_shutdown_room and test_check_can_deactivate_user * Update check_can_deactivate_user to not take a Requester * Fix check_can_shutdown_room docs * Renegade and use `by_admin` instead of `admin_user_id` * fix lint * Update docs/modules/third_party_rules_callbacks.md Co-authored-by: Brendan Abolivier <babolivier@matrix.org> * Update docs/modules/third_party_rules_callbacks.md Co-authored-by: Brendan Abolivier <babolivier@matrix.org> * Update docs/modules/third_party_rules_callbacks.md Co-authored-by: Brendan Abolivier <babolivier@matrix.org> * Update docs/modules/third_party_rules_callbacks.md Co-authored-by: Brendan Abolivier <babolivier@matrix.org> Co-authored-by: Brendan Abolivier <babolivier@matrix.org>
* Allow for ignoring some arguments when caching. (#12189)Patrick Cloke2022-03-091-3/+81
| | | | | * `@cached` can now take an `uncached_args` which is an iterable of names to not use in the cache key. * Requires `@cached`, @cachedList` and `@lru_cache` to use keyword arguments for clarity. * Asserts that keyword-only arguments in cached functions are not accepted. (I tested this briefly and I don't believe this works properly.)
* Merge branch 'master' into developOlivier Wilkinson (reivilibre)2022-03-081-0/+19
|\
| * Fix a bug introduced in 1.54.0rc1 which meant that Synapse would refuse to ↵reivilibre2022-03-081-0/+19
| | | | | | | | | | | | | | | | | | | | | | start if pre-release versions of dependencies were installed. (#12177) * Add failing test to characterise the regression #12176 * Permit pre-release versions of specified packages * Newsfile (bugfix) Signed-off-by: Olivier Wilkinson (reivilibre) <oliverw@matrix.org>
* | Do not return allowed_room_ids from /hierarchy response. (#12175)Patrick Cloke2022-03-081-0/+3
| | | | | | | | | | This field is only to be used in the Server-Server API, and not the Client-Server API, but was being leaked when a federation response was used in the /hierarchy API.
* | Fix a bug in background updates wherein background updates are never run ↵Shay2022-03-072-12/+10
| | | | | | | | using the default batch size (#12157)
* | Invalidate caches when an event with a relation is redacted. (#12121)Patrick Cloke2022-03-071-42/+165
| | | | | | | | | | The caches for the target of the relation must be cleared so that the bundled aggregations are re-calculated after the redaction is processed.
* | Merge remote-tracking branch 'origin/release-v1.54' into developRichard van der Hoff2022-03-041-2/+19
|\|
| * Don't impose version checks on dev extras at runtime (#12129)David Robertson2022-03-031-2/+19
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * Fix incorrect argument in test case * Add copyright header * Docstring and __all__ * Exclude dev depenencies * Use changelog from #12088 * Include version in error messages This will hopefully distinguish between the version of the source code and the version of the distribution package that is installed. * Linter script is your friend
* | Add test for `ObservableDeferred`'s cancellation behaviour (#12149)Sean Quah2022-03-041-0/+28
| | | | | | Signed-off-by: Sean Quah <seanq@element.io>
* | Remove backwards compatibility with RelationPaginationToken. (#12138)Patrick Cloke2022-03-041-72/+1
| |
* | Spread out sending device lists to remote hosts (#12132)Erik Johnston2022-03-041-4/+48
| |
* | Update client-visibility filtering for outlier events (#12155)Richard van der Hoff2022-03-041-3/+73
| | | | | | Avoid trying to get the state for outliers, which isn't a sensible thing to do.
* | Rename various ApplicationServices interested methods (#11915)Andrew Morgan2022-03-032-25/+76
| |
* | Add type hints to `tests/rest` (#12146)Dirk Klimpel2022-03-037-86/+102
| | | | | | | | | | | | | | * Add type hints to `tests/rest` * newsfile * change import from `SigningKey`
* | Use the proper serialization format when bundling aggregations. (#12090)Patrick Cloke2022-03-032-3/+4
| | | | | | | | This ensures that the `latest_event` field of the bundled aggregation for threads uses the same format as the other events in the response.
* | Remove unused mocks from `test_typing` (#12136)David Robertson2022-03-021-31/+1
| | | | | | | | | | | | | | | | | | | | | | * Remove unused mocks from `test_typing` It's not clear what these do. `get_user_by_access_token` has the wrong signature, including the return type. Tests all pass without these. I think we should nuke them. * Changelog * Fixup imports
* | Add type hints to `tests/rest/client` (#12108)Dirk Klimpel2022-03-027-346/+422
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * Add type hints to `tests/rest/client` * newsfile * fix imports * add `test_account.py` * Remove one type hint in `test_report_event.py` * change `on_create_room` to `async` * update new functions in `test_third_party_rules.py` * Add `test_filter.py` * add `test_rooms.py` * change to `assertEquals` to `assertEqual` * lint
* | Improve and refactor the tests for relations. (#12113)Patrick Cloke2022-03-021-208/+178
|/ | | | | | * Modernizes code (f-strings, etc.) * Fixes incorrect comments. * Splits the test case into two. * Factors out some duplicated code.
* Back out in-flight state caching changes. (#12126)reivilibre2022-03-021-454/+0
|
* Make get_room_version use cached get_room_version_id. (#11808)lukasdenk2022-03-021-1/+4
|
* Use importlib.metadata to read requirements (#12088)David Robertson2022-03-011-0/+95
| | | | | | | | | | | | | | | | | | * Pull runtime dep checks into their own module * Reimplement `check_requirements` using `importlib` I've tried to make this clearer. We start by working out which of Synapse's requirements we need to be installed here and now. I was surprised that there wasn't an easier way to see which packages were installed by a given extra. I've pulled out the error messages into functions that deal with "is this for an extra or not". And I've rearranged the loop over two different sets of requirements into one loop with a "must be instaled" flag. I hope you agree that this is clearer. * Test cases
* Fix rare error in `ReadWriteLock` when writers complete immediately (#12105)Sean Quah2022-03-011-0/+30
| | | | Signed-off-by: Sean Quah <seanq@element.io>
* Add module callbacks called for reacting to deactivation status change and ↵Brendan Abolivier2022-03-011-2/+217
| | | | profile update (#12062)
* Add `stop_cancellation` utility function (#12106)Sean Quah2022-03-011-0/+45
|
* Order in-flight state group queries in biggest-first order (#11610)reivilibre2022-03-011-1/+103
| | | Co-authored-by: Patrick Cloke <clokep@users.noreply.github.com>
* Faster joins: persist to database (#12012)Richard van der Hoff2022-03-011-27/+32
| | | | | | | | | | | | When we get a partial_state response from send_join, store information in the database about it: * store a record about the room as a whole having partial state, and stash the list of member servers too. * flag the join event itself as having partial state * also, for any new events whose prev-events are partial-stated, note that they will *also* be partial-stated. We don't yet make any attempt to interpret this data, so API calls (and a bunch of other things) are just going to get incorrect data.
* Fix 'Unhandled error in Deferred' (#12089)Richard van der Hoff2022-03-011-5/+5
| | | | | | | | | | | | | * Fix 'Unhandled error in Deferred' Fixes a CRITICAL "Unhandled error in Deferred" log message which happened when a function wrapped with `@cachedList` failed * Minor optimisation to cachedListDescriptor we can avoid re-using `missing`, which saves looking up entries in `deferreds_map`, and means we don't need to copy it. * Improve type annotation on CachedListDescriptor
* Improve exception handling for concurrent execution (#12109)Richard van der Hoff2022-03-011-2/+113
| | | | | | | | | | | | | | | * fix incorrect unwrapFirstError import this was being imported from the wrong place * Refactor `concurrently_execute` to use `yieldable_gather_results` * Improve exception handling in `yieldable_gather_results` Try to avoid swallowing so many stack traces. * mark unwrapFirstError deprecated * changelog
* Add type hints to `tests/rest/client` (#12094)Dirk Klimpel2022-02-283-61/+71
| | | | | | | | | * Add type hints to `tests/rest/client` * update `mypy.ini` * newsfile * add `test_register.py`
* Remove the unstable `/spaces` endpoint. (#12073)Patrick Cloke2022-02-281-117/+2
| | | | | | | | ...and various code supporting it. The /spaces endpoint was from an old version of MSC2946 and included both a Client-Server and Server-Server API. Note that the unstable /hierarchy endpoint (from the final version of MSC2946) is not yet removed.