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/spam_checker_callbacks.html | 58 +++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) (limited to 'latest/modules/spam_checker_callbacks.html') diff --git a/latest/modules/spam_checker_callbacks.html b/latest/modules/spam_checker_callbacks.html index a7bc547907..2bb382af2a 100644 --- a/latest/modules/spam_checker_callbacks.html +++ b/latest/modules/spam_checker_callbacks.html @@ -99,7 +99,7 @@ @@ -189,13 +189,19 @@ Synapse instances. Spam checker callbacks can be registered using the module API

Callbacks

The available spam checker callbacks are:

check_event_for_spam

+

First introduced in Synapse v1.37.0

async def check_event_for_spam(event: "synapse.events.EventBase") -> Union[bool, str]
 

Called when receiving an event from a client or via federation. The module can return either a bool to indicate whether the event must be rejected because of spam, or a str to indicate the event must be rejected because of spam and to give a rejection reason to forward to clients.

+

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

user_may_join_room

+

First introduced in Synapse v1.37.0

async def user_may_join_room(user: str, room: str, is_invited: bool) -> bool
 

Called when a user is trying to join a room. The module must return a bool to indicate @@ -205,13 +211,23 @@ whether the user can join the room. The user is represented by their Matrix user currently has a pending invite in the room.

This callback isn't called if the join is performed by a server administrator, or in the context of a room creation.

+

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.

user_may_invite

+

First introduced in Synapse v1.37.0

async def user_may_invite(inviter: str, invitee: str, room_id: str) -> bool
 

Called when processing an invitation. The module must return a bool indicating whether the inviter can invite the invitee to the given room. Both inviter and invitee are represented by their Matrix user ID (e.g. @alice:example.com).

+

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.

user_may_send_3pid_invite

+

First introduced in Synapse v1.45.0

async def user_may_send_3pid_invite(
     inviter: str,
     medium: str,
@@ -237,12 +253,22 @@ for more information regarding third-party identifiers.

Note: If the third-party identifier is already associated with a matrix user ID, user_may_invite will be used instead.

+

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.

user_may_create_room

+

First introduced in Synapse v1.37.0

async def user_may_create_room(user: str) -> bool
 

Called when processing a room creation request. The module must return a bool indicating whether the given user (represented by their Matrix user ID) is allowed to create a room.

+

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.

user_may_create_room_with_invites

+

First introduced in Synapse v1.44.0

async def user_may_create_room_with_invites(
     user: str,
     invites: List[str],
@@ -263,19 +289,34 @@ corresponding list(s) will be empty.

Note: This callback is not called when a room is cloned (e.g. during a room upgrade) since no invites are sent when cloning a room. To cover this case, modules also need to implement user_may_create_room.

+

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.

user_may_create_room_alias

+

First introduced in Synapse v1.37.0

async def user_may_create_room_alias(user: str, room_alias: "synapse.types.RoomAlias") -> bool
 

Called when trying to associate an alias with an existing room. The module must return a bool indicating whether the given user (represented by their Matrix user ID) is allowed to set the given alias.

+

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.

user_may_publish_room

+

First introduced in Synapse v1.37.0

async def user_may_publish_room(user: str, room_id: str) -> bool
 

Called when trying to publish a room to the homeserver's public rooms directory. The module must return a bool indicating whether the given user (represented by their Matrix user ID) is allowed to publish the given room.

+

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_username_for_spam

+

First introduced in Synapse v1.37.0

async def check_username_for_spam(user_profile: Dict[str, str]) -> bool
 

Called when computing search results in the user directory. The module must return a @@ -288,7 +329,12 @@ is represented as a dictionary with the following keys:

The module is given a copy of the original dictionary, so modifying it from within the module cannot modify a user's profile when included in user directory search results.

+

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

check_registration_for_spam

+

First introduced in Synapse v1.37.0

async def check_registration_for_spam(
     email_threepid: Optional[dict],
     username: Optional[str],
@@ -309,7 +355,13 @@ second item is an IP address. These user agents and IP addresses are the ones th
 used during the registration process.
 
  • auth_provider_id: The identifier of the SSO authentication provider, if any.
  • +

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

    check_media_file_for_spam

    +

    First introduced in Synapse v1.37.0

    async def check_media_file_for_spam(
         file_wrapper: "synapse.rest.media.v1.media_storage.ReadableFileWrapper",
         file_info: "synapse.rest.media.v1._base.FileInfo",
    @@ -317,6 +369,10 @@ used during the registration process.
     

    Called when storing a local or remote file. The module must return a boolean indicating whether the given file can be stored in the homeserver's media store.

    +

    If multiple modules implement this callback, they will be considered in order. If a +callback returns False, Synapse falls through to the next one. The value of the first +callback that does not return False 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 spam checker callback check_event_for_spam to deny any message sent by users whose Matrix user IDs are -- cgit 1.5.1