summary refs log tree commit diff
path: root/synapse/handlers (follow)
Commit message (Collapse)AuthorAgeFilesLines
* Convert simple_select_one_txn and simple_select_one to return tuples. (#16612)Patrick Cloke2023-11-092-4/+5
|
* Return attrs for more media repo APIs. (#16611)Patrick Cloke2023-11-092-7/+10
|
* Remove remaining usage of cursor_to_dict. (#16564)Patrick Cloke2023-10-313-36/+35
|
* Merge pull request from GHSA-mp92-3jfm-3575Patrick Cloke2023-10-312-0/+9
|
* Claim local one-time-keys in bulk (#16565)David Robertson2023-10-301-0/+10
| | | | Co-authored-by: Patrick Cloke <clokep@users.noreply.github.com>
* Claim fallback keys in bulk (#16570)David Robertson2023-10-301-0/+14
|
* Ensure local invited & knocking users leave before purge. (#16559)Patrick Cloke2023-10-271-3/+4
| | | | | This is mostly useful for federated rooms where some users would get stuck in the invite or knock state when the room was purged from their homeserver.
* Fix cross-worker ratelimiting (#16558)Erik Johnston2023-10-271-16/+57
| | | c.f. #16481
* Add new module API for adding custom fields to events `unsigned` section ↵Erik Johnston2023-10-276-18/+20
| | | | (#16549)
* Remove more usages of cursor_to_dict. (#16551)Patrick Cloke2023-10-262-12/+12
| | | Mostly to improve type safety.
* Add a new module API to update user presence state. (#16544)Patrick Cloke2023-10-263-33/+49
| | | | | | | | | | This adds a module API which allows a module to update a user's presence state/status message. This is useful for controlling presence from an external system. To fully control presence from the module the presence.enabled config parameter gains a new state of "untracked" which disables internal tracking of presence changes via user actions, etc. Only updates from the module will be persisted and sent down sync properly).
* Convert simple_select_list and simple_select_list_txn to return lists of ↵Patrick Cloke2023-10-262-6/+3
| | | | | tuples (#16505) This should use fewer allocations and improves type hints.
* Allow multiple workers to write to receipts stream. (#16432)Erik Johnston2023-10-254-30/+40
| | | Fixes #16417
* Mark sync as limited if there is a gap in the timeline (#16485)Erik Johnston2023-10-191-8/+44
| | | | | | | | This splits thinsg into two queries, but most of the time we won't have new event backwards extremities so this shouldn't actually add an extra RTT for the majority of cases. Note this removes the check for events with no prev events, but that was part of MSC2716 work that has since been removed.
* Improve performance of delete device messages query (#16492)Mathieu Velten2023-10-181-0/+2
|
* Convert DeviceLastConnectionInfo to attrs. (#16507)Patrick Cloke2023-10-171-16/+7
| | | To improve type safety & memory usage.
* Convert state delta processing from a dict to attrs. (#16469)Patrick Cloke2023-10-164-78/+73
| | | For improved type checking & memory usage.
* Remove useless async job to delete device messages on sync (#16491)Mathieu Velten2023-10-161-22/+0
|
* Revert "Drop unused tables & unneeded access token ID for events. (#16268)" ↵Patrick Cloke2023-10-121-2/+6
| | | | | | | | (#16465) This reverts commit cabd57746004fe2dacc11aa8d373854a3d25e306. There are additional usages of these tables which need to be removed first.
* Convert user_get_threepids response to attrs. (#16468)Patrick Cloke2023-10-113-5/+7
| | | This improves type annotations by not having a dictionary of Any values.
* Bump ruff from 0.0.290 to 0.0.292 (#16449)dependabot[bot]2023-10-095-8/+0
| | | | | | | | | | | | | | | | | | | | | | | | | * Bump ruff from 0.0.290 to 0.0.292 Bumps [ruff](https://github.com/astral-sh/ruff) from 0.0.290 to 0.0.292. - [Release notes](https://github.com/astral-sh/ruff/releases) - [Changelog](https://github.com/astral-sh/ruff/blob/main/BREAKING_CHANGES.md) - [Commits](https://github.com/astral-sh/ruff/compare/v0.0.290...v0.0.292) --- updated-dependencies: - dependency-name: ruff dependency-type: direct:development update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <support@github.com> * Fix up lint --------- 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>
* Apply join rate limiter outside the lineariser (#16441)David Robertson2023-10-061-20/+23
|
* Drop unused tables & unneeded access token ID for events. (#16268)Patrick Cloke2023-10-061-6/+2
| | | | Drop the event_txn_id table and the tables related to MSC2716, which is no longer supported in Synapse.
* Stop sending incorrect knock_state_events. (#16403)Patrick Cloke2023-10-061-11/+2
| | | | | | | | | Synapse was incorrectly implemented with a knock_state_events property on some APIs (instead of knock_room_state). This was correct in Synapse 1.70.0, but *both* fields were sent to also be compatible with Synapse versions expecting the wrong field. Enough time has passed that only the correct field needs to be included/handled.
* Factor out `MultiWriter` token from `RoomStreamToken` (#16427)Erik Johnston2023-10-054-6/+5
|
* Some refactors around receipts stream (#16426)Erik Johnston2023-10-043-19/+16
|
* mypy plugin to check `@cached` return types (#14911)David Robertson2023-10-021-2/+2
| | | | | | | | Co-authored-by: David Robertson <davidr@element.io> Co-authored-by: Patrick Cloke <patrickc@matrix.org> Co-authored-by: Erik Johnston <erik@matrix.org> Assert that the return type of callables wrapped in @cached and @cachedList are cachable (aka immutable).
* Add a cache around server ACL checking (#16360)Patrick Cloke2023-09-262-0/+11
| | | | | * Pre-compiles the server ACLs onto an object per room and invalidates them when new events come in. * Converts the server ACL checking into Rust.
* Reduce calls to `send_presence_to_destinations` (#16385)Erik Johnston2023-09-261-15/+18
|
* Convert more cached return values to immutable types (#16356)Patrick Cloke2023-09-202-3/+13
|
* Return immutable objects for cachedList decorators (#16350)Patrick Cloke2023-09-196-33/+37
|
* Make cached account data/tags/admin types immutable (#16325)Patrick Cloke2023-09-182-20/+25
|
* Return an immutable value from get_latest_event_ids_in_room. (#16326)Patrick Cloke2023-09-181-5/+3
|
* Additional validation of receipts (#16327)Patrick Cloke2023-09-181-2/+24
| | | | Reject invalid receipts with a reasonable error message & expands tests for receipts.
* Set email charset as utf-8 rather than utf8 (#16329)José Joaquín Atria2023-09-181-2/+2
|
* Add automatic purge after all users forget a room (#15488)Mathieu Velten2023-09-153-390/+281
| | | | | | Also add restore of purge/shutdown rooms after a synapse restart. Co-authored-by: Eric Eastwood <erice@matrix.org> Co-authored-by: Erik Johnston <erikj@matrix.org>
* Speed up deleting to-device messages task (#16318)Erik Johnston2023-09-141-13/+14
|
* Refactor `get_user_by_id` (#16316)Erik Johnston2023-09-143-31/+26
|
* Fix using dehydrated devices (MSC2697) & refresh tokens (#16288)Hanadi2023-09-131-3/+4
| | | | | Refresh tokens were not correctly moved to the rehydrated device (similar to how the access token is currently handled). This resulted in invalid refresh tokens after rehydration.
* Don't schedule an async task on every sync (#16312)Erik Johnston2023-09-131-11/+26
|
* Fix deleting device inbox when using background worker (#16311)Erik Johnston2023-09-131-31/+31
| | | | | Introduced in #16240 The action for the task was only defined on the "master" handler, rather than the base worker one.
* Add the List-Unsubscribe header for notification emails. (#16274)Patrick Cloke2023-09-111-1/+9
| | | | | | | | Adds both the List-Unsubscribe (RFC2369) and List-Unsubscribe-Post (RFC8058) headers to push notification emails, which together should: * Show an "Unsubscribe" link in the MUA UI when viewing Synapse notification emails. * Enable "one-click" unsubscribe (the user never leaves their MUA, which automatically makes a POST request to the specified endpoint).
* Filter out down hosts when retrying fetching device lists (#16298)Erik Johnston2023-09-111-1/+14
|
* Recheck if remote device is cached before requesting it (#16252)Erik Johnston2023-09-071-6/+15
| | | | This fixes a bug where we could get stuck re-requesting the device over replication again and again.
* Handle "registration_enabled" parameter for CAS (#16262)Aurélien Grimpard2023-09-061-0/+2
| | | | Similar to OIDC, CAS providers can now disable registration such that only existing users are able to login via SSO.
* Allow modules to delete rooms. (#15997)reivilibre2023-09-062-3/+19
| | | | | | | | | | | | | | | * Allow user_id to be optional for room deletion * Add module API method to delete a room * Newsfile Signed-off-by: Olivier Wilkinson (reivilibre) <oliverw@matrix.org> * Don't worry about the case block=True && requester_user_id is None --------- Signed-off-by: Olivier Wilkinson (reivilibre) <oliverw@matrix.org>
* Delete device messages asynchronously and in staged batches (#16240)Mathieu Velten2023-09-063-6/+62
|
* Time out busy presence status & test multi-device busy (#16174)Patrick Cloke2023-09-051-1/+18
| | | | | | | Add a (long) timeout to when a "busy" device is considered not online. This does *not* match MSC3026, but is a reasonable thing for an implementation to do. Expands tests for the (unstable) busy presence with multiple devices.
* Track presence state per-device and combine to a user state. (#16066)Patrick Cloke2023-09-051-47/+232
| | | | | | | | | | | Tracks presence on an individual per-device basis and combine the per-device state into a per-user state. This should help in situations where a user has multiple devices with conflicting status (e.g. one is syncing with unavailable and one is syncing with online). The tie-breaking is done by priority: BUSY > ONLINE > UNAVAILABLE > OFFLINE
* Bump twisted from 22.10.0 to 23.8.0 (#16235)dependabot[bot]2023-09-051-6/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | * Bump twisted from 22.10.0 to 23.8.0 Bumps [twisted](https://github.com/twisted/twisted) from 22.10.0 to 23.8.0. - [Release notes](https://github.com/twisted/twisted/releases) - [Changelog](https://github.com/twisted/twisted/blob/trunk/NEWS.rst) - [Commits](https://github.com/twisted/twisted/compare/twisted-22.10.0...twisted-23.8.0) --- updated-dependencies: - dependency-name: twisted dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] <support@github.com> * Fix types * Fix lint * 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>
* Don't wake up destination transaction queue if they're not due for retry. ↵Erik Johnston2023-09-044-27/+36
| | | | (#16223)
* Add last_seen_ts to the admin users API (#16218)Mathieu Velten2023-09-041-0/+1
|
* Stop writing to the event_txn_id table (#16175)Patrick Cloke2023-08-301-13/+0
|
* Describe which rate limiter was hit in logs (#16135)David Robertson2023-08-305-26/+17
|
* Track currently syncing users by device for presence (#16172)Patrick Cloke2023-08-291-55/+100
| | | | | | | Refactoring to use both the user ID & the device ID when tracking the currently syncing users in the presence handler. This is done both locally and over replication. Note that the device ID is discarded but will be used in a future change.
* Bump ruff from 0.0.277 to 0.0.286 (#16198)dependabot[bot]2023-08-291-1/+1
| | | | Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
* Support IPv6-only SMTP servers (#16155)Evilham2023-08-291-17/+11
| | | | Use Twisted HostnameEndpoint to connect to SMTP servers (instead of connectTCP/connectSSL) which properly supports IPv6-only servers.
* Pass the device ID around in the presence handler (#16171)Patrick Cloke2023-08-283-11/+45
| | | | | | Refactoring to pass the device ID (in addition to the user ID) through the presence handler (specifically the `user_syncing`, `set_state`, and `bump_presence_active_time` methods and their replication versions).
* Combine logic about not overriding BUSY presence. (#16170)Patrick Cloke2023-08-281-92/+63
| | | | | | | | | | | | | Simplify some of the presence code by reducing duplicated code between worker & non-worker modes. The main change is to push some of the logic from `user_syncing` into `set_state`. This is done by passing whether the user is setting the presence via a `/sync` with a new `is_sync` flag to `set_state`. If this is `true` some additional logic is performed: * Don't override `busy` presence. * Update the `last_user_sync_ts`. * Never update the status message.
* Add configuration setting for CAS protocol version (#15816)Aurélien Grimpard2023-08-241-1/+5
|
* Fix typechecking with twisted trunk (#16121)David Robertson2023-08-241-16/+16
|
* Only lock when we're backfilling (#16159)Erik Johnston2023-08-232-146/+156
|
* Disable caching in /sync corner case (#16080)Matthew Ma2023-08-171-10/+10
| | | Fixes #15502
* Rename pagination&purge locks and add comments explaining them (#16112)Mathieu Velten2023-08-164-13/+22
|
* Run pyupgrade for python 3.7 & 3.8. (#16110)Patrick Cloke2023-08-154-11/+16
|
* Allow customizing IdP name and icon for SAML and CAS (#16094)Gabriel Rodríguez2023-08-112-10/+12
|
* Clean-up presence code (#16092)Patrick Cloke2023-08-101-94/+75
| | | | | | | | Misc. clean-ups to: * Use keyword arguments. * Return early (reducing indentation) of some functions. * Removing duplicated / unused code. * Use wrap_as_background_process.
* Implements admin API to lock an user (MSC3939) (#15870)Mathieu Velten2023-08-102-1/+5
|
* Support MSC3814: Dehydrated Devices Part 2 (#16010)Shay2023-08-082-16/+11
|
* Fix deletion for Dehydrated Devices (#16046)Shay2023-08-041-0/+16
|
* Stabilize support for MSC3970: updated transaction semantics (scope to ↵Patrick Cloke2023-08-041-7/+5
| | | | | | | `device_id`) (#15629) For now this maintains compatible with old Synapses by falling back to using transaction semantics on a per-access token. A future version of Synapse will drop support for this.
* Trim whitespace when setting display names (#16031)Mohit Rathee2023-08-011-1/+1
|
* Combine duplicated code for calculating an event ID from a txn ID (#16023)Patrick Cloke2023-07-312-32/+35
| | | | Refactoring related to stabilization of MSC3970, refactor to combine code which has the same logic.
* Add ability to wait for locks and add locks to purge history / room deletion ↵Erik Johnston2023-07-314-25/+414
| | | | | (#15791) c.f. #13476
* Fix 404 on /profile when the display name is empty but not the avatar (#16012)Mathieu Velten2023-07-271-1/+1
|
* Support MSC3814: Dehydrated Devices (#15929)Shay2023-07-242-3/+109
| | | | | | Signed-off-by: Nicolas Werner <n.werner@famedly.com> Co-authored-by: Nicolas Werner <n.werner@famedly.com> Co-authored-by: Nicolas Werner <89468146+nico-famedly@users.noreply.github.com> Co-authored-by: Hubert Chathi <hubert@uhoreg.ca>
* Resync stale devices in background (#15975)Erik Johnston2023-07-241-1/+8
| | | | This is so we don't block responding to federation transaction while we try and fetch the device lists.
* Speed up updating state in large rooms (#15971)Erik Johnston2023-07-201-5/+4
| | | This should speed up updating state in rooms with lots of state.
* Reduce the amount of state we pull out (#15968)Erik Johnston2023-07-203-12/+13
|
* Support room version 11 (#15912)Patrick Cloke2023-07-184-6/+6
| | | | | And fix a bug in the implementation of the updated redaction format (MSC2174) where the top-level redacts field was not properly added for backwards-compatibility.
* Add a locality to a few presence metrics (#15952)Jason Little2023-07-181-13/+24
|
* Better warning in logs when we fail to fetch an alias (#15922)Eric Eastwood2023-07-111-1/+3
| | | | | | | | | | | | | **Before:** ``` Error retrieving alias ``` **After:** ``` Error retrieving alias #foo:bar -> 401 Unauthorized ``` *Spawning from creating the [manual testing strategy for the outbound federation proxy](https://github.com/matrix-org/synapse/pull/15773).*
* Add + as an allowed character for Matrix IDs (MSC4009) (#15911)Patrick Cloke2023-07-113-13/+6
|
* Remove experimental MSC2716 implementation to incrementally import history ↵Eric Eastwood2023-06-165-796/+34
| | | | | | | | | | | | into existing rooms (#15748) Context for why we're removing the implementation: - https://github.com/matrix-org/matrix-spec-proposals/pull/2716#issuecomment-1487441010 - https://github.com/matrix-org/matrix-spec-proposals/pull/2716#issuecomment-1504262734 Anyone wanting to continue MSC2716, should also address these leftover tasks: https://github.com/matrix-org/synapse/issues/10737 Closes https://github.com/matrix-org/synapse/issues/10737 in the fact that it is not longer necessary to track those things.
* Fix joining rooms through aliases where the alias server isn't a real ↵Tulir Asokan2023-06-141-1/+1
| | | | homeserver (#15776)
* Avoid backfill when we already have messages to return (#15737)Eric Eastwood2023-06-131-22/+115
| | | | | We now only block the client to backfill when we see a large gap in the events (more than 2 events missing in a row according to `depth`), more than 3 single-event holes, or not enough messages to fill the response. Otherwise, we return the messages directly to the client and backfill in the background for eventual consistency sake. Fix https://github.com/matrix-org/synapse/issues/15696
* Backfill in the background if we're doing it "just because" (#15710)Eric Eastwood2023-06-091-4/+14
| | | Fix https://github.com/matrix-org/synapse/issues/15702
* Check required power levels earlier in createRoom handler. (#15695)Grant McLean2023-06-071-14/+62
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * Check required power levels earlier in createRoom handler. - If a server was configured to reject the creation of rooms with E2EE enabled (by specifying an unattainably high power level for "m.room.encryption" in default_power_level_content_override), the 403 error was not being triggered until after the room was created and before the "m.room.power_levels" was sent. This allowed a user to access the partially-configured room and complete the setup of E2EE and power levels manually. - This change causes the power level overrides to be checked earlier and the request to be rejected before the user gains access to the room. - A new `_validate_room_config` method is added to contain checks that should be run before a room is created. - The new test case confirms that a user request is rejected by the new validation method. Signed-off-by: Grant McLean <grant@catalyst.net.nz> * Add a changelog file. * Formatting fix for black. * Remove unneeded line from test. --------- Signed-off-by: Grant McLean <grant@catalyst.net.nz>
* Remove some unused `server_name` fields (#15723)Sean Quah2023-06-064-4/+0
| | | Signed-off-by: Sean Quah <seanq@matrix.org>
* Some house keeping on `maybe_backfill()` functions (#15709)Eric Eastwood2023-06-051-0/+17
|
* `N + 3`: Read from column `full_user_id` rather than `user_id` of tables ↵Shay2023-06-026-22/+14
| | | | `profiles` and `user_filters` (#15649)
* Add a catch-all * to the supported relation types when redacting (#15705)Mathieu Velten2023-06-021-5/+11
| | | This is an update to MSC3912 implementation
* Add stricter mypy options (#15694)Patrick Cloke2023-05-312-3/+3
| | | | Enable warn_unused_configs, strict_concatenate, disallow_subclassing_any, and disallow_incomplete_defs.
* Refactor config to be an experimental featureHugh Nimmo-Smith2023-05-301-2/+2
| | | | Also enforce you can't combine it with incompatible config options
* Disable account related endpoints when using OAuth delegationQuentin Gliech2023-05-301-1/+7
|
* Process previously failed backfill events in the background (#15585)Eric Eastwood2023-05-241-8/+62
| | | | | | | | | 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-241-1/+2
| | | | `TransportLayerClient` (#15663)
* Consolidate logic to check for deactivated users. (#15634)Patrick Cloke2023-05-232-25/+8
| | | | | | | 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.
* 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.
* Rename blacklist/whitelist internally. (#15620)Patrick Cloke2023-05-193-12/+10
| | | | 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-191-0/+118
| | | | | 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).
* Handle missing previous read marker event. (#15464)Nick Mills-Barrett2023-05-181-4/+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.
* Error if attempting to set m.push_rules account data, per MSC4010. (#15555)Patrick Cloke2023-05-092-11/+17
| | | | | 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-092-8/+9
|
* 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-052-15/+18
| | | | | 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.
* Clean up and clarify "Create or modify Account" Admin API documentation (#15544)Andrew Morgan2023-05-051-2/+2
|
* Factor out an `is_mine_server_name` method (#15542)Sean Quah2023-05-056-8/+13
| | | | | | | | | | | | 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-049-19/+28
|
* 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.
* Add config option to forget rooms automatically when users leave them (#15224)Sean Quah2023-05-032-22/+154
| | | | | This is largely based off the stats and user directory updater code. Signed-off-by: Sean Quah <seanq@matrix.org>
* Initial implementation of MSC3981: recursive relations API (#15315)Patrick Cloke2023-05-021-0/+3
| | | | | | | | | | | 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 support for claiming multiple OTKs at once. (#15468)Patrick Cloke2023-04-272-16/+29
| | | | | | | 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 column `full_user_id` to tables `profiles` and `user_filters`. (#15458)Shay2023-04-261-6/+2
|
* Add unstable /keys/claim endpoint which always returns fallback keys. (#15462)Patrick Cloke2023-04-252-15/+68
| | | | | | | | | | | | | 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.
* Experimental support for MSC3970: per-device transaction IDs (#15318)Quentin Gliech2023-04-252-12/+59
|
* Remove legacy code of single user device resync api (#15418)Alok Kumar Singh2023-04-213-64/+22
| | | | | * Removed single-user resync usage and updated it to use multi-user counterpart Signed-off-by: Alok Kumar Singh alokaks601@gmail.com
* Move Spam Checker callbacks to a dedicated file (#15453)Andrew Morgan2023-04-187-26/+44
|
* Delete pushers after calling on_logged_out module hook on device delete (#15410)Mathieu Velten2023-04-141-2/+4
|
* Implement MSC2175: remove the creator field from create events. (#15394)Patrick Cloke2023-04-063-12/+22
|
* Don't keep old stream_ordering_to_exterm around (#15382)Erik Johnston2023-04-061-0/+10
|
* Delete server-side backup keys when deactivating an account. (#15181)Shay2023-04-041-0/+3
|
* 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>
* Revert pruning of old devices (#15360)Erik Johnston2023-03-312-51/+3
| | | | | | | | | * 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.
* Implement MSC3984 to proxy /keys/query requests to appservices. (#15321)Patrick Cloke2023-03-302-0/+77
| | | | | 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-302-25/+35
| | | | | | | | 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-302-2/+16
| | | Signed-off-by: Warren Bailey <warren@warrenbailey.net>
* Fix registering a device on an account with lots of devices (#15348)Erik Johnston2023-03-291-0/+2
| | | Fixes up #15183
* Delete stale non-e2e devices for users, take 3 (#15183)Erik Johnston2023-03-292-3/+49
| | | | | 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-282-9/+122
| | | | | | 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.
* Prune old typing notifications (#15332)Erik Johnston2023-03-271-0/+25
| | | | | Rather than keeping them around forever in memory, slowing things down. Fixes #11750.
* Make cleaning up pushers depend on the device_id instead of the token_id ↵Quentin Gliech2023-03-243-4/+10
| | | | | | | | | | | | | | (#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.
* 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
* Refresh remote profiles that have been marked as stale, in order to fill the ↵reivilibre2023-03-162-2/+244
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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-161-85/+14
|
* Preparatory work to fix the user directory assuming that any remote ↵reivilibre2023-03-161-34/+47
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* 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-131-5/+24
|\
| * Refactor `filter_events_for_server` (#15240)David Robertson2023-03-101-5/+24
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * 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
* | 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 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-081-1/+1
| |
* | More speedups/fixes to creating batched events (#15195)Shay2023-03-072-3/+14
|/
* Pass the requester during event serialization. (#15174)Quentin Gliech2023-03-066-46/+93
| | | | This allows Synapse to properly include the transaction ID in the unsigned data of events.
* Experimental MSC3890 Implementation: Fix deleting account data when using an ↵Andrew Morgan2023-03-031-7/+0
| | | | account data writer worker (#14869)
* Add support for knocking to workers. (#15133)Dirk Klimpel2023-03-022-2/+6
|
* Implementation of MSC3967: Don't require UIA for initial upload of cross ↵Hugh Nimmo-Smith2023-03-021-0/+14
| | | | signing keys (#15077)
* Remove support for aggregating reactions (#15172)Richard van der Hoff2023-02-281-75/+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.
* Add module API callbacks for adding and deleting local 3PID associations (#15044Andrew Morgan2023-02-272-27/+42
|
* Batch up storing state groups when creating new room (#14918)Shay2023-02-244-29/+41
|
* Add information on uploaded media to user export command. (#15107)Dirk Klimpel2023-02-231-0/+38
|
* Bump black from 22.12.0 to 23.1.0 (#15103)dependabot[bot]2023-02-2210-16/+12
|
* Remove unused `room_alias` field from `/createRoom` response (#15093)David Robertson2023-02-222-21/+21
| | | | | | | | | | | | | | * 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
* Add account data to export command (#14969)Dirk Klimpel2023-02-171-15/+34
| | | | | | | | | | | * 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-162-5/+15
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * 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 the error code for duplicate annotation (#15075)Richard van der Hoff2023-02-151-1/+5
|
* Fix order of partial state tables when purging (#15068)David Robertson2023-02-141-0/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * 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>
* 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>
* Skip calculating unread push actions in `/sync` when `enable_push` is false. ↵Erik Johnston2023-02-141-0/+8
| | | | (#14980)
* 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-133-33/+26
| | | | separate args (#15053)
* Faster joins: don't stall when a user joins during a fast join (#14606)Mathieu Velten2023-02-107-53/+151
| | | | | | | | | | | | | | | | 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-104-8/+8
| | | | | | | | | | | | | 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>
* Avoid fetching unused account data in sync. (#14973)Patrick Cloke2023-02-104-48/+57
| | | | | | | 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.
* 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-101-4/+7
| | | | | | | | 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.
* Add a class UnpersistedEventContext to allow for the batching up of storing ↵Shay2023-02-093-37/+70
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* Avoid mutating cached room aliases. (#15038)Patrick Cloke2023-02-091-1/+2
| | | | | This might cause incorrect data in other callers which are not expecting the canonical alias to be added into the response.
* Add final type hint to synapse.server. (#15035)Patrick Cloke2023-02-091-1/+1
|
* Limit concurrent event creation for a room to avoid state resolution when ↵Shay2023-02-081-3/+3
| | | | sending bursts of events to a local room (#14977)
* Faster joins: Refactor handling of servers in room (#14954)Sean Quah2023-02-032-5/+16
| | | | | | | | | | | | | | Ensure that the list of servers in a partial state room always contains the server we joined off. Also refactor `get_partial_state_servers_at_join` to return `None` when the given room is no longer partial stated, to explicitly indicate when the room has partial state. Otherwise it's not clear whether an empty list means that the room has full state, or the room is partial stated, but the server we joined off told us that there are no servers in the room. Signed-off-by: Sean Quah <seanq@matrix.org>
* Skip unused calculations in sync handler. (#14908)Patrick Cloke2023-02-021-125/+133
| | | | | | | | | If a sync request does not need to calculate per-room entries & is not generating presence & is not generating device list data (e.g. during initial sync) avoid the expensive calculation of room specific data. This is a micro-optimisation for clients syncing simply to receive to-device information.
* Do not calculate presence or ephemeral events when they are filtered out ↵Patrick Cloke2023-02-021-10/+9
| | | | | | | | (#14970) This expands the previous optimisation from being only for initial sync to being for all sync requests. It also inverts some of the logic to be inclusive instead of exclusive.
* Add helper to parse an enum from query args & use it. (#14956)Patrick Cloke2023-02-013-6/+7
| | | | | | | | The `parse_enum` helper pulls an enum value from the query string (by delegating down to the parse_string helper with values generated from the enum). This is used to pull out "f" and "b" in most places and then we thread the resulting Direction enum throughout more code.
* Add more user information to export-data command. (#14894)Dirk Klimpel2023-02-011-0/+43
| | | | | | * The user's profile information. * The user's devices. * The user's connections / IP address information.
* Fix "Re-starting finished log context" spam when creating events (#14947)Sean Quah2023-01-311-1/+3
| | | | | | | | | | | `run_in_background` calls re-use the current logging context. When they are not awaited, they can complete after the current logging context has been marked as finished, which leads to log spam. Use `run_as_background_process` instead. Fixes one of the instances of #13090. Signed-off-by: Sean Quah <seanq@matrix.org>
* Prefer `type(x) is int` to `isinstance(x, int)` (#14945)David Robertson2023-01-311-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * Perfer `type(x) is int` to `isinstance(x, int)` This covered all additional instances I could see where `x` was user-controlled. The remaining cases are ``` $ rg -s 'isinstance.*[^_]int' tests/replication/_base.py 576: if isinstance(obj, int): synapse/util/caches/stream_change_cache.py 136: assert isinstance(stream_pos, int) 214: assert isinstance(stream_pos, int) 246: assert isinstance(stream_pos, int) 267: assert isinstance(stream_pos, int) synapse/replication/tcp/external_cache.py 133: if isinstance(result, int): synapse/metrics/__init__.py 100: if isinstance(calls, (int, float)): synapse/handlers/appservice.py 262: assert isinstance(new_token, int) synapse/config/_util.py 62: if isinstance(p, int): ``` which cover metrics, logic related to `jsonschema`, and replication and data streams. AFAICS these are all internal to Synapse * Changelog
* Merge branch 'release-v1.76' into developDavid Robertson2023-01-271-7/+17
|\
| * Batch look-ups to see if rooms are partial stated. (#14917)Patrick Cloke2023-01-261-7/+17
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * Batch look-ups to see if rooms are partial stated. * Fix issues found in linting. * Fix typo. * Apply suggestions from code review Co-authored-by: Sean Quah <8349537+squahtx@users.noreply.github.com> * Clarify comments. Co-authored-by: Sean Quah <8349537+squahtx@users.noreply.github.com> * Also improve the cache size while we're at it * is_partial_state_rooms -> is_partial_state_room_batched * Run `black` * Improve annotation for `simple_select_many_batch` * Fix is_partial_state_room_batched impl * Okay, _actually_ fix impl * Update description. * Update synapse/storage/databases/main/room.py Co-authored-by: Patrick Cloke <clokep@users.noreply.github.com> * Run black. Co-authored-by: Sean Quah <8349537+squahtx@users.noreply.github.com> Co-authored-by: David Robertson <davidr@element.io>
* | Use an enum for direction. (#14927)Patrick Cloke2023-01-274-9/+25
| | | | | | | | For better type safety we use an enum instead of strings to configure direction (backwards or forwards).
* | Use StrCollection in place of Collection[str] in (most) handlers code. (#14922)Patrick Cloke2023-01-2611-56/+40
| | | | | | | | Due to the increased safety of StrCollection over Collection[str] and Sequence[str].
* | Fix a bug in the send_local_online_presence_to module API (#14880)Patrick Cloke2023-01-251-6/+12
|/ | | | | | | Destination was being used incorrectly (a single destination instead of a list of destinations was being passed). This also updates some of the types in the area to not use Collection[str], which is a footgun.
* Faster joins: omit partial rooms from eager syncs until the resync completes ↵David Robertson2023-01-232-20/+60
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | (#14870) * Allow `AbstractSet` in `StrCollection` Or else frozensets are excluded. This will be useful in an upcoming commit where I plan to change a function that accepts `List[str]` to accept `StrCollection` instead. * `rooms_to_exclude` -> `rooms_to_exclude_globally` I am about to make use of this exclusion mechanism to exclude rooms for a specific user and a specific sync. This rename helps to clarify the distinction between the global config and the rooms to exclude for a specific sync. * Better function names for internal sync methods * Track a list of excluded rooms on SyncResultBuilder I plan to feed a list of partially stated rooms for this sync to ignore * Exclude partial state rooms during eager sync using the mechanism established in the previous commit * Track un-partial-state stream in sync tokens So that we can work out which rooms have become fully-stated during a given sync period. * Fix mutation of `@cached` return value This was fouling up a complement test added alongside this PR. Excluding a room would mean the set of forgotten rooms in the cache would be extended. This means that room could be erroneously considered forgotten in the future. Introduced in #12310, Synapse 1.57.0. I don't think this had any user-visible side effects (until now). * SyncResultBuilder: track rooms to force as newly joined Similar plan as before. We've omitted rooms from certain sync responses; now we establish the mechanism to reintroduce them into future syncs. * Read new field, to present rooms as newly joined * Force un-partial-stated rooms to be newly-joined for eager incremental syncs only, provided they're still fully stated * Notify user stream listeners to wake up long polling syncs * Changelog * Typo fix Co-authored-by: Sean Quah <8349537+squahtx@users.noreply.github.com> * Unnecessary list cast Co-authored-by: Sean Quah <8349537+squahtx@users.noreply.github.com> * Rephrase comment Co-authored-by: Sean Quah <8349537+squahtx@users.noreply.github.com> * Another comment Co-authored-by: Sean Quah <8349537+squahtx@users.noreply.github.com> * Fixup merge(?) * Poke notifier when receiving un-partial-stated msg over replication * Fixup merge whoops Thanks MV :) Co-authored-by: Mathieu Velen <mathieuv@matrix.org> Co-authored-by: Mathieu Velten <mathieuv@matrix.org> Co-authored-by: Sean Quah <8349537+squahtx@users.noreply.github.com>
* Faster joins: Update room stats and the user directory on workers when ↵Sean Quah2023-01-231-3/+4
| | | | | | | | | | | | | | | | | | | | | | | finishing join (#14874) * Faster joins: Update room stats and user directory on workers when done When finishing a partial state join to a room, we update the current state of the room without persisting additional events. Workers receive notice of the current state update over replication, but neglect to wake the room stats and user directory updaters, which then get incidentally triggered the next time an event is persisted or an unrelated event persister sends out a stream position update. We wake the room stats and user directory updaters at the appropriate time in this commit. Part of #12814 and #12815. Signed-off-by: Sean Quah <seanq@matrix.org> * fixup comment Signed-off-by: Sean Quah <seanq@matrix.org>
* Enable Faster Remote Room Joins against worker-mode Synapse. (#14752)reivilibre2023-01-222-3/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * Enable Complement tests for Faster Remote Room Joins on worker-mode * (dangerous) Add an override to allow Complement to use FRRJ under workers * Newsfile Signed-off-by: Olivier Wilkinson (reivilibre) <oliverw@matrix.org> * Fix race where we didn't send out replication notification * MORE HACKS * Fix get_un_partial_stated_rooms_token to take instance_name * Fix bad merge * Remove warning * Correctly advance un_partial_stated_room_stream * Fix merge * Add another notify_replication * Fixups * Create a separate ReplicationNotifier * Fix test * Fix portdb * Create a separate ReplicationNotifier * Fix test * Fix portdb * Fix presence test * Newsfile * Apply suggestions from code review * Update changelog.d/14752.misc Co-authored-by: Erik Johnston <erik@matrix.org> * lint Signed-off-by: Olivier Wilkinson (reivilibre) <oliverw@matrix.org> Co-authored-by: Erik Johnston <erik@matrix.org>
* Faster joins: Fix incompatibility with restricted joins (#14882)Sean Quah2023-01-221-81/+134
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * Avoid clearing out forward extremities when doing a second remote join When joining a restricted room where the local homeserver does not have a user able to issue invites, we perform a second remote join. We want to avoid clearing out forward extremities in this case because the forward extremities we have are up to date and clearing out forward extremities creates a window in which the room can get bricked if Synapse crashes. Signed-off-by: Sean Quah <seanq@matrix.org> * Do a full join when doing a second remote join into a full state room We cannot persist a partial state join event into a joined full state room, so we perform a full state join for such rooms instead. As a future optimization, we could always perform a partial state join and compute or retrieve the full state ourselves if necessary. Signed-off-by: Sean Quah <seanq@matrix.org> * Add lock around partial state flag for rooms Signed-off-by: Sean Quah <seanq@matrix.org> * Preserve partial state info when doing a second partial state join Signed-off-by: Sean Quah <seanq@matrix.org> * Add newsfile * Add a TODO(faster_joins) marker Signed-off-by: Sean Quah <seanq@matrix.org>
* Faster joins: Avoid starting duplicate partial state syncs (#14844)Sean Quah2023-01-201-8/+98
| | | | | | | | | | | | | | | | | | Currently, we will try to start a new partial state sync every time we perform a remote join, which is undesirable if there is already one running for a given room. We intend to perform remote joins whenever additional local users wish to join a partial state room, so let's ensure that we do not start more than one concurrent partial state sync for any given room. ------------------------------------------------------------------------ There is a race condition where the homeserver leaves a room and later rejoins while the partial state sync from the previous membership is still running. There is no guarantee that the previous partial state sync will process the latest join, so we restart it if needed. Signed-off-by: Sean Quah <seanq@matrix.org>
* Wait for streams to catch up when processing HTTP replication. (#14820)Erik Johnston2023-01-181-0/+4
| | | | This should hopefully mitigate a class of races where data gets out of sync due a HTTP replication request racing with the replication streams.
* Add an early return when handling no-op presence updates. (#14855)Erik Johnston2023-01-161-0/+5
| | | This stops us from incrementing the presence stream position for no-op updates.
* Implement MSC3890: Remotely silence local notifications (#14775)Andrew Morgan2023-01-131-1/+10
|
* Merge account data streams (#14826)Erik Johnston2023-01-133-6/+20
|
* Merge remote-tracking branch 'origin/release-v1.75' into developRichard van der Hoff2023-01-121-4/+0
|\
| * Calculate rooms changed for device lists to work. (#14810)Patrick Cloke2023-01-111-4/+0
| | | | | | | | Back-out some changes from 7e582a25f8f350df29d7d83ca902bdb522d1bbaf (#14786) which skipped necessary logic to calculate device lists properly.
* | Faster remote room joins (worker mode): do not populate external ↵reivilibre2023-01-111-5/+16
|/ | | | | | hosts-in-room cache when sending events as this requires blocking for full state. (#14749) Signed-off-by: Olivier Wilkinson (reivilibre) <oliverw@matrix.org> Co-authored-by: Sean Quah <seanq@matrix.org>
* Batch up replication requests to request the resyncing of remote users's ↵reivilibre2023-01-104-66/+155
| | | | devices. (#14716)
* Improve /sync performance of when passing filters with empty arrays. (#14786)Patrick Cloke2023-01-092-4/+12
| | | | | | | | | | | | | | | | This has two related changes: * It enables fast-path processing for an empty filter (`[]`) which was previously only used for wildcard not-filters (`["*"]`). * It special cases a `/sync` filter with no-rooms to skip all room processing, previously we would partially skip processing, but would generally still calculate intermediate values for each room which were then unused. Future changes might consider further optimizations: * Skip calculating per-room account data when all rooms are filtered (currently this is thrown away). * Make similar improvements to other endpoints which support filters.
* Support RFC7636 PKCE in the OAuth 2.0 flow. (#14750)Patrick Cloke2023-01-041-7/+47
| | | | | | | PKCE can protect against certain attacks and is enabled by default. Support can be controlled manually by setting the pkce_method of each oidc_providers entry to 'auto' (default), 'always', or 'never'. This is required by Twitter OAuth 2.0 support.
* Support non-OpenID compliant user info endpoints (#14753)Patrick Cloke2023-01-041-8/+23
| | | | | | | | OpenID specifies the format of the user info endpoint and some OAuth 2.0 IdPs do not follow it, e.g. NextCloud and Twitter. This adds subject_template and picture_template options to the default mapping provider for more flexibility in matching those user info responses.
* Add experimental support for MSC3391: deleting account data (#14714)Andrew Morgan2023-01-011-8/+103
|
* Actually use the picture_claim as configured in OIDC config. (#14751)Patrick Cloke2022-12-291-1/+1
| | | | Previously it was only using the default value ("picture") when fetching the picture from the user info.
* Log to-device msgids when we return them over /sync (#14724)Richard van der Hoff2022-12-231-7/+13
|
* Add missing type hints to tests.handlers. (#14680)Patrick Cloke2022-12-161-1/+1
| | | And do not allow untyped defs in tests.handlers.
* Make `handle_new_client_event` throws `PartialStateConflictError` (#14665)Mathieu Velten2022-12-155-235/+349
| | | | | | | Then adapts calling code to retry when needed so it doesn't 500 to clients. Signed-off-by: Mathieu Velten <mathieuv@matrix.org> Co-authored-by: Sean Quah <8349537+squahtx@users.noreply.github.com>
* Faster remote room joins: stream the un-partial-stating of events over ↵reivilibre2022-12-141-0/+2
| | | | replication. [rei:frrj/streams/unpsr] (#14545)
* Use the room type from stats in hierarchy response. (#14263)Patrick Cloke2022-12-131-9/+5
| | | | | | | | | This avoids pulling additional state information (and events) from the database for each item returned in the hierarchy response. The room type might be out of date until a background update finishes running, the worst impact of this would be spaces being treated as rooms in the hierarchy response. This should self-heal once the background update finishes.
* Improve validation of field size limits in events. (#14664)reivilibre2022-12-131-0/+20
|
* Allow selecting "prejoin" events by state keys (#14642)David Robertson2022-12-131-11/+18
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * Declare new config * Parse new config * Read new config * Don't use trial/our TestCase where it's not needed Before: ``` $ time trial tests/events/test_utils.py > /dev/null real 0m2.277s user 0m2.186s sys 0m0.083s ``` After: ``` $ time trial tests/events/test_utils.py > /dev/null real 0m0.566s user 0m0.508s sys 0m0.056s ``` * Helper to upsert to event fields without exceeding size limits. * Use helper when adding invite/knock state Now that we allow admins to include events in prejoin room state with arbitrary state keys, be a good Matrix citizen and ensure they don't accidentally create an oversized event. * Changelog * Move StateFilter tests should have done this in #14668 * Add extra methods to StateFilter * Use StateFilter * Ensure test file enforces typed defs; alphabetise * Workaround surprising get_current_state_ids * Whoops, fix mypy
* Move `StateFilter` to `synapse.types` (#14668)David Robertson2022-12-129-9/+9
| | | | | * Move `StateFilter` to `synapse.types` * Changelog
* Revert the deletion of stale devices due to performance issues. (#14662)reivilibre2022-12-121-32/+1
|
* Limit the number of devices we delete at once (#14649)Erik Johnston2022-12-091-1/+3
|
* Delete stale non-e2e devices for users, take 2 (#14595)Erik Johnston2022-12-091-1/+30
| | | | | 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.
* Improve logging and opentracing for to-device message handling (#14598)Richard van der Hoff2022-12-063-24/+41
| | | | | | | A batch of changes intended to make it easier to trace to-device messages through the system. The intention here is that a client can set a property org.matrix.msgid in any to-device message it sends. That ID is then included in any tracing or logging related to the message. (Suggestions as to where this field should be documented welcome. I'm not enthusiastic about speccing it - it's very much an optional extra to help with debugging.) I've also generally improved the data we send to opentracing for these messages.
* Better return type for `get_all_entities_changed` (#14604)Erik Johnston2022-12-054-13/+17
| | | | Help callers from using the return value incorrectly by ensuring that callers explicitly check if there was a cache hit or not.
* Faster remote room joins: stream the un-partial-stating of rooms over ↵reivilibre2022-12-052-1/+5
| | | | replication. [rei:frrj/streams/unpsr] (#14473)
* Properly handle unknown results for the stream change cache. (#14592)Patrick Cloke2022-12-021-2/+2
| | | | | | StreamChangeCache.get_all_changed_entities can return None to signify it does not have information at the given stream position. Two callers (related to device lists and presence) were treating this response the same as an empty list (i.e. there being no updates).
* Revert "POC delete stale non-e2e devices for users (#14038)" (#14582)David Robertson2022-11-291-12/+1
|
* POC delete stale non-e2e devices for users (#14038)Erik Johnston2022-11-291-1/+12
| | | | | | | | 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. Co-authored-by: Patrick Cloke <clokep@users.noreply.github.com> Co-authored-by: Sean Quah <8349537+squahtx@users.noreply.github.com>
* Fix possible variable shadow in `create_new_client_event` (#14575)Shay2022-11-281-2/+4
|
* Use `device_one_time_keys_count` to match MSC3202 (#14565)Andrew Ferrazzutti2022-11-281-3/+3
| | | | | | | | | | | | | | | | | | | * Use `device_one_time_keys_count` to match MSC3202 Rename the `device_one_time_key_counts` key in responses to `device_one_time_keys_count` to match the name specified by MSC3202. Also change related variable/class names for consistency. Signed-off-by: Andrew Ferrazzutti <andrewf@element.io> * Update changelog.d/14565.misc * Revert name change for `one_time_key_counts` key as this is a different key altogether from `device_one_time_keys_count`, which is used for `/sync` instead of appservice transactions. Signed-off-by: Andrew Ferrazzutti <andrewf@element.io>
* Include thread information when sending receipts over federation. (#14466)Patrick Cloke2022-11-281-1/+0
| | | | | | | | | | | | Include the thread_id field when sending read receipts over federation. This might result in the same user having multiple read receipts per-room, meaning multiple EDUs must be sent to encapsulate those receipts. This restructures the PerDestinationQueue APIs to support multiple receipt EDUs, queue_read_receipt now becomes linear time in the number of queued threaded receipts in the room for the given user, it is expected this is a small number since receipt EDUs are sent as filler in transactions.
* Add support for handling avatar with SSO login (#13917)Ashish Kumar2022-11-252-0/+118
| | | | | | | | This commit adds support for handling a provided avatar picture URL when logging in via SSO. Signed-off-by: Ashish Kumar <ashfame@users.noreply.github.com> Fixes #9357.
* Implement message forward pagination from start when no from is given, fixes ↵Benjamin Kampmann2022-11-241-0/+6
| | | | | #12383 (#14149) Fixes https://github.com/matrix-org/synapse/issues/12383
* Faster joins: use servers list approximation in `assert_host_in_room` (#14515)Mathieu Velten2022-11-241-11/+17
| | | Signed-off-by: Mathieu Velten <mathieuv@matrix.org>
* Add a type hint for `get_device_handler()` and fix incorrect types. (#14055)Patrick Cloke2022-11-226-45/+104
| | | | | This was the last untyped handler from the HomeServer object. Since it was being treated as Any (and thus unchecked) it was being used incorrectly in a few places.
* Track unconverted device list outbound pokes using a position instead (#14516)Sean Quah2022-11-221-3/+27
| | | | | | | | | | | | | | | | | | | | | When a local device list change is added to `device_lists_changes_in_room`, the `converted_to_destinations` flag is set to `FALSE` and the `_handle_new_device_update_async` background process is started. This background process looks for unconverted rows in `device_lists_changes_in_room`, copies them to `device_lists_outbound_pokes` and updates the flag. To update the `converted_to_destinations` flag, the database performs a `DELETE` and `INSERT` internally, which fragments the table. To avoid this, track unconverted rows using a `(stream ID, room ID)` position instead of the flag. From now on, the `converted_to_destinations` column indicates rows that need converting to outbound pokes, but does not indicate whether the conversion has already taken place. Closes #14037. Signed-off-by: Sean Quah <seanq@matrix.org>
* Parallelize calls to fetch bundled aggregations. (#14510)Patrick Cloke2022-11-221-32/+51
| | | | The bundled aggregations for annotations, references, and edits can be parallelized.
* Batch fetch bundled references (#14508)Patrick Cloke2022-11-221-69/+59
| | | | | | | | | Avoid an n+1 query problem and fetch the bundled aggregations for m.reference relations in a single query instead of a query per event. This applies similar logic for as was previously done for edits in 8b309adb436c162510ed1402f33b8741d71fc058 (#11660; threads in b65acead428653b988351ae8d7b22127a22039cd (#11752); and annotations in 1799a54a545618782840a60950ef4b64da9ee24d (#14491).
* Batch fetch bundled annotations (#14491)Patrick Cloke2022-11-221-84/+113
| | | | | | | | Avoid an n+1 query problem and fetch the bundled aggregations for m.annotation relations in a single query instead of a query per event. This applies similar logic for as was previously done for edits in 8b309adb436c162510ed1402f33b8741d71fc058 (#11660) and threads in b65acead428653b988351ae8d7b22127a22039cd (#11752).
* Faster joins: filter out non local events when a room doesn't have its full ↵Mathieu Velten2022-11-211-5/+10
| | | | | | state (#14404) Signed-off-by: Mathieu Velten <mathieuv@matrix.org>
* Fix an invalid comparison of `UserPresenceState` to `str` (#14393)Andrew Morgan2022-11-161-1/+1
|
* Remove redundant types from comments. (#14412)Patrick Cloke2022-11-167-10/+11
| | | | | | | Remove type hints from comments which have been added as Python type hints. This helps avoid drift between comments and reality, as well as removing redundant information. Also adds some missing type hints which were simple to fill in.
* Don't filter state in /context response (#14461)Erik Johnston2022-11-161-1/+1
| | | We don't filter state usually, so doing so here is a waste of time. This is not much of an issue for clients that enable lazy loading of members, since there will be fewer state events.
* Include heroes in partial join responses' state (#14442)David Robertson2022-11-151-17/+3
| | | | | | | | | | | * Pull out hero selection logic * Include heroes in partial join response's state * Changelog * Fixup trial test * Remove TODO
* Quieter logging for stateres failure at missing prev events (#14346)David Robertson2022-11-101-3/+2
|
* Correctly create power level event during initial room creation (#14361)Shay2022-11-071-2/+23
|
* Bump flake8-bugbear from 22.9.23 to 22.10.27 (#14329)dependabot[bot]2022-11-041-2/+4
| | | | | Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: GitHub Actions <github-actions[bot]@users.noreply.github.com> Co-authored-by: Olivier Wilkinson (reivilibre) <oliverw@matrix.org>
* Implement MSC3912: Relation-based redactions (#14260)Brendan Abolivier2022-11-032-10/+93
| | | Co-authored-by: Sean Quah <8349537+squahtx@users.noreply.github.com>
* Allow PUT/GET of aliases during faster join (#14292)David Robertson2022-11-011-2/+2
| | | without blocking on full state.
* Support OIDC backchannel logouts (#11414)Quentin Gliech2022-10-312-36/+416
| | | | | | | If configured an OIDC IdP can log a user's session out of Synapse when they log out of the identity provider. The IdP sends a request directly to Synapse (and must be configured with an endpoint) when a user logs out.
* Prevent federation user keys query from returning device names if disallowed ↵Andrew Morgan2022-10-281-4/+33
| | | | (#14304)
* Merge branch 'master' into developOlivier Wilkinson (reivilibre)2022-10-281-5/+11
|\
| * Fix room creation being rate limited too aggressively since Synapse v1.69.0. ↵reivilibre2022-10-281-5/+11
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | (#14314) * Introduce a test for the old behaviour which we want to restore * Reintroduce the old behaviour in a simpler way * Newsfile Signed-off-by: Olivier Wilkinson (reivilibre) <oliverw@matrix.org> * Use 1 credit instead of 2 for creating a room: be more lenient than before Notably, the UI in Element Web was still broken after restoring to prior behaviour. After discussion, we agreed that it would be sensible to increase the limit. Signed-off-by: Olivier Wilkinson (reivilibre) <oliverw@matrix.org>
* | Refactor MSC3030 `/timestamp_to_event` to move away from our snowflake pull ↵Eric Eastwood2022-10-263-100/+72
| | | | | | | | | | | | | | | | | | from `destination` pattern (#14096) 1. `federation_client.timestamp_to_event(...)` now handles all `destination` looping and uses our generic `_try_destination_list(...)` helper. 2. Consistently handling `NotRetryingDestination` and `FederationDeniedError` across `get_pdu` , backfill, and the generic `_try_destination_list` which is used for many places we use this pattern. 3. `get_pdu(...)` now returns `PulledPduInfo` so we know which `destination` we ended up pulling the PDU from
* | fix broken avatar checks when server_name contains a port (#13927)Ashish Kumar2022-10-261-1/+5
| | | | | | | | | | | | Fixes check_avatar_size_and_mime_type() to successfully update avatars on homeservers running on non-default ports which it would mistakenly treat as remote homeserver while validating the avatar's size and mime type. Signed-off-by: Ashish Kumar ashfame@users.noreply.github.com
* | Save login tokens in database (#13844)Quentin Gliech2022-10-261-10/+54
| | | | | | | | | | | | | | | | | | | | | | * Save login tokens in database Signed-off-by: Quentin Gliech <quenting@element.io> * Add upgrade notes * Track login token reuse in a Prometheus metric Signed-off-by: Quentin Gliech <quenting@element.io>
* | Refactor OIDC tests to better mimic an actual OIDC provider. (#13910)Quentin Gliech2022-10-251-4/+11
| | | | | | | | | | | | | | | | | | This implements a fake OIDC server, which intercepts calls to the HTTP client. Improves accuracy of tests by covering more internal methods. One particular example was the ID token validation, which previously mocked. This uncovered an incorrect dependency: Synapse actually requires at least authlib 0.15.1, not 0.14.0.
* | Add initial power level event to batch of bulk persisted events when ↵Shay2022-10-214-43/+18
| | | | | | | | creating a new room. (#14228)