summaryrefslogtreecommitdiff
path: root/internal
diff options
context:
space:
mode:
Diffstat (limited to 'internal')
-rw-r--r--internal/db/bundb/interaction.go22
-rw-r--r--internal/db/interaction.go4
-rw-r--r--internal/processing/account/delete.go6
3 files changed, 32 insertions, 0 deletions
diff --git a/internal/db/bundb/interaction.go b/internal/db/bundb/interaction.go
index 3de75ded1..b42eb46f6 100644
--- a/internal/db/bundb/interaction.go
+++ b/internal/db/bundb/interaction.go
@@ -268,6 +268,28 @@ func (i *interactionDB) DeleteInteractionRequestByID(ctx context.Context, id str
return nil
}
+func (i *interactionDB) DeleteInteractionRequestsByInteractingAccountID(ctx context.Context, accountID string) error {
+ // Gather necessary fields from
+ // deleted for cache invaliation.
+ var deleted []*gtsmodel.InteractionRequest
+
+ if _, err := i.db.NewDelete().
+ Model(&deleted).
+ Returning("?", bun.Ident("id")).
+ Where("? = ?", bun.Ident("interacting_account_id"), accountID).
+ Exec(ctx); err != nil &&
+ !errors.Is(err, db.ErrNoEntries) {
+ return err
+ }
+
+ for _, deleted := range deleted {
+ // Invalidate cached interaction requests by ID.
+ i.state.Caches.DB.InteractionRequest.Invalidate("ID", deleted.ID)
+ }
+
+ return nil
+}
+
func (i *interactionDB) GetInteractionsRequestsForAcct(
ctx context.Context,
acctID string,
diff --git a/internal/db/interaction.go b/internal/db/interaction.go
index 4e58e1db3..4a6ec7e2e 100644
--- a/internal/db/interaction.go
+++ b/internal/db/interaction.go
@@ -47,6 +47,10 @@ type Interaction interface {
// DeleteInteractionRequestByID deletes one request with the given ID.
DeleteInteractionRequestByID(ctx context.Context, id string) error
+ // DeleteInteractionRequestsByInteractingAccountID deletes all requests
+ // originating from the given account ID.
+ DeleteInteractionRequestsByInteractingAccountID(ctx context.Context, accountID string) error
+
// GetInteractionsRequestsForAcct returns pending interactions targeting
// the given (optional) account ID and the given (optional) status ID.
//
diff --git a/internal/processing/account/delete.go b/internal/processing/account/delete.go
index 682da3681..f812909c5 100644
--- a/internal/processing/account/delete.go
+++ b/internal/processing/account/delete.go
@@ -478,6 +478,12 @@ func (p *Processor) deleteAccountPeripheral(
err != nil && !errors.Is(err, db.ErrNoEntries) {
log.Errorf("error deleting poll votes by account: %v", err)
}
+
+ // Delete all interaction requests from given account, local and remote.
+ if err := p.state.DB.DeleteInteractionRequestsByInteractingAccountID(ctx, account.ID); // nocollapse
+ err != nil && !errors.Is(err, db.ErrNoEntries) {
+ log.Errorf("error deleting interaction requests by account: %v", err)
+ }
}
// processSideEffect will process the given side effect details,