Skip to content
This repository has been archived by the owner on Apr 26, 2024. It is now read-only.

Commit

Permalink
Don't delete highlight actions on receipt, add test
Browse files Browse the repository at this point in the history
  • Loading branch information
Fizzadar committed Sep 24, 2022
1 parent ef04bc8 commit 65b5bca
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 0 deletions.
1 change: 1 addition & 0 deletions synapse/storage/databases/main/receipts.py
Original file line number Diff line number Diff line change
Expand Up @@ -711,6 +711,7 @@ def _insert_linearized_receipt_txn(
WHERE room_id = ?
AND user_id = ?
AND stream_ordering <= ?
AND highlight = 0
"""
txn.execute(sql, (room_id, user_id, stream_ordering))

Expand Down
30 changes: 30 additions & 0 deletions tests/storage/test_receipts.py
Original file line number Diff line number Diff line change
Expand Up @@ -313,3 +313,33 @@ def _assert_push_action_count(expected: int):
# 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",
)

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], {}
)
)

# Check that we now have a single push action pending
_assert_push_action_count(1)

0 comments on commit 65b5bca

Please sign in to comment.