From 36a09dd0df06e1b6f64347ed3d3c2c8ca963fc73 Mon Sep 17 00:00:00 2001 From: tobi <31960611+tsmethurst@users.noreply.github.com> Date: Thu, 30 Sep 2021 10:56:02 +0200 Subject: handle remote account deletion more systematically (#254) --- internal/processing/account/delete.go | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) (limited to 'internal/processing/account') diff --git a/internal/processing/account/delete.go b/internal/processing/account/delete.go index 5de706045..632f49751 100644 --- a/internal/processing/account/delete.go +++ b/internal/processing/account/delete.go @@ -31,7 +31,7 @@ import ( // Delete handles the complete deletion of an account. // -// TODO in this function: +// To be done in this function: // 1. Delete account's application(s), clients, and oauth tokens // 2. Delete account's blocks // 3. Delete account's emoji @@ -51,12 +51,16 @@ import ( // 17. Delete account's timeline // 18. Delete account itself func (p *processor) Delete(ctx context.Context, account *gtsmodel.Account, origin string) error { - l := p.log.WithFields(logrus.Fields{ + fields := logrus.Fields{ "func": "Delete", "username": account.Username, - }) + } + if account.Domain != "" { + fields["domain"] = account.Domain + } + l := p.log.WithFields(fields) - l.Debugf("beginning account delete process for username %s", account.Username) + l.Debug("beginning account delete process") // 1. Delete account's application(s), clients, and oauth tokens // we only need to do this step for local account since remote ones won't have any tokens or applications on our server @@ -214,10 +218,16 @@ selectStatusesLoop: // 10. Delete account's notifications l.Debug("deleting account notifications") + // first notifications created by account if err := p.db.DeleteWhere(ctx, []db.Where{{Key: "origin_account_id", Value: account.ID}}, &[]*gtsmodel.Notification{}); err != nil { l.Errorf("error deleting notifications created by account: %s", err) } + // now notifications targeting account + if err := p.db.DeleteWhere(ctx, []db.Where{{Key: "target_account_id", Value: account.ID}}, &[]*gtsmodel.Notification{}); err != nil { + l.Errorf("error deleting notifications targeting account: %s", err) + } + // 11. Delete account's bookmarks l.Debug("deleting account bookmarks") if err := p.db.DeleteWhere(ctx, []db.Where{{Key: "account_id", Value: account.ID}}, &[]*gtsmodel.StatusBookmark{}); err != nil { @@ -267,8 +277,6 @@ selectStatusesLoop: account.HideCollections = true account.Discoverable = false - account.UpdatedAt = time.Now() - account.SuspendedAt = time.Now() account.SuspensionOrigin = origin -- cgit v1.2.3