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

Commit ab8047b

Browse files
authored
Apply & bundle edits for non-message events. (#14034)
Fixes two related bugs: * No edit information was bundled for events which aren't `m.room.message`. * `m.new_content` was not applied for those events.
1 parent 8074430 commit ab8047b

File tree

2 files changed

+5
-7
lines changed

2 files changed

+5
-7
lines changed

changelog.d/14034.bugfix

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
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.

synapse/storage/databases/main/relations.py

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -384,12 +384,11 @@ async def get_applicable_edits(
384384
the event will map to None.
385385
"""
386386

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

391-
# Fetches latest edit that has the same type and sender as the
392-
# original, and is an `m.room.message`.
391+
# Fetches latest edit that has the same type and sender as the original.
393392
if isinstance(self.database_engine, PostgresEngine):
394393
# The `DISTINCT ON` clause will pick the *first* row it encounters,
395394
# so ordering by origin server ts + event ID desc will ensure we get
@@ -405,7 +404,6 @@ async def get_applicable_edits(
405404
WHERE
406405
%s
407406
AND relation_type = ?
408-
AND edit.type = 'm.room.message'
409407
ORDER by original.event_id DESC, edit.origin_server_ts DESC, edit.event_id DESC
410408
"""
411409
else:
@@ -424,7 +422,6 @@ async def get_applicable_edits(
424422
WHERE
425423
%s
426424
AND relation_type = ?
427-
AND edit.type = 'm.room.message'
428425
ORDER by edit.origin_server_ts, edit.event_id
429426
"""
430427

0 commit comments

Comments
 (0)