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.
Update to `check_event_for_spam`. Deprecate the current callback signature, replace it with a new signature that is both less ambiguous (replacing booleans with explicit allow/block) and more powerful (ability to return explicit error codes).
Copy file name to clipboardExpand all lines: docs/upgrade.md
+29Lines changed: 29 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -177,7 +177,36 @@ has queries that can be used to check a database for this problem in advance.
177
177
178
178
</details>
179
179
180
+
## SpamChecker API's `check_event_for_spam` has a new signature.
180
181
182
+
The previous signature has been deprecated.
183
+
184
+
Whereas `check_event_for_spam` callbacks used to return`Union[str, bool]`, they should now return`Union["synapse.module_api.Allow", "synapse.module_api.errors.Codes"]`.
185
+
186
+
This is part of an ongoing refactoring of the SpamChecker API to make it less ambiguous and more powerful.
187
+
188
+
If your module implements `check_event_for_spam` as follows:
189
+
190
+
```python
191
+
async def check_event_for_spam(event):
192
+
if ...:
193
+
# Event is spam
194
+
return True
195
+
# Event is not spam
196
+
return False
197
+
```
198
+
199
+
you should rewrite it as follows:
200
+
201
+
```python
202
+
async def check_event_for_spam(event):
203
+
if ...:
204
+
# Event is spam, mark it as forbidden (you may use some more precise error
0 commit comments