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

Commit f2183dd

Browse files
committed
update documentation for reject_federated_spam_event
Signed-off-by: jesopo <github@lolnerd.net>
1 parent e7c841c commit f2183dd

2 files changed

Lines changed: 23 additions & 0 deletions

File tree

docs/modules/spam_checker_callbacks.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -249,6 +249,24 @@ callback returns `False`, Synapse falls through to the next one. The value of th
249249
callback that does not return `False` will be used. If this happens, Synapse will not call
250250
any of the subsequent implementations of this callback.
251251

252+
### `drop_federated_event`
253+
254+
_First introduced in Synapse v1.?.?_
255+
256+
```python
257+
async def drop_federated_event(event: "synapse.events.EventBase") -> bool
258+
```
259+
260+
Called when checking whether a remote server can federate an event with us. **Returning
261+
`True` from this function will silently drop a federated event and split-brain our view
262+
of a room's DAG, and thus you shouldn't use this callback unless you know what you are
263+
doing.**
264+
265+
If multiple modules implement this callback, they will be considered in order. If a
266+
callback returns `False`, Synapse falls through to the next one. The value of the first
267+
callback that does not return `False` will be used. If this happens, Synapse will not call
268+
any of the subsequent implementations of this callback.
269+
252270
## Example
253271

254272
The example below is a module that implements the spam checker callback

docs/spam_checker.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ well as some specific methods:
3232
* `check_username_for_spam`
3333
* `check_registration_for_spam`
3434
* `check_media_file_for_spam`
35+
* `drop_federated_event`
3536

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

8788
async def check_media_file_for_spam(self, file_wrapper, file_info):
8889
return False # allow all media
90+
91+
92+
async def drop_federated_event(self, foo):
93+
return False # don't silently drop any inbound federated events
8994
```
9095

9196
## Configuration

0 commit comments

Comments
 (0)