summary refs log tree commit diff
diff options
context:
space:
mode:
authorPatrick Cloke <clokep@users.noreply.github.com>2022-10-07 11:27:50 -0400
committerGitHub <noreply@github.com>2022-10-07 15:27:50 +0000
commitab8047b4bf581d0c343c1e900e8740745668d941 (patch)
treed03bd2bbbb4bdcdeed7c7ea573c9a9115f79a982
parentDocument Google OpenID Connect email attribute (#14081) (diff)
downloadsynapse-ab8047b4bf581d0c343c1e900e8740745668d941.tar.xz
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.
-rw-r--r--changelog.d/14034.bugfix1
-rw-r--r--synapse/storage/databases/main/relations.py11
2 files changed, 5 insertions, 7 deletions
diff --git a/changelog.d/14034.bugfix b/changelog.d/14034.bugfix
new file mode 100644
index 0000000000..e437ef3a01
--- /dev/null
+++ b/changelog.d/14034.bugfix
@@ -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.
diff --git a/synapse/storage/databases/main/relations.py b/synapse/storage/databases/main/relations.py
index 154385b1e8..116abef9de 100644
--- a/synapse/storage/databases/main/relations.py
+++ b/synapse/storage/databases/main/relations.py
@@ -384,12 +384,11 @@ class RelationsWorkerStore(SQLBaseStore):
             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
@@ -405,7 +404,6 @@ class RelationsWorkerStore(SQLBaseStore):
                 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:
@@ -424,7 +422,6 @@ class RelationsWorkerStore(SQLBaseStore):
                 WHERE
                     %s
                     AND relation_type = ?
-                    AND edit.type = 'm.room.message'
                 ORDER by edit.origin_server_ts, edit.event_id
             """