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

Commit

Permalink
Apply & bundle edits for non-message events. (#15295)
Browse files Browse the repository at this point in the history
  • Loading branch information
clokep authored Mar 21, 2023
1 parent 96bcc5d commit 1bc4feb
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 7 deletions.
1 change: 1 addition & 0 deletions changelog.d/15295.bugfix
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fix a long-standing bug where edits of non-`m.room.message` events would not be correctly bundled or have their new content applied.
11 changes: 4 additions & 7 deletions synapse/storage/databases/main/relations.py
Original file line number Diff line number Diff line change
Expand Up @@ -472,12 +472,11 @@ async def get_applicable_edits(
the event will map to None.
"""

# We only allow edits for `m.room.message` events that have the same sender
# and event type. We can't assert these things during regular event auth so
# we have to do the checks post hoc.
# We only allow edits for events that have the same sender and event type.
# We can't assert these things during regular event auth so we have to do
# the checks post hoc.

# Fetches latest edit that has the same type and sender as the
# original, and is an `m.room.message`.
# Fetches latest edit that has the same type and sender as the original.
if isinstance(self.database_engine, PostgresEngine):
# The `DISTINCT ON` clause will pick the *first* row it encounters,
# so ordering by origin server ts + event ID desc will ensure we get
Expand All @@ -493,7 +492,6 @@ async def get_applicable_edits(
WHERE
%s
AND relation_type = ?
AND edit.type = 'm.room.message'
ORDER by original.event_id DESC, edit.origin_server_ts DESC, edit.event_id DESC
"""
else:
Expand All @@ -512,7 +510,6 @@ async def get_applicable_edits(
WHERE
%s
AND relation_type = ?
AND edit.type = 'm.room.message'
ORDER by edit.origin_server_ts, edit.event_id
"""

Expand Down

0 comments on commit 1bc4feb

Please sign in to comment.