Andrew Morgan
a38cb2faf7
Rename user1, user2 in tests to something more useful
2021-12-29 11:22:39 +00:00
Andrew Morgan
d5d4d7832d
Rename ApplicationServiceEphemeralEventsTestCase
2021-12-29 11:22:39 +00:00
Andrew Morgan
cc30393cee
_handle_to_device -> _get_to_device_messages
2021-12-29 11:22:39 +00:00
Andrew Morgan
d4a93df981
Deduplicate ephemeral events to send conditional
...
Test cases needed to be updated, as we now always call
submit_ephemeral_events_for_as, it may just be with an
empty events list.
2021-12-29 11:22:39 +00:00
Andrew Morgan
edfb4f5e9f
Broaden type hints; update comment
2021-12-29 11:22:38 +00:00
Andrew Morgan
0fe753cc7f
Move stream filter back into AppserviceHandler
2021-12-29 11:21:35 +00:00
Andrew Morgan
b9b4b55092
Make msc2409_to_device_messages_enabled private; remove unnecessary check
...
The second check for self._msc2409_to_device_messages_enabled was not necessary. It's
already checked in notify_interested_services_ephemeral earlier.
2021-12-29 11:21:34 +00:00
Andrew Morgan
076f959a2d
Changelog
2021-12-29 11:21:34 +00:00
Andrew Morgan
94a2389a97
Add tests
...
I decided to spin up another test class for this as the existing one is
1. quite old and 2. was mocking away too much of the infrastructure to
my liking. I've named the new class alluding to ephemeral messages, and
while we already have some ephemeral tests in AppServiceHandlerTestCase,
ideally I'd like to migrate those over.
There's two new tests here. One for testing that to-device messages for
a local user are received by any application services that have
registered interest in that user - and that those that haven't won't
receive those messages.
The next test is similar, but tests with a whole bunch of to-device
messages. Rather than actually registering tons of devices - which would
make for a very slow unit test - we just directly insert them into the
database.
2021-12-29 11:21:34 +00:00
Andrew Morgan
662756aa7f
Add a to_device_stream_id column to the application_services_state table
...
This is for tracking the stream id that each application service has
been sent up to. In other words, there shouldn't be any need to process
stream ids below the recorded one here as the AS should have already
received them.
Note that there is no reliability built-in here. Reliability of delivery
if intended for a separate PR.
2021-12-29 11:21:34 +00:00
Andrew Morgan
d6288fff7e
Add database method to fetch to-device messages by user_ids from db
...
This method is quite similar to the one below, except that it doesn't
support device ids, and supports querying with more than one user id,
both of which are relevant to application services.
The results are also formatted in a different data structure, so I'm
not sure how much we could really share here between the two methods.
2021-12-29 11:21:33 +00:00
Andrew Morgan
668ac822de
Allow setting/getting stream id per appservice for to-device messages
2021-12-29 11:21:33 +00:00
Andrew Morgan
a1ac23a2b6
Add a new ephemeral AS handler for to_device message edus
...
Here we add the ability for the application service ephemeral message
processor to handle new events on the "to_device" stream.
We keep track of a stream id (token) per application service, and every
time a new to-device message comes in, for each appservice we pull the
messages between the last-recorded and current stream id and check
whether any of the messages are for a user in that appservice's user
namespace.
get_new_messages is implemented in the next commit.
since we rebased off latest develop.
2021-12-29 11:21:33 +00:00
Andrew Morgan
31078e10a1
Add experimental config option to send to-device messages to AS's
2021-12-29 11:21:33 +00:00
Shay
fcfe67578f
Update to the current version of Black and run it on Synapse codebase ( #11596 )
...
* update black version
* run updated version of black on code
* newsfragment
* enumerate python versions
2021-12-23 20:22:15 -08:00
Patrick Cloke
66d7aa783a
Fix mypy error with opentracing.tags. ( #11622 )
2021-12-23 11:47:24 +00:00
AndrewFerr
c500bf37d6
Add details for how to set up TURN behind NAT ( #11553 )
...
Signed-off-by: Andrew Ferrazzutti <fair@miscworks.net >
2021-12-23 10:42:50 +00:00
Shay
87da37374a
Drop EOL python 3.6 from CI ( #11595 )
...
* remove python 3.6 and postgres 9.6 from github workflow
* remove python 3.6 env from tox
* newsfragment
* correct postgres version
* add py310 to tox env list
2021-12-21 11:37:04 -08:00
Richard van der Hoff
144b9ede89
Merge branch 'master' into develop
2021-12-21 18:13:05 +00:00
Richard van der Hoff
9ec46d6231
Merge branch 'release-v1.49'
2021-12-21 18:12:18 +00:00
Richard van der Hoff
6b6dcdc338
update changelog
...
postgres 10 _+_
v1.49.2
2021-12-21 17:41:34 +00:00
Richard van der Hoff
aa874a1390
1.49.2
2021-12-21 17:32:16 +00:00
Richard van der Hoff
2bf31f7807
Pin to frozendict<2.1.2 ( #11625 )
...
... to work around breakage on buster
(https://github.com/Marco-Sulla/python-frozendict/issues/41 )
2021-12-21 17:26:04 +00:00
reivilibre
e6897e7383
Refactor tests.util.setup_test_homeserver and tests.server.setup_test_homeserver. ( #11503 )
2021-12-21 16:12:05 +00:00
Patrick Cloke
b6102230a7
Add type hints to event_push_actions. ( #11594 )
2021-12-21 13:25:34 +00:00
Richard van der Hoff
57ca8ab10f
Add notes about dropping support for Python 3.6 and Postgres 9.6.
v1.49.1
2021-12-21 12:06:31 +00:00
Richard van der Hoff
aa58e8a28a
typopo
2021-12-21 11:24:24 +00:00
Richard van der Hoff
b9f2f6d3c4
more words
2021-12-21 11:23:35 +00:00
Richard van der Hoff
2215954147
Various opentracing enhancements ( #11619 )
...
* Wrap `auth.get_user_by_req` in an opentracing span
give `get_user_by_req` its own opentracing span, since it can result in a
non-trivial number of sub-spans which it is useful to group together.
This requires a bit of reorganisation because it also sets some tags (and may
force tracing) on the servlet span.
* Emit opentracing span for encoding json responses
This can be a significant time sink.
* Rename all sync spans with a prefix
* Write an opentracing span for encoding sync response
* opentracing span to group generate_room_entries
* opentracing spans within sync.encode_response
* changelog
* Use the `trace` decorator instead of context managers
2021-12-21 11:10:36 +00:00
Richard van der Hoff
8c36d332d5
1.49.1
2021-12-21 11:07:41 +00:00
Patrick Cloke
dd47788752
Do not bundle aggregations for APIs which shouldn't include them. ( #11592 )
...
And make bundling aggregations opt-in, instead of opt-out to avoid
having APIs to include extraneous data (and being much heavier than
necessary).
2021-12-20 14:14:38 -05:00
Richard van der Hoff
c3e38b88f2
Improve opentracing support for ResponseCache ( #11607 )
...
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.
2021-12-20 18:12:08 +00:00
Richard van der Hoff
60fa4935b5
Improve opentracing for incoming HTTP requests ( #11618 )
...
* remove `start_active_span_from_request`
Instead, pull out a separate function, `span_context_from_request`, to extract
the parent span, which we can then pass into `start_active_span` as
normal. This seems to be clearer all round.
* Remove redundant tags from `incoming-federation-request`
These are all wrapped up inside a parent span generated in AsyncResource, so
there's no point duplicating all the tags that are set there.
* Leave request spans open until the request completes
It may take some time for the response to be encoded into JSON, and that JSON
to be streamed back to the client, and really we want that inside the top-level
span, so let's hand responsibility for closure to the SynapseRequest.
* opentracing logs for HTTP request events
* changelog
2021-12-20 17:45:03 +00:00
Richard van der Hoff
8e4083e2f6
Merge remote-tracking branch 'origin/release-v1.49' into develop
2021-12-20 16:34:01 +00:00
Richard van der Hoff
76aa5537ad
Disable aggregation bundling on /sync responses ( #11583 )
...
* Disable aggregation bundling on `/sync` responses
A partial revert of #11478 . This turns out to have had a significant CPU impact
on initial-sync handling. For now, let's disable it, until we find a more
efficient way of achieving this.
* Fix tests.
Co-authored-by: Patrick Cloke <patrickc@matrix.org >
2021-12-20 16:33:35 +00:00
Patrick Cloke
3e0cfd447e
Return JSON errors for unknown resources under /matrix/client. ( #11602 )
...
Instead of returning 404 errors with HTML bodies when an unknown
prefix was requested (e.g. /matrix/client/v1 before Synapse v1.49.0).
2021-12-20 16:00:13 +00:00
V02460
7a7ca8f226
Use mock from standard library ( #11588 )
...
Instead of the backported version.
2021-12-20 10:34:46 -05:00
Shay
8ad39438fa
Add opentracing types ( #11603 )
2021-12-20 12:18:09 +00:00
Dirk Klimpel
8428ef66c7
Add type hints to synapse/tests/rest/admin ( #11590 )
2021-12-16 14:59:56 -05:00
Dirk Klimpel
1847d027e6
Add type hints to synapse/storage/databases/main/transactions.py ( #11589 )
2021-12-16 14:59:35 -05:00
Eric Eastwood
43f5cc7adc
Add MSC2716 and MSC3030 to /versions -> unstable_features ( #11582 )
...
As suggested in https://github.com/matrix-org/matrix-react-sdk/pull/7372#discussion_r769523369
2021-12-16 11:25:37 -06:00
Sean Quah
c7fe32edb4
Add type hints to synapse/storage/databases/main/room.py ( #11575 )
2021-12-15 18:00:48 +00:00
Patrick Cloke
f901f8b70e
Require Collections as the parameters for simple_* methods. ( #11580 )
...
Instead of Iterable since the generators are not allowed due
to the potential for their re-use.
2021-12-15 17:00:50 +00:00
Patrick Cloke
323151b787
Convert EventStreamResult to attrs. ( #11574 )
2021-12-15 11:10:02 -05:00
reivilibre
17886d2603
Add experimental support for MSC3202: allowing application services to masquerade as specific devices. ( #11538 )
2021-12-15 10:40:52 +00:00
Sean Quah
ecfcd9bbbe
Add type hints to synapse/storage/databases/main/e2e_room_keys.py ( #11549 )
2021-12-14 17:46:47 +00:00
Sean Quah
0147b3de20
Add missing type hints to synapse.logging.context ( #11556 )
2021-12-14 17:35:28 +00:00
Patrick Cloke
2519beaad2
Add missing type hints to synapse.appservice ( #11360 )
2021-12-14 17:02:46 +00:00
Olivier Wilkinson (reivilibre)
70ca05373b
Merge branch 'master' into develop
2021-12-14 14:22:48 +00:00
Olivier Wilkinson (reivilibre)
a91698df90
Merge tag 'v1.49.0'
...
Synapse 1.49.0 (2021-12-14)
===========================
No significant changes since version 1.49.0rc1.
Support for Ubuntu 21.04 ends next month on the 20th of January
---------------------------------------------------------------
For users of Ubuntu 21.04 (Hirsute Hippo), please be aware that [upstream support for this version of Ubuntu will end next month][Ubuntu2104EOL].
We will stop producing packages for Ubuntu 21.04 after upstream support ends.
[Ubuntu2104EOL]: https://lists.ubuntu.com/archives/ubuntu-announce/2021-December/000275.html
The wiki has been migrated to the documentation website
-------------------------------------------------------
We've decided to move the existing, somewhat stagnant pages from the GitHub wiki
to the [documentation website](https://matrix-org.github.io/synapse/latest/ ).
This was done for two reasons. The first was to ensure that changes are checked by
multiple authors before being committed (everyone makes mistakes!) and the second
was visibility of the documentation. Not everyone knows that Synapse has some very
useful information hidden away in its GitHub wiki pages. Bringing them to the
documentation website should help with visibility, as well as keep all Synapse documentation
in one, easily-searchable location.
Note that contributions to the documentation website happen through [GitHub pull
requests](https://github.com/matrix-org/synapse/pulls ). Please visit [#synapse-dev:matrix.org](https://matrix.to/#/#synapse-dev:matrix.org )
if you need help with the process!
Synapse 1.49.0rc1 (2021-12-07)
==============================
Features
--------
- Add [MSC3030](https://github.com/matrix-org/matrix-doc/pull/3030 ) experimental client and federation API endpoints to get the closest event to a given timestamp. ([\#9445](https://github.com/matrix-org/synapse/issues/9445 ))
- Include bundled relation aggregations during a limited `/sync` request and `/relations` request, per [MSC2675](https://github.com/matrix-org/matrix-doc/pull/2675 ). ([\#11284](https://github.com/matrix-org/synapse/issues/11284 ), [\#11478](https://github.com/matrix-org/synapse/issues/11478 ))
- Add plugin support for controlling database background updates. ([\#11306](https://github.com/matrix-org/synapse/issues/11306 ), [\#11475](https://github.com/matrix-org/synapse/issues/11475 ), [\#11479](https://github.com/matrix-org/synapse/issues/11479 ))
- Support the stable API endpoints for [MSC2946](https://github.com/matrix-org/matrix-doc/pull/2946 ): the room `/hierarchy` endpoint. ([\#11329](https://github.com/matrix-org/synapse/issues/11329 ))
- Add admin API to get some information about federation status with remote servers. ([\#11407](https://github.com/matrix-org/synapse/issues/11407 ))
- Support expiry of refresh tokens and expiry of the overall session when refresh tokens are in use. ([\#11425](https://github.com/matrix-org/synapse/issues/11425 ))
- Stabilise support for [MSC2918](https://github.com/matrix-org/matrix-doc/blob/main/proposals/2918-refreshtokens.md#msc2918-refresh-tokens ) refresh tokens as they have now been merged into the Matrix specification. ([\#11435](https://github.com/matrix-org/synapse/issues/11435 ), [\#11522](https://github.com/matrix-org/synapse/issues/11522 ))
- Update [MSC2918 refresh token](https://github.com/matrix-org/matrix-doc/blob/main/proposals/2918-refreshtokens.md#msc2918-refresh-tokens ) support to confirm with the latest revision: accept the `refresh_tokens` parameter in the request body rather than in the URL parameters. ([\#11430](https://github.com/matrix-org/synapse/issues/11430 ))
- Support configuring the lifetime of non-refreshable access tokens separately to refreshable access tokens. ([\#11445](https://github.com/matrix-org/synapse/issues/11445 ))
- Expose `synapse_homeserver` and `synapse_worker` commands as entry points to run Synapse's main process and worker processes, respectively. Contributed by @Ma27. ([\#11449](https://github.com/matrix-org/synapse/issues/11449 ))
- `synctl stop` will now wait for Synapse to exit before returning. ([\#11459](https://github.com/matrix-org/synapse/issues/11459 ), [\#11490](https://github.com/matrix-org/synapse/issues/11490 ))
- Extend the "delete room" admin api to work correctly on rooms which have previously been partially deleted. ([\#11523](https://github.com/matrix-org/synapse/issues/11523 ))
- Add support for the `/_matrix/client/v3/login/sso/redirect/{idpId}` API from Matrix v1.1. This endpoint was overlooked when support for v3 endpoints was added in Synapse 1.48.0rc1. ([\#11451](https://github.com/matrix-org/synapse/issues/11451 ))
Bugfixes
--------
- Fix using [MSC2716](https://github.com/matrix-org/matrix-doc/pull/2716 ) batch sending in combination with event persistence workers. Contributed by @tulir at Beeper. ([\#11220](https://github.com/matrix-org/synapse/issues/11220 ))
- Fix a long-standing bug where all requests that read events from the database could get stuck as a result of losing the database connection, properly this time. Also fix a race condition introduced in the previous insufficient fix in Synapse 1.47.0. ([\#11376](https://github.com/matrix-org/synapse/issues/11376 ))
- The `/send_join` response now includes the stable `event` field instead of the unstable field from [MSC3083](https://github.com/matrix-org/matrix-doc/pull/3083 ). ([\#11413](https://github.com/matrix-org/synapse/issues/11413 ))
- Fix a bug introduced in Synapse 1.47.0 where `send_join` could fail due to an outdated `ijson` version. ([\#11439](https://github.com/matrix-org/synapse/issues/11439 ), [\#11441](https://github.com/matrix-org/synapse/issues/11441 ), [\#11460](https://github.com/matrix-org/synapse/issues/11460 ))
- Fix a bug introduced in Synapse 1.36.0 which could cause problems fetching event-signing keys from trusted key servers. ([\#11440](https://github.com/matrix-org/synapse/issues/11440 ))
- Fix a bug introduced in Synapse 1.47.1 where the media repository would fail to work if the media store path contained any symbolic links. ([\#11446](https://github.com/matrix-org/synapse/issues/11446 ))
- Fix an `LruCache` corruption bug, introduced in Synapse 1.38.0, that would cause certain requests to fail until the next Synapse restart. ([\#11454](https://github.com/matrix-org/synapse/issues/11454 ))
- Fix a long-standing bug where invites from ignored users were included in incremental syncs. ([\#11511](https://github.com/matrix-org/synapse/issues/11511 ))
- Fix a regression in Synapse 1.48.0 where presence workers would not clear their presence updates over replication on shutdown. ([\#11518](https://github.com/matrix-org/synapse/issues/11518 ))
- Fix a regression in Synapse 1.48.0 where the module API's `looping_background_call` method would spam errors to the logs when given a non-async function. ([\#11524](https://github.com/matrix-org/synapse/issues/11524 ))
Updates to the Docker image
---------------------------
- Update `Dockerfile-workers` to healthcheck all workers in the container. ([\#11429](https://github.com/matrix-org/synapse/issues/11429 ))
Improved Documentation
----------------------
- Update the media repository documentation. ([\#11415](https://github.com/matrix-org/synapse/issues/11415 ))
- Update section about backward extremities in the room DAG concepts doc to correct the misconception about backward extremities indicating whether we have fetched an events' `prev_events`. ([\#11469](https://github.com/matrix-org/synapse/issues/11469 ))
Internal Changes
----------------
- Add `Final` annotation to string constants in `synapse.api.constants` so that they get typed as `Literal`s. ([\#11356](https://github.com/matrix-org/synapse/issues/11356 ))
- Add a check to ensure that users cannot start the Synapse master process when `worker_app` is set. ([\#11416](https://github.com/matrix-org/synapse/issues/11416 ))
- Add a note about postgres memory management and hugepages to postgres doc. ([\#11467](https://github.com/matrix-org/synapse/issues/11467 ))
- Add missing type hints to `synapse.config` module. ([\#11465](https://github.com/matrix-org/synapse/issues/11465 ))
- Add missing type hints to `synapse.federation`. ([\#11483](https://github.com/matrix-org/synapse/issues/11483 ))
- Add type annotations to `tests.storage.test_appservice`. ([\#11488](https://github.com/matrix-org/synapse/issues/11488 ), [\#11492](https://github.com/matrix-org/synapse/issues/11492 ))
- Add type annotations to some of the configuration surrounding refresh tokens. ([\#11428](https://github.com/matrix-org/synapse/issues/11428 ))
- Add type hints to `synapse/tests/rest/admin`. ([\#11501](https://github.com/matrix-org/synapse/issues/11501 ))
- Add type hints to storage classes. ([\#11411](https://github.com/matrix-org/synapse/issues/11411 ))
- Add wiki pages to documentation website. ([\#11402](https://github.com/matrix-org/synapse/issues/11402 ))
- Clean up `tests.storage.test_main` to remove use of legacy code. ([\#11493](https://github.com/matrix-org/synapse/issues/11493 ))
- Clean up `tests.test_visibility` to remove legacy code. ([\#11495](https://github.com/matrix-org/synapse/issues/11495 ))
- Convert status codes to `HTTPStatus` in `synapse.rest.admin`. ([\#11452](https://github.com/matrix-org/synapse/issues/11452 ), [\#11455](https://github.com/matrix-org/synapse/issues/11455 ))
- Extend the `scripts-dev/sign_json` script to support signing events. ([\#11486](https://github.com/matrix-org/synapse/issues/11486 ))
- Improve internal types in push code. ([\#11409](https://github.com/matrix-org/synapse/issues/11409 ))
- Improve type annotations in `synapse.module_api`. ([\#11029](https://github.com/matrix-org/synapse/issues/11029 ))
- Improve type hints for `LruCache`. ([\#11453](https://github.com/matrix-org/synapse/issues/11453 ))
- Preparation for database schema simplifications: disambiguate queries on `state_key`. ([\#11497](https://github.com/matrix-org/synapse/issues/11497 ))
- Refactor `backfilled` into specific behavior function arguments (`_persist_events_and_state_updates` and downstream calls). ([\#11417](https://github.com/matrix-org/synapse/issues/11417 ))
- Refactor `get_version_string` to fix-up types and duplicated code. ([\#11468](https://github.com/matrix-org/synapse/issues/11468 ))
- Refactor various parts of the `/sync` handler. ([\#11494](https://github.com/matrix-org/synapse/issues/11494 ), [\#11515](https://github.com/matrix-org/synapse/issues/11515 ))
- Remove unnecessary `json.dumps` from `tests.rest.admin`. ([\#11461](https://github.com/matrix-org/synapse/issues/11461 ))
- Save the OpenID Connect session ID on login. ([\#11482](https://github.com/matrix-org/synapse/issues/11482 ))
- Update and clean up recently ported documentation pages. ([\#11466](https://github.com/matrix-org/synapse/issues/11466 ))
2021-12-14 14:22:16 +00:00