purge: redact user from global wrap-up reports

This commit is contained in:
2026-10-26 03:16:12 +01:00
parent 9d0166f5cb
commit c9e74d9cc3
2 changed files with 64 additions and 2 deletions

View File

@@ -45,8 +45,12 @@ pub const URL_KEYED_USER_COLUMNS: &[(&str, &str)] = &[
];
/// Columns holding serialized events and activities that carry the user's id
/// (the outbox log keeps finished rows, including authored activity JSON).
pub const PAYLOAD_KEYED_USER_COLUMNS: &[(&str, &str)] = &[("event_queue", "payload")];
/// (the outbox log keeps finished rows, including authored activity JSON) and
/// the global wrap-up reports, whose `most_active_user` names a member.
pub const PAYLOAD_KEYED_USER_COLUMNS: &[(&str, &str)] = &[
("event_queue", "payload"),
("wrap_up_records", "report_json"),
];
pub struct SqliteAccountPurger {
pool: SqlitePool,
@@ -142,6 +146,19 @@ impl AccountPurger for SqliteAccountPurger {
.await
.map_err(map_sqlx_error)?;
// Global wrap-up reports name their most active member; redact it
// (the type allows none) and keep the rest of the report.
sqlx::query(
"UPDATE wrap_up_records
SET report_json = json_set(report_json, '$.most_active_user', NULL)
WHERE user_id IS NULL AND report_json IS NOT NULL
AND instr(report_json, ?) > 0",
)
.bind(&id)
.execute(&mut *tx)
.await
.map_err(map_sqlx_error)?;
// Other accounts' follows of this one.
for table in ["ap_followers", "ap_following"] {
sqlx::query(&format!("DELETE FROM {table} WHERE remote_actor_url = ?"))