Skip to content

Commit

Permalink
Fix remote receipts for events we don't have
Browse files Browse the repository at this point in the history
Introduced in #17032
  • Loading branch information
erikjohnston committed Apr 15, 2024
1 parent 259442f commit bc5dc69
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion synapse/storage/databases/main/receipts.py
Original file line number Diff line number Diff line change
Expand Up @@ -734,9 +734,13 @@ def _insert_linearized_receipt_txn(
thread_clause = "r.thread_id = ?"
thread_args = (thread_id,)

# If the receipt doesn't have a stream ordering it is because we
# don't have the associated event, and so must be a remote receipt.
# Hence it's safe to just allow new receipts to clobber it.
sql = f"""
SELECT r.event_stream_ordering, r.event_id FROM receipts_linearized AS r
WHERE r.room_id = ? AND r.receipt_type = ? AND r.user_id = ? AND {thread_clause}
WHERE r.room_id = ? AND r.receipt_type = ? AND r.user_id = ?
AND r.event_stream_ordering IS NOT NULL AND {thread_clause}
"""
txn.execute(
sql,
Expand Down

0 comments on commit bc5dc69

Please sign in to comment.