summary refs log tree commit diff
path: root/synapse
diff options
context:
space:
mode:
authorErik Johnston <erik@matrix.org>2019-05-20 12:36:06 +0100
committerGitHub <noreply@github.com>2019-05-20 12:36:06 +0100
commit9ad246e6d2f7dd463908231a9237f09117c03914 (patch)
tree3c91ac49a50c035a9e786376a7cf798953a544a3 /synapse
parentMerge pull request #5195 from matrix-org/erikj/edits (diff)
parentFixup comments (diff)
downloadsynapse-9ad246e6d2f7dd463908231a9237f09117c03914.tar.xz
Merge pull request #5207 from matrix-org/erikj/reactions_redactions
Correctly update aggregation counts after redaction
Diffstat (limited to 'synapse')
-rw-r--r--synapse/storage/events.py3
-rw-r--r--synapse/storage/relations.py17
2 files changed, 20 insertions, 0 deletions
diff --git a/synapse/storage/events.py b/synapse/storage/events.py
index b025ebc926..881d6d0126 100644
--- a/synapse/storage/events.py
+++ b/synapse/storage/events.py
@@ -1325,6 +1325,9 @@ class EventsStore(
                     txn, event.room_id, event.redacts
                 )
 
+                # Remove from relations table.
+                self._handle_redaction(txn, event.redacts)
+
         # Update the event_forward_extremities, event_backward_extremities and
         # event_edges tables.
         self._handle_mult_prev_events(
diff --git a/synapse/storage/relations.py b/synapse/storage/relations.py
index 6e216066ab..63e6185ee3 100644
--- a/synapse/storage/relations.py
+++ b/synapse/storage/relations.py
@@ -415,3 +415,20 @@ class RelationsStore(RelationsWorkerStore):
 
         if rel_type == RelationTypes.REPLACES:
             txn.call_after(self.get_applicable_edit.invalidate, (parent_id,))
+
+    def _handle_redaction(self, txn, redacted_event_id):
+        """Handles receiving a redaction and checking whether we need to remove
+        any redacted relations from the database.
+
+        Args:
+            txn
+            redacted_event_id (str): The event that was redacted.
+        """
+
+        self._simple_delete_txn(
+            txn,
+            table="event_relations",
+            keyvalues={
+                "event_id": redacted_event_id,
+            }
+        )