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

Commit 4079736

Browse files
committed
WIP: Applied feedback
See also: - Part 1: #12703 - Part 2: #12808 - Adding an error code for suspended accounts #12845
1 parent 4abb05b commit 4079736

File tree

3 files changed

+15
-8
lines changed

3 files changed

+15
-8
lines changed

changelog.d/12846.feature

Lines changed: 0 additions & 1 deletion
This file was deleted.

changelog.d/12846.misc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Experimental: expand `check_event_for_spam` with ability to return additional fields. This enables spam-checker implementations to experiment with mechanisms to give users more information about why they are blocked and whether any action is needed from them to be unblocked.

synapse/handlers/message.py

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -888,14 +888,21 @@ async def create_and_send_nonmember_event(
888888

889889
spam_check = await self.spam_checker.check_event_for_spam(event)
890890
if spam_check is not synapse.spam_checker_api.Allow.ALLOW:
891-
if isinstance(spam_check, tuple):
892-
[code, dict] = spam_check
893-
raise SynapseError(
894-
403,
895-
"This message had been rejected as probable spam",
896-
code,
897-
dict,
891+
try:
892+
if isinstance(spam_check, tuple):
893+
[code, dict] = spam_check
894+
raise SynapseError(
895+
403,
896+
"This message had been rejected as probable spam",
897+
code,
898+
dict,
899+
)
900+
except ValueError:
901+
logger.warning(
902+
"Spam-check module returned invalid error value. Expecting [code, dict], got %s",
903+
spam_check,
898904
)
905+
spam_check = Codes.FORBIDDEN
899906
raise SynapseError(
900907
403, "This message had been rejected as probable spam", spam_check
901908
)

0 commit comments

Comments
 (0)