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

Commit

Permalink
Describe callbacks signatures as async in new modules doc (#10206)
Browse files Browse the repository at this point in the history
  • Loading branch information
babolivier authored Jun 18, 2021
1 parent 1b3e398 commit e9f2ad8
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
1 change: 1 addition & 0 deletions changelog.d/10206.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Standardised the module interface.
16 changes: 8 additions & 8 deletions docs/modules.md
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ argument name and the function as its value. This is demonstrated in the example
The available spam checker callbacks are:

```python
def check_event_for_spam(event: "synapse.events.EventBase") -> Union[bool, str]
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
Expand All @@ -110,38 +110,38 @@ to indicate the event must be rejected because of spam and to give a rejection r
forward to clients.

```python
def user_may_invite(inviter: str, invitee: str, room_id: str) -> bool
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 (i.e. `@alice:example.com`).

```python
def user_may_create_room(user: str) -> bool
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.

```python
def user_may_create_room_alias(user: str, room_alias: "synapse.types.RoomAlias") -> bool
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.

```python
def user_may_publish_room(user: str, room_id: str) -> bool
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.

```python
def check_username_for_spam(user_profile: Dict[str, str]) -> bool
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
Expand All @@ -156,7 +156,7 @@ The module is given a copy of the original dictionary, so modifying it from with
module cannot modify a user's profile when included in user directory search results.

```python
def check_registration_for_spam(
async def check_registration_for_spam(
email_threepid: Optional[dict],
username: Optional[str],
request_info: Collection[Tuple[str, str]],
Expand All @@ -179,7 +179,7 @@ The arguments passed to this callback are:
* `auth_provider_id`: The identifier of the SSO authentication provider, if any.

```python
def check_media_file_for_spam(
async def check_media_file_for_spam(
file_wrapper: "synapse.rest.media.v1.media_storage.ReadableFileWrapper",
file_info: "synapse.rest.media.v1._base.FileInfo"
) -> bool
Expand Down

0 comments on commit e9f2ad8

Please sign in to comment.