0
0
Fork 1
mirror of https://mau.dev/maunium/synapse.git synced 2024-12-30 10:04:05 +01:00

Add ID generator for push_rules_enable to #resolve SYN-378

This commit is contained in:
David Baker 2015-05-14 11:44:03 +01:00
parent 47fb089eb5
commit 7c549dd557
2 changed files with 13 additions and 2 deletions

View file

@ -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()

View file

@ -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},
)