summary refs log tree commit diff
path: root/docs/spam_checker.md
diff options
context:
space:
mode:
authorRichard van der Hoff <richard@matrix.org>2021-03-16 12:42:54 +0000
committerRichard van der Hoff <richard@matrix.org>2021-03-16 12:42:54 +0000
commitd8953b34f2b593043b518304fa70099432955f81 (patch)
treefdc122f5c1e368ea4716c6c9fe66b3d76c55c2cd /docs/spam_checker.md
parentMerge remote-tracking branch 'origin/develop' into matrix-org-hotfixes (diff)
parentPass SSO IdP information to spam checker's registration function (#9626) (diff)
downloadsynapse-d8953b34f2b593043b518304fa70099432955f81.tar.xz
Merge branch 'develop' into matrix-org-hotfixes
Diffstat (limited to 'docs/spam_checker.md')
-rw-r--r--docs/spam_checker.md18
1 files changed, 17 insertions, 1 deletions
diff --git a/docs/spam_checker.md b/docs/spam_checker.md

index e615ac9910..52947f605e 100644 --- a/docs/spam_checker.md +++ b/docs/spam_checker.md
@@ -14,6 +14,7 @@ The Python class is instantiated with two objects: * An instance of `synapse.module_api.ModuleApi`. It then implements methods which return a boolean to alter behavior in Synapse. +All the methods must be defined. There's a generic method for checking every event (`check_event_for_spam`), as well as some specific methods: @@ -24,6 +25,7 @@ well as some specific methods: * `user_may_publish_room` * `check_username_for_spam` * `check_registration_for_spam` +* `check_media_file_for_spam` The details of each of these methods (as well as their inputs and outputs) are documented in the `synapse.events.spamcheck.SpamChecker` class. @@ -31,6 +33,10 @@ are documented in the `synapse.events.spamcheck.SpamChecker` class. The `ModuleApi` class provides a way for the custom spam checker class to call back into the homeserver internals. +Additionally, a `parse_config` method is mandatory and receives the plugin config +dictionary. After parsing, It must return an object which will be +passed to `__init__` later. + ### Example ```python @@ -41,6 +47,10 @@ class ExampleSpamChecker: self.config = config self.api = api + @staticmethod + def parse_config(config): + return config + async def check_event_for_spam(self, foo): return False # allow all events @@ -59,7 +69,13 @@ class ExampleSpamChecker: async def check_username_for_spam(self, user_profile): return False # allow all usernames - async def check_registration_for_spam(self, email_threepid, username, request_info): + async def check_registration_for_spam( + self, + email_threepid, + username, + request_info, + auth_provider_id, + ): return RegistrationBehaviour.ALLOW # allow all registrations async def check_media_file_for_spam(self, file_wrapper, file_info):