diff options
author | 2023-08-10 15:08:41 +0100 | |
---|---|---|
committer | 2023-08-10 15:08:41 +0100 | |
commit | 91cbcd589e7c4ab87e5994e4d0276ea1248dc5c2 (patch) | |
tree | a6b12c30168eb5fed4267dcb6a1f385b86afdcdf /internal/processing | |
parent | [feature] List replies policy, refactor async workers (#2087) (diff) | |
download | gotosocial-91cbcd589e7c4ab87e5994e4d0276ea1248dc5c2.tar.xz |
[performance] remove last of relational queries to instead rely on caches (#2091)
Diffstat (limited to 'internal/processing')
-rw-r--r-- | internal/processing/account/delete.go | 28 | ||||
-rw-r--r-- | internal/processing/app.go | 2 |
2 files changed, 21 insertions, 9 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 diff --git a/internal/processing/app.go b/internal/processing/app.go index 07739ce92..d4a923e8a 100644 --- a/internal/processing/app.go +++ b/internal/processing/app.go @@ -61,7 +61,7 @@ func (p *Processor) AppCreate(ctx context.Context, authed *oauth.Auth, form *api } // chuck it in the db - if err := p.state.DB.Put(ctx, app); err != nil { + if err := p.state.DB.PutApplication(ctx, app); err != nil { return nil, gtserror.NewErrorInternalError(err) } |