mirror of
https://git.anonymousland.org/anonymousland/synapse-product.git
synced 2025-05-02 12:56:08 -04:00
Uniformize spam-checker API, part 3: Expand check_event_for_spam with the ability to return additional fields (#12846)
Signed-off-by: David Teller <davidt@element.io>
This commit is contained in:
parent
1fd1856afc
commit
af7db19e1e
5 changed files with 43 additions and 17 deletions
|
@ -895,6 +895,21 @@ class EventCreationHandler:
|
|||
|
||||
spam_check = await self.spam_checker.check_event_for_spam(event)
|
||||
if spam_check is not synapse.spam_checker_api.Allow.ALLOW:
|
||||
if isinstance(spam_check, tuple):
|
||||
try:
|
||||
[code, dict] = spam_check
|
||||
raise SynapseError(
|
||||
403,
|
||||
"This message had been rejected as probable spam",
|
||||
code,
|
||||
dict,
|
||||
)
|
||||
except ValueError:
|
||||
logger.error(
|
||||
"Spam-check module returned invalid error value. Expecting [code, dict], got %s",
|
||||
spam_check,
|
||||
)
|
||||
spam_check = Codes.FORBIDDEN
|
||||
raise SynapseError(
|
||||
403, "This message had been rejected as probable spam", spam_check
|
||||
)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue