Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[bugfix] Ensure side effects for local -> local follows get processed #2820

Merged
merged 1 commit into from
Apr 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion internal/processing/account/follow.go
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ func (p *Processor) FollowCreate(ctx context.Context, requestingAccount *gtsmode
err = gtserror.Newf("error accepting follow request for local unlocked account: %w", err)
return nil, gtserror.NewErrorInternalError(err)
}
} else if targetAccount.IsRemote() {
} else {
// Otherwise we leave the follow request as it is,
// and we handle the rest of the process async.
p.state.Workers.EnqueueClientAPI(ctx, messages.FromClientAPI{
Expand Down
36 changes: 36 additions & 0 deletions internal/processing/account/follow_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,12 @@ package account_test
import (
"context"
"testing"
"time"

"github.com/stretchr/testify/suite"
"github.com/superseriousbusiness/gotosocial/internal/ap"
apimodel "github.com/superseriousbusiness/gotosocial/internal/api/model"
"github.com/superseriousbusiness/gotosocial/internal/messages"
"github.com/superseriousbusiness/gotosocial/internal/util"
)

Expand Down Expand Up @@ -130,6 +133,39 @@ func (suite *FollowTestSuite) TestUpdateExistingFollowSetNothing() {
suite.False(relationship.Notifying)
}

func (suite *FollowTestSuite) TestFollowRequestLocal() {
ctx := context.Background()
requestingAccount := suite.testAccounts["admin_account"]
targetAccount := suite.testAccounts["local_account_2"]

// Have admin follow request turtle.
_, err := suite.accountProcessor.FollowCreate(
ctx,
requestingAccount,
&apimodel.AccountFollowRequest{
ID: targetAccount.ID,
Reblogs: util.Ptr(true),
Notify: util.Ptr(false),
})
if err != nil {
suite.FailNow(err.Error())
}

// There should be a message going to the worker.
var cMsg messages.FromClientAPI
select {
case cMsg = <-suite.fromClientAPIChan:
// No problem.
case <-time.After(5 * time.Second):
suite.FailNow("timed out waiting for message")
}

suite.Equal(ap.ActivityCreate, cMsg.APActivityType)
suite.Equal(ap.ActivityFollow, cMsg.APObjectType)
suite.Equal(requestingAccount.ID, cMsg.OriginAccount.ID)
suite.Equal(targetAccount.ID, cMsg.TargetAccount.ID)
}

func TestFollowTestS(t *testing.T) {
suite.Run(t, new(FollowTestSuite))
}