summary refs log tree commit diff
path: root/synapse/storage/push_rule.py
diff options
context:
space:
mode:
authorDavid Baker <dave@matrix.org>2015-05-14 11:44:03 +0100
committerDavid Baker <dave@matrix.org>2015-05-14 11:44:03 +0100
commit7c549dd5572b2881ee61cb11c572a82662414cdb (patch)
tree1495d5f56a9064becb498bba15ac07580bf52923 /synapse/storage/push_rule.py
parentSpecify python 2.7 in the virtualenv setup (SYN-319) #resolved (diff)
downloadsynapse-7c549dd5572b2881ee61cb11c572a82662414cdb.tar.xz
Add ID generator for push_rules_enable to #resolve SYN-378
Diffstat (limited to 'synapse/storage/push_rule.py')
-rw-r--r--synapse/storage/push_rule.py14
1 files changed, 12 insertions, 2 deletions
diff --git a/synapse/storage/push_rule.py b/synapse/storage/push_rule.py
index 34805e276e..e7988676ce 100644
--- a/synapse/storage/push_rule.py
+++ b/synapse/storage/push_rule.py
@@ -204,11 +204,21 @@ class PushRuleStore(SQLBaseStore):
 
     @defer.inlineCallbacks
     def set_push_rule_enabled(self, user_name, rule_id, enabled):
-        yield self._simple_upsert(
+        ret = yield self.runInteraction(
+            "_set_push_rule_enabled_txn",
+            self._set_push_rule_enabled_txn,
+            user_name, rule_id, enabled
+        )
+        defer.returnValue(ret)
+
+    def _set_push_rule_enabled_txn(self, txn, user_name, rule_id, enabled):
+        new_id = self._push_rules_enable_id_gen.get_next_txn(txn)
+        self._simple_upsert_txn(
+            txn,
             PushRuleEnableTable.table_name,
             {'user_name': user_name, 'rule_id': rule_id},
             {'enabled': 1 if enabled else 0},
-            desc="set_push_rule_enabled",
+            {'id': new_id},
         )