From 5ca7f0b20785bac1e17e783b2505260283ef5385 Mon Sep 17 00:00:00 2001 From: tobi Date: Wed, 3 Dec 2025 19:37:17 +0100 Subject: [bugfix] Remove follow (req) notifications on Follow Undo (#4604) # Description > If this is a code change, please include a summary of what you've coded, and link to the issue(s) it closes/implements. > > If this is a documentation change, please briefly describe what you've changed and why. Closes https://codeberg.org/superseriousbusiness/gotosocial/issues/4590 ## Checklist Please put an x inside each checkbox to indicate that you've read and followed it: `[ ]` -> `[x]` If this is a documentation change, only the first two checkboxes must be filled (you can delete the others if you want). - [x] I/we have read the [GoToSocial contribution guidelines](https://codeberg.org/superseriousbusiness/gotosocial/src/branch/main/CONTRIBUTING.md). - [x] I/we have not used so-called 'AI' to create the proposed changes. - [x] I/we have discussed the proposed changes already, either in an issue on the repository, or in the Matrix chat. - [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. - [x] 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/4604 Co-authored-by: tobi Co-committed-by: tobi --- internal/processing/workers/fromclientapi.go | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'internal/processing/workers/fromclientapi.go') diff --git a/internal/processing/workers/fromclientapi.go b/internal/processing/workers/fromclientapi.go index 75201c7dc..e18f941fa 100644 --- a/internal/processing/workers/fromclientapi.go +++ b/internal/processing/workers/fromclientapi.go @@ -871,6 +871,20 @@ func (p *clientAPI) UndoFollow(ctx context.Context, cMsg *messages.FromClientAPI follow.TargetAccountID, follow.AccountID, ) + + // Clear any notifications that were + // generated by this follow (request). + if err := p.state.DB.DeleteNotifications( + ctx, + []gtsmodel.NotificationType{ + gtsmodel.NotificationFollow, + gtsmodel.NotificationFollowRequest, + }, + follow.TargetAccountID, + follow.AccountID, + ); err != nil { + return gtserror.Newf("db error deleting notifications: %w", err) + } } if err := p.federate.UndoFollow(ctx, follow); err != nil { -- cgit v1.3