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

Commit

Permalink
WIP: Applied feedback
Browse files Browse the repository at this point in the history
See also:
- Part 1: #12703
- Part 2: #12808
- Adding an error code for suspended accounts #12845
  • Loading branch information
Yoric committed May 30, 2022
1 parent 83b4130 commit c5e36ca
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 8 deletions.
1 change: 0 additions & 1 deletion changelog.d/12846.feature

This file was deleted.

1 change: 1 addition & 0 deletions changelog.d/12846.misc
Original file line number Diff line number Diff line change
@@ -0,0 +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.
21 changes: 14 additions & 7 deletions synapse/handlers/message.py
Original file line number Diff line number Diff line change
Expand Up @@ -895,14 +895,21 @@ async def create_and_send_nonmember_event(

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):
[code, dict] = spam_check
raise SynapseError(
403,
"This message had been rejected as probable spam",
code,
dict,
try:
if isinstance(spam_check, tuple):
[code, dict] = spam_check
raise SynapseError(
403,
"This message had been rejected as probable spam",
code,
dict,
)
except ValueError:
logger.warning(
"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
)
Expand Down

0 comments on commit c5e36ca

Please sign in to comment.