You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Apr 26, 2024. It is now read-only.
Port spam-checker API callbacks to a new, richer API. This is part of an ongoing change to let spam-checker modules inform users of the reason their event or operation is rejected.
_Changed in Synapse v1.61.0: `synapse.module_api.NOT_SPAM`and`synapse.module_api.errors.Codes` can be returned by this callback. Returning a boolean is now deprecated._
Called when a user is trying to join a room. The module must return a `bool` to indicate
46
-
whether the user can join the room. Return `False` to prevent the user from joining the
47
-
room; otherwise return`True` to permit the joining.
48
-
49
-
The user is represented by their Matrix user ID (e.g.
47
+
Called when a user is trying to join a room. The user is represented by their Matrix user ID (e.g.
50
48
`@alice:example.com`) and the room is represented by its Matrix ID (e.g.
51
49
`!room:example.com`). The module is also given a boolean to indicate whether the user
52
50
currently has a pending invite in the room.
53
51
54
52
This callback isn't called if the join is performed by a server administrator, or in the
55
53
context of a room creation.
56
54
55
+
The callback must return one of:
56
+
-`synapse.module_api.NOT_SPAM`, to allow the operation. Other callbacks may still
57
+
decide to reject it.
58
+
-`synapse.module_api.errors.Codes` to reject the operation with an error code. In case
59
+
of doubt, `synapse.module_api.errors.Codes.FORBIDDEN`is a good error code.
60
+
- (deprecated) `False`, which is the same as returning `synapse.module_api.NOT_SPAM`.
61
+
- (deprecated) `True`, which is the same as returning `synapse.module_api.errors.Codes.FORBIDDEN`.
62
+
57
63
If multiple modules implement this callback, they will be considered in order. If a
58
-
callback returns `True`, Synapse falls through to the next one. The value of the first
59
-
callback that does notreturn`True` will be used. If this happens, Synapse will not call
60
-
any of the subsequent implementations of this callback.
64
+
callback returns `synapse.module_api.NOT_SPAM`, Synapse falls through to the next one.
65
+
The value of the first callback that does notreturn`synapse.module_api.NOT_SPAM` will
66
+
be used. If this happens, Synapse will not call any of the subsequent implementations of
67
+
this callback.
61
68
62
69
### `user_may_invite`
63
70
64
71
_First introduced in Synapse v1.37.0_
65
72
73
+
_Changed in Synapse v1.61.0: `synapse.module_api.NOT_SPAM`and`synapse.module_api.errors.Codes` can be returned by this callback. Returning a boolean is now deprecated._
Called when processing an invitation. The module must return a `bool` indicating whether
71
-
the inviter can invite the invitee to the given room. Both inviter and invitee are
72
-
represented by their Matrix user ID (e.g. `@alice:example.com`). Return `False` to prevent
73
-
the invitation; otherwise return`True` to permit it.
79
+
Called when processing an invitation. Both inviter and invitee are
80
+
represented by their Matrix user ID (e.g. `@alice:example.com`).
81
+
82
+
83
+
The callback must return one of:
84
+
-`synapse.module_api.NOT_SPAM`, to allow the operation. Other callbacks may still
85
+
decide to reject it.
86
+
-`synapse.module_api.errors.Codes` to reject the operation with an error code. In case
87
+
of doubt, `synapse.module_api.errors.Codes.FORBIDDEN`is a good error code.
88
+
89
+
- (deprecated) `False`, which is the same as returning `synapse.module_api.NOT_SPAM`.
90
+
- (deprecated) `True`, which is the same as returning `synapse.module_api.errors.Codes.FORBIDDEN`.
74
91
75
92
If multiple modules implement this callback, they will be considered in order. If a
76
-
callback returns `True`, Synapse falls through to the next one. The value of the first
77
-
callback that does notreturn`True` will be used. If this happens, Synapse will not call
78
-
any of the subsequent implementations of this callback.
93
+
callback returns `synapse.module_api.NOT_SPAM`, Synapse falls through to the next one.
94
+
The value of the first callback that does notreturn`synapse.module_api.NOT_SPAM` will
95
+
be used. If this happens, Synapse will not call any of the subsequent implementations of
96
+
this callback.
97
+
79
98
80
99
### `user_may_send_3pid_invite`
81
100
82
101
_First introduced in Synapse v1.45.0_
83
102
103
+
_Changed in Synapse v1.61.0: `synapse.module_api.NOT_SPAM`and`synapse.module_api.errors.Codes` can be returned by this callback. Returning a boolean is now deprecated._
**Note**: If the third-party identifier is already associated with a matrix user ID,
116
135
[`user_may_invite`](#user_may_invite) will be used instead.
117
136
137
+
The callback must return one of:
138
+
-`synapse.module_api.NOT_SPAM`, to allow the operation. Other callbacks may still
139
+
decide to reject it.
140
+
-`synapse.module_api.errors.Codes` to reject the operation with an error code. In case
141
+
of doubt, `synapse.module_api.errors.Codes.FORBIDDEN`is a good error code.
142
+
143
+
- (deprecated) `False`, which is the same as returning `synapse.module_api.NOT_SPAM`.
144
+
- (deprecated) `True`, which is the same as returning `synapse.module_api.errors.Codes.FORBIDDEN`.
145
+
118
146
If multiple modules implement this callback, they will be considered in order. If a
119
-
callback returns `True`, Synapse falls through to the next one. The value of the first
120
-
callback that does notreturn`True` will be used. If this happens, Synapse will not call
121
-
any of the subsequent implementations of this callback.
147
+
callback returns `synapse.module_api.NOT_SPAM`, Synapse falls through to the next one.
148
+
The value of the first callback that does notreturn`synapse.module_api.NOT_SPAM` will
149
+
be used. If this happens, Synapse will not call any of the subsequent implementations of
150
+
this callback.
151
+
122
152
123
153
### `user_may_create_room`
124
154
125
155
_First introduced in Synapse v1.37.0_
126
156
157
+
_Changed in Synapse v1.61.0: `synapse.module_api.NOT_SPAM`and`synapse.module_api.errors.Codes` can be returned by this callback. Returning a boolean is now deprecated._
Called when processing a room creation request. The module must return a `bool` indicating
132
-
whether the given user (represented by their Matrix user ID) is allowed to create a room.
133
-
Return `False` to prevent room creation; otherwise return`True` to permit it.
163
+
Called when processing a room creation request.
164
+
165
+
The callback must return one of:
166
+
-`synapse.module_api.NOT_SPAM`, to allow the operation. Other callbacks may still
167
+
decide to reject it.
168
+
-`synapse.module_api.errors.Codes` to reject the operation with an error code. In case
169
+
of doubt, `synapse.module_api.errors.Codes.FORBIDDEN`is a good error code.
170
+
171
+
- (deprecated) `False`, which is the same as returning `synapse.module_api.NOT_SPAM`.
172
+
- (deprecated) `True`, which is the same as returning `synapse.module_api.errors.Codes.FORBIDDEN`.
134
173
135
174
If multiple modules implement this callback, they will be considered in order. If a
136
-
callback returns `True`, Synapse falls through to the next one. The value of the first
137
-
callback that does notreturn`True` will be used. If this happens, Synapse will not call
138
-
any of the subsequent implementations of this callback.
175
+
callback returns `synapse.module_api.NOT_SPAM`, Synapse falls through to the next one.
176
+
The value of the first callback that does notreturn`synapse.module_api.NOT_SPAM` will
177
+
be used. If this happens, Synapse will not call any of the subsequent implementations of
178
+
this callback.
179
+
180
+
139
181
140
182
### `user_may_create_room_alias`
141
183
142
184
_First introduced in Synapse v1.37.0_
143
185
186
+
_Changed in Synapse v1.61.0: `synapse.module_api.NOT_SPAM`and`synapse.module_api.errors.Codes` can be returned by this callback. Returning a boolean is now deprecated._
Called when trying to associate an alias with an existing room. The module must return a
149
-
`bool` indicating whether the given user (represented by their Matrix user ID) is allowed
150
-
to set the given alias. Return `False` to prevent the alias creation; otherwise return
151
-
`True` to permit it.
192
+
Called when trying to associate an alias with an existing room.
193
+
194
+
The callback must return one of:
195
+
-`synapse.module_api.NOT_SPAM`, to allow the operation. Other callbacks may still
196
+
decide to reject it.
197
+
-`synapse.module_api.errors.Codes` to reject the operation with an error code. In case
198
+
of doubt, `synapse.module_api.errors.Codes.FORBIDDEN`is a good error code.
199
+
200
+
- (deprecated) `False`, which is the same as returning `synapse.module_api.NOT_SPAM`.
201
+
- (deprecated) `True`, which is the same as returning `synapse.module_api.errors.Codes.FORBIDDEN`.
152
202
153
203
If multiple modules implement this callback, they will be considered in order. If a
154
-
callback returns `True`, Synapse falls through to the next one. The value of the first
155
-
callback that does notreturn`True` will be used. If this happens, Synapse will not call
156
-
any of the subsequent implementations of this callback.
204
+
callback returns `synapse.module_api.NOT_SPAM`, Synapse falls through to the next one.
205
+
The value of the first callback that does notreturn`synapse.module_api.NOT_SPAM` will
206
+
be used. If this happens, Synapse will not call any of the subsequent implementations of
207
+
this callback.
208
+
209
+
157
210
158
211
### `user_may_publish_room`
159
212
160
213
_First introduced in Synapse v1.37.0_
161
214
215
+
_Changed in Synapse v1.61.0: `synapse.module_api.NOT_SPAM`and`synapse.module_api.errors.Codes` can be returned by this callback. Returning a boolean is now deprecated._
Called when trying to publish a room to the homeserver's public rooms directory. The
167
-
module must return a `bool` indicating whether the given user (represented by their
168
-
Matrix user ID) is allowed to publish the given room. Return `False` to prevent the
169
-
room from being published; otherwise return`True` to permit its publication.
221
+
Called when trying to publish a room to the homeserver's public rooms directory.
222
+
223
+
The callback must return one of:
224
+
-`synapse.module_api.NOT_SPAM`, to allow the operation. Other callbacks may still
225
+
decide to reject it.
226
+
-`synapse.module_api.errors.Codes` to reject the operation with an error code. In case
227
+
of doubt, `synapse.module_api.errors.Codes.FORBIDDEN`is a good error code.
228
+
229
+
- (deprecated) `False`, which is the same as returning `synapse.module_api.NOT_SPAM`.
230
+
- (deprecated) `True`, which is the same as returning `synapse.module_api.errors.Codes.FORBIDDEN`.
170
231
171
232
If multiple modules implement this callback, they will be considered in order. If a
172
-
callback returns `True`, Synapse falls through to the next one. The value of the first
173
-
callback that does notreturn`True` will be used. If this happens, Synapse will not call
174
-
any of the subsequent implementations of this callback.
233
+
callback returns `synapse.module_api.NOT_SPAM`, Synapse falls through to the next one.
234
+
The value of the first callback that does notreturn`synapse.module_api.NOT_SPAM` will
235
+
be used. If this happens, Synapse will not call any of the subsequent implementations of
236
+
this callback.
237
+
238
+
175
239
176
240
### `check_username_for_spam`
177
241
@@ -239,21 +303,32 @@ this callback.
239
303
240
304
_First introduced in Synapse v1.37.0_
241
305
306
+
_Changed in Synapse v1.61.0: `synapse.module_api.NOT_SPAM`and`synapse.module_api.errors.Codes` can be returned by this callback. Returning a boolean is now deprecated._
0 commit comments