-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Transfer user's push rules on room upgrade #4838
Transfer user's push rules on room upgrade #4838
Conversation
Codecov Report
@@ Coverage Diff @@
## develop #4838 +/- ##
===========================================
- Coverage 75.34% 67.72% -7.63%
===========================================
Files 340 340
Lines 34920 34940 +20
Branches 5717 5725 +8
===========================================
- Hits 26312 23664 -2648
- Misses 6999 9619 +2620
- Partials 1609 1657 +48 |
Codecov Report
@@ Coverage Diff @@
## develop #4838 +/- ##
===========================================
+ Coverage 75.31% 75.35% +0.04%
===========================================
Files 340 340
Lines 34924 34940 +16
Branches 5718 5724 +6
===========================================
+ Hits 26302 26329 +27
+ Misses 7009 6997 -12
- Partials 1613 1614 +1 |
Cleaned up and stopped using push_rule ID
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
getting there :)
synapse/storage/push_rule.py
Outdated
@@ -185,6 +185,63 @@ def bulk_get_push_rules(self, user_ids): | |||
|
|||
defer.returnValue(results) | |||
|
|||
@defer.inlineCallbacks | |||
def copy_push_rule_from_room_to_room( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
s/copy/move/. Likewise in the docstring
synapse/storage/push_rule.py
Outdated
# delete them from the old room | ||
for rule in user_push_rules: | ||
for condition in rule["conditions"]: | ||
if "key" in condition and condition["key"] == "room_id": |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about simply:
if "key" in condition and condition["key"] == "room_id": | |
if condition.get("key") == "room_id": |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm otherwise
synapse/storage/push_rule.py
Outdated
# Get rules relating to the old room, move them to the new room, then | ||
# delete them from the old room | ||
for rule in user_push_rules: | ||
for condition in rule["conditions"]: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
conditions is apparently optional:
for condition in rule["conditions"]: | |
for condition in rule.get("conditions", []): |
synapse/storage/push_rule.py
Outdated
# delete them from the old room | ||
for rule in user_push_rules: | ||
for condition in rule["conditions"]: | ||
if condition.get("key") == "room_id": |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we probably need to worry about what happens if somebody makes a rule that has two conditions that match: I suspect your code will blow up.
an easy fix might be:
conditions = rule.get("conditions", [])
if any((c.get("key") == "room_id" and c.get("pattern") == old_room_id) for c in conditions):
# ... move
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This works and is very pythonic, thanks.
Codecov Report
@@ Coverage Diff @@
## develop #4838 +/- ##
===========================================
+ Coverage 75.31% 75.35% +0.04%
===========================================
Files 340 340
Lines 34924 34940 +16
Branches 5718 5724 +6
===========================================
+ Hits 26302 26329 +27
+ Misses 7009 6997 -12
- Partials 1613 1614 +1 |
1 similar comment
Codecov Report
@@ Coverage Diff @@
## develop #4838 +/- ##
===========================================
+ Coverage 75.31% 75.35% +0.04%
===========================================
Files 340 340
Lines 34924 34940 +16
Branches 5718 5724 +6
===========================================
+ Hits 26302 26329 +27
+ Misses 7009 6997 -12
- Partials 1613 1614 +1 |
Codecov Report
@@ Coverage Diff @@
## develop #4838 +/- ##
===========================================
+ Coverage 75.31% 75.35% +0.04%
===========================================
Files 340 340
Lines 34924 34940 +16
Branches 5718 5724 +6
===========================================
+ Hits 26302 26329 +27
+ Misses 7009 6997 -12
- Partials 1613 1614 +1 |
Codecov Report
@@ Coverage Diff @@
## develop #4838 +/- ##
===========================================
+ Coverage 75.31% 75.35% +0.03%
===========================================
Files 340 340
Lines 34924 34939 +15
Branches 5718 5722 +4
===========================================
+ Hits 26302 26327 +25
+ Misses 7009 7000 -9
+ Partials 1613 1612 -1 |
1 similar comment
Codecov Report
@@ Coverage Diff @@
## develop #4838 +/- ##
===========================================
+ Coverage 75.31% 75.35% +0.03%
===========================================
Files 340 340
Lines 34924 34939 +15
Branches 5718 5722 +4
===========================================
+ Hits 26302 26327 +25
+ Misses 7009 7000 -9
+ Partials 1613 1612 -1 |
Codecov Report
@@ Coverage Diff @@
## develop #4838 +/- ##
===========================================
+ Coverage 75.31% 75.35% +0.03%
===========================================
Files 340 340
Lines 34924 34939 +15
Branches 5718 5722 +4
===========================================
+ Hits 26302 26327 +25
+ Misses 7009 7000 -9
+ Partials 1613 1612 -1 |
2 similar comments
Codecov Report
@@ Coverage Diff @@
## develop #4838 +/- ##
===========================================
+ Coverage 75.31% 75.35% +0.03%
===========================================
Files 340 340
Lines 34924 34939 +15
Branches 5718 5722 +4
===========================================
+ Hits 26302 26327 +25
+ Misses 7009 7000 -9
+ Partials 1613 1612 -1 |
Codecov Report
@@ Coverage Diff @@
## develop #4838 +/- ##
===========================================
+ Coverage 75.31% 75.35% +0.03%
===========================================
Files 340 340
Lines 34924 34939 +15
Branches 5718 5722 +4
===========================================
+ Hits 26302 26327 +25
+ Misses 7009 7000 -9
+ Partials 1613 1612 -1 |
Transfer's push rules (notification settings) on room upgrade.
Closes #4597.
TODO: