summary refs log tree commit diff
path: root/tests/http/test_fedclient.py (unfollow)
Commit message (Collapse)AuthorFilesLines
2021-10-01Strip "join_authorised_via_users_server" from join events which do not need ↵Patrick Cloke11-25/+46
it. (#10933) This fixes a "Event not signed by authorising server" error when transition room member from join -> join, e.g. when updating a display name or avatar URL for restricted rooms.
2021-09-30 1.44.0rc2 v1.44.0rc2Olivier Wilkinson (reivilibre)6-4/+23
2021-09-30Fix event context for outliers in important MSC2716 spot (#10938)Eric Eastwood2-9/+5
Fix event context for outlier causing failures in all of the MSC2716 Complement tests. The `EventContext.for_outlier` refactor happened in https://github.com/matrix-org/synapse/pull/10883 and this spot was left out.
2021-09-30Fix issue causing sending presence to ASes to fail (due to incomplete type ↵reivilibre2-1/+4
annotations) (#10944)
2021-09-29Update installation instructions (#10919)Richard van der Hoff3-164/+167
Various updates to the install docs.
2021-09-29Bump the date because the release ran over v1.44.0rc1Olivier Wilkinson (reivilibre)1-1/+1
2021-09-29Indicate when bugs were introduced and tidy upOlivier Wilkinson (reivilibre)1-12/+12
2021-09-29Tweak changelogOlivier Wilkinson (reivilibre)1-3/+3
2021-09-28Add #10932 to releaseErik Johnston1-1/+0
2021-09-28Fix exception responding to request that has been closed (#10932)Erik Johnston2-3/+12
Introduced in #10905
2021-09-28Fixup changelogErik Johnston1-2/+2
2021-09-28Fixup changelogErik Johnston1-2/+2
2021-09-28 1.44.0rc1Erik Johnston61-60/+79
2021-09-28Fix debian package builds. (#10931)Erik Johnston2-2/+4
This was due to dh-virtualenv builds being broken due to Shpinx removing deprecated APIs.
2021-09-28Encode JSON responses on a thread in C, mk2 (#10905)Erik Johnston4-18/+76
Currently we use `JsonEncoder.iterencode` to write JSON responses, which ensures that we don't block the main reactor thread when encoding huge objects. The downside to this is that `iterencode` falls back to using a pure Python encoder that is *much* less efficient and can easily burn a lot of CPU for huge responses. To fix this, while still ensuring we don't block the reactor loop, we encode the JSON on a threadpool using the standard `JsonEncoder.encode` functions, which is backed by a C library. Doing so, however, requires `respond_with_json` to have access to the reactor, which it previously didn't. There are two ways of doing this: 1. threading through the reactor object, which is a bit fiddly as e.g. `DirectServeJsonResource` doesn't currently take a reactor, but is exposed to modules and so is a PITA to change; or 2. expose the reactor in `SynapseRequest`, which requires updating a bunch of servlet types. I went with the latter as that is just a mechanical change, and I think makes sense as a request already has a reactor associated with it (via its http channel).
2021-09-27Sign the git tag in release script (#10925)Erik Johnston2-1/+2
2021-09-27Avoid storing URL cache files in storage providers (#10911)Sean Quah6-6/+154
URL cache files are short-lived and it does not make sense to offload them (eg. to the cloud) or back them up.
2021-09-27Fix race conditions when creating media store and config directories (#10913)Sean Quah4-13/+6
2021-09-24Document changes to schema version 61 - 64 (#10917)Eric Eastwood2-0/+12
As pointed out by @richvdh, https://github.com/matrix-org/synapse/pull/10838#discussion_r715424244 Retroactively summarize `61` - `64`
2021-09-24Add a spamchecker callback to allow or deny room creation based on invites ↵Brendan Abolivier5-6/+199
(#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.
2021-09-24Update postgresql testing script (#10906)David Robertson7-19/+92
- Use sytest:bionic. Sytest:latest is two years old (do we want CI to push out latest at all?) and comes with Python 3.5, which we explictly no longer support. The script now runs under PostgreSQL 10 as a result. - Advertise script in the docs - Move pg testing script to scripts-dev directory - Write to host as the script's exector, not root A few changes to make it speedier to re-run the tests: - Create blank DB in the container, not the script, so we don't have to `initdb` each time - Use a named volume to persist the tox environment, so we don't have to fetch and install a bunch of packages from PyPI each time Co-authored-by: reivilibre <olivier@librepush.net>
2021-09-24Stop trying to auth/persist events whose auth events we do not have. (#10907)Richard van der Hoff2-8/+17
2021-09-24Use direct references for configuration variables (part 5). (#10897)Patrick Cloke48-113/+128
2021-09-24Factor out common code for persisting fetched auth events (#10896)Richard van der Hoff4-58/+55
* Factor more stuff out of `_get_events_and_persist` It turns out that the event-sorting algorithm in `_get_events_and_persist` is also useful in other circumstances. Here we move the current `_auth_and_persist_fetched_events` to `_auth_and_persist_fetched_events_inner`, and then factor the sorting part out to `_auth_and_persist_fetched_events`. * `_get_remote_auth_chain_for_event`: remove redundant `outlier` assignment `get_event_auth` returns events with the outlier flag already set, so this is redundant (though we need to update a test where `get_event_auth` is mocked). * `_get_remote_auth_chain_for_event`: move existing-event tests earlier Move a couple of tests outside the loop. This is a bit inefficient for now, but a future commit will make it better. It should be functionally identical. * `_get_remote_auth_chain_for_event`: use `_auth_and_persist_fetched_events` We can use the same codepath for persisting the events fetched as part of an auth chain as for those fetched individually by `_get_events_and_persist` for building the state at a backwards extremity. * `_get_remote_auth_chain_for_event`: use a dict for efficiency `_auth_and_persist_fetched_events` sorts the events itself, so we no longer need to care about maintaining the ordering from `get_event_auth` (and no longer need to sort by depth in `get_event_auth`). That means that we can use a map, making it easier to filter out events we already have, etc. * changelog * `_auth_and_persist_fetched_events`: improve docstring
2021-09-24Simplify `_auth_and_persist_fetched_events` (#10901)Richard van der Hoff2-69/+23
Combine the two loops over the list of events, and hence get rid of `_NewEventInfo`. Also pass the event back alongside the context, so that it's easier to process the result.
2021-09-24Add reactor to `SynapseRequest` and fix up types. (#10868)Erik Johnston24-82/+123
2021-09-24Fix AuthBlocking check when requester is appservice (#10881)Jason Robinson3-1/+64
If the MAU count had been reached, Synapse incorrectly blocked appservice users even though they've been explicitly configured not to be tracked (the default). This was due to bypassing the relevant if as it was chained behind another earlier hit if as an elif. Signed-off-by: Jason Robinson <jasonr@matrix.org>
2021-09-24Improve typing in user_directory files (#10891)David Robertson4-37/+95
* Improve typing in user_directory files This makes the user_directory.py in storage pass most of mypy's checks (including `no-untyped-defs`). Unfortunately that file is in the tangled web of Store class inheritance so doesn't pass mypy at the moment. The handlers directory has already been mypyed. Co-authored-by: reivilibre <olivier@librepush.net>
2021-09-24In `_purge_history_txn`, ensure that txn.fetchall has elements before ↵Kokokokoka2-9/+14
accessing rows (#10690) This change adds a check for row existence before accessing row element, this should fix issue #10669 Signed-off-by: Vasya Boytsov vasiliy.boytsov@phystech.edu
2021-09-23Allow `.` and `~` chars in registration tokens (#10887)Callum Brown3-4/+7
Per updates to MSC3231 in order to use the same grammar as other identifiers.
2021-09-23Factor out `_get_remote_auth_chain_for_event` from ↵Richard van der Hoff2-52/+73
`_update_auth_events_and_context_for_auth` (#10884) * Reload auth events from db after fetching and persisting In `_update_auth_events_and_context_for_auth`, when we fetch the remote auth tree and persist the returned events: load the missing events from the database rather than using the copies we got from the remote server. This is mostly in preparation for additional refactors, but does have an advantage in that if we later get around to checking the rejected status, we'll be able to make use of it. * Factor out `_get_remote_auth_chain_for_event` from `_update_auth_events_and_context_for_auth` * changelog
2021-09-23Use direct references for configuration variables (part 4). (#10893)Patrick Cloke32-64/+77
2021-09-23Break down cache expiry reasons in grafana (#10880)David Robertson2-2/+3
A follow-up to #10829
2021-09-23Fix reactivated users not being added to the user directory (#10782)David Robertson3-4/+48
Co-authored-by: Dirk Klimpel <5740567+dklimpel@users.noreply.github.com> Co-authored-by: reivilibre <olivier@librepush.net> Co-authored-by: Richard van der Hoff <1389908+richvdh@users.noreply.github.com>
2021-09-23Use direct references for some configuration variables (part 3) (#10885)Patrick Cloke32-119/+137
This avoids the overhead of searching through the various configuration classes by directly referencing the class that the attributes are in. It also improves type hints since mypy can now resolve the types of the configuration variables.
2021-09-23Remove unnecessary parentheses around tuples returned from methods (#10889)Andrew Morgan22-32/+33
2021-09-22Factor out a separate `EventContext.for_outlier` (#10883)Richard van der Hoff5-44/+21
Constructing an EventContext for an outlier is actually really simple, and there's no sense in going via an `async` method in the `StateHandler`. This also means that we can resolve a bunch of FIXMEs.
2021-09-22Treat "\u0000" as "\u0020" for the purposes of message search (message ↵Hillery Shay3-9/+100
indexing) (#10820) * add test to check if null code points are being inserted * add logic to detect and replace null code points before insertion into db * lints * add license to test * change approach to null substitution * add type hint for SearchEntry * Add changelog entry Signed-off-by: H.Shay <shaysquared@gmail.com> * updated changelog * update chanelog message * remove duplicate changelog * Update synapse/storage/databases/main/events.py remove extra space Co-authored-by: Patrick Cloke <clokep@users.noreply.github.com> * rename and move test file, update tests, delete old test file * fix typo in comments * update _find_highlights_in_postgres to replace null byte with space * replace null byte in sqlite search insertion * beef up and reorganize test for this pr * update changelog * add type hints and update docstring * check db engine directly vs using env variable * refactor tests to be less repetetive * move rplace logic into seperate function * requested changes * Fix typo. * Update synapse/storage/databases/main/search.py Co-authored-by: reivilibre <olivier@librepush.net> * Update changelog.d/10820.misc Co-authored-by: Aaron Raimist <aaron@raim.ist> Co-authored-by: Patrick Cloke <clokep@users.noreply.github.com> Co-authored-by: reivilibre <olivier@librepush.net> Co-authored-by: Aaron Raimist <aaron@raim.ist>
2021-09-22Fix invalidating OTK count cache after claim (#10875)Tulir Asokan2-0/+5
The invalidation was missing in `_claim_e2e_one_time_key_returning`, which is used on SQLite 3.24+ and Postgres. This could break e2ee if nothing else happened to invalidate the caches before the keys ran out. Signed-off-by: Tulir Asokan <tulir@beeper.com>
2021-09-22Ensure we mark sent knocks as outliers (#10873)Richard van der Hoff2-0/+8
2021-09-22Include more information in oEmbed previews. (#10819)Patrick Cloke4-14/+68
* Improved titles (fall back to the author name if there's not title) and include the site name. * Handle photo/video payloads. * Include the original URL in the Open Graph response. * Fix the expiration time (by properly converting from seconds to milliseconds).
2021-09-22Fix /initialSync error due to unhashable `RoomStreamToken` (#10827)Sean Quah3-6/+19
The deprecated /initialSync endpoint maintains a cache of responses, using parameter values as part of the cache key. When a `from` or `to` parameter is specified, it gets converted into a `StreamToken`, which contains a `RoomStreamToken` and forms part of the cache key. `RoomStreamToken`s need to be made hashable for this to work.
2021-09-22Add documentation for experimental feature flags. (#10865)Patrick Cloke3-0/+39
2021-09-22Opt out of cache expiry for `get_users_who_share_room_with_user` (#10826)David Robertson5-6/+30
* Allow LruCaches to opt out of time-based expiry * Don't expire `get_users_who_share_room` & friends
2021-09-22Extend ModuleApi with the methods we'll need to reject spam based on …IP - ↵David Teller4-8/+174
resolves #10832 (#10833) Extend ModuleApi with the methods we'll need to reject spam based on IP - resolves #10832 Signed-off-by: David Teller <davidt@element.io>
2021-09-22Include outlier status in `str(event)` for V2/V3 events (#10879)Richard van der Hoff2-22/+13
I meant to do this before, in #10591, but because I'm stupid I forgot to do it for V2 and V3 events. I've factored the common code out to `EventBase` to save us having two copies of it. This means that for `FrozenEvent` we replace `self.get("event_id", None)` with `self.event_id`, which I think is safe. `get()` is an alias for `self._dict.get()`, whereas `event_id()` is an `@property` method which looks up `self._event_id`, which is populated during construction from the same dict. We don't seem to rely on the fallback, because if the `event_id` key is absent from the dict then construction of the `EventBase` object will fail. Long story short, the only way this could change behaviour is if `event_dict["event_id"]` is changed *after* the `EventBase` object is constructed without updating the `_event_id` field, or vice versa - either of which would be very problematic anyway and the behavior of `str(event)` is the least of our worries.
2021-09-22Track why we're evicting from caches (#10829)David Robertson4-15/+31
So we can see distinguish between "evicting because the cache is too big" and "evicting because the cache entries haven't been recently used".
2021-09-21Rename MSC2716 things from `chunk` to `batch` to match `/batch_send` ↵Eric Eastwood13-117/+162
endpoint (#10838) See https://github.com/matrix-org/matrix-doc/pull/2716#discussion_r684574497 Dropping support for older MSC2716 room versions so we don't have to worry about supporting both chunk and batch events.
2021-09-21Add type hints for event streams. (#10856)Patrick Cloke18-60/+169
2021-09-21Add types to http.site (#10867)Erik Johnston2-18/+23
2021-09-21Clear our destination directories before copying files to GitHub pages. (#10869)Patrick Cloke2-1/+1
This should fix stale deleted files being still accessible.
2021-09-21Refactor oEmbed previews (#10814)Patrick Cloke5-220/+299
The major change is moving the decision of whether to use oEmbed further up the call-stack. This reverts the _download_url method to being a "dumb" functionwhich takes a single URL and downloads it (as it was before #7920). This also makes more minor refactorings: * Renames internal variables for clarity. * Factors out shared code between the HTML and rich oEmbed previews. * Fixes tests to preview an oEmbed image.
2021-09-21Test that state events sent by modules correctly end up in the room's state ↵Brendan Abolivier2-0/+85
(#10835) Test for #10830 Ideally the test would also make sure the new state event comes down sync, but this is probably good enough.
2021-09-21Allow Synapse Admin API's Room Search to accept non-ASCII characters (#10859)Hillery Shay3-1/+29
* add tests for checking if room search works with non-ascii char * change encoding on parse_string to UTF-8 * lints * properly encode search term * lints * add changelog file * update changelog number * set changelog entry filetype to .bugfix * Revert "set changelog entry filetype to .bugfix" This reverts commit be8e5a314251438ec4ec7dbc59ba32162c93e550. * update changelog message and file type * change parse_string default encoding back to ascii and update room search admin api calll to parse string * refactor tests * Update tests/rest/admin/test_room.py Co-authored-by: Patrick Cloke <clokep@users.noreply.github.com> Co-authored-by: Patrick Cloke <clokep@users.noreply.github.com>
2021-09-21Rename `/batch_send` query parameter from `?prev_event` to more obvious ↵Eric Eastwood2-7/+10
usage with `?prev_event_id` (MSC2716) (#10839) As mentioned in https://github.com/matrix-org/matrix-doc/pull/2716#discussion_r705872887 and https://github.com/matrix-org/synapse/issues/10737
2021-09-21Always add local users to the user directory (#10796)David Robertson9-55/+54
It's a simplification, but one that'll help make the user directory logic easier to follow with the other changes upcoming. It's not strictly required for those changes, but this will help simplify the resulting logic that listens for `m.room.member` events and generally make the logic easier to follow. This means the config option `search_all_users` ends up controlling the search query only, and not the data we store. The cost of doing so is an extra row in the `user_directory` and `user_directory_search` tables for each local user which - belongs to no public rooms - belongs to no private rooms of size ≥ 2 I think the cost of this will be marginal (since they'll already have entries in `users` and `profiles` anyway). As a small upside, a homeserver whose directory was built with this change can toggle `search_all_users` without having to rebuild their directory. Co-authored-by: Richard van der Hoff <1389908+richvdh@users.noreply.github.com>
2021-09-21Fix typo again v1.43.0David Robertson1-1/+1
2021-09-21Specify MSC name; fix typoDavid Robertson1-3/+3
one day I'll learn how to spell hierarchy
2021-09-21Point to upgrade notesDavid Robertson1-0/+2
2021-09-21Move deprecation notice from 1.43 rc to releaseDavid Robertson1-3/+2
2021-09-21 1.43.0David Robertson3-1/+13
2021-09-21Allow sending a membership event to unban a user (#10807)Aaron Raimist4-2/+99
* Allow membership event to unban user Signed-off-by: Aaron Raimist <aaron@raim.ist>
2021-09-20GHA: reintroduce an env var for `$GITHUB_HEAD_REF` (#10659)David Robertson2-0/+2
This should ensure GHA runs synapse against the same-named sytest branch
2021-09-20Require type hints in the handlers mod