Skip to content
Snippets Groups Projects
Unverified Commit ab8047b4 authored by Patrick Cloke's avatar Patrick Cloke Committed by GitHub
Browse files

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.
parent 8074430d
No related branches found
No related tags found
No related merge requests found
Fix a long-standing bug where edits of non-`m.room.message` events would not be correctly bundled or have their new content applied.
...@@ -384,12 +384,11 @@ class RelationsWorkerStore(SQLBaseStore): ...@@ -384,12 +384,11 @@ class RelationsWorkerStore(SQLBaseStore):
the event will map to None. the event will map to None.
""" """
# We only allow edits for `m.room.message` events that have the same sender # We only allow edits for events that have the same sender and event type.
# and event type. We can't assert these things during regular event auth so # We can't assert these things during regular event auth so we have to do
# we have to do the checks post hoc. # the checks post hoc.
# Fetches latest edit that has the same type and sender as the # Fetches latest edit that has the same type and sender as the original.
# original, and is an `m.room.message`.
if isinstance(self.database_engine, PostgresEngine): if isinstance(self.database_engine, PostgresEngine):
# The `DISTINCT ON` clause will pick the *first* row it encounters, # The `DISTINCT ON` clause will pick the *first* row it encounters,
# so ordering by origin server ts + event ID desc will ensure we get # so ordering by origin server ts + event ID desc will ensure we get
...@@ -405,7 +404,6 @@ class RelationsWorkerStore(SQLBaseStore): ...@@ -405,7 +404,6 @@ class RelationsWorkerStore(SQLBaseStore):
WHERE WHERE
%s %s
AND relation_type = ? AND relation_type = ?
AND edit.type = 'm.room.message'
ORDER by original.event_id DESC, edit.origin_server_ts DESC, edit.event_id DESC ORDER by original.event_id DESC, edit.origin_server_ts DESC, edit.event_id DESC
""" """
else: else:
...@@ -424,7 +422,6 @@ class RelationsWorkerStore(SQLBaseStore): ...@@ -424,7 +422,6 @@ class RelationsWorkerStore(SQLBaseStore):
WHERE WHERE
%s %s
AND relation_type = ? AND relation_type = ?
AND edit.type = 'm.room.message'
ORDER by edit.origin_server_ts, edit.event_id ORDER by edit.origin_server_ts, edit.event_id
""" """
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment