diff options
author | David Teller <D.O.Teller@gmail.com> | 2020-12-11 20:05:15 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-12-11 14:05:15 -0500 |
commit | f14428b25c37e44675edac4a80d7bd1e47112586 (patch) | |
tree | 7565992e70db2c48c7008b2e3fdfe122d315308e /synapse/federation/federation_base.py | |
parent | Add type hints to the push module. (#8901) (diff) | |
download | synapse-f14428b25c37e44675edac4a80d7bd1e47112586.tar.xz |
Allow spam-checker modules to be provide async methods. (#8890)
Spam checker modules can now provide async methods. This is implemented in a backwards-compatible manner.
Diffstat (limited to 'synapse/federation/federation_base.py')
-rw-r--r-- | synapse/federation/federation_base.py | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/synapse/federation/federation_base.py b/synapse/federation/federation_base.py index 38aa47963f..383737520a 100644 --- a/synapse/federation/federation_base.py +++ b/synapse/federation/federation_base.py @@ -78,6 +78,7 @@ class FederationBase: ctx = current_context() + @defer.inlineCallbacks def callback(_, pdu: EventBase): with PreserveLoggingContext(ctx): if not check_event_content_hash(pdu): @@ -105,7 +106,11 @@ class FederationBase: ) return redacted_event - if self.spam_checker.check_event_for_spam(pdu): + result = yield defer.ensureDeferred( + self.spam_checker.check_event_for_spam(pdu) + ) + + if result: logger.warning( "Event contains spam, redacting %s: %s", pdu.event_id, |