summary refs log tree commit diff
path: root/synapse/handlers/room.py (follow)
Commit message (Collapse)AuthorAgeFilesLines
* Include user membership on events (#17282)Richard van der Hoff2024-06-131-1/+0
| | | | | MSC4115 has now completed FCP, so we can enable it by default and switch to the stable identifier.
* Reorganize Pydantic models and types used in handlers (#17279)Eric Eastwood2024-06-101-2/+1
| | | | | | Spawning from https://github.com/element-hq/synapse/pull/17187#discussion_r1619492779 around wanting to put `SlidingSyncBody` (parse the request in the rest layer), `SlidingSyncConfig` (from the rest layer, pass to the handler), `SlidingSyncResponse` (pass the response from the handler back to the rest layer to respond) somewhere that doesn't contaminate the imports and cause circular import issues. - Moved Pydantic parsing models to `synapse/types/rest` - Moved handler types to `synapse/types/handlers`
* Use fully-qualified `PersistedEventPosition` when returning `RoomsForUser` ↵Eric Eastwood2024-06-041-58/+2
| | | | | | | (#17265) Use fully-qualified `PersistedEventPosition` (`instance_name` and `stream_ordering`) when returning `RoomsForUser` to facilitate proper comparisons and `RoomStreamToken` generation. Spawning from https://github.com/element-hq/synapse/pull/17187 where we want to utilize this change
* Add support for MSC4115 (#17104)Richard van der Hoff2024-04-291-0/+1
| | | | Co-authored-by: Andrew Morgan <1342360+anoadragon453@users.noreply.github.com>
* Fix PR #16677, a parameter was missing in a function call (#17033)Mathieu Velten2024-04-091-0/+1
| | | | Co-authored-by: Andrew Morgan <1342360+anoadragon453@users.noreply.github.com>
* Update power level default for public rooms (#16907)Shay2024-03-191-1/+1
|
* Bump black from 23.10.1 to 24.2.0 (#16936)dependabot[bot]2024-03-131-7/+9
|
* Correctly mention previous copyright (#16820)Erik Johnston2024-01-231-0/+1
| | | | | During the migration the automated script to update the copyright headers accidentally got rid of some of the existing copyright lines. Reinstate them.
* Allow room creation but not publishing to continue if room publication rules ↵Shay2024-01-221-4/+2
| | | | | | | | | | | | | are violated when creating a new room. (#16811) Prior to this PR, if a request to create a public (public as in published to the rooms directory) room violated the room list publication rules set in the [config](https://matrix-org.github.io/synapse/latest/usage/configuration/config_documentation.html#room_list_publication_rules), the request to create the room was denied and the room was not created. This PR changes the behavior such that when a request to create a room published to the directory violates room list publication rules, the room is still created but the room is not published to the directory.
* Fix linting (#16780)Erik Johnston2024-01-051-1/+11
| | | Introduced in #16762
* Simplify internal metadata class. (#16762)Erik Johnston2024-01-051-2/+8
| | | | | | | | | We remove these fields as they're just duplicating data the event already stores, and (for reasons :shushing_face:) I'd like to simplify the class to only store simple types. I'm not entirely convinced that we shouldn't instead add helper methods to the event class to generate stream tokens, but I don't really think that's where they belong either
* Merge remote-tracking branch 'gitlab/clokep/license-license' into new_developErik Johnston2023-12-131-10/+16
|\
| * Update license headersPatrick Cloke2023-11-211-10/+16
| |
* | Fix upgrading a room without `events` field in power levels (#16725)David Robertson2023-12-051-1/+1
| |
* | Ignore `encryption_enabled_by_default_for_room_type` for notices room (#16677)Mathieu Velten2023-11-281-1/+7
|/
* Convert simple_select_one_txn and simple_select_one to return tuples. (#16612)Patrick Cloke2023-11-091-3/+3
|
* 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.
* Bump ruff from 0.0.290 to 0.0.292 (#16449)dependabot[bot]2023-10-091-1/+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>
* Factor out `MultiWriter` token from `RoomStreamToken` (#16427)Erik Johnston2023-10-051-1/+1
|
* Add automatic purge after all users forget a room (#15488)Mathieu Velten2023-09-151-76/+101
| | | | | | 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>
* Allow modules to delete rooms. (#15997)reivilibre2023-09-061-1/+9
| | | | | | | | | | | | | | | * 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>
* Support room version 11 (#15912)Patrick Cloke2023-07-181-1/+1
| | | | | 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.
* 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-061-1/+0
| | | Signed-off-by: Sean Quah <seanq@matrix.org>
* Move ThirdPartyEventRules into module_api/callbacks (#15535)Andrew Morgan2023-05-041-4/+6
|
* Move Spam Checker callbacks to a dedicated file (#15453)Andrew Morgan2023-04-181-3/+7
|
* Implement MSC2175: remove the creator field from create events. (#15394)Patrick Cloke2023-04-061-10/+12
|
* Add topic and name events to group of events that are batch persisted when ↵Shay2023-03-081-56/+52
| | | | creating a room. (#15229)
* More speedups/fixes to creating batched events (#15195)Shay2023-03-071-1/+3
|
* Batch up storing state groups when creating new room (#14918)Shay2023-02-241-15/+22
|
* Bump black from 22.12.0 to 23.1.0 (#15103)dependabot[bot]2023-02-221-3/+5
|
* Remove unused `room_alias` field from `/createRoom` response (#15093)David Robertson2023-02-221-19/+19
| | | | | | | | | | | | | | * 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
* Faster joins: don't stall when a user joins during a fast join (#14606)Mathieu Velten2023-02-101-1/+1
| | | | | | | | | | | | | | | | 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-101-1/+1
| | | | | | | | | | | | | 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>
* Add final type hint to synapse.server. (#15035)Patrick Cloke2023-02-091-1/+1
|
* Add helper to parse an enum from query args & use it. (#14956)Patrick Cloke2023-02-011-4/+5
| | | | | | | | 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.
* Use StrCollection in place of Collection[str] in (most) handlers code. (#14922)Patrick Cloke2023-01-261-11/+3
| | | | Due to the increased safety of StrCollection over Collection[str] and Sequence[str].
* Make `handle_new_client_event` throws `PartialStateConflictError` (#14665)Mathieu Velten2022-12-151-38/+57
| | | | | | | 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>
* Move `StateFilter` to `synapse.types` (#14668)David Robertson2022-12-121-1/+1
| | | | | * Move `StateFilter` to `synapse.types` * Changelog
* 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.
* Correctly create power level event during initial room creation (#14361)Shay2022-11-071-2/+23
|
* 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-261-77/+49
| | | | | | | | | | | | | | | | | | 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
* | Add initial power level event to batch of bulk persisted events when ↵Shay2022-10-211-29/+10
|/ | | | creating a new room. (#14228)
* Prepatory work for adding power level event to batched events (#14214)Shay2022-10-181-3/+1
|
* Do not allow a None-limit on PaginationConfig. (#14146)Patrick Cloke2022-10-141-1/+1
| | | | | | | The callers either set a default limit or manually handle a None-limit later on (by setting a default value). Update the callers to always instantiate PaginationConfig with a default limit and then assume the limit is non-None.
* Fix performance regression in `get_users_in_room` (#13972)Erik Johnston2022-09-301-1/+3
| | | | | Fixes #13942. Introduced in #13575. Basically, let's only get the ordered set of hosts out of the DB if we need an ordered set of hosts. Since we split the function up the caching won't be as good, but I think it will still be fine as e.g. multiple backfill requests for the same room will hit the cache.
* Persist CreateRoom events to DB in a batch (#13800)Shay2022-09-281-10/+11
|
* Prepatory work for batching events to send (#13487)Shay2022-09-281-46/+109
| | | This PR begins work on batching up events during the creation of a room. The PR splits out the creation and sending/persisting of the events. The first three events in the creation of the room-creating the room, joining the creator to the room, and the power levels event are sent sequentially, while the subsequent events are created and collected to be sent at the end of the function. This is currently done by appending them to a list and then iterating over the list to send, the next step (after this PR) would be to send and persist the collected events as a batch.
* Drop support for calling `/_matrix/client/v3/rooms/{roomId}/invite` without ↵Jacek Kuśnierz2022-08-311-3/+17
| | | | | | | an `id_access_token` (#13241) Fixes #13206 Signed-off-by: Jacek Kusnierz jacek.kusnierz@tum.de
* Optimize how we calculate `likely_domains` during backfill (#13575)Eric Eastwood2022-08-301-8/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Optimize how we calculate `likely_domains` during backfill because I've seen this take 17s in production just to `get_current_state` which is used to `get_domains_from_state` (see case [*2. Loading tons of events* in the `/messages` investigation issue](https://github.com/matrix-org/synapse/issues/13356)). There are 3 ways we currently calculate hosts that are in the room: 1. `get_current_state` -> `get_domains_from_state` - Used in `backfill` to calculate `likely_domains` and `/timestamp_to_event` because it was cargo-culted from `backfill` - This one is being eliminated in favor of `get_current_hosts_in_room` in this PR 🕳 1. `get_current_hosts_in_room` - Used for other federation things like sending read receipts and typing indicators 1. `get_hosts_in_room_at_events` - Used when pushing out events over federation to other servers in the `_process_event_queue_loop` Fix https://github.com/matrix-org/synapse/issues/13626 Part of https://github.com/matrix-org/synapse/issues/13356 Mentioned in [internal doc](https://docs.google.com/document/d/1lvUoVfYUiy6UaHB6Rb4HicjaJAU40-APue9Q4vzuW3c/edit#bookmark=id.2tvwz3yhcafh) ### Query performance #### Before The query from `get_current_state` sucks just because we have to get all 80k events. And we see almost the exact same performance locally trying to get all of these events (16s vs 17s): ``` synapse=# SELECT type, state_key, event_id FROM current_state_events WHERE room_id = '!OGEhHVWSdvArJzumhm:matrix.org'; Time: 16035.612 ms (00:16.036) synapse=# SELECT type, state_key, event_id FROM current_state_events WHERE room_id = '!OGEhHVWSdvArJzumhm:matrix.org'; Time: 4243.237 ms (00:04.243) ``` But what about `get_current_hosts_in_room`: When there is 8M rows in the `current_state_events` table, the previous query in `get_current_hosts_in_room` took 13s from complete freshness (when the events were first added). But takes 930ms after a Postgres restart or 390ms if running back to back to back. ```sh $ psql synapse synapse=# \timing on synapse=# SELECT COUNT(DISTINCT substring(state_key FROM '@[^:]*:(.*)$')) FROM current_state_events WHERE type = 'm.room.member' AND membership = 'join' AND room_id = '!OGEhHVWSdvArJzumhm:matrix.org'; count ------- 4130 (1 row) Time: 13181.598 ms (00:13.182) synapse=# SELECT COUNT(*) from current_state_events where room_id = '!OGEhHVWSdvArJzumhm:matrix.org'; count ------- 80814 synapse=# SELECT COUNT(*) from current_state_events; count --------- 8162847 synapse=# SELECT pg_size_pretty( pg_total_relation_size('current_state_events') ); pg_size_pretty ---------------- 4702 MB ``` #### After I'm not sure how long it takes from complete freshness as I only really get that opportunity once (maybe restarting computer but that's cumbersome) and it's not really relevant to normal operating times. Maybe you get closer to the fresh times the more access variability there is so that Postgres caches aren't as exact. Update: The longest I've seen this run for is 6.4s and 4.5s after a computer restart. After a Postgres restart, it takes 330ms and running back to back takes 260ms. ```sh $ psql synapse synapse=# \timing on Timing is on. synapse=# SELECT substring(c.state_key FROM '@[^:]*:(.*)$') as host FROM current_state_events c /* Get the depth of the event from the events table */ INNER JOIN events AS e USING (event_id) WHERE c.type = 'm.room.member' AND c.membership = 'join' AND c.room_id = '!OGEhHVWSdvArJzumhm:matrix.org' GROUP BY host ORDER BY min(e.depth) ASC; Time: 333.800 ms ``` #### Going further To improve things further we could add a `limit` parameter to `get_current_hosts_in_room`. Realistically, we don't need 4k domains to choose from because there is no way we're going to query that many before we a) probably get an answer or b) we give up. Another thing we can do is optimize the query to use a index skip scan: - https://wiki.postgresql.org/wiki/Loose_indexscan - Index Skip Scan, https://commitfest.postgresql.org/37/1741/ - https://www.timescale.com/blog/how-we-made-distinct-queries-up-to-8000x-faster-on-postgresql/
* Directly lookup local membership instead of getting all members in a room ↵Eric Eastwood2022-08-241-2/+5
| | | | | first (`get_users_in_room` mis-use) (#13608) See https://github.com/matrix-org/synapse/pull/13575#discussion_r953023755
* `synapse.api.auth.Auth` cleanup: make permission-related methods use ↵Quentin Gliech2022-08-221-2/+2
| | | | | | | | | `Requester` instead of the `UserID` (#13024) Part of #13019 This changes all the permission-related methods to rely on the Requester instead of the UserID. This is a first step towards enabling scoped access tokens at some point, since I expect the Requester to have scope-related informations in it. It also changes methods which figure out the user/device/appservice out of the access token to return a Requester instead of something else. This avoids having store-related objects in the methods signatures.
* Backfill remote event fetched by MSC3030 so we can paginate from it later ↵Eric Eastwood2022-07-221-14/+45
| | | | | | | | | (#13205) Depends on https://github.com/matrix-org/synapse/pull/13320 Complement tests: https://github.com/matrix-org/complement/pull/406 We could use the same method to backfill for `/context` as well in the future, see https://github.com/matrix-org/synapse/issues/3848
* Optimise room creation event lookups part 2 (#13224)Nick Mills-Barrett2022-07-131-8/+37
|
* Reduce event lookups during room creation by passing known event IDs (#13210)Nick Mills-Barrett2022-07-111-2/+16
| | | | | | | | Inspired by the room batch handler, this uses previous event inserts to pre-populate prev events during room creation, reducing the number of queries required to create a room. Signed off by Nick @ Beeper (@Fizzadar)
* Uniformize spam-checker API, part 5: expand other spam-checker callbacks to ↵David Teller2022-07-111-2/+10
| | | | | | return `Tuple[Codes, dict]` (#13044) Signed-off-by: David Teller <davidt@element.io> Co-authored-by: Brendan Abolivier <babolivier@matrix.org>
* Fix exception when using MSC3030 to look for remote federated events before ↵Eric Eastwood2022-07-071-1/+5
| | | | | | | | | | | | | | | | room creation (#13197) Complement tests: https://github.com/matrix-org/complement/pull/405 This happens when you have some messages imported before the room is created. Then use MSC3030 to look backwards before the room creation from a remote federated server. The server won't find anything locally, but will ask over federation which will have the remote event. The previous logic would choke on not having the local event assigned. ``` Failed to fetch /timestamp_to_event from hs2 because of exception(UnboundLocalError) local variable 'local_event' referenced before assignment args=("local variable 'local_event' referenced before assignment",) ```
* Decouple `synapse.api.auth_blocking.AuthBlocking` from ↵Quentin Gliech2022-06-141-1/+2
| | | | `synapse.api.auth.Auth`. (#13021)
* Uniformize spam-checker API, part 4: port other spam-checker callbacks to ↵David Teller2022-06-131-10/+10
| | | | | return `Union[Allow, Codes]`. (#12857) Co-authored-by: Brendan Abolivier <babolivier@matrix.org>
* Remove redundant `room_version` param from `check_auth_rules_from_context`Richard van der Hoff2022-06-121-2/+1
| | | | It's now implied by the room_version property on the event.
* Remove `room_version` param from `validate_event_for_room_version`Richard van der Hoff2022-06-121-1/+1
| | | | | | | Instead, use the `room_version` property of the event we're validating. The `room_version` was originally added as a parameter somewhere around #4482, but really it's been redundant since #6875 added a `room_version` field to `EventBase`.
* Reduce the amount of state we pull from the DB (#12811)Erik Johnston2022-06-061-1/+4
|
* Wait for lazy join to complete when getting current state (#12872)Erik Johnston2022-06-011-4/+9
|
* Remove remaining bits of groups code. (#12936)Patrick Cloke2022-06-011-1/+0
| | | | | | * Update worker docs to remove group endpoints. * Removes an unused parameter to `ApplicationService`. * Break dependency between media repo and groups. * Avoid copying `m.room.related_groups` state events during room upgrades.
* Rename storage classes (#12913)Erik Johnston2022-05-311-4/+7
|
* Fix up `state_store` naming (#12871)Erik Johnston2022-05-251-2/+2
|
* Update EventContext `get_current_event_ids` and `get_prev_event_ids` to ↵Shay2022-05-201-1/+4
| | | | accept state filters and update calls where possible (#12791)
* Add a unit test for copying over arbitrary room types when upgrading a room ↵Andrew Morgan2022-05-191-1/+1
| | | | (#12792)
* Implement MSC3818: copy room type on upgrade (#12786)Aminda Suomalainen2022-05-191-8/+8
| | | | | Resolves: #11896 Signed-off-by: Aminda Suomalainen <suomalainen+git@mikaela.info>
* Give a meaningful error message when a client tries to create a room with an ↵reivilibre2022-05-181-0/+15
| | | | invalid alias localpart. (#12779)
* Add `StreamKeyType` class and replace string literals with constants (#12567)Andrew Morgan2022-05-161-4/+5
|
* Fix room upgrades creating an empty room when auth fails (#12696)Sean Quah2022-05-161-43/+82
| | | | Signed-off-by: Sean Quah <seanq@element.io>
* add default_power_level_content_override config option. (#12618)Andy Balaam2022-05-121-1/+15
| | | Co-authored-by: Matthew Hodgson <matthew@matrix.org>
* Convert stringy power levels to integers on room upgrade (#12657)David Robertson2022-05-071-6/+8
|
* Generate historic pagination token for `/messages` when no `?from` token ↵Eric Eastwood2022-04-061-2/+2
| | | | provided (#12370)
* Refactor and convert `Linearizer` to async (#12357)Sean Quah2022-04-051-1/+1
| | | | | | | | | | | Refactor and convert `Linearizer` to async. This makes a `Linearizer` cancellation bug easier to fix. Also refactor to use an async context manager, which eliminates an unlikely footgun where code that doesn't immediately use the context manager could forget to release the lock. Signed-off-by: Sean Quah <seanq@element.io>
* Default to `private` room visibility rather than `public` when a client does ↵reivilibre2022-04-011-1/+3
| | | | not specify one, according to spec. (#12350)
* Move get_bundled_aggregations to relations handler. (#12237)Patrick Cloke2022-03-181-2/+3
| | | | | The get_bundled_aggregations code is fairly high-level and uses a lot of store methods, we move it into the handler as that seems like a better fit.
* Add third_party module callbacks to check if a user can delete a room and ↵Will Hunt2022-03-091-0/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | deactivate a user (#12028) * Add check_can_deactivate_user * Add check_can_shutdown_rooms * Documentation * callbacks, not functions * Various suggested tweaks * Add tests for test_check_can_shutdown_room and test_check_can_deactivate_user * Update check_can_deactivate_user to not take a Requester * Fix check_can_shutdown_room docs * Renegade and use `by_admin` instead of `admin_user_id` * fix lint * Update docs/modules/third_party_rules_callbacks.md Co-authored-by: Brendan Abolivier <babolivier@matrix.org> * Update docs/modules/third_party_rules_callbacks.md Co-authored-by: Brendan Abolivier <babolivier@matrix.org> * Update docs/modules/third_party_rules_callbacks.md Co-authored-by: Brendan Abolivier <babolivier@matrix.org> * Update docs/modules/third_party_rules_callbacks.md Co-authored-by: Brendan Abolivier <babolivier@matrix.org> Co-authored-by: Brendan Abolivier <babolivier@matrix.org>
* Remove `HomeServer.get_datastore()` (#12031)Richard van der Hoff2022-02-231-5/+5
| | | | | | | The presence of this method was confusing, and mostly present for backwards compatibility. Let's get rid of it. Part of #11733
* Remove deprecated user_may_create_room_with_invites callback (#11950)Brendan Abolivier2022-02-111-5/+0
| | | Co-authored-by: Patrick Cloke <clokep@users.noreply.github.com>
* Improvements to bundling aggregations. (#11815)Patrick Cloke2022-01-261-36/+41
| | | | | | | | | | | This is some odds and ends found during the review of #11791 and while continuing to work in this code: * Return attrs classes instead of dictionaries from some methods to improve type safety. * Call `get_bundled_aggregations` fewer times. * Adds a missing assertion in the tests. * Do not return empty bundled aggregations for an event (preferring to not include the bundle at all, as the docstring states).
* Include whether the requesting user has participated in a thread. (#11577)Patrick Cloke2022-01-181-3/+9
| | | | | | Per updates to MSC3440. This is implement as a separate method since it needs to be cached on a per-user basis, instead of a per-thread basis.
* Bundle aggregations outside of the serialization method. (#11612)Patrick Cloke2022-01-071-0/+10
| | | | | | | | This makes the serialization of events synchronous (and it no longer access the database), but we must manually calculate and provide the bundled aggregations. Overall this should cause no change in behavior, but is prep work for other improvements.
* Make room creations denied by `user_may_create_room` cause an `M_FORBIDDEN` ↵lukasdenk2022-01-061-2/+6
| | | | | error to be returned, not `M_UNKNOWN` (#11672) Co-authored-by: reivilibre <olivier@librepush.net>
* Improve opentracing support for `ResponseCache` (#11607)Richard van der Hoff2021-12-201-1/+1
| | | This adds some opentracing annotations to ResponseCache, to make it easier to see what's going on; in particular, it adds a link back to the initial trace which is actually doing the work of generating the response.
* Fix 'delete room' admin api to work on incomplete rooms (#11523)Richard van der Hoff2021-12-071-14/+7
| | | | | If, for some reason, we don't have the create event, we should still be able to purge a room.
* Add MSC3030 experimental client and federation API endpoints to get the ↵Eric Eastwood2021-12-021-0/+144
| | | | | | | | | | | | | | | | | | | | | | | | | closest event to a given timestamp (#9445) MSC3030: https://github.com/matrix-org/matrix-doc/pull/3030 Client API endpoint. This will also go and fetch from the federation API endpoint if unable to find an event locally or we found an extremity with possibly a closer event we don't know about. ``` GET /_matrix/client/unstable/org.matrix.msc3030/rooms/<roomID>/timestamp_to_event?ts=<timestamp>&dir=<direction> { "event_id": ... "origin_server_ts": ... } ``` Federation API endpoint: ``` GET /_matrix/federation/unstable/org.matrix.msc3030/timestamp_to_event/<roomID>?ts=<timestamp>&dir=<direction> { "event_id": ... "origin_server_ts": ... } ``` Co-authored-by: Erik Johnston <erik@matrix.org>
* Fix checking whether a room can be published on creation. (#11392)Patrick Cloke2021-11-191-1/+4
| | | | | | | | If `room_list_publication_rules` was configured with a rule with a non-wildcard alias and a room was created with an alias then an internal server error would have been thrown. This fixes the error and properly applies the publication rules during room creation.
* Convert delete room admin API to async endpoint (#11223)Dirk Klimpel2021-11-121-2/+11
| | | Signed-off-by: Dirk Klimpel dirk@klimpel.org
* Allow admins to proactively block rooms (#11228)David Robertson2021-11-091-11/+40
| | | | Co-authored-by: Dirk Klimpel <5740567+dklimpel@users.noreply.github.com> Co-authored-by: Andrew Morgan <1342360+anoadragon453@users.noreply.github.com>
* Support filtering by relations per MSC3440 (#11236)Patrick Cloke2021-11-091-3/+5
| | | | Adds experimental support for `relation_types` and `relation_senders` fields for filters.
* Add remaining type hints to `synapse.events`. (#11098)Patrick Cloke2021-11-021-1/+1
|
* Refactor `Filter` to handle fields according to data being filtered. (#11194)Patrick Cloke2021-10-271-1/+1
| | | | This avoids filtering against fields which cannot exist on an event source. E.g. presence updates don't have a room.
* Don't set new room alias before potential 403 (#10930)AndrewFerr2021-10-251-9/+9
| | | | | | Fixes: #10929 Signed-off-by: Andrew Ferrazzutti <fair@miscworks.net>
* Add type hints to synapse.events.*. (#11066)Patrick Cloke2021-10-131-2/+20
| | | Except `synapse/events/__init__.py`, which will be done in a follow-up.
* Remove the deprecated BaseHandler. (#11005)Patrick Cloke2021-10-081-7/+8
| | | | | | | | The shared ratelimit function was replaced with a dedicated RequestRatelimiter class (accessible from the HomeServer object). Other properties were copied to each sub-class that inherited from BaseHandler.
* Add a spamchecker callback to allow or deny room joins (#10910)Brendan Abolivier2021-10-061-0/+2
| | | Co-authored-by: Erik Johnston <erik@matrix.org>
* Split `event_auth.check` into two parts (#10940)Richard van der Hoff2021-09-291-2/+4
| | | | | | | | | | | | | Broadly, the existing `event_auth.check` function has two parts: * a validation section: checks that the event isn't too big, that it has the rught signatures, etc. This bit is independent of the rest of the state in the room, and so need only be done once for each event. * an auth section: ensures that the event is allowed, given the rest of the state in the room. This gets done multiple times, against various sets of room state, because it forms part of the state res algorithm. Currently, this is implemented with `do_sig_check` and `do_size_check` parameters, but I think that makes everything hard to follow. Instead, we split the function in two and call each part separately where it is needed.
* Use direct references for configuration variables (part 6). (#10916)Patrick Cloke2021-09-291-1/+1
|
* Use `RoomVersion` objects (#10934)Richard van der Hoff2021-09-291-2/+2
| | | Various refactors to use `RoomVersion` objects instead of room version identifiers.
* Add a spamchecker callback to allow or deny room creation based on invites ↵Brendan Abolivier2021-09-241-4/+10
| | | | | | | (#10898) This is in the context of creating new module callbacks that modules in https://github.com/matrix-org/synapse-dinsic can use, in an effort to reconcile the spam checker API in synapse-dinsic with the one in mainline. This adds a callback that's fairly similar to user_may_create_room except it also allows processing based on the invites sent at room creation.
* Use direct references for configuration variables (part 5). (#10897)Patrick Cloke2021-09-241-3/+5
|
* Remove unnecessary parentheses around tuples returned from methods (#10889)Andrew Morgan2021-09-231-1/+1
|
* Add type hints for event streams. (#10856)Patrick Cloke2021-09-211-4/+14
|
* Require type hints in the handlers module. (#10831)Patrick Cloke2021-09-201-9/+7
| | | | | | | Adds missing type hints to methods in the synapse.handlers module and requires all methods to have type hints there. This also removes the unused construct_auth_difference method from the FederationHandler.
* Handle room upgrades for spaces (#10774)Patrick Cloke2021-09-101-2/+17
| | | | | By copying the `room_type` field of the create event and migrating any non-empty `m.space.child` events to the new room that is created.
* Add a constant for m.federate. (#10775)Patrick Cloke2021-09-081-2/+2
|
* Move `maybe_kick_guest_users` out of `BaseHandler` (#10744)Richard van der Hoff2021-09-061-1/+4
| | | This is part of my ongoing war against BaseHandler. I've moved kick_guest_users into RoomMemberHandler (since it calls out to that handler anyway), and split maybe_kick_guest_users into the two places it is called.
* Raise an error if an unknown preset is used to create a room. (#10738)Patrick Cloke2021-09-031-1/+6
| | | | Raises a 400 error instead of a 500 if an unknown preset is passed from a client to create a room.
* Make historical events discoverable from backfill for servers without any ↵Eric Eastwood2021-07-281-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | scrollback history (MSC2716) (#10245) * Make historical messages available to federated servers Part of MSC2716: https://github.com/matrix-org/matrix-doc/pull/2716 Follow-up to https://github.com/matrix-org/synapse/pull/9247 * Debug message not available on federation * Add base starting insertion point when no chunk ID is provided * Fix messages from multiple senders in historical chunk Follow-up to https://github.com/matrix-org/synapse/pull/9247 Part of MSC2716: https://github.com/matrix-org/matrix-doc/pull/2716 --- Previously, Synapse would throw a 403, `Cannot force another user to join.`, because we were trying to use `?user_id` from a single virtual user which did not match with messages from other users in the chunk. * Remove debug lines * Messing with selecting insertion event extremeties * Move db schema change to new version * Add more better comments * Make a fake requester with just what we need See https://github.com/matrix-org/synapse/pull/10276#discussion_r660999080 * Store insertion events in table * Make base insertion event float off on its own See https://github.com/matrix-org/synapse/pull/10250#issuecomment-875711889 Conflicts: synapse/rest/client/v1/room.py * Validate that the app service can actually control the given user See https://github.com/matrix-org/synapse/pull/10276#issuecomment-876316455 Conflicts: synapse/rest/client/v1/room.py * Add some better comments on what we're trying to check for * Continue debugging * Share validation logic * Add inserted historical messages to /backfill response * Remove debug sql queries * Some marker event implemntation trials * Clean up PR * Rename insertion_event_id to just event_id * Add some better sql comments * More accurate description * Add changelog * Make it clear what MSC the change is part of * Add more detail on which insertion event came through * Address review and improve sql queries * Only use event_id as unique constraint * Fix test case where insertion event is already in the normal DAG * Remove debug changes * Switch to chunk events so we can auth via power_levels Previously, we were using `content.chunk_id` to connect one chunk to another. But these events can be from any `sender` and we can't tell who should be able to send historical events. We know we only want the application service to do it but these events have the sender of a real historical message, not the application service user ID as the sender. Other federated homeservers also have no indicator which senders are an application service on the originating homeserver. So we want to auth all of the MSC2716 events via power_levels and have them be sent by the application service with proper PL levels in the room. * Switch to chunk events for federation * Add unstable room version to support new historical PL * Fix federated events being rejected for no state_groups Add fix from https://github.com/matrix-org/synapse/pull/10439 until it merges. * Only connect base insertion event to prev_event_ids Per discussion with @erikjohnston, https://matrix.to/#/!UytJQHLQYfvYWsGrGY:jki.re/$12bTUiObDFdHLAYtT7E-BvYRp3k_xv8w0dUQHibasJk?via=jki.re&via=matrix.org * Make it possible to get the room_version with txn * Allow but ignore historical events in unsupported room version See https://github.com/matrix-org/synapse/pull/10245#discussion_r675592489 We can't reject historical events on unsupported room versions because homeservers without knowledge of MSC2716 or the new room version don't reject historical events either. Since we can't rely on the auth check here to stop historical events on unsupported room versions, I've added some additional checks in the processing/persisting code (`synapse/storage/databases/main/events.py` -> `_handle_insertion_event` and `_handle_chunk_event`). I've had to do some refactoring so there is method to fetch the room version by `txn`. * Move to unique index syntax See https://github.com/matrix-org/synapse/pull/10245#discussion_r675638509 * High-level document how the insertion->chunk lookup works * Remove create_event fallback for room_versions See https://github.com/matrix-org/synapse/pull/10245/files#r677641879 * Use updated method name
* Port the ThirdPartyEventRules module interface to the new generic interface ↵Brendan Abolivier2021-07-201-7/+3
| | | | | (#10386) Port the third-party event rules interface to the generic module interface introduced in v1.37.0
* Use inline type hints in `handlers/` and `rest/`. (#10382)Jonathan de Jong2021-07-161-8/+8
|
* Move methods involving event authentication to EventAuthHandler. (#10268)Patrick Cloke2021-07-011-1/+2
| | | Instead of mixing them with user authentication methods.
* Correctly ratelimit invites when creating a room (#9968)Brendan Abolivier2021-05-121-7/+20
| | | | | * Correctly ratelimit invites when creating a room Also allow ratelimiting for more than one action at a time.
* Use get_current_users_in_room from store and not StateHandler (#9910)Erik Johnston2021-05-051-1/+1
|
* Remove redundant "coding: utf-8" lines (#9786)Jonathan de Jong2021-04-141-1/+0
| | | | | | | Part of #9744 Removes all redundant `# -*- coding: utf-8 -*-` lines from files, as python 3 automatically reads source code as utf-8 now. `Signed-off-by: Jonathan de Jong <jonathan@automatia.nl>`
* Add ResponseCache tests. (#9458)Jonathan de Jong2021-03-081-1/+1
|
* Update black, and run auto formatting over the codebase (#9381)Eric Eastwood2021-02-161-7/+22
| | | | | | | - Update black version to the latest - Run black auto formatting over the codebase - Run autoformatting according to [`docs/code_style.md `](https://github.com/matrix-org/synapse/blob/80d6dc9783aa80886a133756028984dbf8920168/docs/code_style.md) - Update `code_style.md` docs around installing black to use the correct version
* Handle missing data in power levels events during room upgrade. (#9395)Patrick Cloke2021-02-161-5/+8
|
* Fix some typos.Patrick Cloke2021-02-121-1/+1
|
* Merge pull request #9150 from Yoric/develop-contextDavid Teller2021-02-081-5/+16
|\ | | | | New API /_synapse/admin/rooms/{roomId}/context/{eventId}
| * FIXUP: linterDavid Teller2021-01-281-1/+1
| |
| * FIXUP: Making get_event_context a bit more paranoidDavid Teller2021-01-281-2/+8
| |
| * FIXUP: Removing awaitableDavid Teller2021-01-281-3/+3
| |
| * FIXUP: Don't filter events at all for admin/v1/rooms/.../context/...David Teller2021-01-281-6/+4
| |
| * New API /_synapse/admin/rooms/{roomId}/context/{eventId}David Teller2021-01-281-2/+9
| | | | | | | | Signed-off-by: David Teller <davidt@element.io>
* | Ratelimit invites by room and target user (#9258)Erik Johnston2021-01-291-0/+7
|/
* Support icons for Identity Providers (#9154)Richard van der Hoff2021-01-201-1/+1
|
* Implement MSC2176: Updated redaction rules (#8984)Patrick Cloke2021-01-051-1/+1
| | | | An experimental room version ("org.matrix.msc2176") contains the new redaction rules for testing.
* Do not assume that the contents dictionary includes history_visibility. (#8945)Patrick Cloke2020-12-161-3/+4
|
* Allow spam-checker modules to be provide async methods. (#8890)David Teller2020-12-111-2/+2
| | | | Spam checker modules can now provide async methods. This is implemented in a backwards-compatible manner.
* Don't ratelimit autojoining of rooms (#8921)Erik Johnston2020-12-111-1/+4
| | | Fixes #8866
* Add admin API for logging in as a user (#8617)Erik Johnston2020-11-171-3/+7
|
* Optimise createRoom with multiple invites (#8559)Richard van der Hoff2020-10-291-11/+18
| | | | | By not dropping the membership lock between invites, we can stop joins from grabbing the lock when we're half-done and slowing the whole thing down.
* Fix typos and spelling errors. (#8639)Patrick Cloke2020-10-231-1/+1
|
* Remove redundant `token_id` parameter to create_eventRichard van der Hoff2020-10-131-1/+0
| | | | this is always the same as requester.access_token_id.
* Add type hints to response cache. (#8507)Patrick Cloke2020-10-091-1/+1
|
* Remove the deprecated Handlers object (#8494)Patrick Cloke2020-10-091-1/+1
| | | All handlers now available via get_*_handler() methods on the HomeServer.
* kill off `send_nonmember_event`Richard van der Hoff2020-10-051-2/+2
| | | | This is now redundant, and we can just call `handle_new_client_event` directly.
* pull up event.sender assertionRichard van der Hoff2020-10-051-0/+1
|
* Allow ThirdPartyEventRules modules to manipulate public room state (#8292)Andrew Morgan2020-10-051-0/+9
| | | | | This PR allows `ThirdPartyEventRules` modules to view, manipulate and block changes to the state of whether a room is published in the public rooms directory. While the idea of whether a room is in the public rooms list is not kept within an event in the room, `ThirdPartyEventRules` generally deal with controlling which modifications can happen to a room. Public rooms fits within that idea, even if its toggle state isn't controlled through a state event.
* Enable mypy checking for unreachable code and fix instances. (#8432)Patrick Cloke2020-10-011-2/+0
|
* Make token serializing/deserializing async (#8427)Erik Johnston2020-09-301-3/+5
| | | The idea is that in future tokens will encode a mapping of instance to position. However, we don't want to include the full instance name in the string representation, so instead we'll have a mapping between instance name and an immutable integer ID in the DB that we can use instead. We'll then do the lookup when we serialize/deserialize the token (we could alternatively pass around an `Instance` type that includes both the name and ID, but that turns out to be a lot more invasive).
* Various clean ups to room stream tokens. (#8423)Erik Johnston2020-09-291-2/+2
|
* Simplify super() calls to Python 3 syntax. (#8344)Patrick Cloke2020-09-181-1/+1
| | | | | | | This converts calls like super(Foo, self) -> super(). Generated with: sed -i "" -Ee 's/super\([^\(]+\)/super()/g' **/*.py
* Add experimental support for sharding event persister. Again. (#8294)Erik Johnston2020-09-141-5/+9
| | | | | | This is *not* ready for production yet. Caveats: 1. We should write some tests... 2. The stream token that we use for events can get stalled at the minimum position of all writers. This means that new events may not be processed and e.g. sent down sync streams if a writer isn't writing or is slow.
* Make `StreamToken.room_key` be a `RoomStreamToken` instance. (#8281)Erik Johnston2020-09-111-8/+7
|
* Stop sub-classing object (#8249)Patrick Cloke2020-09-041-3/+3
|
* Revert "Add experimental support for sharding event persister. (#8170)" (#8242)Brendan Abolivier2020-09-041-9/+5
| | | | | | | * Revert "Add experimental support for sharding event persister. (#8170)" This reverts commit 82c1ee1c22a87b9e6e3179947014b0f11c0a1ac3. * Changelog
* Add experimental support for sharding event persister. (#8170)Erik Johnston2020-09-021-5/+9
| | | | | | This is *not* ready for production yet. Caveats: 1. We should write some tests... 2. The stream token that we use for events can get stalled at the minimum position of all writers. This means that new events may not be processed and e.g. sent down sync streams if a writer isn't writing or is slow.
* Convert state and stream stores and related code to async (#8194)Patrick Cloke2020-08-281-1/+1
|
* Define StateMap as immutable and add a MutableStateMap type. (#8183)Patrick Cloke2020-08-281-1/+2
|
* Convert simple_update* and simple_select* to async (#8173)Patrick Cloke2020-08-271-4/+2
|
* Stop shadow-banned users from sending non-member events. (#8142)Patrick Cloke2020-08-241-1/+18
|
* Stop shadow-banned users from sending invites. (#8095)Patrick Cloke2020-08-201-2/+14
|
* Add type hints to synapse.handlers.room (#8090)Erik Johnston2020-08-141-38/+66
|
* Convert streams to async. (#8014)Patrick Cloke2020-08-041-5/+5
|
* Fix up types and comments that refer to Deferreds. (#7945)Patrick Cloke2020-07-241-9/+4
|
* Add delete room admin endpoint (#7613)Dirk Klimpel2020-07-141-2/+206
| | | | | | | | | | | | | | | | | | The Delete Room admin API allows server admins to remove rooms from server and block these rooms. `DELETE /_synapse/admin/v1/rooms/<room_id>` It is a combination and improvement of "[Shutdown room](https://github.com/matrix-org/synapse/blob/develop/docs/admin_api/shutdown_room.md)" and "[Purge room](https://github.com/matrix-org/synapse/blob/develop/docs/admin_api/purge_room.md)" API. Fixes: #6425 It also fixes a bug in [synapse/storage/data_stores/main/room.py](synapse/storage/data_stores/main/room.py) in ` get_room_with_stats`. It should return `None` if the room is unknown. But it returns an `IndexError`. https://github.com/matrix-org/synapse/blob/901b1fa561e3cc661d78aa96d59802cf2078cb0d/synapse/storage/data_stores/main/room.py#L99-L105 Related to: - #5575 - https://github.com/Awesome-Technologies/synapse-admin/issues/17 Signed-off-by: Dirk Klimpel dirk@klimpel.org
* Replace all remaining six usage with native Python 3 equivalents (#7704)Dagfinn Ilmari Mannsåker2020-06-161-3/+1
|
* Replace iteritems/itervalues/iterkeys with native versions. (#7692)Patrick Cloke2020-06-151-3/+3
|
* Add option to enable encryption by default for new rooms (#7639)Andrew Morgan2020-06-101-27/+47
| | | | | | | | | Fixes https://github.com/matrix-org/synapse/issues/2431 Adds config option `encryption_enabled_by_default_for_room_type`, which determines whether encryption should be enabled with the default encryption algorithm in private or public rooms upon creation. Whether the room is private or public is decided based upon the room creation preset that is used. Part of this PR is also pulling out all of the individual instances of `m.megolm.v1.aes-sha2` into a constant variable to eliminate typos ala https://github.com/matrix-org/synapse/pull/7637 Based on #7637
* Add option to move event persistence off master (#7517)Erik Johnston2020-05-221-0/+7
|
* Add ability to wait for replication streams (#7542)Erik Johnston2020-05-221-20/+45
| | | | | | | The idea here is that if an instance persists an event via the replication HTTP API it can return before we receive that event over replication, which can lead to races where code assumes that persisting an event immediately updates various caches (e.g. current state of the room). Most of Synapse doesn't hit such races, so we don't do the waiting automagically, instead we do so where necessary to avoid unnecessary delays. We may decide to change our minds here if it turns out there are a lot of subtle races going on. People probably want to look at this commit by commit.
* On upgrade room only send canonical alias once. (#7547)Erik Johnston2020-05-221-55/+60
| | | | | | | | Instead of doing a complicated dance of deleting and moving aliases one by one, which sends a canonical alias update into the old room for each one, lets do it all in one go. This also changes the function to move *all* local alias events to the new room, however that happens later on anyway.
* Convert the room handler to async/await. (#7396)Patrick Cloke2020-05-041-24/+18
|
* async/await is_server_admin (#7363)Andrew Morgan2020-05-011-63/+58
|
* Check on room creation if the user is allowed to publish the room to the ↵PeerD2020-04-131-0/+7
| | | | room directory. (#7260)
* Default PL100 to enable encryption in a room (#7230)Andrew Morgan2020-04-091-0/+1
|
* Remove special casing of `m.room.aliases` events (#7034)Patrick Cloke2020-03-171-15/+1
|
* Clarify list/set/dict/tuple comprehensions and enforce via flake8 (#6957)Patrick Cloke2020-02-211-1/+1
| | | | Ensure good comprehension hygiene using flake8-comprehensions.
* Do not send alias events when creating / upgrading a room (#6941)Patrick Cloke2020-02-201-23/+13
| | | Stop emitting room alias update events during room creation/upgrade.
* Stop sending events when creating or deleting aliases (#6904)Patrick Cloke2020-02-181-5/+1
| | | Stop sending events when creating or deleting associations (room aliases). Send an updated canonical alias event if one of the alt_aliases is deleted.
* Raise the default power levels for invites, tombstones and server acls (#6834)Andrew Morgan2020-02-171-1/+9
|
* Third party event rules Update (#6781)PeerD2020-02-061-1/+5
|
* Reduce amount of logging at INFO level. (#6862)Erik Johnston2020-02-061-5/+5
| | | | | | | | A lot of the things we log at INFO are now a bit superfluous, so lets make them DEBUG logs to reduce the amount we log by default. Co-Authored-By: Brendan Abolivier <babolivier@matrix.org> Co-authored-by: Brendan Abolivier <github@brendanabolivier.com>
* Fix detecting unknown devices from remote encrypted events. (#6848)Erik Johnston2020-02-041-1/+1
| | | | | | | | We were looking at the wrong event type (`m.room.encryption` vs `m.room.encrypted`). Also fixup the duplicate `EvenTypes` entries. Introduced in #6776.
* s/get_room_version/get_room_version_id/Richard van der Hoff2020-01-311-1/+1
| | | | | ... to make way for a forthcoming get_room_version which returns a RoomVersion object.
* Set the PL for aliases events to 0.Richard van der Hoff2020-01-291-2/+15
|
* Factor out a `copy_power_levels_contents` methodRichard van der Hoff2020-01-291-12/+11
| | | | I'm going to need another copy (hah!) of this.
* Add `rooms.room_version` column (#6729)Erik Johnston2020-01-271-20/+32
| | | This is so that we don't have to rely on pulling it out from `current_state_events` table.
* Add StateMap type alias (#6715)Erik Johnston2020-01-161-6/+18
|
* Fix some test failures when frozen_dicts are enabled (#6642)Richard van der Hoff2020-01-061-6/+9
| | | | Fixes #4026
* Fix power levels being incorrectly set in old and new rooms after a room ↵Andrew Morgan2020-01-061-7/+10
| | | | | | upgrade (#6633) Modify a copy of an upgraded room's PL before sending to the new room
* Change EventContext to use the Storage class (#6564)Erik Johnston2019-12-201-1/+1
|
* Merge release-v1.7.1 into developRichard van der Hoff2019-12-181-2/+5
|\
| * Incorporate reviewBrendan Abolivier2019-12-161-1/+1
| |
| * Use the filtered version of an event when responding to /context requests ↵Brendan Abolivier2019-12-161-1/+4
| | | | | | | | | | | | for that event Sometimes the filtering function can return a pruned version of an event (on top of either the event itself or an empty list), if it thinks the user should be able to see that there's an event there but not the content of that event. Therefore, the previous logic of 'if filtered is empty then we can use the event we retrieved from the database' is flawed, and we should use the event returned by the filtering function.
* | Remove unused `get_pagination_rows` methods. (#6557)Erik Johnston2019-12-171-12/+0
|/ | | Remove unused get_pagination_rows methods
* Merge branch 'develop' into babolivier/context_filtersBrendan Abolivier2019-12-041-5/+31
|\
| * Transfer power level state events on room upgrade (#6237)Andrew Morgan2019-12-021-5/+31
| |
* | Incorporate reviewBrendan Abolivier2019-12-041-2/+1
| |
* | Also filter state eventsBrendan Abolivier2019-11-061-1/+7
| |
* | Only filter if a filter was providedBrendan Abolivier2019-11-051-4/+6
| |
* | Update copyrightBrendan Abolivier2019-11-051-1/+2
| |
* | Filter events_before and events_after in /context requestsBrendan Abolivier2019-11-051-2/+4
|/ | | | While the current version of the spec doesn't say much about how this endpoint uses filters (see https://github.com/matrix-org/matrix-doc/issues/2338), the current implementation is that some fields of an EventFilter apply (the ones that are used when running the SQL query) and others don't (the ones that are used by the filter itself) because we don't call event_filter.filter(...). This seems counter-intuitive and probably not what we want so this commit fixes it.
* Depublish a room from the public rooms list when it is upgraded (#6232)Andrew Morgan2019-11-011-1/+7
|
* Update black to 19.10b0 (#6304)Amber Brown2019-11-011-14/+15
| | | * update version of black and also fix the mypy config being overridden
* Merge pull request #6294 from matrix-org/erikj/add_state_storageErik Johnston2019-10-311-2/+4
|\ | | | | Add StateGroupStorage interface
| * Port to use state storageErik Johnston2019-10-301-2/+4
| |
* | Remove usage of deprecated logger.warn method from codebase (#6271)Andrew Morgan2019-10-311-1/+1
|/ | | Replace every instance of `logger.warn` with `logger.warning` as the former is deprecated.
* Add domain validation when creating room with list of invitees (#6121)werner2912019-10-101-1/+3
|
* Use the v2 Identity Service API for lookups (MSC2134 + MSC2140) (#5976)Andrew Morgan2019-09-111-1/+3
| | | | | | | This is a redo of https://github.com/matrix-org/synapse/pull/5897 but with `id_access_token` accepted. Implements [MSC2134](https://github.com/matrix-org/matrix-doc/pull/2134) plus Identity Service v2 authentication ala [MSC2140](https://github.com/matrix-org/matrix-doc/pull/2140). Identity lookup-related functions were also moved from `RoomMemberHandler` to `IdentityHandler`.
* Remove double return statements (#5962)Andrew Morgan2019-09-031-1/+0
| | | | | | | | | | Remove all the "double return" statements which were a result of us removing all the instances of ``` defer.returnValue(...) return ``` statements when we switched to python3 fully.
* Don't create broken room when power_level_content_override.users does not ↵Michael Telatynski2019-08-151-1/+13
| | | | contain creator_id. (#5633)
* Replace returnValue with return (#5736)Amber Brown2019-07-231-8/+8
|
* Prevent multiple upgrades on the same room at once (#5051)Andrew Morgan2019-06-251-51/+89
| | | | | | | Closes #4583 Does slightly less than #5045, which prevented a room from being upgraded multiple times, one after another. This PR still allows that, but just prevents two from happening at the same time. Mostly just to mitigate the fact that servers are slow and it can take a moment for the room upgrade to actually complete. We don't want people sending another request to upgrade the room when really they just thought the first didn't go through.
* Run Black. (#5482)Amber Brown2019-06-201-184/+111
|
* Add third party rules hook into create roomErik Johnston2019-06-171-1/+24
|
* Add config option for setting homeserver's default room version (#5223)Andrew Morgan2019-05-231-2/+7
| | | | | Replaces DEFAULT_ROOM_VERSION constant with a method that first checks the config, then returns a hardcoded value if the option is not present. That hardcoded value is now located in the server.py config file.
* Add some limitations to alias creationBrendan Abolivier2019-05-021-1/+2
|
* Transfer related groups on room upgrade (#4990)Andrew Morgan2019-04-021-0/+1
| | | Transfers the m.room.related_groups state event on room upgrade.
* Collect room-version variations into one place (#4969)Richard van der Hoff2019-04-011-8/+3
| | | | Collect all the things that make room-versions different to one another into one place, so that it's easier to define new room versions.
* lintAndrew Morgan2019-02-181-1/+3
|
* Move member event processing and changelog fixAndrew Morgan2019-02-181-9/+7
|
* Membership events are done laterAndrew Morgan2019-02-181-12/+20
|
* Transfer bans on room upgradeAndrew Morgan2019-02-181-0/+14
|
* Transfer Server ACLs on room upgradeAndrew Morgan2019-02-111-0/+1
|
* New function for getting room's create eventAndrew Morgan2019-01-311-7/+1
|
* lintAndrew Morgan2019-01-311-2/+4
|
* Copy over non-federatable trait on room upgradeAndrew Morgan2019-01-301-0/+14
|
* Merge pull request #4482 from matrix-org/erikj/event_auth_room_versionErik Johnston2019-01-281-1/+4
|\ | | | | Pass through room version to event auth
| * Pass through room version to event authErik Johnston2019-01-251-1/+4
| |
* | Join logic covers both room creator and arbitrary usersAndrew Morgan2019-01-221-33/+0
| |
* | tags, m.direct copying over correctlyAndrew Morgan2019-01-221-9/+13
| |
* | Migrating dm and room tags work for migratorAndrew Morgan2019-01-221-2/+13
| |
* | Prevent crash on user who doesn't have any direct roomsAndrew Morgan2019-01-221-1/+1
| |
* | Preserve DM status of a room on upgradeAndrew Morgan2019-01-221-0/+19
| | | | | | | | Signed-off-by: Andrew Morgan <andrew@amorgan.xyz>
* | Fix typoAndrew Morgan2019-01-221-2/+2
|/
* Migrate encryption state on room upgrade (#4411)Andrew Morgan2019-01-211-0/+1
| | | | | | | | * Migrate encryption state on room upgrade Signed-off-by: Andrew Morgan <andrew@amorgan.xyz> * Add changelog file
* create support user (#4141)Neil Johnson2018-12-141-1/+1
| | | | | | Allow for the creation of a support user. A support user can access the server, join rooms, interact with other users, but does not appear in the user directory nor does it contribute to monthly active user limits.
* Merge pull request #4101 from matrix-org/rav/aliases_for_upgradesRichard van der Hoff2018-10-311-8/+112
|\ | | | | Attempt to move room aliases on room upgrades
| * Avoid else clause on exception for clarityRichard van der Hoff2018-10-311-2/+1
| |
| * Attempt to move room aliases on room upgradesRichard van der Hoff2018-10-311-8/+113
| |
* | Log some bits about event creation (#4121)Richard van der Hoff2018-10-311-0/+4
|/ | | | I found these helpful in debugging my room upgrade tests.
* Merge pull request #4100 from matrix-org/rav/room_upgrade_avatarRichard van der Hoff2018-10-291-1/+2
|\ | | | | Remember to copy the avatar on room upgrades
| * Remember to copy the avatar on room upgradesRichard van der Hoff2018-10-261-1/+2
| |
* | Better handling of odd PLs during room upgradesRichard van der Hoff2018-10-271-44/+81
|/ | | | | | | Fixes handling of rooms where we have permission to send the tombstone, but not other state. We need to (a) fail more gracefully when we can't send the PLs in the old room, and (b) not set the PLs in the new room until we are done with the other stuff.
* optimise state copyingRichard van der Hoff2018-10-261-7/+5
|
* Address review commentsRichard van der Hoff2018-10-261-7/+9
| | | | Improve comments, get old room state from the context we already have
* restrict PLs in old roomRichard van der Hoff2018-10-251-1/+43
|
* copy stateRichard van der Hoff2018-10-251-11/+26
|
* preserve PLsRichard van der Hoff2018-10-251-1/+7
|
* preserve room visibilityRichard van der Hoff2018-10-251-3/+5
|
* Basic initial support for room upgradesRichard van der Hoff2018-10-251-0/+121
| | | | | Currently just creates a new, empty, room, and sends a tombstone in the old room.
* Allow power_level_content_override=None for _send_events_for_new_roomRichard van der Hoff2018-10-251-5/+6
|
* Make room_member_handler a member of RoomCreationHandlerRichard van der Hoff2018-10-251-6/+3
| | | | ... to save passing it into `_send_events_for_new_room`