0
0
Fork 1
mirror of https://mau.dev/maunium/synapse.git synced 2024-12-19 23:23:57 +01:00

Merge pull request #2531 from matrix-org/dbkr/spamcheck_error_messages

Allow error strings from spam checker
This commit is contained in:
David Baker 2017-10-12 10:31:03 +01:00 committed by GitHub
commit b8d8ed1ba9

View file

@ -1,5 +1,6 @@
# -*- coding: utf-8 -*-
# Copyright 2014 - 2016 OpenMarket Ltd
# Copyright 2017 New Vector Ltd
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
@ -325,9 +326,12 @@ class MessageHandler(BaseHandler):
txn_id=txn_id
)
if self.spam_checker.check_event_for_spam(event):
spam_error = self.spam_checker.check_event_for_spam(event)
if spam_error:
if not isinstance(spam_error, basestring):
spam_error = "Spam is not permitted here"
raise SynapseError(
403, "Spam is not permitted here", Codes.FORBIDDEN
403, spam_error, Codes.FORBIDDEN
)
yield self.send_nonmember_event(