summary refs log tree commit diff
path: root/synapse (follow)
Commit message (Collapse)AuthorAgeFilesLines
* Disable account related endpoints when using OAuth delegationQuentin Gliech2023-05-307-16/+66
|
* Actually enforce guest + return www-authenticate headerHugh Nimmo-Smith2023-05-303-5/+47
|
* MSC2967: Check access token scope for use as user and add guest supportHugh Nimmo-Smith2023-05-301-10/+20
|
* Use `name` claim as display name when registering users on the fly.Hugh Nimmo-Smith2023-05-301-1/+8
| | | | | This makes is so that the `name` claim got when introspecting the token is used as the display name when registering a user on the fly.
* Record the `sub` claims as an external_idQuentin Gliech2023-05-301-22/+37
|
* Handle the Synapse admin scopeQuentin Gliech2023-05-301-0/+3
|
* Save the scopes in the requesterQuentin Gliech2023-05-302-0/+9
|
* MSC2965: OIDC Provider discovery via well-known documentQuentin Gliech2023-05-301-0/+9
|
* Expose the public keys used for client authentication on an endpointQuentin Gliech2023-05-302-0/+78
|
* Initial MSC3964 support: delegation of auth to OIDC serverQuentin Gliech2023-05-303-1/+260
|
* Make the api.auth.Auth a ProtocolQuentin Gliech2023-05-304-242/+458
|
* Remove unused `FederationServer.__str__` override (#15690)Sean Quah2023-05-301-3/+0
| | | Signed-off-by: Sean Quah <seanq@matrix.org>
* Add Unix socket support for Redis connections (#15644)Jason Little2023-05-264-23/+92
| | | | Adds a new configuration setting to connect to Redis via a Unix socket instead of over TCP. Disabled by default.
* Add `MSC3820opt2` as a known room version (#15678)Travis Ralston2023-05-261-0/+1
|
* Set thread_id column to non-null for ↵Patrick Cloke2023-05-268-223/+291
| | | | | | | | | | | | | | | | event_push_{actions,actions_staging,summary} (#15597) Updates the database schema to require a thread_id (by adding a constraint that the column is non-null) for event_push_actions, event_push_actions_staging, and event_push_actions_summary. For PostgreSQL we add the constraint as NOT VALID, then VALIDATE the constraint a background job to avoid locking the table during an upgrade. Each table is updated as a separate schema delta to avoid deadlocks between them. For SQLite we simply rebuild the table & copy the data.
* Merge branch 'master' into developOlivier Wilkinson (reivilibre)2023-05-261-1/+1
|\
| * Fix a bug introduced in Synapse v1.84.0 where workers do not start up when ↵reivilibre2023-05-261-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | no `instance_map` was provided. (#15672) * Fix #15669: always populate instance map even if it was empty * Fix some tests * Fix more tests * Newsfile Signed-off-by: Olivier Wilkinson (reivilibre) <oliverw@matrix.org> * CI fix: don't forget to update apt repository sources before installing olddeps deps * Add test testing the backwards compatibility --------- Signed-off-by: Olivier Wilkinson (reivilibre) <oliverw@matrix.org>
| * `traceback.format_exception(...)` usage that is compatible with Python 3.7 ↵Eric Eastwood2023-05-161-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | and 3.11 (#15599) * Usage that is compatible with Python 3.8 and 3.11 > Since Python 3.10, instead of passing value and tb, an exception object can be passed as the first argument. If value and tb are provided, the first argument is ignored in order to provide backwards compatibility. > > -- https://docs.python.org/3/library/traceback.html * Add changelog
* | Add MSC3820 (room version 11) option 2 unstable room version. (#15666)Travis Ralston2023-05-261-0/+24
| |
* | Process previously failed backfill events in the background (#15585)Eric Eastwood2023-05-243-9/+119
| | | | | | | | | | | | | | | | | | Process previously failed backfill events in the background because they are bound to fail again and we don't need to waste time holding up the request for something that is bound to fail again. Fix https://github.com/matrix-org/synapse/issues/13623 Follow-up to https://github.com/matrix-org/synapse/issues/13621 and https://github.com/matrix-org/synapse/issues/13622 Part of making `/messages` faster: https://github.com/matrix-org/synapse/issues/13356
* | Add requesting user id parameter to key claim methods in ↵Shay2023-05-244-10/+23
| | | | | | | | `TransportLayerClient` (#15663)
* | Speed up user directory rebuild for users some more... (#15665)Erik Johnston2023-05-241-76/+114
| |
* | Improve type hints for cached decorator. (#15658)Patrick Cloke2023-05-242-3/+5
| | | | | | | | | | The cached decorators always return a Deferred, which was not properly propagated. It was close enough when wrapping coroutines, but failed if a bare function was wrapped.
* | Fix `@trace` not wrapping some state methods that return coroutines ↵Eric Eastwood2023-05-231-7/+8
| | | | | | | | | | | | | | | | | | | | | | correctly (#15647) ``` 2023-05-21 09:30:09,288 - synapse.logging.opentracing - 940 - ERROR - POST-1 - @trace may not have wrapped StateStorageController.get_state_for_groups correctly! The function is not async but returned a coroutine ``` Tracing instrumentation for these functions originally introduced in https://github.com/matrix-org/synapse/pull/15610
* | Consolidate logic to check for deactivated users. (#15634)Patrick Cloke2023-05-234-29/+30
| | | | | | | | | | | | | | This moves the deactivated user check to the method which all login types call. Additionally updates the application service tests to be more realistic by removing invalid tests and fixing server names.
* | Use a custom scheme & the worker name for replication requests. (#15578)Jason Little2023-05-233-19/+34
| | | | | | | | | | | | | | | | All the information needed is already in the `instance_map`, so use that instead of passing the hostname / IP & port manually for each replication request. This consolidates logic for future improvements of using e.g. UNIX sockets for workers.
* | Remove outdated comment in log config (#15648)Andrew Morgan2023-05-221-3/+1
| |
* | Properly parse event_fields in filters (#15607)Patrick Cloke2023-05-222-28/+59
| | | | | | | | | | | | | | | | The event_fields property in filters should use the proper escape rules, namely backslashes can be escaped with an additional backslash. This adds tests (adapted from matrix-js-sdk) and implements the logic to properly split the event_fields strings.
* | Instrument `state` and `state_group` storage related things (tracing) (#15610)Eric Eastwood2023-05-195-0/+62
| | | | | | | | | | Instrument `state` and `state_group` storage related things (tracing) so it's a little more clear where these database transactions are coming from as there is a lot of wires crossing in these functions. Part of `/messages` performance investigation: https://github.com/matrix-org/synapse/issues/13356
* | Trace how many new events from the backfill response we need to process (#15633)Eric Eastwood2023-05-191-0/+5
| | | | | | You can kinda derive this information from how many `_process_pulled_event` spans there are but it would be nice to quickly glance.
* | Remove old R30 because R30v2 supercedes it (#10428)reivilibre2023-05-192-87/+0
| | | | | | | | | | R30v2 has been out since 2021-07-19 (https://github.com/matrix-org/synapse/pull/10332) and we started collecting stats on 2021-08-16. Since it's been over a year now (almost 2 years), this is enough grace period for us to now rip it out.
* | Rename blacklist/whitelist internally. (#15620)Patrick Cloke2023-05-1913-129/+117
| | | | | | | | Avoid renaming configuration settings for now and rename internal code to use blocklist and allowlist instead.
* | Do not allow deactivated users to login with JWT. (#15624)Patrick Cloke2023-05-193-65/+137
| | | | | | | | | | To improve the organization of this code it moves the JWT login checks to a separate handler and then fixes the bug (and a deprecation warning).
* | Remove experimental configuration flags & unstable values for faster joins ↵Patrick Cloke2023-05-194-51/+4
| | | | | | | | | | | | | | (#15625) Synapse will no longer send (or respond to) the unstable flags for faster joins. These were only available behind a configuration flag and handled in parallel with the stable flags.
* | Fix `HomeServer`s leaking during `trial` test runs (#15630)Sean Quah2023-05-191-1/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This change fixes two memory leaks during `trial` test runs. Garbage collection is disabled during each test case and a gen-0 GC is run at the end of each test. However, when the gen-0 GC is run, the `TestCase` object usually still holds references to the `HomeServer` used during the test. As a result, the `HomeServer` gets promoted to gen-1 and then never garbage collected. Fix this by periodically running full GCs. Additionally, fix `HomeServer`s leaking after tests that touch inbound federation due to `FederationRateLimiter`s adding themselves to a global set, by turning the set into a `WeakSet`. Resolves #15622. Signed-off-by: Sean Quah <seanq@matrix.org>
* | Handle missing previous read marker event. (#15464)Nick Mills-Barrett2023-05-182-10/+14
| | | | | | | | | | If the previous read marker is pointing to an event that no longer exists (e.g. due to retention) then assume that the newly given read marker is newer.
* | Update Mutual Rooms (MSC2666) implementation (#15621)Jonathan de Jong2023-05-182-13/+32
| | | | | | | | | | | | | | | | To track changes in MSC2666: - The change from `/mutual_rooms/{user_id}` to `/mutual_rooms?user_id={user_id}`. - The addition of `next_batch_token` (and logic). - Unstable flag now being `uk.half-shot.msc2666.query_mutual_rooms`. - The error code when your own user is requested.
* | Re-type config paths in `ConfigError`s to be `StrSequence`s (#15615)Sean Quah2023-05-187-26/+30
| | | | | | | | | | | | Part of #14809. Signed-off-by: Sean Quah <seanq@matrix.org>
* | Fix error message when `app_service_config_files` validation fails (#15614)Sean Quah2023-05-181-2/+1
| | | | | | | | | | | | | | | | | | | | The second argument of `ConfigError` is a path, passed as an optional `Iterable[str]` and not a `str`. If a string is passed directly, Synapse unhelpfully emits "Error in configuration at a.p.p._.s.e.r.v.i.c.e._.c.o.n.f.i.g._.f.i.l.e.s'" when the config option has the wrong data type. Signed-off-by: Sean Quah <seanq@matrix.org>
* | Add a new admin API to create a new device for a user. (#15611)Quentin Gliech2023-05-171-0/+29
| | | | | | | | This allows an external service (e.g. the matrix-authentication-service) to create devices for users.
* | Apply url_preview_url_blacklist to oEmbed and pre-cached images (#15601)Patrick Cloke2023-05-161-46/+75
| | | | | | | | | | | | | | | | There are two situations which were previously not properly checked: 1. If the requested URL was replaced with an oEmbed URL, then the oEmbed URL was not checked against url_preview_url_blacklist. 2. Follow-up URLs (either via autodiscovery of oEmbed or to pre-cache images) were not checked against url_preview_url_blacklist.
* | Update code to refer to "workers". (#15606)Patrick Cloke2023-05-1610-35/+22
| | | | | | | | A bunch of comments and variables are out of date and use obsolete terms.
* | Add not null constraint to column `full_user_id` of tables `profiles` and ↵Shay2023-05-167-4/+267
| | | | | | | | `user_filters` (#15537)
* | `traceback.format_exception(...)` usage that is compatible with Python 3.7 ↵Eric Eastwood2023-05-161-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | and 3.11 (#15599) * Usage that is compatible with Python 3.8 and 3.11 > Since Python 3.10, instead of passing value and tb, an exception object can be passed as the first argument. If value and tb are provided, the first argument is ignored in order to provide backwards compatibility. > > -- https://docs.python.org/3/library/traceback.html * Add changelog
* | Fix subscriptable type usage in Python <3.9 (#15604)Eric Eastwood2023-05-161-2/+1
|/ | | | | | | | | | | | Fix the following `mypy` errors when running `mypy` with Python 3.7: ``` synapse/storage/controllers/stats.py:58: error: "Counter" is not subscriptable, use "typing.Counter" instead [misc] tests/test_state.py:267: error: "dict" is not subscriptable, use "typing.Dict" instead [misc] ``` Part of https://github.com/matrix-org/synapse/issues/15603 In Python 3.9, `typing` is deprecated and the types are subscriptable (generics) by default, https://peps.python.org/pep-0585/#implementation
* Export `run_as_background_process` from the module API (#15577)Shay2023-05-151-0/+1
|
* Implement MSC3821 to update redaction rules (`third_party_invite.signed`) ↵Patrick Cloke2023-05-152-0/+50
| | | | | | (#15563) Updates the redaction rules to protect enough information that the event can still be properly verified.
* Reject instead of erroring on invalid membership events. (#15564)Patrick Cloke2023-05-151-6/+11
| | | | Instead of resulting in an internal server error for invalid events, return that the event is invalid.
* Implement MSC3389 to protect relations from redaction. (#15565)Patrick Cloke2023-05-152-0/+29
| | | | | | MSC3389 proposes protecting the relation type & parent event ID from redaction. This keeps the relation information intact after redaction which helps with some UX flaws (e.g. deleting an event causes it to no longer be in a thread, which is confusing).
* Add an unstable feature flag for MSC3981 to the /versions endpoint (#15558)Michael Weimann2023-05-151-0/+2
| | | | Signed-off-by: Michael Weimann <michaelw@matrix.org> Co-authored-by: Patrick Cloke <clokep@users.noreply.github.com>
* Declare support for Matrix 1.6 (#15559)Patrick Cloke2023-05-123-1/+22
| | | | | | | Adds logging for key server requests which include a key ID. This is technically in violation of the 1.6 spec, but is the only way to remain backwards compatibly with earlier versions of Synapse (and possibly other homeservers) which *did* include the key ID.
* Revert "Set thread_id column to non-null for ↵Erik Johnston2023-05-126-224/+234
| | | | | event_push_{actions,actions_staging,summary} (#15437)" (#15580) This reverts commit a7b3e9ce65335e452de216cb42b9e724e8f3ad1d.
* Print full startup/initialization error (#15569)Eric Eastwood2023-05-111-1/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | I found the error in the **Before** really vague and obtuse and didn't realize port `5432` corresponded to the Postgres port until searching the codebase. It says to check the logs but that wasn't my first instinct. It's just more obvious if we just print the full thing which gives context of the error type and the traceback to the relevant area of code. #### Before ``` $ poetry run python -m synapse.app.homeserver -c homeserver.yaml ********************************************************************************** Error during initialisation: connection to server at "localhost" (::1), port 5432 failed: Connection refused Is the server running on that host and accepting TCP/IP connections? connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused Is the server running on that host and accepting TCP/IP connections? There may be more information in the logs. ********************************************************************************** ``` #### After ```sh $ poetry run python -m synapse.app.homeserver -c homeserver.yaml ********************************************************************************** Error during initialisation: Traceback (most recent call last): File "/home/eric/Documents/github/element/synapse/synapse/app/homeserver.py", line 352, in setup hs.setup() File "/home/eric/Documents/github/element/synapse/synapse/server.py", line 337, in setup self.datastores = Databases(self.DATASTORE_CLASS, self) File "/home/eric/Documents/github/element/synapse/synapse/storage/databases/__init__.py", line 65, in __init__ with make_conn(database_config, engine, "startup") as db_conn: File "/home/eric/Documents/github/element/synapse/synapse/storage/database.py", line 161, in make_conn native_db_conn = engine.module.connect(**db_params) File "/home/eric/.cache/pypoetry/virtualenvs/matrix-synapse-xCtC9ulO-py3.10/lib/python3.10/site-packages/psycopg2/__init__.py", line 122, in connect conn = _connect(dsn, connection_factory=connection_factory, **kwasync) psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: Connection refused Is the server running on that host and accepting TCP/IP connections? connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused Is the server running on that host and accepting TCP/IP connections? There may be more information in the logs. ********************************************************************************** ```
* Add redis SSL configuration options (#15312)Roel ter Maat2023-05-114-14/+82
| | | | | | | | | | | | | | | | | * Add SSL options to redis config * fix lint issues * Add documentation and changelog file * add missing . at the end of the changelog * Move client context factory to new file * Rename ssl to tls and fix typo * fix lint issues * Added when redis attributes were added
* Remove `worker_replication_*` settings (#15491)Jason Little2023-05-112-28/+66
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * Add master to the instance_map as part of Complement, have ReplicationEndpoint look at instance_map for master. * Fix typo in drive by. * Remove unnecessary worker_replication_* bits from unit tests and add master to instance_map(hopefully in the right place) * Several updates: 1. Switch from master to main for naming the main process in the instance_map. Add useful constants for easier adjustment of names in the future. 2. Add backwards compatibility for worker_replication_* to allow time to transition to new style. Make sure to prioritize declaring main directly on the instance_map. 3. Clean up old comments/commented out code. 4. Adjust unit tests to match with new code. 5. Adjust Complement setup infrastructure to only add main to the instance_map if workers are used and remove now unused options from the worker.yaml template. * Initial Docs upload * Changelog * Missed some commented out code that can go now * Remove TODO comment that no longer holds true. * Fix links in docs * More docs * Remove debug logging * Apply suggestions from code review Co-authored-by: reivilibre <olivier@librepush.net> * Apply suggestions from code review Co-authored-by: reivilibre <olivier@librepush.net> * Update version to latest, include completeish before/after examples in upgrade notes. * Fix up and docs too --------- Co-authored-by: reivilibre <olivier@librepush.net>
* Add an unstable feature flag for MSC3391 to the /versions endpoint (#15562)Andrew Morgan2023-05-111-0/+2
|
* Stabilize MSC2659 support for AS ping endpoint. (#15528)Tulir Asokan2023-05-095-15/+10
|
* HTTP Replication Client (#15470)Jason Little2023-05-094-3/+295
| | | | | | Separate out a HTTP client for replication in preparation for also supporting using UNIX sockets. The major difference from the base class is that this does not use treq to handle HTTP requests.
* Add config option to prevent media downloads from listed domains. (#15197)Travis Ralston2023-05-093-0/+22
| | | | | | | This stops media (and thumbnails) from being accessed from the listed domains. It does not delete any already locally cached media, but will prevent accessing it. Note that admin APIs are unaffected by this change.
* Error if attempting to set m.push_rules account data, per MSC4010. (#15555)Patrick Cloke2023-05-096-34/+93
| | | | | m.push_rules, like m.fully_read, is a special account data type that cannot be set using the normal /account_data endpoint. Return an error instead of allowing data that will not be used to be stored.
* Use account data constants in more places. (#15554)Patrick Cloke2023-05-094-9/+12
|
* Check appservices for devices during a /user/devices query. (#15539)Patrick Cloke2023-05-051-0/+28
| | | | | | | | MSC3984 proxies /keys/query requests to appservices, but servers will can also requests devices / keys from the /user/devices endpoint. The formats are close enough that we can "proxy" that /user/devices to appservices (by calling /keys/query) and then change the format of the returned data before returning it over federation.
* Implement MSC4009 to widen the allowed Matrix ID grammar (#15536)Patrick Cloke2023-05-054-17/+40
| | | | | Behind a configuration flag this adds + to the list of allowed characters in Matrix IDs. The main feature this enables is using full E.164 phone numbers as Matrix IDs.
* Handle `DNSNotImplementedError` in SRV resolver (#15523)Zdziszek2023-05-051-1/+4
| | | Signed-off-by: Zdzichu <zdzichu.rks@protonmail.com>
* Clean up and clarify "Create or modify Account" Admin API documentation (#15544)Andrew Morgan2023-05-054-4/+24
|
* Factor out an `is_mine_server_name` method (#15542)Sean Quah2023-05-0521-34/+49
| | | | | | | | | | | | Add an `is_mine_server_name` method, similar to `is_mine_id`. Ideally we would use this consistently, instead of sometimes comparing against `hs.hostname` and other times reaching into `hs.config.server.server_name`. Also fix a bug in the tests where `hs.hostname` would sometimes differ from `hs.config.server.server_name`. Signed-off-by: Sean Quah <seanq@matrix.org>
* Move ThirdPartyEventRules into module_api/callbacks (#15535)Andrew Morgan2023-05-0416-46/+53
|
* Update the base rules to remove the dont_notify action. (MSC3987) (#15534)Patrick Cloke2023-05-041-0/+2
| | | | | A dont_notify action is a no-op (and coalesce is undefined). These are both considered no-ops by the spec, per MSC3987 and the predefined push rules were updated to remove dont_notify from the list of actions.
* Use oEmbed for YouTube Shorts (#15025)Sandro2023-05-031-0/+13
| | | | | | | | | | | | It seems that YouTube Short previews do not work in some regions, but the oEmbed information for those areas is still valid. This causes YouTube Shorts to always use (only) the oEmbed endpoint which is a minor regression for regions where the URL preview was already working -- some of the additional video metadata is lost. It is not likely that clients are using this today and it is more beneficial to have a limited preview working everywhere than unused metadata in the Open Graph response.
* Merge branch 'release-v1.83' into developSean Quah2023-05-033-26/+12
|\
| * Revert "Reduce the size of the HTTP connection pool for non-pushers" (#15530) v1.83.0rc1Sean Quah2023-05-033-26/+12
| | | | | | | | | | | | | | | | | | #15514 introduced a regression where Synapse would encounter `PartialDownloadError`s when fetching OpenID metadata for certain providers on startup. Due to #8088, this prevents Synapse from starting entirely. Revert the change while we decide what to do about the regression.
* | Speed up deleting of old rows in `event_push_actions` (#15531)Erik Johnston2023-05-031-0/+9
| | | | | | Enforce that we use index scans (rather than seq scans), which we also do for state queries. The reason to enforce this is that we can't correctly get PostgreSQL to understand the distribution of `stream_ordering` depends on `highlight`, and so it always defaults (on matrix.org) to sequential scans.
* | Speed up rebuilding of the user directory for local users (#15529)Erik Johnston2023-05-032-77/+171
| | | | | | The idea here is to batch up the work.
* | Set thread_id column to non-null for ↵Patrick Cloke2023-05-036-234/+224
| | | | | | | | | | | | | | | | | | | | | | | | | | event_push_{actions,actions_staging,summary} (#15437) Updates the database schema to require a thread_id (by adding a constraint that the column is non-null) for event_push_actions, event_push_actions_staging, and event_push_actions_summary. For PostgreSQL we add the constraint as NOT VALID, then VALIDATE the constraint a background job to avoid locking the table during an upgrade. For SQLite we simply rebuild the table & copy the data.
* | Add config option to forget rooms automatically when users leave them (#15224)Sean Quah2023-05-036-47/+237
| | | | | | | | | | This is largely based off the stats and user directory updater code. Signed-off-by: Sean Quah <seanq@matrix.org>
* | Remove references to supporting per-user flag for msc2654 (#15522)Shay2023-05-021-1/+0
| |
* | Allow adding random delay to push (#15516)Erik Johnston2023-05-022-2/+26
|/ | | This is to discourage timing based profiling on the push gateways.
* Reduce the size of the HTTP connection pool for non-pushers. (#15514)Patrick Cloke2023-05-023-12/+26
| | | | | | | | | | | | | | Pushers tend to make many connections to the same HTTP host (e.g. a new event comes in, causes events to be pushed, and then the homeserver connects to the same host many times). Due to this the per-host HTTP connection pool size was increased, but this does not make sense for other SimpleHttpClients. Add a parameter for the connection pool and override it for pushers (making a separate SimpleHttpClient for pushers with the increased configuration). This returns the HTTP connection pool settings to the default Twisted ones for non-pusher HTTP clients.
* Initial implementation of MSC3981: recursive relations API (#15315)Patrick Cloke2023-05-024-18/+65
| | | | | | | | | | | Adds an optional keyword argument to the /relations API which will recurse a limited number of event relationships. This will cause the API to return not just the events related to the parent event, but also events related to those related to the parent event, etc. This is disabled by default behind an experimental configuration flag and is currently implemented using prefixed parameters.
* Add an admin API endpoint to support per-user feature flags (#15344)Shay2023-04-286-0/+226
|
* Add support for claiming multiple OTKs at once. (#15468)Patrick Cloke2023-04-279-74/+251
| | | | | | | MSC3983 provides a way to request multiple OTKs at once from appservices, this extends this concept to the Client-Server API. Note that this will likely be spit out into a separate MSC, but is currently part of MSC3983.
* Add type hints to schema deltas (#15497)Patrick Cloke2023-04-2728-134/+131
| | | | | | | | | | Cleans-up the schema delta files: * Removes no-op functions. * Adds missing type hints to function parameters. * Fixes any issues with type hints. This also renames one (very old) schema delta to avoid a conflict that mypy complains about.
* Check databases/__init__ and main/cache with mypy. (#15496)Patrick Cloke2023-04-272-9/+11
|
* Disable push rule evaluation for rooms excluded from sync (#15361)mcalinghee2023-04-271-0/+1
| | | | | | | | * no push for excluded room from sync * add changelog Signed-off-by: Maghen Calinghee <maghen.calinghee@beta.gouv.fr> * correct changelog
* Add column `full_user_id` to tables `profiles` and `user_filters`. (#15458)Shay2023-04-2610-30/+129
|
* Add a module API to send an HTTP push notification (#15387)Mathieu Velten2023-04-262-77/+159
| | | Co-authored-by: Patrick Cloke <clokep@users.noreply.github.com>
* Add admin endpoint to query room sizes (#15482)Erik Johnston2023-04-264-1/+145
|
* Add unstable /keys/claim endpoint which always returns fallback keys. (#15462)Patrick Cloke2023-04-257-23/+135
| | | | | | | | | | | | | It can be useful to always return the fallback key when attempting to claim keys. This adds an unstable endpoint for `/keys/claim` which always returns fallback keys in addition to one-time-keys. The fallback key(s) are not marked as "used" unless there are no corresponding OTKs. This is currently defined in MSC3983 (although likely to be split out to a separate MSC). The endpoint shape may change or be requested differently (i.e. a keyword parameter on the current endpoint), but the core logic should be reasonable.
* Re re introduce membership tables event stream ordering (#15356)Nick Mills-Barrett2023-04-256-12/+162
|
* Experimental support for MSC3970: per-device transaction IDs (#15318)Quentin Gliech2023-04-2510-48/+264
|
* Finish type hints for federation client HTTP code. (#15465)Patrick Cloke2023-04-243-28/+73
|
* Remove legacy code of single user device resync api (#15418)Alok Kumar Singh2023-04-214-121/+22
| | | | | * Removed single-user resync usage and updated it to use multi-user counterpart Signed-off-by: Alok Kumar Singh alokaks601@gmail.com
* Modify StoreKeyFetcher to read from server_keys_json. (#15417)Patrick Cloke2023-04-203-28/+103
| | | | | | | | | | | | | | | | | | | | | | | | | | | Before this change: * `PerspectivesKeyFetcher` and `ServerKeyFetcher` write to `server_keys_json`. * `PerspectivesKeyFetcher` also writes to `server_signature_keys`. * `StoreKeyFetcher` reads from `server_signature_keys`. After this change: * `PerspectivesKeyFetcher` and `ServerKeyFetcher` write to `server_keys_json`. * `PerspectivesKeyFetcher` also writes to `server_signature_keys`. * `StoreKeyFetcher` reads from `server_keys_json`. This results in `StoreKeyFetcher` now using the results from `ServerKeyFetcher` in addition to those from `PerspectivesKeyFetcher`, i.e. keys which are directly fetched from a server will now be pulled from the database instead of refetched. An additional minor change is included to avoid creating a `PerspectivesKeyFetcher` (and checking it) if no `trusted_key_servers` are configured. The overall impact of this should be better usage of cached results: * If a server has no trusted key servers configured then it should reduce how often keys are fetched. * if a server's trusted key server does not have a requested server's keys cached then it should reduce how often keys are directly fetched.
* Move Spam Checker callbacks to a dedicated file (#15453)Andrew Morgan2023-04-1815-63/+84
|
* Switch `InstanceLocationConfig` to a pydantic `BaseModel` (#15431)Jason Little2023-04-172-10/+70
| | | | | * Switch InstanceLocationConfig to a pydantic BaseModel, apply Strict* types and add a few helper methods(that will make more sense in follow up work). Co-authored-by: David Robertson <davidr@element.io>
* Refactor `SimpleHttpClient` to pull out reusable methods (#15427)Jason Little2023-04-141-56/+76
| | | | Pulls out some methods to `BaseHttpClient` to eventually be reused in other contexts.
* More precise type for LoggingTransaction.execute (#15432)David Robertson2023-04-143-14/+31
| | | | | | * More precise type for LoggingTransaction.execute * Add an annotation for stream_ordering_month_ago This would have spotted the error that was fixed in "Add comma missing from #15382. (#15429)"
* Disable directory listing for `StaticResource` (#15438)Dirk Klimpel2023-04-141-0/+10
|
* Load `/capabilities` endpoint on workers (#15436)Dirk Klimpel2023-04-142-1/+2
|
* User directory background update speedup (#15435)Erik Johnston2023-04-141-45/+44
| | | | | | | c.f. #15264 The two changes are: 1. Add indexes so that the select / deletes don't do sequential scans 2. Don't repeatedly call `SELECT count(*)` each iteration, as that's slow
* Delete pushers after calling on_logged_out module hook on device delete (#15410)Mathieu Velten2023-04-141-2/+4
|
* Load `/directory/room/{roomAlias}` endpoint on workers (#15333)Dirk Klimpel2023-04-143-6/+9
| | | | | | | | | * Enable `directory` * move to worker store * newsfile * disable `ClientDirectoryListServer` and `ClientAppserviceDirectoryListServer` for workers
* Remove registration fallback code. (#15405)Patrick Cloke2023-04-139-227/+16
| | | | | | The registration fallback is broken and unspecced. This removes it since there is no plan to spec it. Note that this does not modify the login fallback code.
* Improve robustness when handling a perspective key response by deduplicating ↵reivilibre2023-04-132-7/+25
| | | | | | | | | | | | | | | received server keys. (#15423) * Change `store_server_verify_keys` to take a `Mapping[(str, str), FKR]` This is because we already can't handle duplicate keys — leads to cardinality violation * Newsfile Signed-off-by: Olivier Wilkinson (reivilibre) <oliverw@matrix.org> --------- Signed-off-by: Olivier Wilkinson (reivilibre) <oliverw@matrix.org>
* Add comma missing from #15382. (#15429)reivilibre2023-04-131-1/+1
| | | | | | | | | | | * Add missing comma * Newsfile Signed-off-by: Olivier Wilkinson (reivilibre) <oliverw@matrix.org> --------- Signed-off-by: Olivier Wilkinson (reivilibre) <oliverw@matrix.org>
* Implement MSC2174: move redacts to a content property. (#15395)Patrick Cloke2023-04-135-13/+39
| | | | | | | This moves `redacts` from being a top-level property to a `content` property in a new room version. MSC2176 (which was previously implemented) states to not `redact` this property.
* Only load the SSO redirect servlet if SSO is enabled. (#15421)Dirk Klimpel2023-04-131-1/+6
|
* Disable loading `RefreshTokenServlet` on workers (#15428)Dirk Klimpel2023-04-131-1/+4
|
* Throw if the appservice config list is the wrong type (#15425)Will Hunt2023-04-121-4/+10
| | | | | | | | | | | * raise a ConfigError on an invalid app_service_config_files * changelog * Move config check to read_config * Add test * Ensure list also contains strings
* Implement MSC2175: remove the creator field from create events. (#15394)Patrick Cloke2023-04-067-24/+71
|
* Don't keep old stream_ordering_to_exterm around (#15382)Erik Johnston2023-04-062-10/+52
|
* Merge remote-tracking branch 'origin/release-v1.81' into developPatrick Cloke2023-04-061-1/+1
|\
| * Fix the 'set_device_id_for_pushers_txn' background update. (#15391)Quentin Gliech2023-04-051-1/+1
| | | | | | | | Refer to the correct field from the response when updating the background update progress.
* | Implement MSC3989 to redact the origin field. (#15393)Patrick Cloke2023-04-052-1/+41
| | | | | | | | This will be done in a future room version, for now an unstable room version is added which redacts the origin field.
* | Delete server-side backup keys when deactivating an account. (#15181)Shay2023-04-044-3/+133
|/
* Speed up membership queries for users with forgotten rooms (#15385)Erik Johnston2023-04-042-1/+30
|
* Fix a rare bug where initial /syncs would fail (#15383)Sean Quah2023-04-041-5/+19
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This change fixes a rare bug where initial /syncs would fail with a `KeyError` under the following circumstances: 1. A user fast joins a remote room. 2. The user is kicked from the room before the room's full state has been synced. 3. A second local user fast joins the room. 4. Events are backfilled into the room with a higher topological ordering than the original user's leave. They are assigned a negative stream ordering. It's not clear how backfill happened here, since it is expected to be equivalent to syncing the full state. 5. The second local user leaves the room before the room's full state has been synced. The homeserver does not complete the sync. 6. The original user performs an initial /sync with lazy_load_members enabled. * Because they were kicked from the room, the room is included in the /sync response even though the include_leave option is not specified. * To populate the room's timeline, `_load_filtered_recents` / `get_recent_events_for_room` fetches events with a lower stream ordering than the leave event and picks the ones with the highest topological orderings (which are most recent). This captures the backfilled events after the leave, since they have a negative stream ordering. These events are filtered out of the timeline, since the user was not in the room at the time and cannot view them. The sync code ends up with an empty timeline for the room that notably does not include the user's leave event. This seems buggy, but at least we don't disclose events the user isn't allowed to see. * Normally, `compute_state_delta` would fetch the state at the start and end of the room's timeline to generate the sync response. Since the timeline is empty, it fetches the state at `min(now, last event in the room)`, which corresponds with the second user's leave. The state during the entirety of the second user's membership does not include the membership for the first user because of partial state. This part is also questionable, since we are fetching state from outside the bounds of the user's membership. * `compute_state_delta` then tries and fails to find the user's membership in the auth events of timeline events. Because there is no timeline event whose auth events are expected to contain the user's membership, a `KeyError` is raised. Also contains a drive-by fix for a separate unlikely race condition. Signed-off-by: Sean Quah <seanq@matrix.org>
* Call appservices on modern paths, falling back to legacy paths. (#15317)Patrick Cloke2023-04-032-46/+100
| | | | | This uses the specced /_matrix/app/v1/... paths instead of the "legacy" paths. If the homeserver receives an error it will retry using the legacy path.
* Experimental Unix socket support (#15353)Jason Little2023-04-037-90/+238
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * Add IReactorUNIX to ISynapseReactor type hint. * Create listen_unix(). Two options, 'path' to the file and 'mode' of permissions(not umask, recommend 666 as default as nginx/other reverse proxies write to it and it's setup as user www-data) For the moment, leave the option to always create a PID lockfile turned on by default * Create UnixListenerConfig and wire it up. Rename ListenerConfig to TCPListenerConfig, then Union them together into ListenerConfig. This spidered around a bit, but I think I got it all. Metrics and manhole have been placed behind a conditional in case of accidental putting them onto a unix socket. Use new helpers to get if a listener is configured for TLS, and to help create a site tag for logging. There are 2 TODO things in parse_listener_def() to finish up at a later point. * Refactor SynapseRequest to handle logging correctly when using a unix socket. This prevents an exception when an IP address can not be retrieved for a request. * Make the 'Synapse now listening on Unix socket' log line a little prettier. * No silent failures on generic workers when trying to use a unix socket with metrics or manhole. * Inline variables in app/_base.py * Update docstring for listen_unix() to remove reference to a hardcoded permission of 0o666 and add a few comments saying where the default IS declared. * Disallow both a unix socket and a ip/port combo on the same listener resource * Linting * Changelog * review: simplify how listen_unix returns(and get rid of a type: ignore) * review: fix typo from ConfigError in app/homeserver.py * review: roll conditional for http_options.tag into get_site_tag() helper(and add docstring) * review: enhance the conditionals for checking if a port or path is valid, remove a TODO line * review: Try updating comment in get_client_ip_if_available to clarify what is being retrieved and why * Pretty up how 'Synapse now listening on Unix Socket' looks by decoding the byte string. * review: In parse_listener_def(), raise ConfigError if neither socket_path nor port is declared(and fix a typo)
* Fix copyright year in SSO footer template (#15358)Jason Robinson2023-03-311-2/+2
|
* Revert pruning of old devices (#15360)Erik Johnston2023-03-313-133/+4
| | | | | | | | | * Revert "Fix registering a device on an account with lots of devices (#15348)" This reverts commit f0d8f66eaaacfa75bed65bc5d0c602fbc5339c85. * Revert "Delete stale non-e2e devices for users, take 3 (#15183)" This reverts commit 78cdb72cd6b0e007c314d9fed9f629dfc5b937a6.
* Revert "Set thread_id column to non-null for ↵Olivier Wilkinson (reivilibre)2023-03-315-153/+243
| | | | | | | | event_push_{actions,actions_staging,summary} (#15350)" This reverts commit 2a234b788e2b5706ee83cf8eb86dfd004bc7c166. See #15359 for context.
* Set thread_id column to non-null for ↵Patrick Cloke2023-03-305-243/+153
| | | | | | | | | | | event_push_{actions,actions_staging,summary} (#15350) Clean-up from adding the thread_id column, which was initially null but backfilled with values. It is desirable to require it to now be non-null. In addition to altering this column to be non-null, we clean up obsolete background jobs, indexes, and just-in-time updating code.
* to_device updates could be dropped when consuming the replication stream ↵Mathieu Velten2023-03-301-10/+4
| | | | | (#15349) Co-authored-by: reivilibre <oliverw@matrix.org>
* Speed up SQLite unit test CI (#15334)Erik Johnston2023-03-301-1/+16
| | | Tests now take 40% of the time.
* Implement MSC3984 to proxy /keys/query requests to appservices. (#15321)Patrick Cloke2023-03-306-46/+176
| | | | | If enabled, for users which are exclusively owned by an application service then the appservice will be queried for devices in addition to any information stored in the Synapse database.
* Fix spinloop during partial state sync when a prev event is in backoff (#15351)Sean Quah2023-03-304-43/+69
| | | | | | | | Previously, we would spin in a tight loop until `update_state_for_partial_state_event` stopped raising `FederationPullAttemptBackoffError`s. Replace the spinloop with a wait until the backoff period has expired. Signed-off-by: Sean Quah <seanq@matrix.org>
* Add the ability to enable/disable registrations when in the OIDC flow (#14978)Warren Bailey2023-03-303-2/+21
| | | Signed-off-by: Warren Bailey <warren@warrenbailey.net>
* Add some clarification to the doc/comments regarding TCP replication (#15354)Mathieu Velten2023-03-302-32/+3
|
* Fix missing app variable in mail subject for password resets (#15352)Cyberes2023-03-301-1/+1
| | | | | | | | | | | | | * Update mailer.py Fix `KeyError: 'app'` * Create 15352.bugfix Signed-off-by: Cyberes <cyberes@evulid.cc> --------- Signed-off-by: Cyberes <cyberes@evulid.cc>
* Fix registering a device on an account with lots of devices (#15348)Erik Johnston2023-03-292-3/+8
| | | Fixes up #15183
* Revert "Reintroduce membership tables event stream ordering (#15128)" (#15347)Erik Johnston2023-03-295-130/+12
| | | This reverts commit e6af49fbea939d9e69ed05e0a0ced5948c722ea4.
* Delete stale non-e2e devices for users, take 3 (#15183)Erik Johnston2023-03-293-4/+128
| | | | | This should help reduce the number of devices e.g. simple bots the repeatedly login rack up. We only delete non-e2e devices as they should be safe to delete, whereas if we delete e2e devices for a user we may accidentally break their ability to receive e2e keys for a message.
* Fix joining rooms you have been unbanned from (#15323)DeepBlueV7.X2023-03-292-53/+58
| | | | | | | | | | | | | | | | | | | | | | | * Fix joining rooms you have been unbanned from Since forever synapse did not allow you to join a room after you have been unbanned from it over federation. This was not actually because of the unban event not federating. Synapse simply used outdated state to validate the join transition. This skips the validation if we are not in the room and for that reason won't have the current room state. Fixes #1563 Signed-off-by: Nicolas Werner <nicolas.werner@hotmail.de> * Add changelog Signed-off-by: Nicolas Werner <nicolas.werner@hotmail.de> * Update changelog.d/15323.bugfix --------- Signed-off-by: Nicolas Werner <nicolas.werner@hotmail.de>
* Implement MSC3983 to proxy /keys/claim queries to appservices. (#15314)Patrick Cloke2023-03-286-28/+220
| | | | | | Experimental support for MSC3983 is behind a configuration flag. If enabled, for users which are exclusively owned by an application service then the appservice will be queried for one-time keys *if* there are none uploaded to Synapse.
* Bump ruff from 0.0.252 to 0.0.259 (#15328)dependabot[bot]2023-03-287-12/+24
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | * Bump ruff from 0.0.252 to 0.0.259 Bumps [ruff](https://github.com/charliermarsh/ruff) from 0.0.252 to 0.0.259. - [Release notes](https://github.com/charliermarsh/ruff/releases) - [Changelog](https://github.com/charliermarsh/ruff/blob/main/BREAKING_CHANGES.md) - [Commits](https://github.com/charliermarsh/ruff/compare/v0.0.252...v0.0.259) --- updated-dependencies: - dependency-name: ruff dependency-type: direct:development update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <support@github.com> * Fix new warnings * Mypy * Newsfile --------- Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Erik Johnston <erik@matrix.org>
* Prune old typing notifications (#15332)Erik Johnston2023-03-271-0/+25
| | | | | Rather than keeping them around forever in memory, slowing things down. Fixes #11750.
* Load `/password_policy` endpoint on workers. (#15331)Dirk Klimpel2023-03-272-2/+2
|
* Add developer documentation for the Federation Sender and add a ↵reivilibre2023-03-241-0/+113
| | | | | | documentation mechanism using Sphinx. (#15265) Co-authored-by: Patrick Cloke <clokep@users.noreply.github.com>
* As an optimisation, use `TRUNCATE` on Postgres when clearing the user ↵reivilibre2023-03-241-4/+11
| | | | directory tables. (#15316)
* Make cleaning up pushers depend on the device_id instead of the token_id ↵Quentin Gliech2023-03-2410-33/+113
| | | | | | | | | | | | | | (#15280) This makes it so that we rely on the `device_id` to delete pushers on logout, instead of relying on the `access_token_id`. This ensures we're not removing pushers on token refresh, and prepares for a world without access token IDs (also known as the OIDC). This actually runs the `set_device_id_for_pushers` background update, which was forgotten in #13831. Note that for backwards compatibility it still deletes pushers based on the `access_token` until the background update finishes.
* Reject mentions on the C-S API which are invalid. (#15311)Patrick Cloke2023-03-242-16/+48
| | | | | | Invalid mentions data received over the Client-Server API should be rejected with a 400 error. This will hopefully stop clients from sending invalid data, although does not help with data received over federation.
* Reintroduce membership tables event stream ordering (#15128)Nick Mills-Barrett2023-03-245-12/+130
| | | | | | | | | | | | | | | | | | * Add `event_stream_ordering` column to membership state tables Specifically this adds the column to `current_state_events`, `local_current_membership` and `room_memberships`. Each of these tables is regularly joined with the `events` table to get the stream ordering and denormalising this into each table will yield significant query performance improvements once used. * Make denormalised `event_stream_ordering` columns foreign keys * Add comment in schema file explaining new denormalised columns * Add triggers to enforce consistency of `event_stream_ordering` columns * Re-order purge room tables to account for foreign keys * Bump schema version to 75 Co-authored-by: David Robertson <david.m.robertson1@gmail.com> Co-authored-by: Richard van der Hoff <1389908+richvdh@users.noreply.github.com>
* Add a primitive helper script for listing worker endpoints. (#15243)reivilibre2023-03-2330-12/+423
| | | | Co-authored-by: Patrick Cloke <patrickc@matrix.org>
* Use immutabledict instead of frozendict (#15113)David Robertson2023-03-2211-48/+59
| | | | | | | | | | Additionally: * Consistently use `freeze()` in test --------- Co-authored-by: Patrick Cloke <clokep@users.noreply.github.com> Co-authored-by: 6543 <6543@obermui.de>
* Add a check to SQLite port DB script to ensure that the sqlite database ↵Shay2023-03-221-0/+8
| | | | passed to the script exists before trying to port from it (#15306)
* Have replication clients remove _INT_STREAM_POS (#15309)David Robertson2023-03-221-1/+1
| | | | | | | | | | | | | | | | | | | * Have replication clients remove _INT_STREAM_POS Suppose worker A makes an internal http request from worker B. B may make changes that A later learns about over replication. We want A's request to block until it has seen those changes—mainly to ensure A's caches are invalidated promptly. This helps provide read-after-write consistency, eliminating entire categories of races and test flakes. To implement this, B includes a top-level field `_INT_STREAM_POS` in its response JSON. Roughly speaking, the field's value tells A what to wait for. But we weren't removing that internal field before A's request completed! Introduced in https://github.com/matrix-org/synapse/pull/14820. Fixes #15308. * Changelog
* Change the parameter `immediate` of `send_device_messages` to default to ↵Shay2023-03-212-2/+2
| | | | `True` (#15297)
* Apply & bundle edits for non-message events. (#15295)Patrick Cloke2023-03-211-7/+4
|
* Revert "check sqlite database file exists before porting/#14692" (#15301)Shay2023-03-211-1/+1
|
* Make `POST /_matrix/client/v3/rooms/{roomId}/report/{eventId}` endpoint ↵Andrew Morgan2023-03-212-6/+11
| | | | return 404 if event exists, but the user lacks access (#15300)
* Make `EventHandler.get_event` return `None` when the requested event is not ↵Andrew Morgan2023-03-211-4/+5
| | | | found (#15298)
* Fix error when sending message into deleted room. (#15235)Erik Johnston2023-03-211-2/+15
| | | | | | | | When a room is deleted in Synapse we remove the event forward extremities in the room, so if (say a bot) tries to send a message into the room we error out due to not being able to calculate prev events for the new event *before* we check if the sender is in the room. Fixes #8094
* Separate HTTP preview code and URL previewer. (#15269)Patrick Cloke2023-03-202-792/+837
| | | Separates REST layer code from the actual URL previewing.
* Add Synapse-Trace-Id to access-control-expose-headers header (#14974)Shay2023-03-201-0/+4
|
* Add /versions flag for MSC3952. (#15293)Patrick Cloke2023-03-201-0/+2
|
* Load `/register/available` endpoint on workers (#15268)Jason Little2023-03-171-1/+1
|
* Remove no-op send_command for Redis replication. (#15274)Patrick Cloke2023-03-161-25/+1
| | | | | With Redis commands do not need to be re-issued by the main process (they fan-out to all processes at once) and thus it is no longer necessary to worry about them reflecting recursively forever.
* Implement MSC2659: application service ping endpoint (#15249)Tulir Asokan2023-03-166-0/+140
| | | Signed-off-by: Tulir Asokan <tulir@maunium.net>
* Refresh remote profiles that have been marked as stale, in order to fill the ↵reivilibre2023-03-163-2/+318
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | user directory. [rei:userdirpriv] (#14756) * Scaffolding for background process to refresh profiles * Add scaffolding for background process to refresh profiles for a given server * Implement the code to select servers to refresh from * Ensure we don't build up multiple looping calls * Make `get_profile` able to respect backoffs * Add logic for refreshing users * When backing off, schedule a refresh when the backoff is over * Wake up the background processes when we receive an interesting state event * Add tests * Newsfile Signed-off-by: Olivier Wilkinson (reivilibre) <oliverw@matrix.org> * Add comment about 1<<62 --------- Signed-off-by: Olivier Wilkinson (reivilibre) <oliverw@matrix.org>
* Move Account Validity callbacks to a dedicated file (#15237)Andrew Morgan2023-03-166-103/+151
|
* Preparatory work to fix the user directory assuming that any remote ↵reivilibre2023-03-163-34/+126
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | membership state events represent a profile change. [rei:userdirpriv] (#14755) * Remove special-case method for new memberships only, use more generic method * Only collect profiles from state events in public rooms * Add a table to track stale remote user profiles * Add store methods to set and delete rows in this new table * Mark remote profiles as stale when a member state event comes in to a private room * Newsfile Signed-off-by: Olivier Wilkinson (reivilibre) <oliverw@matrix.org> * Simplify by removing Optionality of `event_id` * Replace names and avatars with None if they're set to dodgy things I think this makes more sense anyway. * Move schema delta to 74 (I missed the boat?) * Turns out these can be None after all --------- Signed-off-by: Olivier Wilkinson (reivilibre) <oliverw@matrix.org>
* Remove unused class: DirectTcpReplicationClientFactory. (#15272)Patrick Cloke2023-03-151-51/+0
|
* Add schema comments about the `destinations` and `destination_rooms` tables. ↵reivilibre2023-03-151-0/+52
| | | | (#15247)
* Remove unused store method `_set_destination_retry_timings_emulated`. (#15266)reivilibre2023-03-141-54/+2
|
* Avoid unneeded work if auto-join rooms aren't configured. (#15262)Patrick Cloke2023-03-141-2/+8
| | | | | | It is not necessary to reach out to the database to check some parameters if the auto-join rooms are not configured, or (in some cases) if auto-create rooms is not configured.
* Merge branch 'release-v1.79' into developDavid Robertson2023-03-134-27/+85
|\
| * Ensure fed-sender catchup does not block for full state (#15248)David Robertson2023-03-131-2/+7
| | | | | | | | * Reproduce bad scenario in test * Avoid catchup optimisation for partial state rooms
| * Refactor `filter_events_for_server` (#15240)David Robertson2023-03-103-25/+73
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * Tweak docstring and type hint * Flip logic and provide better name * Separate decision from action * Track a set of strings, not EventBases * Require explicit boolean options from callers * Add explicit option for partial state rooms * Changelog * Rename param
| * Fix missing conditional for registering ↵Andrew Morgan2023-03-101-0/+5
| | | | | | | | `on_remove_user_third_party_identifier` module api callbacks (#15227
* | Give PyCharm some help with `@cache_in_self` (#15238)David Robertson2023-03-091-3/+26
| | | | | | | | | | | | | | * Give PyCharm some help with `@cache_in_self` * Changelog * Fix import for old python versions
* | Faster joins: Fix spurious errors on incremental sync (#15232)Sean Quah2023-03-091-2/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | When pushing events in partial state rooms down incremental /sync, we try to find the `m.room.member` state event for their senders by digging through their auth events, so that we can present the membership to the client. Events usually have a membership event in their auth events, with the exception of the `m.room.create` event and a user's first join into the room. When implementing #13477, we took the case of a user's first join into account, but forgot to handle the `m.room.create` case. This change fixes that. Signed-off-by: Sean Quah <seanq@matrix.org>
* | Add missing type hints to `synapse.storage.database`. (#15230)Patrick Cloke2023-03-091-5/+16
| |
* | Pull in netaddr type hints. (#15231)Patrick Cloke2023-03-092-4/+6
| | | | | | And fix any issues from having those type hints.
* | Add topic and name events to group of events that are batch persisted when ↵Shay2023-03-081-56/+52
| | | | | | | | creating a room. (#15229)
* | Include the room ID in more purge room log lines. (#15222)Patrick Cloke2023-03-084-15/+22
| |
* | More speedups/fixes to creating batched events (#15195)Shay2023-03-074-9/+32
| |
* | Stabilize support for MSC3873: disambuguated event push keys. (#15190)Patrick Cloke2023-03-072-35/+8
| | | | | | | | | | | | | | This removes the experimental configuration option and always escapes the push rule condition keys. Also escapes any (experimental) push rule condition keys in the base rules which contain dot in a field name.
* | Pass the Requester down to the HttpTransactionCache. (#15200)Quentin Gliech2023-03-074-116/+172
| |
* | Stabilize support for MSC3966: event_property_contains push condition. (#15187)Patrick Cloke2023-03-072-9/+2
|/ | | | This removes the configuration flag & updates the identifiers to use the stable version.
* Split up txn for fetching device keys (#15215)Erik Johnston2023-03-072-9/+25
| | | | We look up keys in batches, but we should do that outside of the transaction to avoid starving the database pool.
* Pass the requester during event serialization. (#15174)Quentin Gliech2023-03-0611-75/+150
| | | | This allows Synapse to properly include the transaction ID in the unsigned data of events.
* Stop applying edits to event contents (MSC3925). (#15193)Patrick Cloke2023-03-064-60/+4
| | | | | | | | | | | Enables MSC3925 support by default, which: * Includes the full edit event in the bundled aggregations of an edited event. * Stops modifying the original event's content to return the new content from the edit event. This is a backwards-incompatible change that is considered to be "correct" by the spec.
* Stabilize support for MSC3758: event_property_is push condition (#15185)Patrick Cloke2023-03-062-8/+1
| | | | This removes the configuration flag & updates the identifiers to use the stable version.
* Combine AbstractStreamIdTracker and AbstractStreamIdGenerator. (#15192)Patrick Cloke2023-03-036-27/+14
| | | | | AbstractStreamIdTracker (now) has only a single sub-class: AbstractStreamIdGenerator, combine them to simplify some code and remove any direct references to AbstractStreamIdTracker.
* Remove unspecced and buggy `PUT` method on the unstable ↵Quentin Gliech2023-03-031-15/+1
| | | | `/rooms/<room_id>/batch_send` endpoint. (#15199)
* Experimental MSC3890 Implementation: Fix deleting account data when using an ↵Andrew Morgan2023-03-032-26/+15
| | | | account data writer worker (#14869)
* Add a `get_next_txn` method to `StreamIdGenerator` to match ↵Andrew Morgan2023-03-023-11/+47
| | | | `MultiWriterIdGenerator` (#15191
* Add support for knocking to workers. (#15133)Dirk Klimpel2023-03-026-16/+12
|
* Remove the unspecced and bugged PUT /knock/{roomIdOrAlias} endpoint (#15189)Quentin Gliech2023-03-021-15/+1
|
* Update intentional mentions (MSC3952) to depend on ↵Patrick Cloke2023-03-023-20/+17
| | | | | | | `exact_event_property_contains` (MSC3966). (#15051) This replaces the specific `is_user_mention` push rule condition used in MSC3952 with the generic `exact_event_property_contains` push rule condition from MSC3966.
* Fix conflicting URLs for dehydrated devices. (#15180)Patrick Cloke2023-03-021-1/+1
|
* Move event_reports to `RoomWorkerStore` (#15165)Dirk Klimpel2023-03-021-177/+177
|
* Implementation of MSC3967: Don't require UIA for initial upload of cross ↵Hugh Nimmo-Smith2023-03-023-9/+40
| | | | signing keys (#15077)
* Remove support for aggregating reactions (#15172)Richard van der Hoff2023-02-286-227/+1
| | | | | | | | | | It turns out that no clients rely on server-side aggregation of `m.annotation` relationships: it's just not very useful as currently implemented. It's also non-trivial to calculate. I want to remove it from MSC2677, so to keep the implementation in line, let's remove it here.
* Merge branch 'master' into developH. Shay2023-02-281-0/+18
|\
| * Fix bug where 5s delays would occasionally happen. (#15150)Erik Johnston2023-02-241-0/+18
| | | | | | This only affects deployments using workers.
* | Fix a long-standing bug where an initial sync would not respond to changes ↵reivilibre2023-02-282-2/+54
| | | | | | | | to the list of ignored users if there was an initial sync cached. (#15163)
* | Allow use of the `/filter` Client-Server APIs on workers. (#15134)reivilibre2023-02-283-8/+24
| |
* | Add missing type hints to InsecureInterceptableContextFactory. (#15164)Patrick Cloke2023-02-281-2/+3
| |
* | Admin API endpoint to delete a reported event (#15116)Dirk Klimpel2023-02-282-9/+68
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * Admin api to delete event report * lint + tests * newsfile * Apply suggestions from code review Co-authored-by: David Robertson <david.m.robertson1@gmail.com> * revert changes - move to WorkerStore * update unit test * Note that timestamp is in millseconds --------- Co-authored-by: David Robertson <david.m.robertson1@gmail.com>
* | Remove dangling reference to being a reference implementation (#15167)Travis Ralston2023-02-271-2/+3
| | | | | | | | | | * Remove dangling reference to being a reference implementation * Create 15167.misc
* | Add module API callbacks for adding and deleting local 3PID associations (#15044Andrew Morgan2023-02-277-43/+132
| |
* | Refactor media modules. (#15146)Patrick Cloke2023-02-2721-1108/+1174
| | | | | | | | | | | | | | * Removes the `v1` directory from `test.rest.media.v1`. * Moves the non-REST code from `synapse.rest.media.v1` to `synapse.media`. * Flatten the `v1` directory from `synapse.rest.media`, but leave compatiblity with 3rd party media repositories and spam checkers.
* | Small fixes to `MatrixFederationHttpClient` docstrings (#15148)Andrew Morgan2023-02-271-7/+9
| |
* | Batch up storing state groups when creating new room (#14918)Shay2023-02-246-29/+209
| |
* | Improve handling of non-ASCII characters in user directory search (#15143)Sean Quah2023-02-241-2/+50
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * Fix a long-standing bug where non-ASCII characters in search terms, including accented letters, would not match characters in a different case. * Fix a long-standing bug where search terms using combining accents would not match display names using precomposed accents and vice versa. To fully take effect, the user directory must be rebuilt after this change. Fixes #14630. Signed-off-by: Sean Quah <seanq@matrix.org>
* | Do not fail completely if oEmbed autodiscovery fails. (#15092)Patrick Cloke2023-02-231-10/+23
| | | | | | | | | | | | Previously if an autodiscovered oEmbed request failed (e.g. the oEmbed endpoint is down or does not exist) then the entire URL preview would fail. Instead we now return everything we can, even if this additional request fails.
* | Stop parsing the unspecced type parameter on thumbnail requests. (#15137)Patrick Cloke2023-02-231-1/+2
| | | | | | | | | | | | | | | | Ideally we would replace this with parsing of the Accept header or something else, but for now just make Synapse spec compliant by ignoring the unspecced parameter. It does not seem that this is ever sent by a client, and even if it is there's a reasonable fallback.
* | Fix a typo in MSC3873 config option. (#15138)Patrick Cloke2023-02-232-8/+8
| | | | | | | | Previously the experimental configuration option referred to the wrong MSC number.
* | Add information on uploaded media to user export command. (#15107)Dirk Klimpel2023-02-232-0/+48
| |
* | Bump black from 22.12.0 to 23.1.0 (#15103)dependabot[bot]2023-02-2267-99/+55
| |
* | Tighten the default rate limit of creating new devices. (#15135)Patrick Cloke2023-02-221-2/+11
| |
* | Use `json.dump` in `FileExfiltrationWriter` (#15095)Dirk Klimpel2023-02-221-8/+8
| | | | | | | | To directly write to the open file, instead of writing to an in-memory string first.
* | Remove unused `room_alias` field from `/createRoom` response (#15093)David Robertson2023-02-225-28/+27
|/ | | | | | | | | | | | | | * Change `create_room` return type * Don't return room alias from /createRoom * Update other callsites * Fix up mypy complaints It looks like new_room_user_id is None iff new_room_id is None. It's a shame we haven't expressed this in a way that mypy can understand. * Changelog
* Tweak logging for when a worker waits for its view of a replication stream ↵reivilibre2023-02-211-2/+10
| | | | | | | | | | | | | | | | | | to catch up. (#15120)Co-authored-by: Sean Quah <8349537+squahtx@users.noreply.github.com> * Improve logging messages for the 'wait for repl stream' read-after-write consistency feature * Newsfile Signed-off-by: Olivier Wilkinson (reivilibre) <oliverw@matrix.org> * Update synapse/replication/tcp/client.py Co-authored-by: Sean Quah <8349537+squahtx@users.noreply.github.com> --------- Signed-off-by: Olivier Wilkinson (reivilibre) <oliverw@matrix.org> Co-authored-by: Sean Quah <8349537+squahtx@users.noreply.github.com>
* Teach portdb about `un_partial_stated_event_stream` (#15108)David Robertson2023-02-201-33/+52
| | | | | | | | | | | | * Sort BOOLEAN_COLUMNS and APPEND_ONLY_TABLES So I can see if a given table is present in logarithmic time, rather than linear. * Teach portdb about `un_partial_stated_event_streams` * Comments comments comments * Changelog
* Allow health listener resource to load (#15096)realtyem2023-02-201-0/+1
| | | | | | | * Allow health listener resource to load. * changelog * Update changelog.d/15096.bugfix
* Fix a bug introduced in Synapse v1.74.0 where searching with colons when ↵reivilibre2023-02-201-4/+20
| | | | | | using ICU for search term tokenisation would fail with an error. (#15079) Co-authored-by: David Robertson <davidr@element.io>
* Add account data to export command (#14969)Dirk Klimpel2023-02-172-16/+48
| | | | | | | | | | | * Add account data to to export command * newsfile * remove not needed function * update newsfile * adopt #14973
* Mitigate a race where /make_join could 403 for restricted rooms (#15080)Sean Quah2023-02-171-1/+15
| | | | | | | | | | | | | | | | | | | | | | | | | Previously, when creating a join event in /make_join, we would decide whether to include additional fields to satisfy restricted room checks based on the current state of the room. Then, when building the event, we would capture the forward extremities of the room to use as prev events. This is subject to race conditions. For example, when leaving and rejoining a room, the following sequence of events leads to a misleading 403 response: 1. /make_join reads the current state of the room and sees that the user is still in the room. It decides to omit the field required for restricted room joins. 2. The leave event is persisted and the room's forward extremities are updated. 3. /make_join builds the event, using the post-leave forward extremities. The event then fails the restricted room checks. To mitigate the race, we move the read of the forward extremities closer to the read of the current state. Ideally, we would compute the state based off the chosen prev events, but that can involve state resolution, which is expensive. Signed-off-by: Sean Quah <seanq@matrix.org>
* Use mypy 1.0 (#15052)David Robertson2023-02-168-33/+107
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * Update mypy and mypy-zope * Remove unused ignores These used to suppress ``` synapse/storage/engines/__init__.py:28: error: "__new__" must return a class instance (got "NoReturn") [misc] ``` and ``` synapse/http/matrixfederationclient.py:1270: error: "BaseException" has no attribute "reasons" [attr-defined] ``` (note that we check `hasattr(e, "reasons")` above) * Avoid empty body warnings, sometimes by marking methods as abstract E.g. ``` tests/handlers/test_register.py:58: error: Missing return statement [empty-body] tests/handlers/test_register.py:108: error: Missing return statement [empty-body] ``` * Suppress false positive about `JaegerConfig` Complaint was ``` synapse/logging/opentracing.py:450: error: Function "Type[Config]" could always be true in boolean context [truthy-function] ``` * Fix not calling `is_state()` Oops! ``` tests/rest/client/test_third_party_rules.py:428: error: Function "Callable[[], bool]" could always be true in boolean context [truthy-function] ``` * Suppress false positives from ParamSpecs ```` synapse/logging/opentracing.py:971: error: Argument 2 to "_custom_sync_async_decorator" has incompatible type "Callable[[Arg(Callable[P, R], 'func'), **P], _GeneratorContextManager[None]]"; expected "Callable[[Callable[P, R], **P], _GeneratorContextManager[None]]" [arg-type] synapse/logging/opentracing.py:1017: error: Argument 2 to "_custom_sync_async_decorator" has incompatible type "Callable[[Arg(Callable[P, R], 'func'), **P], _GeneratorContextManager[None]]"; expected "Callable[[Callable[P, R], **P], _GeneratorContextManager[None]]" [arg-type] ```` * Drive-by improvement to `wrapping_logic` annotation * Workaround false "unreachable" positives See https://github.com/Shoobx/mypy-zope/issues/91 ``` tests/http/test_proxyagent.py:626: error: Statement is unreachable [unreachable] tests/http/test_proxyagent.py:762: error: Statement is unreachable [unreachable] tests/http/test_proxyagent.py:826: error: Statement is unreachable [unreachable] tests/http/test_proxyagent.py:838: error: Statement is unreachable [unreachable] tests/http/test_proxyagent.py:845: error: Statement is unreachable [unreachable] tests/http/federation/test_matrix_federation_agent.py:151: error: Statement is unreachable [unreachable] tests/http/federation/test_matrix_federation_agent.py:452: error: Statement is unreachable [unreachable] tests/logging/test_remote_handler.py:60: error: Statement is unreachable [unreachable] tests/logging/test_remote_handler.py:93: error: Statement is unreachable [unreachable] tests/logging/test_remote_handler.py:127: error: Statement is unreachable [unreachable] tests/logging/test_remote_handler.py:152: error: Statement is unreachable [unreachable] ``` * Changelog * Tweak DBAPI2 Protocol to be accepted by mypy 1.0 Some extra context in: - https://github.com/matrix-org/python-canonicaljson/pull/57 - https://github.com/python/mypy/issues/6002 - https://mypy.readthedocs.io/en/latest/common_issues.html#covariant-subtyping-of-mutable-protocol-members-is-rejected * Pull in updated canonicaljson lib so the protocol check just works * Improve comments in opentracing I tried to workaround the ignores but found it too much trouble. I think the corresponding issue is https://github.com/python/mypy/issues/12909. The mypy repo has a PR claiming to fix this (https://github.com/python/mypy/pull/14677) which might mean this gets resolved soon? * Better annotation for INTERACTIVE_AUTH_CHECKERS * Drive-by AUTH_TYPE annotation, to remove an ignore
* Update intentional mentions (MSC3952) to depend on `exact_event_match` ↵Patrick Cloke2023-02-162-7/+4
| | | | | | | | | | (MSC3758). (#15037) This replaces the specific `is_room_mention` push rule condition used in MSC3952 with the generic `exact_event_match` push rule condition from MSC3758. No functionality changes due to this.
* Fix federated joins when the first server in the list is not in the room ↵Sean Quah2023-02-151-6/+5
| | | | | | | | (#15074) Previously we would give up upon receiving a 404 from the first server, instead of trying the rest of the servers in the list. Signed-off-by: Sean Quah <seanq@matrix.org>
* Support for selecting the Redis logical database. (#15034)999lakhisidhu2023-02-152-0/+2
| | | | Note that this is only used for key-value store (cached values) and not for the pub/sub replication used by Synapse.
* Update the error code for duplicate annotation (#15075)Richard van der Hoff2023-02-152-1/+9
|
* Fix order of partial state tables when purging (#15068)David Robertson2023-02-142-2/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * Fix order of partial state tables when purging `partial_state_rooms` has an FK on `events` pointing to the join event we get from `/send_join`, so we must delete from that table before deleting from `events`. **NB:** It would be nice to cancel any resync processes for the room being purged. We do not do this at present. To do so reliably we'd need an internal HTTP "replication" endpoint, because the worker doing the resync process may be different to that handling the purge request. The first time the resync process tries to write data after the deletion it will fail because we have deleted necessary data e.g. auth events. AFAICS it will not retry the resync, so the only downside to not cancelling the resync is a scary-looking traceback. (This is presumably extremely race-sensitive.) * Changelog * admist(?) -> between * Warn about a race * Fix typo, thanks Sean Co-authored-by: Sean Quah <8349537+squahtx@users.noreply.github.com> --------- Co-authored-by: Sean Quah <8349537+squahtx@users.noreply.github.com>
* Implement MSC3966: Add a push rule condition to search for a value in an ↵Patrick Cloke2023-02-143-7/+20
| | | | | | array. (#15045) The `exact_event_property_contains` condition can be used to search for a value inside of an array.
* Prevent clients from reporting nonexistent events. (#13779)reivilibre2023-02-141-1/+10
|
* Faster joins: Omit device list updates from partial state rooms in /sync ↵Sean Quah2023-02-141-0/+5
| | | | | | | | | | | | (#15069) ...when lazy loading of members is not enabled. It's weird to notify a client that another user's device list has changed when the client doesn't think that they share a room. Note that when a room is un-partial stated, device list updates are emitted for every member in that room over /sync. Signed-off-by: Sean Quah <seanq@matrix.org>
* Fix clashing DB txn name (#15070)Erik Johnston2023-02-141-1/+1
| | | | | * Fix clashing DB txn name * Newsfile
* Skip calculating unread push actions in `/sync` when `enable_push` is false. ↵Erik Johnston2023-02-142-0/+15
| | | | (#14980)
* Change collection[str] to StrCollection in event_auth code (#14929)Harishankar Kumar2023-02-144-24/+18
| | | Signed-off-by: Harishankar Kumar <hari01584@gmail.com>
* Tweak comment on `_is_local_room_accessible` as part of room visibility in ↵reivilibre2023-02-131-2/+2
| | | | `/hierarchy` to clarify the condition for a room being visible. (#14834)
* Refactor arguments of `try_unbind_threepid(_with_id_server)` from dict to ↵Andrew Morgan2023-02-134-39/+27
| | | | separate args (#15053)
* Apply logging from hotfixes branch to develop (#15054)David Robertson2023-02-131-0/+3
| | | | | | | | | * Apply logging from hotfixes branch to develop Part of #4826. Originally added in #11882. * Changelog
* Faster joins: don't stall when a user joins during a fast join (#14606)Mathieu Velten2023-02-1010-74/+175
| | | | | | | | | | | | | | | | Fixes #12801. Complement tests are at https://github.com/matrix-org/complement/pull/567. Avoid blocking on full state when handling a subsequent join into a partial state room. Also always perform a remote join into partial state rooms, since we do not know whether the joining user has been banned and want to avoid leaking history to banned users. Signed-off-by: Mathieu Velten <mathieuv@matrix.org> Co-authored-by: Sean Quah <seanq@matrix.org> Co-authored-by: David Robertson <davidr@element.io>
* Return read-only collections from `@cached` methods (#13755)Sean Quah2023-02-1025-75/+95
| | | | | | | | | | | | | It's important that collections returned from `@cached` methods are not modified, otherwise future retrievals from the cache will return the modified collection. This applies to the return values from `@cached` methods and the values inside the dictionaries returned by `@cachedList` methods. It's not necessary for the dictionaries returned by `@cachedList` methods themselves to be read-only. Signed-off-by: Sean Quah <seanq@matrix.org> Co-authored-by: David Robertson <davidr@element.io>
* Support for MSC3758: exact_event_match push condition (#14964)Patrick Cloke2023-02-103-7/+18
| | | | | This specifies to search for an exact value match, instead of string globbing. It only works across non-compound JSON values (null, boolean, integer, and strings).
* Avoid fetching unused account data in sync. (#14973)Patrick Cloke2023-02-107-90/+175
| | | | | | | The per-room account data is no longer unconditionally fetched, even if all rooms will be filtered out. Global account data will not be fetched if it will all be filtered out.
* Merge branch 'release-v1.77' into developDavid Robertson2023-02-102-2/+9
|\
| * Bump schema version (#15036)David Robertson2023-02-091-2/+7
| | | | | | | | | | | | | | | | * Bump schema version This should have been included in f10caa73eee0caa91cf373966104d1ededae2aee (and #14979). * Changelog
| * Fix bug in replication where response is cached (#15024)Erik Johnston2023-02-081-0/+2
| |
* | Avoid mutating cached values in `_generate_sync_entry_for_account_data` (#15047)Sean Quah2023-02-101-0/+2
| |
* | Refactor get_user_devices_from_cache to avoid mutating cached values. (#15040)Patrick Cloke2023-02-102-18/+24
| | | | | | | | | | | | | | | | The previous version of the code could mutate a cached value, but only if the input requested all devices of a user *and* a specific device. To avoid this nonsensical situation we no longer fetch a specific device ID if all of a user's devices are returned.
* | Fix exception on start up about device lists (#15041)Erik Johnston2023-02-101-0/+1
| | | | | | Fixes #15010.
* | Tag federation request spans with the worker name (#15042)David Robertson2023-02-092-8/+9
| | | | | | | | | | | | | | * Systematically include worker name as process info * Changelog * don't bother with inner setdefault
* | Add a class UnpersistedEventContext to allow for the batching up of storing ↵Shay2023-02-096-148/+315
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | state groups (#14675) * add class UnpersistedEventContext * modify create new client event to create unpersistedeventcontexts * persist event contexts after creation * fix tests to persist unpersisted event contexts * cleanup * misc lints + cleanup * changelog + fix comments * lints * fix batch insertion? * reduce redundant calculation * add unpersisted event classes * rework compute_event_context, split into function that returns unpersisted event context and then persists it * use calculate_context_info to create unpersisted event contexts * update typing * $%#^&* * black * fix comments and consolidate classes, use attr.s for class * requested changes * lint * requested changes * requested changes * refactor to be stupidly explicit * clearer renaming and flow * make partial state non-optional * update docstrings --------- Co-authored-by: Erik Johnston <erik@matrix.org>
* | Do not always start a db txn on Postgres (#14840)Andrew Morgan2023-02-091-4/+9
| |
* | Respond correctly to unknown methods on known endpoints (#14605)Patrick Cloke2023-02-094-47/+63
| | | | | | | | Respond with a 405 error if a request is received on a known endpoint, but to an unknown method, per MSC3743.