diff options
author | David Teller <D.O.Teller@gmail.com> | 2022-05-23 19:27:39 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-05-23 17:27:39 +0000 |
commit | 28199e93579b5a73841a95ed4d355322227432b5 (patch) | |
tree | c720d7ca13a54d6d7fd0405dd8bbad7921cd856d /synapse/handlers | |
parent | Prevent expired events from being filtered out when retention is disabled (#1... (diff) | |
download | synapse-28199e93579b5a73841a95ed4d355322227432b5.tar.xz |
Uniformize spam-checker API, part 2: check_event_for_spam (#12808)
Signed-off-by: David Teller <davidt@element.io>
Diffstat (limited to 'synapse/handlers')
-rw-r--r-- | synapse/handlers/message.py | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/synapse/handlers/message.py b/synapse/handlers/message.py index e566ff1f8e..cb1bc4c06f 100644 --- a/synapse/handlers/message.py +++ b/synapse/handlers/message.py @@ -23,6 +23,7 @@ from canonicaljson import encode_canonical_json from twisted.internet.interfaces import IDelayedCall +import synapse from synapse import event_auth from synapse.api.constants import ( EventContentFields, @@ -885,11 +886,11 @@ class EventCreationHandler: event.sender, ) - spam_error = await self.spam_checker.check_event_for_spam(event) - if spam_error: - if not isinstance(spam_error, str): - spam_error = "Spam is not permitted here" - raise SynapseError(403, spam_error, Codes.FORBIDDEN) + spam_check = await self.spam_checker.check_event_for_spam(event) + if spam_check is not synapse.spam_checker_api.Allow.ALLOW: + raise SynapseError( + 403, "This message had been rejected as probable spam", spam_check + ) ev = await self.handle_new_client_event( requester=requester, |