This repository has been archived by the owner on Apr 26, 2024. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Delete push actions on receipt #13834
Closed
Fizzadar
wants to merge
10
commits into
matrix-org:develop
from
beeper:delete-push-actions-on-receipt
Closed
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
51eb263
Delete event push actions when inserting receipts
Fizzadar a392a8a
Remove comparison against receipt positions when processing push actions
Fizzadar c25e4b2
Add changelog file
Fizzadar 4b85442
Add `content` kwarg to `HomserverTestCase.create_and_send_event` method
Fizzadar ef04bc8
Add test for deleting push actions on receipt
Fizzadar 65b5bca
Don't delete highlight actions on receipt, add test
Fizzadar 8c687e3
Merge branch 'develop' into delete-push-actions-on-receipt
Fizzadar df149c9
Update test for merged thread ID change
Fizzadar 85c819c
Merge branch 'develop' into delete-push-actions-on-receipt
Fizzadar ceb6bbe
Handle threads when deleting push actions on receipt
Fizzadar File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Clear out pending push actions when processing read receipts, removing extra checks during push action processing. Contributed by Nick @ Beeper (@fizzadar). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -292,3 +292,76 @@ def test_get_last_receipt_event_id_for_user(self) -> None: | |||||
[ReceiptTypes.READ, ReceiptTypes.READ_PRIVATE], room_id=self.room_id2 | ||||||
) | ||||||
self.assertEqual(res, event2_1_id) | ||||||
|
||||||
def test_receipts_clear_push_actions(self) -> None: | ||||||
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. Could you add a docstring explaining what this test tests please? Same with the other test. |
||||||
event_1_id = self.create_and_send_event( | ||||||
self.room_id1, UserID.from_string(OTHER_USER_ID) | ||||||
) | ||||||
event_2_id = self.create_and_send_event( | ||||||
self.room_id1, UserID.from_string(OTHER_USER_ID) | ||||||
) | ||||||
|
||||||
def _assert_push_action_count(expected: int): | ||||||
result = self.get_success( | ||||||
self.store.db_pool.simple_select_list( | ||||||
table="event_push_actions", | ||||||
keyvalues={"1": 1}, | ||||||
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. You can also just set |
||||||
retcols=("event_id",), | ||||||
desc="", | ||||||
) | ||||||
) | ||||||
self.assertEqual(len(result), expected) | ||||||
|
||||||
# Check we have 2 push actions pending | ||||||
_assert_push_action_count(2) | ||||||
|
||||||
# Send a read receipt for the first event | ||||||
self.get_success( | ||||||
self.store.insert_receipt( | ||||||
self.room_id1, ReceiptTypes.READ, OUR_USER_ID, [event_1_id], None, {} | ||||||
) | ||||||
) | ||||||
|
||||||
# Check that we now have a single push action pending | ||||||
_assert_push_action_count(1) | ||||||
|
||||||
# Send a read receipt for the second event | ||||||
self.get_success( | ||||||
self.store.insert_receipt( | ||||||
self.room_id1, ReceiptTypes.READ, OUR_USER_ID, [event_2_id], None, {} | ||||||
) | ||||||
) | ||||||
|
||||||
# Check that we have no push actions pending | ||||||
_assert_push_action_count(0) | ||||||
|
||||||
def test_receipts_not_clear_highlight_push_actions(self) -> None: | ||||||
event_1_id = self.create_and_send_event( | ||||||
self.room_id1, | ||||||
UserID.from_string(OTHER_USER_ID), | ||||||
content="our", | ||||||
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.
Suggested change
Bit more boilerplatey, but it makes it easier to understand what |
||||||
) | ||||||
|
||||||
def _assert_push_action_count(expected: int): | ||||||
result = self.get_success( | ||||||
self.store.db_pool.simple_select_list( | ||||||
table="event_push_actions", | ||||||
keyvalues={"1": 1}, | ||||||
retcols=("*",), | ||||||
desc="", | ||||||
) | ||||||
) | ||||||
self.assertEqual(len(result), expected) | ||||||
|
||||||
# Check we have 1 push actions pending | ||||||
_assert_push_action_count(1) | ||||||
|
||||||
# Send a read receipt for the first event | ||||||
self.get_success( | ||||||
self.store.insert_receipt( | ||||||
self.room_id1, ReceiptTypes.READ, OUR_USER_ID, [event_1_id], None, {} | ||||||
) | ||||||
) | ||||||
|
||||||
# Check that we now have a single push action pending | ||||||
_assert_push_action_count(1) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Could you add a comment explaining why we are special casing highlights here?