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

Commit 49c839b

Browse files
committed
Add documentation for new module api callback methods
1 parent ceb02d6 commit 49c839b

File tree

2 files changed

+65
-1
lines changed

2 files changed

+65
-1
lines changed

docs/modules/third_party_rules_callbacks.md

Lines changed: 39 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -265,6 +265,44 @@ server_.
265265

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

268+
### `on_add_user_third_party_identifier`
269+
270+
_First introduced in Synapse v1.78.0_
271+
272+
```python
273+
async def on_add_user_third_party_identifier(user_id: str, medium: str, address: str) -> None:
274+
```
275+
276+
Called just before creating an association between a user and a third-party identifier
277+
(email address, phone number). The module is given the Matrix ID of the user the
278+
association is for, as well as the medium (`email` or `msisdn`) and address of the
279+
third-party identifier (i.e. an email address).
280+
281+
Note that this callback is _not_ called if a user attempts to bind their third-party identifier
282+
to an identity server (via a call to [`POST
283+
/_matrix/client/v3/account/3pid/bind`](https://spec.matrix.org/v1.5/client-server-api/#post_matrixclientv3account3pidbind)).
284+
285+
If multiple modules implement this callback, Synapse runs them all in order.
286+
287+
### `on_remove_user_third_party_identifier`
288+
289+
_First introduced in Synapse v1.78.0_
290+
291+
```python
292+
async def on_remove_user_third_party_identifier(user_id: str, medium: str, address: str) -> None:
293+
```
294+
295+
Called just before removing an association between a user and a third-party identifier
296+
(email address, phone number). The module is given the Matrix ID of the user the
297+
association is for, as well as the medium (`email` or `msisdn`) and address of the
298+
third-party identifier (i.e. an email address).
299+
300+
Note that this callback is _not_ called if a user attempts to unbind their third-party
301+
identifier from an identity server (via a call to [`POST
302+
/_matrix/client/v3/account/3pid/unbind`](https://spec.matrix.org/v1.5/client-server-api/#post_matrixclientv3account3pidunbind)).
303+
304+
If multiple modules implement this callback, Synapse runs them all in order.
305+
268306
## Example
269307
270308
The example below is a module that implements the third-party rules callback
@@ -297,4 +335,4 @@ class EventCensorer:
297335
)
298336
event_dict["content"] = new_event_content
299337
return event_dict
300-
```
338+
```

docs/upgrade.md

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,32 @@ admin API with an identical endpoint at `/_synapse/admin/v1/media/delete`. Pleas
9797
update your tooling to use the new endpoint. The deprecated version will be removed
9898
in a future release.
9999
100+
## The `on_threepid_bind` module callback method has been deprecated
101+
102+
The [`on_threepid_bind`](modules/third_party_rules_callbacks.md#on_threepid_bind) "third-party rules"
103+
Synapse module callback method has been deprecated
104+
in favour of a new module method,
105+
[`on_add_user_third_party_identifier`](modules/third_party_rules_callbacks.md#on_add_user_third_party_identifier).
106+
`on_threepid_bind` will be removed in a future version of Synapse. You should check whether any Synapse
107+
modules in use in your deployment are making use of `on_threepid_bind`, and update them where possible.
108+
109+
The arguments and functionality of the new method are nearly the same; `on_threepid_bind` was called
110+
directly *after* a user adds a third-party identifier (email, phone number) to their account, while
111+
`on_add_user_third_party_identifier` is called just *before* a user adds a third-party identifier.
112+
113+
The justification behind the swap in logical ordering is that `on_add_user_third_party_identifier`
114+
may be extended in the future to allow blocking a user from adding a third-party identifier to their
115+
account. The reason behind the name change is that the old method's name, `on_threepid_bind`, was
116+
misleading. A user is considered to "bind" their third-party ID to their Matrix ID only if they
117+
do so via an [identity server](https://spec.matrix.org/latest/identity-service-api/)
118+
(so that users on other homeservers may find them). But this method was not called in that case -
119+
it was only called when a user added a third-party identifier on the local homeserver.
120+
121+
Module developers may also be interested in the related
122+
[`on_remove_user_third_party_identifier`](modules/third_party_rules_callbacks.md#on_remove_user_third_party_identifier)
123+
module callback method that was also added in Synapse v1.77.0. This new method is called when a
124+
user removes a third-party identifier from their account.
125+
100126
# Upgrading to v1.76.0
101127

102128
## Faster joins are enabled by default

0 commit comments

Comments
 (0)