Skip to content
This repository has been archived by the owner on Apr 26, 2024. It is now read-only.

Commit

Permalink
Merge remote-tracking branch 'origin/develop' into dmr/pyproject-poetry
Browse files Browse the repository at this point in the history
Resolves conflicts from #12334 (merged to develop in 9a3f1f5)
  • Loading branch information
David Robertson committed Mar 31, 2022
2 parents e96fd31 + 5e88143 commit d2df831
Show file tree
Hide file tree
Showing 53 changed files with 714 additions and 747 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -370,7 +370,7 @@ jobs:
# Run Complement
- run: |
set -o pipefail
go test -v -json -tags synapse_blacklist,msc2403,msc2716,msc3030 ./tests/... 2>&1 | gotestfmt
go test -v -json -tags synapse_blacklist,msc2716,msc3030 ./tests/... 2>&1 | gotestfmt
shell: bash
name: Run Complement Tests
env:
Expand Down
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@ __pycache__/
/media_store/
/uploads

# For direnv users
/.envrc

# IDEs
/.idea/
/.ropeproject/
Expand Down
1 change: 1 addition & 0 deletions changelog.d/11881.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Send device list changes to application services as specified by [MSC3202](https://github.com/matrix-org/matrix-spec-proposals/pull/3202), using unstable prefixes. The `msc3202_transaction_extensions` experimental homeserver config option must be enabled and `org.matrix.msc3202: true` must be present in the application service registration file for device list changes to be sent. The "left" field is currently always empty.
1 change: 1 addition & 0 deletions changelog.d/12165.misc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Remove lingering unstable references to MSC2403 (knocking).
1 change: 1 addition & 0 deletions changelog.d/12193.misc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Omit sending "offline" presence updates to application services after they are initially configured.
1 change: 1 addition & 0 deletions changelog.d/12271.doc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Clarify documentation for running SyTest against Synapse, including use of Postgres and worker mode.
1 change: 1 addition & 0 deletions changelog.d/12293.removal
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Remove the unused and unstable `/aggregations` endpoint which was removed from [MSC2675](https://github.com/matrix-org/matrix-doc/pull/2675).
1 change: 1 addition & 0 deletions changelog.d/12302.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Add a module callback to react to new 3PID (email address, phone number) associations.
1 change: 1 addition & 0 deletions changelog.d/12330.misc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Avoid trying to calculate the state at outlier events.
1 change: 1 addition & 0 deletions changelog.d/12331.doc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Update dead links in `check-newsfragment.sh` to point to the correct documentation URL.
1 change: 1 addition & 0 deletions changelog.d/12333.bugfix
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fix a long-standing bug affecting URL previews that would generate a 500 response instead of a 403 if the previewed URL includes a port that isn't allowed by the relevant blacklist.
1 change: 1 addition & 0 deletions changelog.d/12334.misc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Remove the `tox` packaging job: it will be redundant once #11537 lands.
1 change: 1 addition & 0 deletions changelog.d/12335.misc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Ignore `.envrc` for `direnv` users.
1 change: 1 addition & 0 deletions changelog.d/12336.misc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Remove the (broadly unused, dev-only) dockerfile for pg tests.
1 change: 1 addition & 0 deletions changelog.d/12338.misc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Refactor relations code to remove an unnecessary class.
30 changes: 0 additions & 30 deletions docker/Dockerfile-pgtests

This file was deleted.

2 changes: 1 addition & 1 deletion docker/README-testing.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ the root of your Complement checkout and run:
docker build -t matrixdotorg/complement-synapse-workers -f dockerfiles/SynapseWorkers.Dockerfile dockerfiles
```

This will build an image with the tag `complement-synapse`, which can be handed to
This will build an image with the tag `complement-synapse-workers`, which can be handed to
Complement for testing via the `COMPLEMENT_BASE_IMAGE` environment variable. Refer to
[Complement's documentation](https://github.com/matrix-org/complement/#running) for
how to run the tests, as well as the various available command line flags.
Expand Down
19 changes: 0 additions & 19 deletions docker/run_pg_tests.sh

This file was deleted.

29 changes: 7 additions & 22 deletions docs/development/contributing_guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -215,27 +215,6 @@ export SYNAPSE_POSTGRES_PASSWORD=mydevenvpassword
trial
```

#### Prebuilt container

Since configuring PostgreSQL can be fiddly, we can make use of a pre-made
Docker container to set up PostgreSQL and run our tests for us. To do so, run

```shell
scripts-dev/test_postgresql.sh
```

Any extra arguments to the script will be passed to `tox` and then to `trial`,
so we can run a specific test in this container with e.g.

```shell
scripts-dev/test_postgresql.sh tests.replication.test_sharded_event_persister.EventPersisterShardTestCase
```

The container creates a folder in your Synapse checkout called
`.tox-pg-container` and uses this as a tox environment. The output of any
`trial` runs goes into `_trial_temp` in your synapse source directory — the same
as running `trial` directly on your host machine.

## Run the integration tests ([Sytest](https://github.com/matrix-org/sytest)).

The integration tests are a more comprehensive suite of tests. They
Expand All @@ -249,8 +228,14 @@ configuration:
```sh
$ docker run --rm -it -v /path/where/you/have/cloned/the/repository\:/src:ro -v /path/to/where/you/want/logs\:/logs matrixdotorg/sytest-synapse:buster
```
(Note that the paths must be full paths! You could also write `$(realpath relative/path)` if needed.)

This configuration should generally cover your needs.

- To run with Postgres, supply the `-e POSTGRES=1 -e MULTI_POSTGRES=1` environment flags.
- To run with Synapse in worker mode, supply the `-e WORKERS=1 -e REDIS=1` environment flags (in addition to the Postgres flags).

This configuration should generally cover your needs. For more details about other configurations, see [documentation in the SyTest repo](https://github.com/matrix-org/sytest/blob/develop/docker/README.md).
For more details about other configurations, see the [Docker-specific documentation in the SyTest repo](https://github.com/matrix-org/sytest/blob/develop/docker/README.md).


## Run the integration tests ([Complement](https://github.com/matrix-org/complement)).
Expand Down
18 changes: 18 additions & 0 deletions docs/modules/third_party_rules_callbacks.md
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,24 @@ admin API.

If multiple modules implement this callback, Synapse runs them all in order.

### `on_threepid_bind`

_First introduced in Synapse v1.56.0_

```python
async def on_threepid_bind(user_id: str, medium: str, address: str) -> None:
```

Called after creating an association between a local user and a third-party identifier
(email address, phone number). The module is given the Matrix ID of the user the
association is for, as well as the medium (`email` or `msisdn`) and address of the
third-party identifier.

Note that this callback is _not_ called after a successful association on an _identity
server_.

If multiple modules implement this callback, Synapse runs them all in order.

## Example

The example below is a module that implements the third-party rules callback
Expand Down
4 changes: 2 additions & 2 deletions scripts-dev/check-newsfragment.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ if ! git diff --quiet FETCH_HEAD... -- debian; then
if git diff --quiet FETCH_HEAD... -- debian/changelog; then
echo "Updates to debian directory, but no update to the changelog." >&2
echo "!! Please see the contributing guide for help writing your changelog entry:" >&2
echo "https://github.com/matrix-org/synapse/blob/develop/CONTRIBUTING.md#debian-changelog" >&2
echo "https://matrix-org.github.io/synapse/latest/development/contributing_guide.html#debian-changelog" >&2
exit 1
fi
fi
Expand All @@ -32,7 +32,7 @@ fi

# Print a link to the contributing guide if the user makes a mistake
CONTRIBUTING_GUIDE_TEXT="!! Please see the contributing guide for help writing your changelog entry:
https://github.com/matrix-org/synapse/blob/develop/CONTRIBUTING.md#changelog"
https://matrix-org.github.io/synapse/latest/development/contributing_guide.html#changelog"

# If check-newsfragment returns a non-zero exit code, print the contributing guide and exit
python -m towncrier.check --compare-with=origin/develop || (echo -e "$CONTRIBUTING_GUIDE_TEXT" >&2 && exit 1)
Expand Down
2 changes: 1 addition & 1 deletion scripts-dev/complement.sh
Original file line number Diff line number Diff line change
Expand Up @@ -71,4 +71,4 @@ fi

# Run the tests!
echo "Images built; running complement"
go test -v -tags synapse_blacklist,msc2403,msc2716,msc3030 -count=1 $EXTRA_COMPLEMENT_ARGS ./tests/...
go test -v -tags synapse_blacklist,msc2716,msc3030 -count=1 $EXTRA_COMPLEMENT_ARGS ./tests/...
19 changes: 0 additions & 19 deletions scripts-dev/test_postgresql.sh

This file was deleted.

12 changes: 11 additions & 1 deletion synapse/appservice/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# Copyright 2015, 2016 OpenMarket Ltd
# Copyright 2022 The Matrix.org Foundation C.I.C.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand All @@ -22,7 +23,13 @@

from synapse.api.constants import EventTypes
from synapse.events import EventBase
from synapse.types import GroupID, JsonDict, UserID, get_domain_from_id
from synapse.types import (
DeviceListUpdates,
GroupID,
JsonDict,
UserID,
get_domain_from_id,
)
from synapse.util.caches.descriptors import _CacheContext, cached

if TYPE_CHECKING:
Expand Down Expand Up @@ -400,6 +407,7 @@ def __init__(
to_device_messages: List[JsonDict],
one_time_key_counts: TransactionOneTimeKeyCounts,
unused_fallback_keys: TransactionUnusedFallbackKeys,
device_list_summary: DeviceListUpdates,
):
self.service = service
self.id = id
Expand All @@ -408,6 +416,7 @@ def __init__(
self.to_device_messages = to_device_messages
self.one_time_key_counts = one_time_key_counts
self.unused_fallback_keys = unused_fallback_keys
self.device_list_summary = device_list_summary

async def send(self, as_api: "ApplicationServiceApi") -> bool:
"""Sends this transaction using the provided AS API interface.
Expand All @@ -424,6 +433,7 @@ async def send(self, as_api: "ApplicationServiceApi") -> bool:
to_device_messages=self.to_device_messages,
one_time_key_counts=self.one_time_key_counts,
unused_fallback_keys=self.unused_fallback_keys,
device_list_summary=self.device_list_summary,
txn_id=self.id,
)

Expand Down
10 changes: 9 additions & 1 deletion synapse/appservice/api.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# Copyright 2015, 2016 OpenMarket Ltd
# Copyright 2022 The Matrix.org Foundation C.I.C.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -27,7 +28,7 @@
from synapse.events import EventBase
from synapse.events.utils import SerializeEventConfig, serialize_event
from synapse.http.client import SimpleHttpClient
from synapse.types import JsonDict, ThirdPartyInstanceID
from synapse.types import DeviceListUpdates, JsonDict, ThirdPartyInstanceID
from synapse.util.caches.response_cache import ResponseCache

if TYPE_CHECKING:
Expand Down Expand Up @@ -225,6 +226,7 @@ async def push_bulk(
to_device_messages: List[JsonDict],
one_time_key_counts: TransactionOneTimeKeyCounts,
unused_fallback_keys: TransactionUnusedFallbackKeys,
device_list_summary: DeviceListUpdates,
txn_id: Optional[int] = None,
) -> bool:
"""
Expand Down Expand Up @@ -268,6 +270,7 @@ async def push_bulk(
}
)

# TODO: Update to stable prefixes once MSC3202 completes FCP merge
if service.msc3202_transaction_extensions:
if one_time_key_counts:
body[
Expand All @@ -277,6 +280,11 @@ async def push_bulk(
body[
"org.matrix.msc3202.device_unused_fallback_keys"
] = unused_fallback_keys
if device_list_summary:
body["org.matrix.msc3202.device_lists"] = {
"changed": list(device_list_summary.changed),
"left": list(device_list_summary.left),
}

try:
await self.put_json(
Expand Down
Loading

0 comments on commit d2df831

Please sign in to comment.