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

Commit

Permalink
update documentation for reject_federated_spam_event
Browse files Browse the repository at this point in the history
Signed-off-by: jesopo <github@lolnerd.net>
  • Loading branch information
jesopo committed May 16, 2022
1 parent fc09de4 commit 0f7d78d
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
17 changes: 17 additions & 0 deletions docs/modules/spam_checker_callbacks.md
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,23 @@ callback returns `False`, Synapse falls through to the next one. The value of th
callback that does not return `False` will be used. If this happens, Synapse will not call
any of the subsequent implementations of this callback.

### `reject_federated_spam_event`

_First introduced in Synapse v1.?.?_

```python
async def reject_federated_spam_event(event: "synapse.events.EventBase") -> bool
```

Called when checking whether a remote server can federate an event with us. **Returning
`True` from this function will split-brain our view of a room's DAG, and thus you
shouldn't use this callback unless you know what you are doing.**

If multiple modules implement this callback, they will be considered in order. If a
callback returns `False`, Synapse falls through to the next one. The value of the first
callback that does not return `False` will be used. If this happens, Synapse will not call
any of the subsequent implementations of this callback.

## Example

The example below is a module that implements the spam checker callback
Expand Down
5 changes: 5 additions & 0 deletions docs/spam_checker.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ well as some specific methods:
* `check_username_for_spam`
* `check_registration_for_spam`
* `check_media_file_for_spam`
* `reject_federated_spam_event`

The details of each of these methods (as well as their inputs and outputs)
are documented in the `synapse.events.spamcheck.SpamChecker` class.
Expand Down Expand Up @@ -86,6 +87,10 @@ class ExampleSpamChecker:

async def check_media_file_for_spam(self, file_wrapper, file_info):
return False # allow all media


async def reject_federated_spam_event(self, foo):
return False # don't hard-reject any federated events
```

## Configuration
Expand Down

0 comments on commit 0f7d78d

Please sign in to comment.