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.
pull/6141/head
Erik Johnston 2019-10-01 11:05:48 +01:00
parent 479fbac96f
commit a27fb7d5ca
1 changed files with 17 additions and 1 deletions

View File

@ -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
)