From 74b65bfc5f3c58005e3892b314e73cfde32355f6 Mon Sep 17 00:00:00 2001 From: erikjohnston Date: Tue, 2 Nov 2021 14:27:50 +0000 Subject: deploy: 2d44ee6868805d4ff23489a8dd6b4072ff358663 --- latest/modules/third_party_rules_callbacks.html | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) (limited to 'latest/modules/third_party_rules_callbacks.html') diff --git a/latest/modules/third_party_rules_callbacks.html b/latest/modules/third_party_rules_callbacks.html index da6ae86b87..7d9f8f0aac 100644 --- a/latest/modules/third_party_rules_callbacks.html +++ b/latest/modules/third_party_rules_callbacks.html @@ -99,7 +99,7 @@ @@ -189,6 +189,7 @@ the module API's register_third_party_rules_callbacks method.

Callbacks

The available third party rules callbacks are:

check_event_allowed

+

First introduced in Synapse v1.39.0

async def check_event_allowed(
     event: "synapse.events.EventBase",
     state_events: "synapse.types.StateMap",
@@ -216,7 +217,12 @@ that, it is recommended the module calls event.get_dict() to get th
 dictionary, and modify the returned dictionary accordingly.

Note that replacing the event only works for events sent by local users, not for events received over federation.

+

If multiple modules implement this callback, they will be considered in order. If a +callback returns True, Synapse falls through to the next one. The value of the first +callback that does not return True will be used. If this happens, Synapse will not call +any of the subsequent implementations of this callback.

on_create_room

+

First introduced in Synapse v1.39.0

async def on_create_room(
     requester: "synapse.types.Requester",
     request_content: dict,
@@ -230,7 +236,13 @@ for a list of possible parameters), and a boolean indicating whether the user pe
 the request is a server admin.

Modules can modify the request_content (by e.g. adding events to its initial_state), or deny the room's creation by raising a module_api.errors.SynapseError.

+

If multiple modules implement this callback, they will be considered in order. If a +callback returns without raising an exception, Synapse falls through to the next one. The +room creation will be forbidden as soon as one of the callbacks raises an exception. If +this happens, Synapse will not call any of the subsequent implementations of this +callback.

check_threepid_can_be_invited

+

First introduced in Synapse v1.39.0

async def check_threepid_can_be_invited(
     medium: str,
     address: str,
@@ -239,7 +251,12 @@ or deny the room's creation by raising a module_api.errors.SynapseError

Called when processing an invite via a third-party identifier (i.e. email or phone number). The module must return a boolean indicating whether the invite can go through.

+

If multiple modules implement this callback, they will be considered in order. If a +callback returns True, Synapse falls through to the next one. The value of the first +callback that does not return True will be used. If this happens, Synapse will not call +any of the subsequent implementations of this callback.

check_visibility_can_be_modified

+

First introduced in Synapse v1.39.0

async def check_visibility_can_be_modified(
     room_id: str,
     state_events: "synapse.types.StateMap",
@@ -249,6 +266,10 @@ The module must return a boolean indicating whether the invite can go through.Called when changing the visibility of a room in the local public room directory. The
 visibility is a string that's either "public" or "private". The module must return a
 boolean indicating whether the change can go through.

+

If multiple modules implement this callback, they will be considered in order. If a +callback returns True, Synapse falls through to the next one. The value of the first +callback that does not return True will be used. If this happens, Synapse will not call +any of the subsequent implementations of this callback.

Example

The example below is a module that implements the third-party rules callback check_event_allowed to censor incoming messages as dictated by a third-party service.

-- cgit 1.5.1