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

Fix spam checker modules documentation example #9580

Merged
merged 4 commits into from
Mar 10, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions changelog.d/9580.doc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fix spam checker modules documentation example to clarify parse_config is a required method.
jaywink marked this conversation as resolved.
Show resolved Hide resolved
9 changes: 9 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 are mandatory to be defined.
jaywink marked this conversation as resolved.
Show resolved Hide resolved

There's a generic method for checking every event (`check_event_for_spam`), as
well as some specific methods:
Expand All @@ -31,6 +32,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 possible sanitizing, It must return a dictionary which
will be passed to `__init__` later.
jaywink marked this conversation as resolved.
Show resolved Hide resolved

### Example

```python
Expand All @@ -41,6 +46,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