diff options
author | Erik Johnston <erik@matrix.org> | 2019-10-01 11:05:48 +0100 |
---|---|---|
committer | Erik Johnston <erik@matrix.org> | 2019-10-01 11:05:48 +0100 |
commit | a27fb7d5cac3cacc55a1c778f02d074d4115eea6 (patch) | |
tree | e90f9881142fb2d5f7358dc074aad23307e012c3 | |
parent | Merge pull request #6135 from matrix-org/erikj/fixup_devices_last_seen_query (diff) | |
download | synapse-a27fb7d5cac3cacc55a1c778f02d074d4115eea6.tar.xz |
Don't repeatedly attempt to censor events we don't have.
Currently we don't set `have_censored` column if we don't have the target event of a redaction, which means we repeatedly attempt to censor the same non-existant event. When we persist non-redacted events we unset the `have_censored` column for any redactions that target said event.
-rw-r--r-- | synapse/storage/events.py | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/synapse/storage/events.py b/synapse/storage/events.py index ddf7ab6479..5d56ceeab3 100644 --- a/synapse/storage/events.py +++ b/synapse/storage/events.py @@ -1389,6 +1389,22 @@ class EventsStore( ], ) + for event, _ in events_and_contexts: + if not event.internal_metadata.is_redacted(): + # If we're persisting an unredacted event we go and ensure + # that we mark any redactions that reference this event as + # requiring censoring. + self._simple_update_txn( + txn, + table="redactions", + keyvalues={ + "redacts": event.event_id, + }, + updatevalues={ + "have_censored": False, + } + ) + def _store_rejected_events_txn(self, txn, events_and_contexts): """Add rows to the 'rejections' table for received events which were rejected @@ -1589,7 +1605,7 @@ class EventsStore( sql = """ SELECT redact_event.event_id, redacts FROM redactions INNER JOIN events AS redact_event USING (event_id) - INNER JOIN events AS original_event ON ( + LEFT JOIN events AS original_event ON ( redact_event.room_id = original_event.room_id AND redacts = original_event.event_id ) |