summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--synapse/rest/client/v1/push_rule.py4
-rw-r--r--synapse/storage/push_rule.py8
2 files changed, 7 insertions, 5 deletions
diff --git a/synapse/rest/client/v1/push_rule.py b/synapse/rest/client/v1/push_rule.py
index 7df3fc7f09..77a0772479 100644
--- a/synapse/rest/client/v1/push_rule.py
+++ b/synapse/rest/client/v1/push_rule.py
@@ -166,8 +166,8 @@ class PushRuleRestServlet(RestServlet):
             )
         except InconsistentRuleException as e:
             raise SynapseError(400, e.message)
-        except RuleNotFoundException:
-            raise SynapseError(400, "before/after rule not found")
+        except RuleNotFoundException as e:
+            raise SynapseError(400, e.message)
 
         defer.returnValue((200, {}))
 
diff --git a/synapse/storage/push_rule.py b/synapse/storage/push_rule.py
index d087257ffc..2366090e09 100644
--- a/synapse/storage/push_rule.py
+++ b/synapse/storage/push_rule.py
@@ -46,7 +46,7 @@ class PushRuleStore(SQLBaseStore):
         defer.returnValue(dicts)
 
     @defer.inlineCallbacks
-    def add_push_rule(self, **kwargs):
+    def add_push_rule(self, before, after, **kwargs):
         vals = copy.copy(kwargs)
         if 'conditions' in vals:
             vals['conditions'] = json.dumps(vals['conditions'])
@@ -57,10 +57,12 @@ class PushRuleStore(SQLBaseStore):
         if 'id' in vals:
             del vals['id']
 
-        if 'after' in kwargs or 'before' in kwargs:
+        if before or after:
             ret = yield self.runInteraction(
                 "_add_push_rule_relative_txn",
                 self._add_push_rule_relative_txn,
+                before=before,
+                after=after,
                 **vals
             )
             defer.returnValue(ret)
@@ -89,7 +91,7 @@ class PushRuleStore(SQLBaseStore):
         txn.execute(sql, (user_name, relative_to_rule))
         res = txn.fetchall()
         if not res:
-            raise RuleNotFoundException()
+            raise RuleNotFoundException("before/after rule not found: %s" % (relative_to_rule))
         (priority_class, base_rule_priority) = res[0]
 
         if 'priority_class' in kwargs and kwargs['priority_class'] != priority_class: