mirror of
https://github.com/element-hq/synapse
synced 2024-09-03 19:00:06 +00:00
Don't mutate cached values
This commit is contained in:
parent
74f49f99f9
commit
db6e26bb8c
1 changed files with 6 additions and 2 deletions
|
@ -55,11 +55,15 @@ def _get_rules(room_id, user_ids, store):
|
||||||
|
|
||||||
user_enabled_map = rules_enabled_by_user[uid]
|
user_enabled_map = rules_enabled_by_user[uid]
|
||||||
|
|
||||||
for rule in rules_by_user[uid]:
|
for i, rule in enumerate(rules_by_user[uid]):
|
||||||
rule_id = rule['rule_id']
|
rule_id = rule['rule_id']
|
||||||
|
|
||||||
if rule_id in user_enabled_map:
|
if rule_id in user_enabled_map:
|
||||||
rule['enabled'] = user_enabled_map[rule_id]
|
if rule.get('enabled', True) != bool(user_enabled_map[rule_id]):
|
||||||
|
# Rules are cached across users.
|
||||||
|
rule = dict(rule)
|
||||||
|
rule['enabled'] = bool(user_enabled_map[rule_id])
|
||||||
|
rules_by_user[uid][i] = rule
|
||||||
|
|
||||||
defer.returnValue(rules_by_user)
|
defer.returnValue(rules_by_user)
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue