summary refs log tree commit diff
path: root/docs/upgrade.md
diff options
context:
space:
mode:
authorDavid Teller <D.O.Teller@gmail.com>2022-05-23 19:27:39 +0200
committerGitHub <noreply@github.com>2022-05-23 17:27:39 +0000
commit28199e93579b5a73841a95ed4d355322227432b5 (patch)
treec720d7ca13a54d6d7fd0405dd8bbad7921cd856d /docs/upgrade.md
parentPrevent expired events from being filtered out when retention is disabled (#1... (diff)
downloadsynapse-28199e93579b5a73841a95ed4d355322227432b5.tar.xz
Uniformize spam-checker API, part 2: check_event_for_spam (#12808)
Signed-off-by: David Teller <davidt@element.io>
Diffstat (limited to 'docs/upgrade.md')
-rw-r--r--docs/upgrade.md29
1 files changed, 29 insertions, 0 deletions
diff --git a/docs/upgrade.md b/docs/upgrade.md
index 92ca31b2f8..e7eadadb64 100644
--- a/docs/upgrade.md
+++ b/docs/upgrade.md
@@ -177,7 +177,36 @@ has queries that can be used to check a database for this problem in advance.
 
 </details>
 
+## SpamChecker API's `check_event_for_spam` has a new signature.
 
+The previous signature has been deprecated.
+
+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"]`.
+
+This is part of an ongoing refactoring of the SpamChecker API to make it less ambiguous and more powerful.
+
+If your module implements `check_event_for_spam` as follows:
+
+```python
+async def check_event_for_spam(event):
+    if ...:
+        # Event is spam
+        return True
+    # Event is not spam
+    return False
+```
+
+you should rewrite it as follows:
+
+```python
+async def check_event_for_spam(event):
+    if ...:
+        # Event is spam, mark it as forbidden (you may use some more precise error
+        # code if it is useful).
+        return synapse.module_api.errors.Codes.FORBIDDEN
+    # Event is not spam, mark it as `ALLOW`.
+    return synapse.module_api.ALLOW
+```
 
 # Upgrading to v1.59.0