summary refs log tree commit diff
path: root/synapse/handlers/message.py
diff options
context:
space:
mode:
authorDavid Baker <dbkr@users.noreply.github.com>2017-10-12 10:31:03 +0100
committerGitHub <noreply@github.com>2017-10-12 10:31:03 +0100
commitb8d8ed1ba9dc055a5e10d5bbb81b8b2ba3c68b8c (patch)
treecc7108a0d4d08507dc706ea1e9f8f6590dfccae1 /synapse/handlers/message.py
parentMerge pull request #2532 from matrix-org/rav/fix_linearizer (diff)
parentfix isinstance (diff)
downloadsynapse-b8d8ed1ba9dc055a5e10d5bbb81b8b2ba3c68b8c.tar.xz
Merge pull request #2531 from matrix-org/dbkr/spamcheck_error_messages
Allow error strings from spam checker
Diffstat (limited to 'synapse/handlers/message.py')
-rw-r--r--synapse/handlers/message.py8
1 files changed, 6 insertions, 2 deletions
diff --git a/synapse/handlers/message.py b/synapse/handlers/message.py
index fbf88b46ef..28792788d9 100644
--- a/synapse/handlers/message.py
+++ b/synapse/handlers/message.py
@@ -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(