summaryrefslogtreecommitdiff
path: root/internal/db/bundb/interaction.go
diff options
context:
space:
mode:
Diffstat (limited to 'internal/db/bundb/interaction.go')
-rw-r--r--internal/db/bundb/interaction.go22
1 files changed, 22 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,