mirror of
https://github.com/superseriousbusiness/gotosocial.git
synced 2024-11-22 11:46:40 +00:00
[bugfix] Ensure side effects for local -> local follows get processed (#2820)
This commit is contained in:
parent
85bc140b58
commit
6db7d014dc
|
@ -114,7 +114,7 @@ func(columns ...string) error { return p.state.DB.UpdateFollowRequest(ctx, follo
|
||||||
err = gtserror.Newf("error accepting follow request for local unlocked account: %w", err)
|
err = gtserror.Newf("error accepting follow request for local unlocked account: %w", err)
|
||||||
return nil, gtserror.NewErrorInternalError(err)
|
return nil, gtserror.NewErrorInternalError(err)
|
||||||
}
|
}
|
||||||
} else if targetAccount.IsRemote() {
|
} else {
|
||||||
// Otherwise we leave the follow request as it is,
|
// Otherwise we leave the follow request as it is,
|
||||||
// and we handle the rest of the process async.
|
// and we handle the rest of the process async.
|
||||||
p.state.Workers.EnqueueClientAPI(ctx, messages.FromClientAPI{
|
p.state.Workers.EnqueueClientAPI(ctx, messages.FromClientAPI{
|
||||||
|
|
|
@ -20,9 +20,12 @@
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"testing"
|
"testing"
|
||||||
|
"time"
|
||||||
|
|
||||||
"github.com/stretchr/testify/suite"
|
"github.com/stretchr/testify/suite"
|
||||||
|
"github.com/superseriousbusiness/gotosocial/internal/ap"
|
||||||
apimodel "github.com/superseriousbusiness/gotosocial/internal/api/model"
|
apimodel "github.com/superseriousbusiness/gotosocial/internal/api/model"
|
||||||
|
"github.com/superseriousbusiness/gotosocial/internal/messages"
|
||||||
"github.com/superseriousbusiness/gotosocial/internal/util"
|
"github.com/superseriousbusiness/gotosocial/internal/util"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -130,6 +133,39 @@ func (suite *FollowTestSuite) TestUpdateExistingFollowSetNothing() {
|
||||||
suite.False(relationship.Notifying)
|
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) {
|
func TestFollowTestS(t *testing.T) {
|
||||||
suite.Run(t, new(FollowTestSuite))
|
suite.Run(t, new(FollowTestSuite))
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue