-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Prevent duplicate push notifications for room reads #11835
Changes from 3 commits
10acfc7
e417f14
e5bfb55
f41ec2d
6297735
f2767e9
c6eae47
88a163d
2203143
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| Make a `POST` to `/rooms/<room_id>/receipt/m.read/<event_id>` only trigger a push notification if the count of unread messages is different to the one in the last successfully sent push. |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -572,7 +572,7 @@ def test_push_unread_count_group_by_room(self): | |
| # | ||
| # This push should still only contain an unread count of 1 (for 1 unread room) | ||
| self.assertEqual( | ||
| self.push_attempts[5][2]["notification"]["counts"]["unread"], 1 | ||
| self.push_attempts[4][2]["notification"]["counts"]["unread"], 1 | ||
| ) | ||
|
|
||
| @override_config({"push": {"group_unread_count_by_room": False}}) | ||
|
|
@@ -588,7 +588,7 @@ def test_push_unread_count_message_count(self): | |
| # We're counting every unread message, so there should now be 4 since the | ||
| # last read receipt | ||
| self.assertEqual( | ||
| self.push_attempts[5][2]["notification"]["counts"]["unread"], 4 | ||
| self.push_attempts[4][2]["notification"]["counts"]["unread"], 4 | ||
| ) | ||
|
|
||
| def _test_push_unread_count(self): | ||
|
|
@@ -673,30 +673,20 @@ def _test_push_unread_count(self): | |
| ) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. there's a comment just above 'This will actually trigger a new notification to be sent out so that even if the user does not receive another message, their unread count goes down'... It doesn't make much sense to me though because it was already at zero right before. I would say 'I think it may be worth removing the comment', but this test is trying to test that pushes go out when you read something. As it stands, we're not testing that anymore. The test currently looks like:
I wonder if it should look like this:
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ok, I think I will start working on that issue by the beginning of next week.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @reivilibre: I still refactored the test a bit. If you do not like it, the commit before preserves |
||
| self.assertEqual(channel.code, 200, channel.json_body) | ||
|
|
||
| # Advance time and make the push succeed | ||
| self.push_attempts[1][0].callback({}) | ||
| self.pump() | ||
|
|
||
| # Unread count is still zero as we've read the only message in the room | ||
| self.assertEqual(len(self.push_attempts), 2) | ||
| self.assertEqual( | ||
| self.push_attempts[1][2]["notification"]["counts"]["unread"], 0 | ||
| ) | ||
|
|
||
| # Send another message | ||
| self.helper.send( | ||
| room_id, body="How's the weather today?", tok=other_access_token | ||
| ) | ||
|
|
||
| # Advance time and make the push succeed | ||
| self.push_attempts[2][0].callback({}) | ||
| self.push_attempts[1][0].callback({}) | ||
| self.pump() | ||
|
|
||
| # This push should contain an unread count of 1 as there's now been one | ||
| # message since our last read receipt | ||
| self.assertEqual(len(self.push_attempts), 3) | ||
| self.assertEqual(len(self.push_attempts), 2) | ||
| self.assertEqual( | ||
| self.push_attempts[2][2]["notification"]["counts"]["unread"], 1 | ||
| self.push_attempts[1][2]["notification"]["counts"]["unread"], 1 | ||
| ) | ||
|
|
||
| # Since we're grouping by room, sending more messages shouldn't increase the | ||
|
|
@@ -705,18 +695,18 @@ def _test_push_unread_count(self): | |
|
|
||
| # Advance time and make the push succeed | ||
| self.pump() | ||
| self.push_attempts[3][0].callback({}) | ||
| self.push_attempts[2][0].callback({}) | ||
|
|
||
| self.helper.send(room_id, body="Hello??", tok=other_access_token) | ||
|
|
||
| # Advance time and make the push succeed | ||
| self.pump() | ||
| self.push_attempts[4][0].callback({}) | ||
| self.push_attempts[3][0].callback({}) | ||
|
|
||
| self.helper.send(room_id, body="HELLO???", tok=other_access_token) | ||
|
|
||
| # Advance time and make the push succeed | ||
| self.pump() | ||
| self.push_attempts[5][0].callback({}) | ||
| self.push_attempts[4][0].callback({}) | ||
|
|
||
| self.assertEqual(len(self.push_attempts), 6) | ||
| self.assertEqual(len(self.push_attempts), 5) | ||
Uh oh!
There was an error while loading. Please reload this page.