diff options
| author | 2025-12-03 19:37:17 +0100 | |
|---|---|---|
| committer | 2026-01-22 13:26:54 +0100 | |
| commit | 5ca7f0b20785bac1e17e783b2505260283ef5385 (patch) | |
| tree | cf85644171d8a78c01913e7038a949bff4598ce6 /internal/processing/workers/fromfediapi_test.go | |
| parent | [bugfix] don't apply visibility / status filtering when requesting your own a... (diff) | |
| download | gotosocial-5ca7f0b20785bac1e17e783b2505260283ef5385.tar.xz | |
[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 <tobi.smethurst@protonmail.com>
Co-committed-by: tobi <tobi.smethurst@protonmail.com>
Diffstat (limited to 'internal/processing/workers/fromfediapi_test.go')
| -rw-r--r-- | internal/processing/workers/fromfediapi_test.go | 63 |
1 files changed, 63 insertions, 0 deletions
diff --git a/internal/processing/workers/fromfediapi_test.go b/internal/processing/workers/fromfediapi_test.go index 790c78b70..f683dd9f0 100644 --- a/internal/processing/workers/fromfediapi_test.go +++ b/internal/processing/workers/fromfediapi_test.go @@ -738,6 +738,69 @@ func (suite *FromFediAPITestSuite) TestUndoAnnounce() { } } +func (suite *FromFediAPITestSuite) TestUndoFollow() { + var ( + ctx = suite.T().Context() + testStructs = testrig.SetupTestStructs(rMediaPath, rTemplatePath) + requestingAcct = suite.testAccounts["remote_account_1"] + receivingAcct = suite.testAccounts["local_account_1"] + ) + defer testrig.TearDownTestStructs(testStructs) + + // Put a notification in the db as though + // remote_account_1 had follow requested local_account_1. + notif := >smodel.Notification{ + ID: "01F8PY8RHWRQZV038T4E8T9YK8", + CreatedAt: testrig.TimeMustParse("2022-05-14T16:21:09+02:00"), + UpdatedAt: testrig.TimeMustParse("2022-05-14T16:21:09+02:00"), + NotificationType: gtsmodel.NotificationFollowRequest, + OriginAccountID: "01F8MH5ZK5VRH73AKHQM6Y9VNX", + OriginAccount: requestingAcct, + TargetAccountID: "01F8MH1H7YV1Z7D2C8K2730QBF", + TargetAccount: receivingAcct, + } + if err := testStructs.State.DB.PutNotification(ctx, notif); err != nil { + suite.FailNow(err.Error()) + } + + // Hold a follow in memory as though remote_account_1 + // has now undone the follow request. + follow := >smodel.Follow{ + ID: "01F8PY8RHWRQZV038T4E8T9YK8", + CreatedAt: testrig.TimeMustParse("2022-05-14T16:21:09+02:00"), + UpdatedAt: testrig.TimeMustParse("2022-05-14T16:21:09+02:00"), + AccountID: "01F8MH5ZK5VRH73AKHQM6Y9VNX", + Account: requestingAcct, + TargetAccountID: "01F8MH1H7YV1Z7D2C8K2730QBF", + TargetAccount: receivingAcct, + ShowReblogs: util.Ptr(true), + URI: "https://fossbros-anonymous.io/users/foss_satan/follows/01F8PY8RHWRQZV038T4E8T9YK8", + Notify: util.Ptr(false), + } + + // Process the undo message, passing the follow. + err := testStructs.Processor.Workers().ProcessFromFediAPI(ctx, &messages.FromFediAPI{ + APObjectType: ap.ActivityFollow, + APActivityType: ap.ActivityUndo, + GTSModel: follow, + Receiving: receivingAcct, + Requesting: requestingAcct, + }) + suite.NoError(err) + + // Wait for side effects to trigger: + // the notification should be deleted. + if !testrig.WaitFor(func() bool { + _, err := testStructs.State.DB.GetNotificationByID( + gtscontext.SetBarebones(ctx), + notif.ID, + ) + return errors.Is(err, db.ErrNoEntries) + }) { + suite.FailNow("timed out waiting for notif to be removed") + } +} + func (suite *FromFediAPITestSuite) TestUpdateNote() { var ( ctx = suite.T().Context() |
