summaryrefslogtreecommitdiff
path: root/internal/processing/account/delete.go
diff options
context:
space:
mode:
authorLibravatar kim <89579420+NyaaaWhatsUpDoc@users.noreply.github.com>2023-08-10 15:08:41 +0100
committerLibravatar GitHub <noreply@github.com>2023-08-10 15:08:41 +0100
commit91cbcd589e7c4ab87e5994e4d0276ea1248dc5c2 (patch)
treea6b12c30168eb5fed4267dcb6a1f385b86afdcdf /internal/processing/account/delete.go
parent[feature] List replies policy, refactor async workers (#2087) (diff)
downloadgotosocial-91cbcd589e7c4ab87e5994e4d0276ea1248dc5c2.tar.xz
[performance] remove last of relational queries to instead rely on caches (#2091)
Diffstat (limited to 'internal/processing/account/delete.go')
-rw-r--r--internal/processing/account/delete.go28
1 files changed, 20 insertions, 8 deletions
diff --git a/internal/processing/account/delete.go b/internal/processing/account/delete.go
index d2483aeb1..da13eb20e 100644
--- a/internal/processing/account/delete.go
+++ b/internal/processing/account/delete.go
@@ -46,12 +46,6 @@ func (p *Processor) Delete(ctx context.Context, account *gtsmodel.Account, origi
}...)
l.Trace("beginning account delete process")
- if account.IsLocal() {
- if err := p.deleteUserAndTokensForAccount(ctx, account); err != nil {
- return gtserror.NewErrorInternalError(err)
- }
- }
-
if err := p.deleteAccountFollows(ctx, account); err != nil {
return gtserror.NewErrorInternalError(err)
}
@@ -72,6 +66,14 @@ func (p *Processor) Delete(ctx context.Context, account *gtsmodel.Account, origi
return gtserror.NewErrorInternalError(err)
}
+ if account.IsLocal() {
+ // we tokens, applications and clients for account as one of the last
+ // stages during deletion, as other database models rely on these.
+ if err := p.deleteUserAndTokensForAccount(ctx, account); err != nil {
+ return gtserror.NewErrorInternalError(err)
+ }
+ }
+
// To prevent the account being created again,
// stubbify it and update it in the db.
// The account will not be deleted, but it
@@ -129,7 +131,7 @@ func (p *Processor) deleteUserAndTokensForAccount(ctx context.Context, account *
}
// Delete any OAuth applications associated with this token.
- if err := p.state.DB.DeleteWhere(ctx, []db.Where{{Key: "client_id", Value: t.ClientID}}, &[]*gtsmodel.Application{}); err != nil {
+ if err := p.state.DB.DeleteApplicationByClientID(ctx, t.ClientID); err != nil {
return gtserror.Newf("db error deleting application: %w", err)
}
@@ -305,7 +307,17 @@ func (p *Processor) deleteAccountStatuses(ctx context.Context, account *gtsmodel
statusLoop:
for {
// Page through account's statuses.
- statuses, err = p.state.DB.GetAccountStatuses(ctx, account.ID, deleteSelectLimit, false, false, maxID, "", false, false)
+ statuses, err = p.state.DB.GetAccountStatuses(
+ ctx,
+ account.ID,
+ deleteSelectLimit,
+ false,
+ false,
+ maxID,
+ "",
+ false,
+ false,
+ )
if err != nil && !errors.Is(err, db.ErrNoEntries) {
// Make sure we don't have a real error.
return err