summaryrefslogtreecommitdiff
path: root/internal/db/bundb
diff options
context:
space:
mode:
authorLibravatar nicole mikołajczyk <git@mkljczk.pl>2025-06-19 10:21:03 +0200
committerLibravatar tobi <kipvandenbos@noreply.codeberg.org>2025-06-19 10:21:03 +0200
commit29d481d76912a8b0de0eebc41e2d8bed5b17c535 (patch)
tree610ea31156735d7bca2d95377f08c8bf36a93ad3 /internal/db/bundb
parent[bugfix] Remove errant `alsoKnownAs` inline `@context` entry (#4280) (diff)
downloadgotosocial-29d481d76912a8b0de0eebc41e2d8bed5b17c535.tar.xz
[bugfix] delete interaction requests when deleting account (#4278)
Signed-off-by: nicole mikołajczyk <git@mkljczk.pl> # Description I recently noticed that pending interaction requests don't disappear on domain suspension. ## Checklist - [x] I/we have read the [GoToSocial contribution guidelines](https://codeberg.org/superseriousbusiness/gotosocial/src/branch/main/CONTRIBUTING.md). - [ ] I/we have discussed the proposed changes already, either in an issue on the repository, or in the Matrix chat. - [x] I/we have not leveraged AI to create the proposed changes. - [x] I/we have performed a self-review of added code. - [x] I/we have written code that is legible and maintainable by others. - [x] I/we have commented the added code, particularly in hard-to-understand areas. - [ ] I/we have made any necessary changes to documentation. - [ ] I/we have added tests that cover new code. - [x] I/we have run tests and they pass locally with the changes. - [x] I/we have run `go fmt ./...` and `golangci-lint run`. Reviewed-on: https://codeberg.org/superseriousbusiness/gotosocial/pulls/4278 Co-authored-by: nicole mikołajczyk <git@mkljczk.pl> Co-committed-by: nicole mikołajczyk <git@mkljczk.pl>
Diffstat (limited to 'internal/db/bundb')
-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,