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

Commit

Permalink
Merge remote-tracking branch 'origin/develop' into erikj/device_list_…
Browse files Browse the repository at this point in the history
…perf
  • Loading branch information
erikjohnston committed Apr 4, 2022
2 parents dee8f55 + 80839a4 commit 3574541
Show file tree
Hide file tree
Showing 81 changed files with 1,374 additions and 1,095 deletions.
1 change: 1 addition & 0 deletions changelog.d/12040.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Optimise fetching large quantities of missing room state over federation.
1 change: 1 addition & 0 deletions changelog.d/12191.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/12209.misc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Switch to using a sequence to generate AS transaction IDs. Contributed by Nick Beeper. If running synapse with a dedicated appservice worker, this MUST be stopped before upgrading the main process and database.
1 change: 1 addition & 0 deletions changelog.d/12251.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Offload the `update_client_ip` background job from the main process to the background worker, when using Redis-based replication.
1 change: 1 addition & 0 deletions changelog.d/12267.misc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Add missing type hints for storage.
1 change: 1 addition & 0 deletions changelog.d/12295.misc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Move [MSC2654](https://github.com/matrix-org/matrix-doc/pull/2654) support behind an experimental configuration flag.
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/12327.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Add a module callback to react to account data changes.
1 change: 1 addition & 0 deletions changelog.d/12332.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/12341.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Allow setting user admin status using the module API. Contributed by Famedly.
1 change: 1 addition & 0 deletions changelog.d/12346.misc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Remove redundant `get_success` calls in test code.
1 change: 1 addition & 0 deletions changelog.d/12347.misc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Add type annotations for `tests/unittest.py`.
1 change: 1 addition & 0 deletions changelog.d/12348.misc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Move single-use methods out of `TestCase`.
1 change: 1 addition & 0 deletions changelog.d/12349.misc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Remove broken and unused development scripts.
1 change: 1 addition & 0 deletions changelog.d/12350.bugfix
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Default to `private` room visibility rather than `public` when a client does not specify one, according to spec.
1 change: 1 addition & 0 deletions changelog.d/12351.misc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Remove broken and unused development scripts.
1 change: 1 addition & 0 deletions changelog.d/12355.misc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Remove broken and unused development scripts.
1 change: 1 addition & 0 deletions docs/SUMMARY.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
- [Account validity callbacks](modules/account_validity_callbacks.md)
- [Password auth provider callbacks](modules/password_auth_provider_callbacks.md)
- [Background update controller callbacks](modules/background_update_controller_callbacks.md)
- [Account data callbacks](modules/account_data_callbacks.md)
- [Porting a legacy module to the new interface](modules/porting_legacy_module.md)
- [Workers](workers.md)
- [Using `synctl` with Workers](synctl_workers.md)
Expand Down
106 changes: 106 additions & 0 deletions docs/modules/account_data_callbacks.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
# Account data callbacks

Account data callbacks allow module developers to react to changes of the account data
of local users. Account data callbacks can be registered using the module API's
`register_account_data_callbacks` method.

## Callbacks

The available account data callbacks are:

### `on_account_data_updated`

_First introduced in Synapse v1.57.0_

```python
async def on_account_data_updated(
user_id: str,
room_id: Optional[str],
account_data_type: str,
content: "synapse.module_api.JsonDict",
) -> None:
```

Called after user's account data has been updated. The module is given the
Matrix ID of the user whose account data is changing, the room ID the data is associated
with, the type associated with the change, as well as the new content. If the account
data is not associated with a specific room, then the room ID is `None`.

This callback is triggered when new account data is added or when the data associated with
a given type (and optionally room) changes. This includes deletion, since in Matrix,
deleting account data consists of replacing the data associated with a given type
(and optionally room) with an empty dictionary (`{}`).

Note that this doesn't trigger when changing the tags associated with a room, as these are
processed separately by Synapse.

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

## Example

The example below is a module that implements the `on_account_data_updated` callback, and
sends an event to an audit room when a user changes their account data.

```python
import json
import attr
from typing import Any, Dict, Optional

from synapse.module_api import JsonDict, ModuleApi
from synapse.module_api.errors import ConfigError


@attr.s(auto_attribs=True)
class CustomAccountDataConfig:
audit_room: str
sender: str


class CustomAccountDataModule:
def __init__(self, config: CustomAccountDataConfig, api: ModuleApi):
self.api = api
self.config = config

self.api.register_account_data_callbacks(
on_account_data_updated=self.log_new_account_data,
)

@staticmethod
def parse_config(config: Dict[str, Any]) -> CustomAccountDataConfig:
def check_in_config(param: str):
if param not in config:
raise ConfigError(f"'{param}' is required")

check_in_config("audit_room")
check_in_config("sender")

return CustomAccountDataConfig(
audit_room=config["audit_room"],
sender=config["sender"],
)

async def log_new_account_data(
self,
user_id: str,
room_id: Optional[str],
account_data_type: str,
content: JsonDict,
) -> None:
content_raw = json.dumps(content)
msg_content = f"{user_id} has changed their account data for type {account_data_type} to: {content_raw}"

if room_id is not None:
msg_content += f" (in room {room_id})"

await self.api.create_and_send_event_into_room(
{
"room_id": self.config.audit_room,
"sender": self.config.sender,
"type": "m.room.message",
"content": {
"msgtype": "m.text",
"body": msg_content
}
}
)
```
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
2 changes: 1 addition & 1 deletion docs/modules/writing_a_module.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ A module can implement the following static method:

```python
@staticmethod
def parse_config(config: dict) -> dict
def parse_config(config: dict) -> Any
```

This method is given a dictionary resulting from parsing the YAML configuration for the
Expand Down
13 changes: 13 additions & 0 deletions docs/upgrade.md
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,19 @@ process, for example:
dpkg -i matrix-synapse-py3_1.3.0+stretch1_amd64.deb
```

# Upgrading to v1.57.0

## Changes to database schema for application services

Synapse v1.57.0 includes a [change](https://github.com/matrix-org/synapse/pull/12209) to the
way transaction IDs are managed for application services. If your deployment uses a dedicated
worker for application service traffic, **it must be stopped** when the database is upgraded
(which normally happens when the main process is upgraded), to ensure the change is made safely
without any risk of reusing transaction IDs.

Deployments which do not use separate worker processes can be upgraded as normal. Similarly,
deployments where no applciation services are in use can be upgraded as normal.

# Upgrading to v1.56.0

## Groups/communities feature has been deprecated
Expand Down
7 changes: 0 additions & 7 deletions mypy.ini
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,8 @@ files =
exclude = (?x)
^(
|scripts-dev/build_debian_packages.py
|scripts-dev/check_signature.py
|scripts-dev/definitions.py
|scripts-dev/federation_client.py
|scripts-dev/hash_history.py
|scripts-dev/list_url_patterns.py
|scripts-dev/release.py
|scripts-dev/tail-synapse.py

|synapse/_scripts/export_signing_key.py
|synapse/_scripts/move_remote_media_to_new_store.py
Expand All @@ -43,7 +38,6 @@ exclude = (?x)
|synapse/storage/databases/main/event_federation.py
|synapse/storage/databases/main/push_rule.py
|synapse/storage/databases/main/roommember.py
|synapse/storage/databases/main/state.py
|synapse/storage/schema/

|tests/api/test_auth.py
Expand Down Expand Up @@ -86,7 +80,6 @@ exclude = (?x)
|tests/test_server.py
|tests/test_state.py
|tests/test_terms_auth.py
|tests/unittest.py
|tests/util/caches/test_cached_call.py
|tests/util/caches/test_deferred_cache.py
|tests/util/caches/test_descriptors.py
Expand Down
72 changes: 0 additions & 72 deletions scripts-dev/check_signature.py

This file was deleted.

Loading

0 comments on commit 3574541

Please sign in to comment.