diff options
author | Mark Haines <mark.haines@matrix.org> | 2015-05-18 13:50:01 +0100 |
---|---|---|
committer | Mark Haines <mark.haines@matrix.org> | 2015-05-18 13:50:01 +0100 |
commit | 0b0033c40b29fd78384863bce932b31ebe281d95 (patch) | |
tree | 1e56a17d193b01f12c3bb5b897274f8753ed3531 /synapse/storage | |
parent | Make sure the notifier stream token goes forward when it is updated. Sort the... (diff) | |
parent | Merge pull request #153 from matrix-org/markjh/presence_docstring (diff) | |
download | synapse-0b0033c40b29fd78384863bce932b31ebe281d95.tar.xz |
Merge branch 'develop' into notifier_performance
Diffstat (limited to 'synapse/storage')
-rw-r--r-- | synapse/storage/_base.py | 1 | ||||
-rw-r--r-- | synapse/storage/push_rule.py | 14 |
2 files changed, 13 insertions, 2 deletions
diff --git a/synapse/storage/_base.py b/synapse/storage/_base.py index c9fe5a3555..81052409b7 100644 --- a/synapse/storage/_base.py +++ b/synapse/storage/_base.py @@ -309,6 +309,7 @@ class SQLBaseStore(object): self._access_tokens_id_gen = IdGenerator("access_tokens", "id", self) self._pushers_id_gen = IdGenerator("pushers", "id", self) self._push_rule_id_gen = IdGenerator("push_rules", "id", self) + self._push_rules_enable_id_gen = IdGenerator("push_rules_enable", "id", self) def start_profiling(self): self._previous_loop_ts = self._clock.time_msec() 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}, ) |