0
0
Fork 1
mirror of https://mau.dev/maunium/synapse.git synced 2024-12-21 16:03:52 +01:00

push_rules table expects an 'id' field

This commit is contained in:
Erik Johnston 2015-05-11 10:58:36 +01:00
parent 2640d6718d
commit cd525c0f5a
2 changed files with 13 additions and 13 deletions

View file

@ -308,6 +308,7 @@ class SQLBaseStore(object):
self._state_groups_id_gen = IdGenerator("state_groups", "id", self) self._state_groups_id_gen = IdGenerator("state_groups", "id", self)
self._access_tokens_id_gen = IdGenerator("access_tokens", "id", self) self._access_tokens_id_gen = IdGenerator("access_tokens", "id", self)
self._pushers_id_gen = IdGenerator("pushers", "id", self) self._pushers_id_gen = IdGenerator("pushers", "id", self)
self._push_rule_id_gen = IdGenerator("push_rules", "id", self)
def start_profiling(self): def start_profiling(self):
self._previous_loop_ts = self._clock.time_msec() self._previous_loop_ts = self._clock.time_msec()

View file

@ -120,6 +120,7 @@ class PushRuleStore(SQLBaseStore):
del new_rule['after'] del new_rule['after']
new_rule['priority_class'] = priority_class new_rule['priority_class'] = priority_class
new_rule['user_name'] = user_name new_rule['user_name'] = user_name
new_rule['id'] = self._push_rule_id_gen.get_next_txn(txn)
# check if the priority before/after is free # check if the priority before/after is free
new_rule_priority = base_rule_priority new_rule_priority = base_rule_priority
@ -153,12 +154,11 @@ class PushRuleStore(SQLBaseStore):
txn.execute(sql, (user_name, priority_class, new_rule_priority)) txn.execute(sql, (user_name, priority_class, new_rule_priority))
# now insert the new rule self._simple_insert_txn(
sql = "INSERT INTO "+PushRuleTable.table_name+" (" txn,
sql += ",".join(new_rule.keys())+") VALUES (" table=PushRuleTable.table_name,
sql += ", ".join(["?" for _ in new_rule.keys()])+")" values=new_rule,
)
txn.execute(sql, new_rule.values())
def _add_push_rule_highest_priority_txn(self, txn, user_name, def _add_push_rule_highest_priority_txn(self, txn, user_name,
priority_class, **kwargs): priority_class, **kwargs):
@ -177,17 +177,16 @@ class PushRuleStore(SQLBaseStore):
# and insert the new rule # and insert the new rule
new_rule = copy.copy(kwargs) new_rule = copy.copy(kwargs)
if 'id' in new_rule: new_rule['id'] = self._push_rule_id_gen.get_next_txn(txn)
del new_rule['id']
new_rule['user_name'] = user_name new_rule['user_name'] = user_name
new_rule['priority_class'] = priority_class new_rule['priority_class'] = priority_class
new_rule['priority'] = new_prio new_rule['priority'] = new_prio
sql = "INSERT INTO "+PushRuleTable.table_name+" (" self._simple_insert_txn(
sql += ",".join(new_rule.keys())+") VALUES (" txn,
sql += ", ".join(["?" for _ in new_rule.keys()])+")" table=PushRuleTable.table_name,
values=new_rule,
txn.execute(sql, new_rule.values()) )
@defer.inlineCallbacks @defer.inlineCallbacks
def delete_push_rule(self, user_name, rule_id): def delete_push_rule(self, user_name, rule_id):