mirror of
https://mau.dev/maunium/synapse.git
synced 2024-10-01 01:36:05 -04:00
bugfix: always prefer unthreaded receipt when >1 exist (MSC4102) (#16927)
Co-authored-by: Andrew Morgan <1342360+anoadragon453@users.noreply.github.com>
This commit is contained in:
parent
e5dfb6ecbf
commit
c51a2240d1
1
changelog.d/16927.bugfix
Normal file
1
changelog.d/16927.bugfix
Normal file
@ -0,0 +1 @@
|
||||
Always prefer unthreaded receipt when >1 exist ([MSC4102](https://github.com/matrix-org/matrix-spec-proposals/pull/4102)).
|
@ -472,7 +472,22 @@ class ReceiptsWorkerStore(SQLBaseStore):
|
||||
event_entry = room_event["content"].setdefault(event_id, {})
|
||||
receipt_type_dict = event_entry.setdefault(receipt_type, {})
|
||||
|
||||
receipt_type_dict[user_id] = db_to_json(data)
|
||||
# MSC4102: always replace threaded receipts with unthreaded ones if there is a clash.
|
||||
# Specifically:
|
||||
# - if there is no existing receipt, great, set the data.
|
||||
# - if there is an existing receipt, is it threaded (thread_id present)?
|
||||
# YES: replace if this receipt has no thread id. NO: do not replace.
|
||||
# This means we will drop some receipts, but MSC4102 is designed to drop semantically
|
||||
# meaningless receipts, so this is okay. Previously, we would drop meaningful data!
|
||||
receipt_data = db_to_json(data)
|
||||
if user_id in receipt_type_dict: # existing receipt
|
||||
# is the existing receipt threaded and we are currently processing an unthreaded one?
|
||||
if "thread_id" in receipt_type_dict[user_id] and not thread_id:
|
||||
receipt_type_dict[
|
||||
user_id
|
||||
] = receipt_data # replace with unthreaded one
|
||||
else: # receipt does not exist, just set it
|
||||
receipt_type_dict[user_id] = receipt_data
|
||||
if thread_id:
|
||||
receipt_type_dict[user_id]["thread_id"] = thread_id
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user