mirror of
https://github.com/superseriousbusiness/gotosocial.git
synced 2024-05-13 01:52:40 +00:00
Compare commits
5 commits
e961715154
...
936217cf1d
Author | SHA1 | Date | |
---|---|---|---|
936217cf1d | |||
9e7b0dfb58 | |||
51d8d839f3 | |||
f1a59b82e2 | |||
2fd621507b |
|
@ -74,9 +74,9 @@ func (f *federatingDB) Delete(ctx context.Context, id *url.URL) error {
|
|||
return err
|
||||
}
|
||||
|
||||
// Log at warning level, as lots of these could indicate federation
|
||||
// Log at debug level, as lots of these could indicate federation
|
||||
// issues between remote and this instance, or help with debugging.
|
||||
log.Warnf(ctx, "received delete for unknown target: %s", uriStr)
|
||||
log.Debugf(ctx, "received delete for unknown target: %s", uriStr)
|
||||
return nil
|
||||
}
|
||||
|
||||
|
@ -96,8 +96,9 @@ func (f *federatingDB) deleteAccount(
|
|||
|
||||
if account != nil {
|
||||
if account.ID != requesting.ID {
|
||||
const text = "signing account does not match delete target"
|
||||
return false, gtserror.NewErrorForbidden(err, text)
|
||||
// TODO: handled forwarded deletes,
|
||||
// for now we silently drop this.
|
||||
return true, nil
|
||||
}
|
||||
|
||||
log.Debugf(ctx, "deleting account: %s", account.URI)
|
||||
|
@ -131,8 +132,9 @@ func (f *federatingDB) deleteStatus(
|
|||
|
||||
if status != nil {
|
||||
if status.AccountID != requesting.ID {
|
||||
const text = "signing account does not match delete target owner"
|
||||
return false, gtserror.NewErrorForbidden(err, text)
|
||||
// TODO: handled forwarded deletes,
|
||||
// for now we silently drop this.
|
||||
return true, nil
|
||||
}
|
||||
|
||||
log.Debugf(ctx, "deleting status: %s", status.URI)
|
||||
|
|
|
@ -18,6 +18,9 @@
|
|||
package account_test
|
||||
|
||||
import (
|
||||
"context"
|
||||
"time"
|
||||
|
||||
"github.com/stretchr/testify/suite"
|
||||
"github.com/superseriousbusiness/gotosocial/internal/db"
|
||||
"github.com/superseriousbusiness/gotosocial/internal/email"
|
||||
|
@ -25,6 +28,7 @@ import (
|
|||
"github.com/superseriousbusiness/gotosocial/internal/filter/visibility"
|
||||
"github.com/superseriousbusiness/gotosocial/internal/gtsmodel"
|
||||
"github.com/superseriousbusiness/gotosocial/internal/media"
|
||||
"github.com/superseriousbusiness/gotosocial/internal/messages"
|
||||
"github.com/superseriousbusiness/gotosocial/internal/oauth"
|
||||
"github.com/superseriousbusiness/gotosocial/internal/processing"
|
||||
"github.com/superseriousbusiness/gotosocial/internal/processing/account"
|
||||
|
@ -64,6 +68,13 @@ type AccountStandardTestSuite struct {
|
|||
accountProcessor account.Processor
|
||||
}
|
||||
|
||||
func (suite *AccountStandardTestSuite) getClientMsg(timeout time.Duration) (*messages.FromClientAPI, bool) {
|
||||
ctx := context.Background()
|
||||
ctx, cncl := context.WithTimeout(ctx, timeout)
|
||||
defer cncl()
|
||||
return suite.state.Workers.Client.Queue.PopCtx(ctx)
|
||||
}
|
||||
|
||||
func (suite *AccountStandardTestSuite) SetupSuite() {
|
||||
suite.testTokens = testrig.NewTestTokens()
|
||||
suite.testClients = testrig.NewTestClients()
|
||||
|
|
|
@ -20,6 +20,7 @@ package account_test
|
|||
import (
|
||||
"context"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/stretchr/testify/suite"
|
||||
"github.com/superseriousbusiness/gotosocial/internal/ap"
|
||||
|
@ -150,7 +151,7 @@ func (suite *FollowTestSuite) TestFollowRequestLocal() {
|
|||
}
|
||||
|
||||
// There should be a message going to the worker.
|
||||
cMsg := suite.checkClientAPIChan()
|
||||
cMsg, _ := suite.getClientMsg(5 * time.Second)
|
||||
suite.Equal(ap.ActivityCreate, cMsg.APActivityType)
|
||||
suite.Equal(ap.ActivityFollow, cMsg.APObjectType)
|
||||
suite.Equal(requestingAccount.ID, cMsg.Origin.ID)
|
||||
|
|
|
@ -71,7 +71,7 @@ func (suite *MoveTestSuite) TestMoveAccountOK() {
|
|||
}
|
||||
|
||||
// There should be a message going to the worker.
|
||||
cMsg := suite.checkClientAPIChan()
|
||||
cMsg, _ := suite.getClientMsg(5 * time.Second)
|
||||
move, ok := cMsg.GTSModel.(*gtsmodel.Move)
|
||||
if !ok {
|
||||
suite.FailNow("", "could not cast %T to *gtsmodel.Move", move)
|
||||
|
|
|
@ -26,27 +26,12 @@ import (
|
|||
"github.com/superseriousbusiness/gotosocial/internal/ap"
|
||||
apimodel "github.com/superseriousbusiness/gotosocial/internal/api/model"
|
||||
"github.com/superseriousbusiness/gotosocial/internal/gtsmodel"
|
||||
"github.com/superseriousbusiness/gotosocial/internal/messages"
|
||||
)
|
||||
|
||||
type AccountUpdateTestSuite struct {
|
||||
AccountStandardTestSuite
|
||||
}
|
||||
|
||||
func (suite *AccountStandardTestSuite) checkClientAPIChan() *messages.FromClientAPI {
|
||||
select {
|
||||
case <-suite.state.Workers.Client.Queue.Wait():
|
||||
case <-time.After(5 * time.Second):
|
||||
}
|
||||
|
||||
msg, ok := suite.state.Workers.Client.Queue.Pop()
|
||||
if !ok {
|
||||
suite.FailNow("no queued message")
|
||||
}
|
||||
|
||||
return msg
|
||||
}
|
||||
|
||||
func (suite *AccountUpdateTestSuite) TestAccountUpdateSimple() {
|
||||
testAccount := >smodel.Account{}
|
||||
*testAccount = *suite.testAccounts["local_account_1"]
|
||||
|
@ -75,7 +60,7 @@ func (suite *AccountUpdateTestSuite) TestAccountUpdateSimple() {
|
|||
suite.Equal(noteExpected, apiAccount.Note)
|
||||
|
||||
// We should have an update in the client api channel.
|
||||
msg := suite.checkClientAPIChan()
|
||||
msg, _ := suite.getClientMsg(5 * time.Second)
|
||||
|
||||
// Profile update.
|
||||
suite.Equal(ap.ActivityUpdate, msg.APActivityType)
|
||||
|
@ -125,7 +110,7 @@ func (suite *AccountUpdateTestSuite) TestAccountUpdateWithMention() {
|
|||
suite.Equal(noteExpected, apiAccount.Note)
|
||||
|
||||
// We should have an update in the client api channel.
|
||||
msg := suite.checkClientAPIChan()
|
||||
msg, _ := suite.getClientMsg(5 * time.Second)
|
||||
|
||||
// Profile update.
|
||||
suite.Equal(ap.ActivityUpdate, msg.APActivityType)
|
||||
|
@ -181,7 +166,7 @@ func (suite *AccountUpdateTestSuite) TestAccountUpdateWithMarkdownNote() {
|
|||
suite.Equal(noteExpected, apiAccount.Note)
|
||||
|
||||
// We should have an update in the client api channel.
|
||||
msg := suite.checkClientAPIChan()
|
||||
msg, _ := suite.getClientMsg(5 * time.Second)
|
||||
|
||||
// Profile update.
|
||||
suite.Equal(ap.ActivityUpdate, msg.APActivityType)
|
||||
|
@ -266,7 +251,7 @@ func (suite *AccountUpdateTestSuite) TestAccountUpdateWithFields() {
|
|||
suite.EqualValues(emojisExpected, apiAccount.Emojis)
|
||||
|
||||
// We should have an update in the client api channel.
|
||||
msg := suite.checkClientAPIChan()
|
||||
msg, _ := suite.getClientMsg(5 * time.Second)
|
||||
|
||||
// Profile update.
|
||||
suite.Equal(ap.ActivityUpdate, msg.APActivityType)
|
||||
|
@ -323,7 +308,7 @@ func (suite *AccountUpdateTestSuite) TestAccountUpdateNoteNotFields() {
|
|||
suite.Equal(fieldsBefore, len(apiAccount.Fields))
|
||||
|
||||
// We should have an update in the client api channel.
|
||||
msg := suite.checkClientAPIChan()
|
||||
msg, _ := suite.getClientMsg(5 * time.Second)
|
||||
|
||||
// Profile update.
|
||||
suite.Equal(ap.ActivityUpdate, msg.APActivityType)
|
||||
|
|
|
@ -706,15 +706,14 @@ func (p *clientAPI) DeleteAccount(ctx context.Context, cMsg *messages.FromClient
|
|||
p.state.Workers.Federator.Queue.Delete("Receiving.ID", account.ID)
|
||||
p.state.Workers.Federator.Queue.Delete("TargetURI", account.URI)
|
||||
|
||||
// First perform the actual account deletion.
|
||||
if err := p.account.Delete(ctx, cMsg.Target, originID); err != nil {
|
||||
log.Errorf(ctx, "error deleting account: %v", err)
|
||||
}
|
||||
|
||||
if err := p.federate.DeleteAccount(ctx, cMsg.Target); err != nil {
|
||||
log.Errorf(ctx, "error federating account delete: %v", err)
|
||||
}
|
||||
|
||||
if err := p.account.Delete(ctx, cMsg.Target, originID); err != nil {
|
||||
log.Errorf(ctx, "error deleting account: %v", err)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
|
|
|
@ -42,25 +42,23 @@ import (
|
|||
// Starts workers on the provided state using noop processing functions.
|
||||
// Useful when you *don't* want to trigger side effects in a test.
|
||||
func StartNoopWorkers(state *state.State) {
|
||||
state.Workers.Client.Process = func(ctx context.Context, msg *messages.FromClientAPI) error {
|
||||
log.Debugf(ctx, "Workers{}.Client{}.Noop(%s)", dump(msg))
|
||||
return nil // noop
|
||||
}
|
||||
|
||||
state.Workers.Federator.Process = func(ctx context.Context, msg *messages.FromFediAPI) error {
|
||||
log.Debugf(ctx, "Workers{}.Federator{}.Noop(%s)", dump(msg))
|
||||
return nil // noop
|
||||
}
|
||||
state.Workers.Client.Process = func(ctx context.Context, msg *messages.FromClientAPI) error { return nil }
|
||||
state.Workers.Federator.Process = func(ctx context.Context, msg *messages.FromFediAPI) error { return nil }
|
||||
|
||||
state.Workers.Client.Init(messages.ClientMsgIndices())
|
||||
state.Workers.Federator.Init(messages.FederatorMsgIndices())
|
||||
state.Workers.Delivery.Init(nil)
|
||||
|
||||
// Specifically do NOT start the workers
|
||||
// as caller may require queue contents.
|
||||
// (i.e. don't want workers pulling)
|
||||
// _ = state.Workers.Client.Start(1)
|
||||
// _ = state.Workers.Federator.Start(1)
|
||||
// _ = state.Workers.Dereference.Start(1)
|
||||
// _ = state.Workers.Media.Start(1)
|
||||
//
|
||||
// (except for the scheduler, that's fine)
|
||||
_ = state.Workers.Scheduler.Start()
|
||||
_ = state.Workers.Client.Start(1)
|
||||
_ = state.Workers.Federator.Start(1)
|
||||
_ = state.Workers.Dereference.Start(1)
|
||||
_ = state.Workers.Media.Start(1)
|
||||
}
|
||||
|
||||
// Starts workers on the provided state using processing functions from the given
|
||||
|
|
Loading…
Reference in a new issue