diff options
Diffstat (limited to 'internal/federation')
| -rw-r--r-- | internal/federation/dereferencing/dereferencer_test.go | 6 | ||||
| -rw-r--r-- | internal/federation/federatingdb/federatingdb_test.go | 7 | ||||
| -rw-r--r-- | internal/federation/federatingdb/undo.go | 48 | ||||
| -rw-r--r-- | internal/federation/federator_test.go | 7 |
4 files changed, 37 insertions, 31 deletions
diff --git a/internal/federation/dereferencing/dereferencer_test.go b/internal/federation/dereferencing/dereferencer_test.go index 95c879920..bd1bf50f1 100644 --- a/internal/federation/dereferencing/dereferencer_test.go +++ b/internal/federation/dereferencing/dereferencer_test.go @@ -77,12 +77,6 @@ func (suite *DereferencerStandardTestSuite) SetupTest() { suite.intFilter = interaction.NewFilter(&suite.state) suite.media = testrig.NewTestMediaManager(&suite.state) - testrig.StartTimelines( - &suite.state, - suite.visFilter, - suite.converter, - ) - suite.client = testrig.NewMockHTTPClient(nil, "../../../testrig/media") suite.storage = testrig.NewInMemoryStorage() suite.state.DB = suite.db diff --git a/internal/federation/federatingdb/federatingdb_test.go b/internal/federation/federatingdb/federatingdb_test.go index ee8f84e55..a67abe762 100644 --- a/internal/federation/federatingdb/federatingdb_test.go +++ b/internal/federation/federatingdb/federatingdb_test.go @@ -25,7 +25,6 @@ import ( "github.com/superseriousbusiness/gotosocial/internal/admin" "github.com/superseriousbusiness/gotosocial/internal/db" "github.com/superseriousbusiness/gotosocial/internal/federation/federatingdb" - "github.com/superseriousbusiness/gotosocial/internal/filter/visibility" "github.com/superseriousbusiness/gotosocial/internal/gtscontext" "github.com/superseriousbusiness/gotosocial/internal/gtsmodel" "github.com/superseriousbusiness/gotosocial/internal/messages" @@ -80,12 +79,6 @@ func (suite *FederatingDBTestSuite) SetupTest() { suite.testActivities = testrig.NewTestActivities(suite.testAccounts) suite.tc = typeutils.NewConverter(&suite.state) - testrig.StartTimelines( - &suite.state, - visibility.NewFilter(&suite.state), - suite.tc, - ) - suite.federatingDB = testrig.NewTestFederatingDB(&suite.state) testrig.StandardDBSetup(suite.db, suite.testAccounts) diff --git a/internal/federation/federatingdb/undo.go b/internal/federation/federatingdb/undo.go index a40b6c31a..6233c9de3 100644 --- a/internal/federation/federatingdb/undo.go +++ b/internal/federation/federatingdb/undo.go @@ -136,10 +136,7 @@ func (f *federatingDB) undoFollow( // Convert AS Follow to barebones *gtsmodel.Follow, // retrieving origin + target accts from the db. - follow, err := f.converter.ASFollowToFollow( - gtscontext.SetBarebones(ctx), - asFollow, - ) + follow, err := f.converter.ASFollowToFollow(ctx, asFollow) if err != nil && !errors.Is(err, db.ErrNoEntries) { err := gtserror.Newf("error converting AS Follow to follow: %w", err) return err @@ -152,6 +149,11 @@ func (f *federatingDB) undoFollow( return nil } + // Lock on the Follow URI + // as we may be updating it. + unlock := f.state.FedLocks.Lock(follow.URI) + defer unlock() + // Ensure addressee is follow target. if follow.TargetAccountID != receivingAcct.ID { const text = "receivingAcct was not Follow target" @@ -178,7 +180,16 @@ func (f *federatingDB) undoFollow( return err } - log.Debug(ctx, "Follow undone") + // Send the deleted follow through to + // the fedi worker to process side effects. + f.state.Workers.Federator.Queue.Push(&messages.FromFediAPI{ + APObjectType: ap.ActivityFollow, + APActivityType: ap.ActivityUndo, + GTSModel: follow, + Receiving: receivingAcct, + Requesting: requestingAcct, + }) + return nil } @@ -269,7 +280,16 @@ func (f *federatingDB) undoLike( return err } - log.Debug(ctx, "Like undone") + // Send the deleted block through to + // the fedi worker to process side effects. + f.state.Workers.Federator.Queue.Push(&messages.FromFediAPI{ + APObjectType: ap.ActivityLike, + APActivityType: ap.ActivityUndo, + GTSModel: fave, + Receiving: receivingAcct, + Requesting: requestingAcct, + }) + return nil } @@ -298,10 +318,7 @@ func (f *federatingDB) undoBlock( // Convert AS Block to barebones *gtsmodel.Block, // retrieving origin + target accts from the DB. - block, err := f.converter.ASBlockToBlock( - gtscontext.SetBarebones(ctx), - asBlock, - ) + block, err := f.converter.ASBlockToBlock(ctx, asBlock) if err != nil && !errors.Is(err, db.ErrNoEntries) { err := gtserror.Newf("error converting AS Block to block: %w", err) return err @@ -333,7 +350,16 @@ func (f *federatingDB) undoBlock( return err } - log.Debug(ctx, "Block undone") + // Send the deleted block through to + // the fedi worker to process side effects. + f.state.Workers.Federator.Queue.Push(&messages.FromFediAPI{ + APObjectType: ap.ActivityBlock, + APActivityType: ap.ActivityUndo, + GTSModel: block, + Receiving: receivingAcct, + Requesting: requestingAcct, + }) + return nil } diff --git a/internal/federation/federator_test.go b/internal/federation/federator_test.go index a4f8c4683..7ea0432a1 100644 --- a/internal/federation/federator_test.go +++ b/internal/federation/federator_test.go @@ -23,7 +23,6 @@ import ( "github.com/stretchr/testify/suite" "github.com/superseriousbusiness/gotosocial/internal/federation" - "github.com/superseriousbusiness/gotosocial/internal/filter/visibility" "github.com/superseriousbusiness/gotosocial/internal/gtsmodel" "github.com/superseriousbusiness/gotosocial/internal/state" "github.com/superseriousbusiness/gotosocial/internal/storage" @@ -67,12 +66,6 @@ func (suite *FederatorStandardTestSuite) SetupTest() { suite.state.Storage = suite.storage suite.typeconverter = typeutils.NewConverter(&suite.state) - testrig.StartTimelines( - &suite.state, - visibility.NewFilter(&suite.state), - suite.typeconverter, - ) - // Ensure it's possible to deref // main key of foss satan. fossSatanAS, err := suite.typeconverter.AccountToAS(context.Background(), suite.testAccounts["remote_account_1"]) |
