summary refs log tree commit diff
path: root/synapse
diff options
context:
space:
mode:
authorDavid Baker <dave@matrix.org>2017-10-11 14:39:22 +0100
committerDavid Baker <dave@matrix.org>2017-10-11 14:39:22 +0100
commitc3b7a45e84f0aaf45e671eef295993e3d09d6908 (patch)
tree2285738ae5deacb9c7086d072a670b8801cf4b0d /synapse
parentFix schema delta versions (diff)
downloadsynapse-c3b7a45e84f0aaf45e671eef295993e3d09d6908.tar.xz
Allow error strings from spam checker
Diffstat (limited to 'synapse')
-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..06672df3bc 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, (str, 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(