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

Commit

Permalink
Fix spam checker modules documentation example (#9580)
Browse files Browse the repository at this point in the history
Mention that parse_config must exist and note the
check_media_file_for_spam method.
  • Loading branch information
jaywink authored Mar 10, 2021
1 parent 2a99cc6 commit 17cd48f
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
1 change: 1 addition & 0 deletions changelog.d/9580.doc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Clarify the spam checker modules documentation example to mention that `parse_config` is a required method.
10 changes: 10 additions & 0 deletions docs/spam_checker.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -24,13 +25,18 @@ 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.

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
Expand All @@ -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

Expand Down

0 comments on commit 17cd48f

Please sign in to comment.