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

Commit e9f2ad8

Browse files
authored
Describe callbacks signatures as async in new modules doc (#10206)
1 parent 1b3e398 commit e9f2ad8

File tree

2 files changed

+9
-8
lines changed

2 files changed

+9
-8
lines changed

changelog.d/10206.feature

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Standardised the module interface.

docs/modules.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ argument name and the function as its value. This is demonstrated in the example
101101
The available spam checker callbacks are:
102102

103103
```python
104-
def check_event_for_spam(event: "synapse.events.EventBase") -> Union[bool, str]
104+
async def check_event_for_spam(event: "synapse.events.EventBase") -> Union[bool, str]
105105
```
106106

107107
Called when receiving an event from a client or via federation. The module can return
@@ -110,38 +110,38 @@ to indicate the event must be rejected because of spam and to give a rejection r
110110
forward to clients.
111111

112112
```python
113-
def user_may_invite(inviter: str, invitee: str, room_id: str) -> bool
113+
async def user_may_invite(inviter: str, invitee: str, room_id: str) -> bool
114114
```
115115

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

120120
```python
121-
def user_may_create_room(user: str) -> bool
121+
async def user_may_create_room(user: str) -> bool
122122
```
123123

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

127127
```python
128-
def user_may_create_room_alias(user: str, room_alias: "synapse.types.RoomAlias") -> bool
128+
async def user_may_create_room_alias(user: str, room_alias: "synapse.types.RoomAlias") -> bool
129129
```
130130

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

135135
```python
136-
def user_may_publish_room(user: str, room_id: str) -> bool
136+
async def user_may_publish_room(user: str, room_id: str) -> bool
137137
```
138138

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

143143
```python
144-
def check_username_for_spam(user_profile: Dict[str, str]) -> bool
144+
async def check_username_for_spam(user_profile: Dict[str, str]) -> bool
145145
```
146146

147147
Called when computing search results in the user directory. The module must return a
@@ -156,7 +156,7 @@ The module is given a copy of the original dictionary, so modifying it from with
156156
module cannot modify a user's profile when included in user directory search results.
157157

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

181181
```python
182-
def check_media_file_for_spam(
182+
async def check_media_file_for_spam(
183183
file_wrapper: "synapse.rest.media.v1.media_storage.ReadableFileWrapper",
184184
file_info: "synapse.rest.media.v1._base.FileInfo"
185185
) -> bool

0 commit comments

Comments
 (0)