summary refs log tree commit diff
path: root/tests (follow)
Commit message (Collapse)AuthorAgeFilesLines
* 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.
* Add type hints to `tests/rest/client` (#12084)Dirk Klimpel2022-02-2810-136/+196
|
* Fix `PushRuleEvaluator` and `Filter` to work on frozendicts (#12100)Richard van der Hoff2022-02-282-0/+19
| | | | | | | | | | * Fix `PushRuleEvaluator` to work on frozendicts frozendicts do not (necessarily) inherit from dict, so this needs to handle them correctly. * Fix event filtering for frozen events Looks like this one was introduced by #11194.
* Actually fix bad debug logging rejecting device list & signing key ↵David Robertson2022-02-281-1/+19
| | | | transactions (#12098)
* Replace assertEquals and friends with non-deprecated versions. (#12092)Patrick Cloke2022-02-2861-889/+887
|
* Add type hints to `tests/rest/client` (#12072)Dirk Klimpel2022-02-2410-102/+159
|
* Add support for MSC3202: sending one-time key counts and fallback key usage ↵reivilibre2022-02-243-24/+233
| | | | | states to Application Services. (#11617) Co-authored-by: Erik Johnston <erik@matrix.org>
* Fix non-strings in the `event_search` table (#12037)Sean Quah2022-02-241-2/+115
| | | | | | | Don't attempt to add non-string `value`s to `event_search` and add a background update to clear out bad rows from `event_search` when using sqlite. Signed-off-by: Sean Quah <seanq@element.io>
* Add type hints to `tests/rest/client` (#12066)Dirk Klimpel2022-02-234-119/+148
|
* Remove more references to `get_datastore` (#12067)Richard van der Hoff2022-02-231-1/+3
| | | | | These have snuck in since #12031 was started. Also a couple of other cleanups while we're in the area.
* Remove `HomeServer.get_datastore()` (#12031)Richard van der Hoff2022-02-23103-255/+277
| | | | | | | The presence of this method was confusing, and mostly present for backwards compatibility. Let's get rid of it. Part of #11733
* Implement account status endpoints (MSC3720) (#12001)Brendan Abolivier2022-02-221-4/+200
| | | | | See matrix-org/matrix-doc#3720 Co-authored-by: Sean Quah <8349537+squahtx@users.noreply.github.com>
* Cap the number of in-flight requests for state from a single group (#11608)reivilibre2022-02-221-0/+69
|
* Fix slow performance of `/logout` in some cases where refresh tokens are in ↵reivilibre2022-02-221-2/+91
| | | | use. The slowness existed since the initial implementation of refresh tokens. (#12056)
* Faster joins: Support for calling `/federation/v1/state` (#12013)Richard van der Hoff2022-02-222-0/+170
| | | | This is an endpoint that we have server-side support for, but no client-side support. It's going to be useful for resyncing partial-stated rooms, so let's introduce it.
* Add more tests for in-flight state query duplication. (#12033)reivilibre2022-02-221-21/+171
|
* Track and deduplicate in-flight requests to `_get_state_for_groups`. (#10870)reivilibre2022-02-181-0/+133
| | | Co-authored-by: Patrick Cloke <clokep@users.noreply.github.com>
* Fix bug in `StateFilter.return_expanded()` and add some tests. (#12016)reivilibre2022-02-181-0/+109
|
* Use stable MSC3069 `is_guest` flag on `/whoami`. (#12021)Travis Ralston2022-02-181-3/+6
| | | Keeping backwards compatibility with the unstable flag for now.
* Allow modules to set a display name on registration (#12009)Brendan Abolivier2022-02-171-30/+93
| | | Co-authored-by: Patrick Cloke <clokep@users.noreply.github.com>
* Faster joins: parse msc3706 fields in send_join response (#12011)Richard van der Hoff2022-02-171-0/+32
| | | Part of my work on #11249: add code to handle the new fields added in MSC3706.
* Prevent duplicate push notifications for room reads (#11835)lukasdenk2022-02-171-65/+64
|
* Fix incorrect `get_rooms_for_user` for remote user (#11999)Erik Johnston2022-02-151-0/+107
| | | | | | | When the server leaves a room the `get_rooms_for_user` cache is not correctly invalidated for the remote users in the room. This means that subsequent calls to `get_rooms_for_user` for the remote users would incorrectly include the room (it shouldn't be included because the server no longer knows anything about the room).
* Fix incorrect thread summaries when the latest event is edited. (#11992)Patrick Cloke2022-02-151-0/+42
| | | | | If the latest event in a thread was edited than the original event content was included in bundled aggregation for threads instead of the edited event content.
* Add some tests for propagation of device list changes between local users ↵Andrew Morgan2022-02-152-1/+160
| | | | (#11972)
* Implement MSC3706: partial state in `/send_join` response (#11967)Richard van der Hoff2022-02-122-4/+152
| | | | | | | | | | | | * Make `get_auth_chain_ids` return a Set It has a set internally, and a set is often useful where it gets used, so let's avoid converting to an intermediate list. * Minor refactors in `on_send_join_request` A little bit of non-functional groundwork * Implement MSC3706: partial state in /send_join response
* Support the MSC3715 for `/relations`. (#11941)Patrick Cloke2022-02-111-6/+31
| | | | This adds an unstable org.matrix.msc3715.dir parameter which acts like dir on /mesages.
* Remove deprecated user_may_create_room_with_invites callback (#11950)Brendan Abolivier2022-02-111-117/+2
| | | Co-authored-by: Patrick Cloke <clokep@users.noreply.github.com>
* Fix to-device being dropped in limited sync in SQLite. (#11966)Erik Johnston2022-02-111-0/+40
| | | | | | | | | If ther are more than 100 to-device messages pending for a device `/sync` will only return the first 100, however the next batch token was incorrectly calculated and so all other pending messages would be dropped. This is due to `txn.rowcount` only returning the number of rows that *changed*, rather than the number *selected* in SQLite.
* Adds misc missing type hints (#11953)Patrick Cloke2022-02-111-7/+2
|
* Tests: replace mocked Authenticator with the real thing (#11913)Richard van der Hoff2022-02-116-44/+116
| | | | | | | | | | | | If we prepopulate the test homeserver with a key for a remote homeserver, we can make federation requests to it without having to stub out the authenticator. This has two advantages: * means that what we are testing is closer to reality (ie, we now have complete tests for the incoming-request-authorisation flow) * some tests require that other objects be signed by the remote server (eg, the event in `/send_join`), and doing that would require a whole separate set of mocking out. It's much simpler just to use real keys.
* Support the stable API endpoint for MSC3283: new settings in `/capabilities` ↵Dirk Klimpel2022-02-111-48/+21
| | | | endpoint (#11933)
* Support pagination tokens from /sync and /messages in the relations API. ↵Patrick Cloke2022-02-101-14/+137
| | | | (#11952)
* Implement a content type allow list for URL previews (#11936)Denis Kasak2022-02-101-0/+72
| | | | | | | This implements an allow list for content types for which Synapse will attempt URL preview. If a URL resolves to a resource with a content type which isn't in the list, the download will terminate immediately. This makes sense given that Synapse would never successfully generate a URL preview for such files in the first place, and helps prevent issues with streaming media servers, such as #8302. Signed-off-by: Denis Kasak dkasak@termina.org.uk
* Add missing type hints to synapse.replication. (#11938)Patrick Cloke2022-02-082-3/+7
|
* Experimental support to include bundled aggregations in search results ↵Patrick Cloke2022-02-081-1/+38
| | | | (MSC3666) (#11837)
* Add a callback to allow modules to deny 3PID (#11854)Brendan Abolivier2022-02-081-1/+75
| | | | | Part of the Tchap Synapse mainlining. This allows modules to implement extra logic to figure out whether a given 3PID can be added to the local homeserver. In the Tchap use case, this will allow a Synapse module to interface with the custom endpoint /internal_info.
* Remove optional state of `ApplicationService.is_interested`'s `store` ↵Andrew Morgan2022-02-071-6/+32
| | | | parameter (#11911)
* Add a unit test for users receiving their own device list updates (#11909)Andrew Morgan2022-02-071-1/+56
|
* Stabilise MSC3231 (Token Based Registration) (#11867)Jonathan de Jong2022-02-041-1/+1
|
* Remove support for the webclient listener. (#11895)Patrick Cloke2022-02-031-108/+0
| | | Also remove support for non-HTTP(S) web_client_location.
* Allow specifying the application service-specific `user_id` parameter in the ↵reivilibre2022-02-031-5/+26
| | | | `join` test helper. (#11616)
* Fixes for opentracing scopes (#11869)Richard van der Hoff2022-02-021-0/+184
| | | | | | | | | | | | | | | | | | | | `start_active_span` was inconsistent as to whether it would activate the span immediately, or wait for `scope.__enter__` to happen (it depended on whether the current logcontext already had an associated scope). The inconsistency was rather confusing if you were hoping to set up a couple of separate spans before activating either. Looking at the other implementations of opentracing `ScopeManager`s, the intention is that it *should* be activated immediately, as the name implies. Indeed, the idea is that you don't have to use the scope as a contextmanager at all - you can just call `.close` on the result. Hence, our cleanup has to happen in `.close` rather than `.__exit__`. So, the main change here is to ensure that `start_active_span` does activate the span, and that `scope.close()` does close the scope. We also add some tests, which requires a `tracer` param so that we don't have to rely on the global variable in unit tests.
* Add a background database update to purge account data for deactivated ↵reivilibre2022-02-021-0/+106
| | | | users. (#11655)
* Expose the registered device ID from the `register_appservice_user` test ↵reivilibre2022-02-024-8/+13
| | | | helper. (#11615)
* Convert `ApplicationServiceTestCase` to use `simple_async_mock` (#11880)Andrew Morgan2022-02-011-10/+9
|
* Send to-device messages to application services (#11215)Andrew Morgan2022-02-013-68/+348
| | | Co-authored-by: Richard van der Hoff <1389908+richvdh@users.noreply.github.com>
* Add type hints to `tests/rest/admin` (#11851)Dirk Klimpel2022-01-313-229/+183
|
* Configurable limits on avatars (#11846)Brendan Abolivier2022-01-282-2/+248
| | | | | | Only allow files which file size and content types match configured limits to be set as avatar. Most of the inspiration from the non-test code comes from matrix-org/synapse-dinsic#19
* Add a module callback to set username at registration (#11790)Brendan Abolivier2022-01-261-2/+77
| | | | | | This is in the context of mainlining the Tchap fork of Synapse. Currently in Tchap usernames are derived from the user's email address (extracted from the UIA results, more specifically the m.login.email.identity step). This change also exports the check_username method from the registration handler as part of the module API, so that a module can check if the username it's trying to generate is correct and doesn't conflict with an existing one, and fallback gracefully if not. Co-authored-by: David Robertson <davidr@element.io>
* Improvements to bundling aggregations. (#11815)Patrick Cloke2022-01-261-1/+1
| | | | | | | | | | | This is some odds and ends found during the review of #11791 and while continuing to work in this code: * Return attrs classes instead of dictionaries from some methods to improve type safety. * Call `get_bundled_aggregations` fewer times. * Adds a missing assertion in the tests. * Do not return empty bundled aggregations for an event (preferring to not include the bundle at all, as the docstring states).
* Add a config flag to inhibit `M_USER_IN_USE` during registration (#11743)Brendan Abolivier2022-01-261-0/+41
| | | | | | | This is mostly motivated by the tchap use case, where usernames are automatically generated from the user's email address (in a way that allows figuring out the email address from the username). Therefore, it's an issue if we respond to requests on /register and /register/available with M_USER_IN_USE, because it can potentially leak email addresses (which include the user's real name and place of work). This commit adds a flag to inhibit the M_USER_IN_USE errors that are raised both by /register/available, and when providing a username early into the registration process. This error will still be raised if the user completes the registration process but the username conflicts. This is particularly useful when using modules (https://github.com/matrix-org/synapse/pull/11790 adds a module callback to set the username of users at registration) or SSO, since they can ensure the username is unique. More context is available in the PR that introduced this behaviour to synapse-dinsic: matrix-org/synapse-dinsic#48 - as well as the issue in the matrix-dinsic repo: matrix-org/matrix-dinsic#476
* Add admin API to get a list of federated rooms (#11658)Dirk Klimpel2022-01-251-25/+277
|
* Add admin API to reset connection timeouts for remote server (#11639)Dirk Klimpel2022-01-251-4/+51
| | | * Fix get federation status of destination if no error occured
* Support rendering previews with data: URLs in them (#11767)Patrick Cloke2022-01-243-10/+107
| | | | | Images which are data URLs will no longer break URL previews and will properly be "downloaded" and thumbnailed.
* Merge tag 'v1.51.0rc2' into developAndrew Morgan2022-01-241-6/+24
|\ | | | | | | | | | | | | | | | | | | Synapse 1.51.0rc2 (2022-01-24) ============================== Bugfixes -------- - Fix a bug introduced in Synapse 1.40.0 that caused Synapse to fail to process incoming federation traffic after handling a large amount of events in a v1 room. ([\#11806](https://github.com/matrix-org/synapse/issues/11806))
| * Fix logic for dropping old events in fed queue (#11806)Andrew Morgan2022-01-241-6/+24
| | | | | | | | Co-authored-by: Brendan Abolivier <babolivier@matrix.org> Co-authored-by: Richard van der Hoff <richard@matrix.org>
| * Do not try to serialize raw aggregations dict. (#11791)Patrick Cloke2022-01-211-35/+73
| |
* | Remove account data (including client config, push rules and ignored users) ↵reivilibre2022-01-241-0/+219
| | | | | | | | | | upon user deactivation. (#11621) Co-authored-by: Patrick Cloke <clokep@users.noreply.github.com>
* | Add `state_key` and `rejection_reason` to `events` (#11792)Richard van der Hoff2022-01-211-1/+4
| | | | | | | | ... and start populating them for new events
* | Do not try to serialize raw aggregations dict. (#11791)Patrick Cloke2022-01-211-35/+73
| |
* | Drop unused table `public_room_list_stream`. (#11795)Richard van der Hoff2022-01-211-1/+0
| | | | | | This is a follow-up to #10565.
* | Make the `get_global_account_data_by_type_for_user` cache be a tree-cache ↵reivilibre2022-01-211-2/+2
|/ | | | whose key is prefixed with the user ID (#11788)
* Correctly await on_logged_out callbacks (#11786)Brendan Abolivier2022-01-201-1/+27
|
* Add a regression test for using both webclient and client resources ↵Andrew Morgan2022-01-201-0/+108
| | | | simultaneously (#11765)
* Fix a bug that corrupted the cache of federated space hierarchies (#11775)Sean Quah2022-01-201-2/+90
| | | | `FederationClient.get_room_hierarchy()` caches its return values, so refactor the code to avoid modifying the returned room summary.
* Include whether the requesting user has participated in a thread. (#11577)Patrick Cloke2022-01-181-0/+3
| | | | | | Per updates to MSC3440. This is implement as a separate method since it needs to be cached on a per-user basis, instead of a per-thread basis.
* Make pagination of rooms in admin api stable (#11737)Daniel Sonck2022-01-171-19/+28
| | | | | | | | | | | | | | Always add state.room_id after the configurable ORDER BY. Otherwise, for any sort, certain pages can contain results from other pages. (Especially when sorting by creator, since there may be many rooms by the same creator) * Document different order direction of numerical fields "joined_members", "joined_local_members", "version" and "state_events" are ordered in descending direction by default (dir=f). Added a note in tests to explain the differences in ordering. Signed-off-by: Daniël Sonck <daniel@sonck.nl>
* Merge branch 'release-v1.50' into developOlivier Wilkinson (reivilibre)2022-01-141-1/+159
|\
| * Fix a bug introduced in Synapse v1.50.0rc1 whereby outbound federation could ↵reivilibre2022-01-131-1/+111
| | | | | | | | | | fail because too many EDUs were produced for device updates. (#11730) Co-authored-by: David Robertson <davidr@element.io>
| * Fix a bug introduced in Synapse v1.0.0 whereby device list updates would not ↵reivilibre2022-01-121-1/+49
| | | | | | | | | | be sent to remote homeservers if there were too many to send at once. (#11729) Co-authored-by: Brendan Abolivier <babolivier@matrix.org>
| * Deal with mypy errors w/ type-hinted pynacl 1.5.0 (#11714)David Robertson2022-01-121-1/+7
| | | | | | | | | | | | | | | | | | | | | | | | * Deal with mypy errors w/ type-hinted pynacl 1.5.0 Fixes #11644. I really don't like that we're monkey patching pynacl SignedKey instances with alg and version objects. But I'm too scared to make the changes necessary right now. (Ideally I would replace `signedjson.types.SingingKey` with a runtime class which wraps or inherits from `nacl.signing.SigningKey`.) C.f. https://github.com/matrix-org/python-signedjson/issues/16
* | Remove the 'password_hash' from the Users Admin API endpoint response ↵Andrew Morgan2022-01-141-17/+33
| | | | | | | | dictionary (#11576)
* | Replace uses of simple_insert_many with simple_insert_many_values. (#11742)Patrick Cloke2022-01-132-21/+20
| | | | | | | | This should be (slightly) more efficient and it is simpler to have a single method for inserting multiple values.
* | Include bundled aggregations in the sync response cache. (#11659)Patrick Cloke2022-01-131-5/+5
| |
* | Allow tracking puppeted users for MAU (#11561)Jason Robinson2022-01-121-0/+33
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Currently when puppeting another user, the user doing the puppeting is tracked for client IPs and MAU (if configured). When tracking MAU is important, it becomes necessary to be possible to also track the client IPs and MAU of puppeted users. As an example a client that manages user creation and creation of tokens via the Synapse admin API, passing those tokens for the client to use. This PR adds optional configuration to enable tracking of puppeted users into monthly active users. The default behaviour stays the same. Signed-off-by: Jason Robinson <jasonr@matrix.org>
* | Deal with mypy errors w/ type-hinted pynacl 1.5.0 (#11714)David Robertson2022-01-101-1/+7
| | | | | | | | | | | | | | | | | | | | | | | | * Deal with mypy errors w/ type-hinted pynacl 1.5.0 Fixes #11644. I really don't like that we're monkey patching pynacl SignedKey instances with alg and version objects. But I'm too scared to make the changes necessary right now. (Ideally I would replace `signedjson.types.SingingKey` with a runtime class which wraps or inherits from `nacl.signing.SigningKey`.) C.f. https://github.com/matrix-org/python-signedjson/issues/16
* | Support spaces with > 50 rooms in the /hierarchy endpoint. (#11695)Patrick Cloke2022-01-071-0/+32
| | | | | | | | | | | | | | By returning all of the m.space.child state of the space, not just the first 50. The number of rooms returned is still capped at 50. For the federation API this implies that the requesting server will need to individually query for any other rooms it is not joined to.
* | Optionally use an on-disk sqlite db in tests (#11702)David Robertson2022-01-072-1/+22
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * Optionally use an on-disk sqlite db in tests When debugging a test it is sometimes useful to inspect the state of the DB. This is not easy when the db is in-memory: one cannot attach the sqlite CLI to another process's DB. With this change, if SYNAPSE_TEST_PERSIST_SQLITE_DB is set, we use `_trial_temp/test.db` as our sqlite database. One can then use `sqlite3 _trial_temp/test.db` and query to your heart's content. The DB is destroyed and recreated between different test cases. Co-authored-by: Patrick Cloke <clokep@users.noreply.github.com>
* | Test that bans win a join against a race when computing `/sync` response ↵David Robertson2022-01-072-3/+104
| | | | | | | | (#11701)
* | Bundle aggregations outside of the serialization method. (#11612)Patrick Cloke2022-01-071-1/+1
| | | | | | | | | | | | | | | | This makes the serialization of events synchronous (and it no longer access the database), but we must manually calculate and provide the bundled aggregations. Overall this should cause no change in behavior, but is prep work for other improvements.
* | Remove the /send_relation endpoint. (#11682)Patrick Cloke2022-01-061-13/+13
| | | | | | | | This was removed from MSC2674 before that was approved and is not used by any known clients.
* | Strip unauthorized fields from `unsigned` object in events received over ↵Shay2022-01-061-0/+72
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | federation (#11530) * add some tests to verify we are stripping unauthorized fields out of unsigned * add function to strip unauthorized fields from the unsigned object of event * newsfragment * update newsfragment number * add check to on_send_membership_event * refactor tests * fix lint error * slightly refactor tests and add some comments * slight refactor * refactor tests * fix import error * slight refactor * remove unsigned filtration code from synapse/handlers/federation_event.py * lint * move unsigned filtering code to event base * refactor tests * update newsfragment * requested changes * remove unused retun values
* | Fix get federation status of destination if no error occured (#11593)Dirk Klimpel2022-01-051-18/+57
| |
* | Cache empty responses from `/user/devices` (#11587)David Robertson2022-01-052-2/+98
|/ | | If we've never made a request to a remote homeserver, we should cache the response---even if the response is "this user has no devices".
* Refactor the way we set `outlier` (#11634)Richard van der Hoff2022-01-051-3/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * `_auth_and_persist_outliers`: mark persisted events as outliers Mark any events that get persisted via `_auth_and_persist_outliers` as, well, outliers. Currently this will be a no-op as everything will already be flagged as an outlier, but I'm going to change that. * `process_remote_join`: stop flagging as outlier The events are now flagged as outliers later on, by `_auth_and_persist_outliers`. * `send_join`: remove `outlier=True` The events created here are returned in the result of `send_join` to `FederationHandler.do_invite_join`. From there they are passed into `FederationEventHandler.process_remote_join`, which passes them to `_auth_and_persist_outliers`... which sets the `outlier` flag. * `get_event_auth`: remove `outlier=True` stop flagging the events returned by `get_event_auth` as outliers. This method is only called by `_get_remote_auth_chain_for_event`, which passes the results into `_auth_and_persist_outliers`, which will flag them as outliers. * `_get_remote_auth_chain_for_event`: remove `outlier=True` we pass all the events into `_auth_and_persist_outliers`, which will now flag the events as outliers. * `_check_sigs_and_hash_and_fetch`: remove unused `outlier` parameter This param is now never set to True, so we can remove it. * `_check_sigs_and_hash_and_fetch_one`: remove unused `outlier` param This is no longer set anywhere, so we can remove it. * `get_pdu`: remove unused `outlier` parameter ... and chase it down into `get_pdu_from_destination_raw`. * `event_from_pdu_json`: remove redundant `outlier` param This is never set to `True`, so can be removed. * changelog * update docstring
* Add admin API to get users' account data (#11664)Dirk Klimpel2022-01-051-0/+90
| | | Co-authored-by: reivilibre <olivier@librepush.net>
* Re-apply: Move glob_to_regex and re_word_boundary to matrix-python-common ↵reivilibre2022-01-051-59/+0
| | | | | #11505 (#11687) Co-authored-by: Sean Quah <seanq@element.io>
* Include the topic event in the prejoin state, per MSC3173. (#11666)Patrick Cloke2022-01-041-0/+9
| | | | Invites and knocks will now include the topic in the stripped state send to clients before joining the room.
* Convert all namedtuples to attrs. (#11665)Patrick Cloke2021-12-301-1/+5
| | | To improve type hints throughout the code.
* Fix a type annotation in `test_account_data.py` and remove it from the Mypy ↵reivilibre2021-12-291-2/+2
| | | | | exclusion list. (#11657) Co-authored-by: Patrick Cloke <clokep@users.noreply.github.com>
* Refactor `tests.util.setup_test_homeserver` and ↵reivilibre2021-12-214-185/+194
| | | | `tests.server.setup_test_homeserver`. (#11503)
* Add type hints to event_push_actions. (#11594)Patrick Cloke2021-12-212-8/+11
|
* Improve opentracing support for `ResponseCache` (#11607)Richard van der Hoff2021-12-201-11/+34
| | | This adds some opentracing annotations to ResponseCache, to make it easier to see what's going on; in particular, it adds a link back to the initial trace which is actually doing the work of generating the response.
* Merge remote-tracking branch 'origin/release-v1.49' into developRichard van der Hoff2021-12-201-5/+5
|\
| * Disable aggregation bundling on `/sync` responses (#11583)Richard van der Hoff2021-12-201-5/+5
| | | | | | | | | | | | | | | | | | | | | | * Disable aggregation bundling on `/sync` responses A partial revert of #11478. This turns out to have had a significant CPU impact on initial-sync handling. For now, let's disable it, until we find a more efficient way of achieving this. * Fix tests. Co-authored-by: Patrick Cloke <patrickc@matrix.org>
* | Use mock from standard library (#11588)V024602021-12-201-9/+8
| | | | | | Instead of the backported version.
* | Add type hints to `synapse/tests/rest/admin` (#11590)Dirk Klimpel2021-12-165-57/+70
| |
* | Add experimental support for MSC3202: allowing application services to ↵reivilibre2021-12-151-0/+64
| | | | | | | | masquerade as specific devices. (#11538)
* | Add type hints to `synapse/storage/databases/main/e2e_room_keys.py` (#11549)Sean Quah2021-12-141-1/+3
| |
* | Add missing type hints to `synapse.logging.context` (#11556)Sean Quah2021-12-141-35/+0
| |
* | Add missing type hints to `synapse.appservice` (#11360)Patrick Cloke2021-12-141-8/+3
| |
* | Remove redundant `COALESCE()`s around `COUNT()`s in database queries (#11570)Sean Quah2021-12-141-1/+1
| | | | | | | | | | `COUNT()` never returns `NULL`. A `COUNT(*)` over 0 rows is 0 and a `COUNT(NULL)` is also 0.
* | Move HTML parsing to a separate file for URL previews. (#11566)Patrick Cloke2021-12-132-23/+24
| | | | | | | | | | | | | | * Splits the logic for parsing HTML from the resource handling code. * Fix a circular import in the oEmbed code (which uses the HTML parsing code). * Renames some of the HTML parsing methods to: * Make it clear which methods are "internal" to the module. * Clarify what the methods do.
* | Allow events to be created with no `prev_events` (MSC2716) (#11243)Eric Eastwood2021-12-101-0/+103
| | | | | | | | | | The event still needs to have `auth_events` defined to be valid. Split out from https://github.com/matrix-org/synapse/pull/11114
* | Test to ensure we share the same `state_group` across the whole historical ↵Eric Eastwood2021-12-101-0/+180
| | | | | | | | | | | | | | | | batch (MSC2716) (#11487) Part of MSC2716: https://github.com/matrix-org/matrix-doc/pull/2716 We did some work on making sure the `state_groups` were shared in https://github.com/matrix-org/synapse/pull/10975
* | Ensure emails are canonicalized before fetching associated user. (#11547)Patrick Cloke2021-12-101-1/+2
| | | | | | | | This should fix pushers with an email in non-canonical form is used as the pushkey.
* | Do not allow cross-room relations, per MSC2674. (#11516)Patrick Cloke2021-12-091-0/+115
| |
* | Support unprefixed versions of fallback key property names. (#11541)Hubert Chathi2021-12-091-5/+25
| |
* | Add missing `errcode` to `parse_string` and `parse_boolean` (#11542)Dirk Klimpel2021-12-094-10/+10
| |
* | Clean up `synapse.rest.admin` (#11535)Dirk Klimpel2021-12-081-1/+1
| |
* | Use HTTPStatus constants in place of literals in ↵reivilibre2021-12-081-47/+87
| | | | | | | | `tests.rest.client.test_auth`. (#11520)
* | Send and handle cross-signing messages using the stable prefix. (#10520)Hubert Chathi2021-12-081-2/+3
| |
* | Fix case in `wait_for_background_updates` where `self.store` does not exist ↵Andrew Morgan2021-12-071-7/+4
|/ | | | | | (#11331) Pull the DataStore from the HomeServer instance, which always exists.
* Revert "Move `glob_to_regex` and `re_word_boundary` to ↵Sean Quah2021-12-071-0/+59
| | | | | | `matrix-python-common` (#11505) (#11527) This reverts commit a77c36989785c0d5565ab9a1169f4f88e512ce8a.
* Fix 'delete room' admin api to work on incomplete rooms (#11523)Richard van der Hoff2021-12-071-17/+25
| | | | | If, for some reason, we don't have the create event, we should still be able to purge a room.
* Fix the test breakage introduced by #11435 as a result of concurrent PRs ↵reivilibre2021-12-071-1/+1
| | | | (#11522)
* Stabilise support for MSC2918 refresh tokens as they have now been merged ↵reivilibre2021-12-061-15/+15
| | | | into the Matrix specification. (#11435)
* Save the OIDC session ID (sid) with the device on login (#11482)Quentin Gliech2021-12-064-33/+188
| | | As a step towards allowing back-channel logout for OIDC.
* Add admin API to get some information about federation status (#11407)Dirk Klimpel2021-12-061-0/+456
|
* Include bundled aggregations in /sync and related fixes (#11478)Patrick Cloke2021-12-061-39/+96
| | | | | | | | Due to updates to MSC2675 this includes a few fixes: * Include bundled aggregations for /sync. * Do not include bundled aggregations for /initialSync and /events. * Do not bundle aggregations for state events. * Clarifies comments and variable names.
* Move `glob_to_regex` and `re_word_boundary` to `matrix-python-common` (#11505)Sean Quah2021-12-061-59/+0
|
* Support configuring the lifetime of non-refreshable access tokens separately ↵reivilibre2021-12-032-0/+154
| | | | to refreshable access tokens. (#11445)
* Add type hints to `synapse/tests/rest/admin` (#11501)Dirk Klimpel2021-12-039-225/+256
|
* Revert accidental commits to develop.Olivier Wilkinson (reivilibre)2021-12-034-194/+185
|
* Give `tests.server.setup_test_homeserver` (nominally!) the same behaviourOlivier Wilkinson (reivilibre)2021-12-031-0/+3
| | | | | | | | | | by calling into `make_test_homeserver_synchronous`. The function *could* have been inlined at this point but the function is big enough and it felt fine to leave it as is. At least there isn't a confusing name clash anymore!
* Move `tests.utils.setup_test_homeserver` to `tests.server`Olivier Wilkinson (reivilibre)2021-12-034-177/+188
| | | | | | | It had no users. We have just taken the identity of a previous function but don't provide the same behaviour, so we need to fix this in the next commit...
* Convert one of the `setup_test_homeserver`s to ↵Olivier Wilkinson (reivilibre)2021-12-031-8/+3
| | | | | | | | `make_test_homeserver_synchronous` and pass in the homeserver rather than calling a same-named function to ask for one. Later commits will jiggle things around to make this sensible.
* Clean up tests.storage.test_appservice (#11492)reivilibre2021-12-021-177/+168
|
* Clean up `tests.storage.test_main` to remove use of legacy code. (#11493)reivilibre2021-12-021-17/+10
|
* Clean up `tests.test_visibility` to remove legacy code. (#11495)reivilibre2021-12-021-202/+39
|
* Fix media repository failing when media store path contains symlinks (#11446)Sean Quah2021-12-021-1/+108
|
* Add type annotations to `tests.storage.test_appservice`. (#11488)reivilibre2021-12-021-48/+92
|
* Add a license header and comment. (#11479)Patrick Cloke2021-12-011-0/+15
|
* Don't start Synapse master process if `worker_app` is set (#11416)Shay2021-11-301-0/+31
| | | | | | | | | | | | | | | | | | | | | * Add check to catch syanpse master process starting when workers are configured * add test to verify that starting master process with worker config raises error * newsfragment * specify config.worker.worker_app in check * update test * report specific config option that triggered the error Co-authored-by: reivilibre <oliverw@matrix.org> * clarify error message Co-authored-by: reivilibre <oliverw@matrix.org> Co-authored-by: reivilibre <oliverw@matrix.org>
* Bundle relations of relations into the `/relations` result. (#11284)Patrick Cloke2021-11-301-0/+118
| | | | | Per updates to MSC2675 which now states that bundled aggregations should be included from the `/relations` endpoint.
* Fix `LruCache` corruption bug with a `size_callback` that can return 0 (#11454)Sean Quah2021-11-301-0/+12
| | | | | | | | | | | When all entries in an `LruCache` have a size of 0 according to the provided `size_callback`, and `drop_from_cache` is called on a cache node, the node would be unlinked from the LRU linked list but remain in the cache dictionary. An assertion would be later be tripped due to the inconsistency. Avoid unintentionally calling `__len__` and use a strict `is None` check instead when unwrapping the weak reference.
* Remove unnecessary `json.dumps` from `tests.rest.admin` (#11461)Dirk Klimpel2021-11-301-41/+20
| | | | | The tests helpers automatically convert dictionaries to JSON payloads, no need to do it manually for each test.
* Add missing copyright header. (#11460)Patrick Cloke2021-11-301-0/+14
|
* Convert status codes to `HTTPStatus` in `tests.rest.admin` (#11455)Dirk Klimpel2021-11-3011-557/+886
|
* Support the stable /hierarchy endpoint from MSC2946 (#11329)Patrick Cloke2021-11-291-29/+65
| | | | | | This also makes additional updates where the implementation had drifted from the approved MSC. Unstable endpoints will be removed at a later data.
* Make background updates controllable via a plugin (#11306)Erik Johnston2021-11-296-30/+104
| | | Co-authored-by: Brendan Abolivier <babolivier@matrix.org>
* Fix perspectives requests for multiple keys for the same server (#11440)Richard van der Hoff2021-11-291-0/+71
| | | | | If we tried to request multiple keys for the same server, we would end up dropping some of those requests.
* Add a test case for the SendJoinParser (#11441)David Robertson2021-11-291-0/+50
| | | This would have caught the bug #11438 introduced in #11217 and fixed in #11439.