mirror of
https://mau.dev/maunium/synapse.git
synced 2024-08-21 09:45:29 +00:00
Convert _censor_redactions to async since it awaits on coroutines
This commit is contained in:
parent
cc5f6eb608
commit
31da85e467
@ -1039,22 +1039,20 @@ class EventsStore(
|
|||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
|
||||||
@defer.inlineCallbacks
|
async def _censor_redactions(self):
|
||||||
def _censor_redactions(self):
|
|
||||||
"""Censors all redactions older than the configured period that haven't
|
"""Censors all redactions older than the configured period that haven't
|
||||||
been censored yet.
|
been censored yet.
|
||||||
|
|
||||||
By censor we mean update the event_json table with the redacted event.
|
By censor we mean update the event_json table with the redacted event.
|
||||||
|
|
||||||
Returns:
|
|
||||||
Deferred
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
if self.hs.config.redaction_retention_period is None:
|
if self.hs.config.redaction_retention_period is None:
|
||||||
return
|
return
|
||||||
|
|
||||||
if self.db.updates.has_completed_background_update(
|
if not (
|
||||||
"redactions_have_censored_ts_idx"
|
await self.db.updates.has_completed_background_update(
|
||||||
|
"redactions_have_censored_ts_idx"
|
||||||
|
)
|
||||||
):
|
):
|
||||||
# We don't want to run this until the appropriate index has been
|
# We don't want to run this until the appropriate index has been
|
||||||
# created.
|
# created.
|
||||||
@ -1081,15 +1079,15 @@ class EventsStore(
|
|||||||
LIMIT ?
|
LIMIT ?
|
||||||
"""
|
"""
|
||||||
|
|
||||||
rows = yield self.db.execute(
|
rows = await self.db.execute(
|
||||||
"_censor_redactions_fetch", None, sql, before_ts, 100
|
"_censor_redactions_fetch", None, sql, before_ts, 100
|
||||||
)
|
)
|
||||||
|
|
||||||
updates = []
|
updates = []
|
||||||
|
|
||||||
for redaction_id, event_id in rows:
|
for redaction_id, event_id in rows:
|
||||||
redaction_event = yield self.get_event(redaction_id, allow_none=True)
|
redaction_event = await self.get_event(redaction_id, allow_none=True)
|
||||||
original_event = yield self.get_event(
|
original_event = await self.get_event(
|
||||||
event_id, allow_rejected=True, allow_none=True
|
event_id, allow_rejected=True, allow_none=True
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -1122,7 +1120,7 @@ class EventsStore(
|
|||||||
updatevalues={"have_censored": True},
|
updatevalues={"have_censored": True},
|
||||||
)
|
)
|
||||||
|
|
||||||
yield self.db.runInteraction("_update_censor_txn", _update_censor_txn)
|
await self.db.runInteraction("_update_censor_txn", _update_censor_txn)
|
||||||
|
|
||||||
def _censor_event_txn(self, txn, event_id, pruned_json):
|
def _censor_event_txn(self, txn, event_id, pruned_json):
|
||||||
"""Censor an event by replacing its JSON in the event_json table with the
|
"""Censor an event by replacing its JSON in the event_json table with the
|
||||||
|
Loading…
Reference in New Issue
Block a user