summaryrefslogtreecommitdiff
path: root/internal/federation
diff options
context:
space:
mode:
authorLibravatar tobi <31960611+tsmethurst@users.noreply.github.com>2021-12-20 15:19:53 +0100
committerLibravatar GitHub <noreply@github.com>2021-12-20 15:19:53 +0100
commitcb8688f4298a1a3ed5e28565004588be3c071df0 (patch)
tree038b196e914b949857bf8b7c00f22374408bc1ca /internal/federation
parentreturn first offer when no accept header set (#351) (diff)
downloadgotosocial-cb8688f4298a1a3ed5e28565004588be3c071df0.tar.xz
Remove unnecessary storage config variables (#344)
* rewire config to not use extraneous serve vars * rename 'file' to 'local' for consistency * use Type and Size again
Diffstat (limited to 'internal/federation')
-rw-r--r--internal/federation/authenticate.go6
-rw-r--r--internal/federation/dereferencing/thread.go4
-rw-r--r--internal/federation/federatingdb/accept.go4
-rw-r--r--internal/federation/federatingdb/federatingdb_test.go8
-rw-r--r--internal/federation/federatingdb/get.go10
-rw-r--r--internal/federation/federatingdb/owns.go26
-rw-r--r--internal/federation/federatingdb/reject.go4
-rw-r--r--internal/federation/federatingdb/reject_test.go4
-rw-r--r--internal/federation/federatingdb/update.go3
-rw-r--r--internal/federation/federatingdb/util.go26
-rw-r--r--internal/federation/federatingprotocol.go15
-rw-r--r--internal/federation/federator_test.go14
-rw-r--r--internal/federation/transport.go10
13 files changed, 67 insertions, 67 deletions
diff --git a/internal/federation/authenticate.go b/internal/federation/authenticate.go
index 9d715c549..44e527dcb 100644
--- a/internal/federation/authenticate.go
+++ b/internal/federation/authenticate.go
@@ -35,10 +35,10 @@ import (
"github.com/superseriousbusiness/activity/pub"
"github.com/superseriousbusiness/activity/streams"
"github.com/superseriousbusiness/activity/streams/vocab"
+ "github.com/superseriousbusiness/gotosocial/internal/ap"
"github.com/superseriousbusiness/gotosocial/internal/config"
"github.com/superseriousbusiness/gotosocial/internal/db"
"github.com/superseriousbusiness/gotosocial/internal/gtsmodel"
- "github.com/superseriousbusiness/gotosocial/internal/util"
)
/*
@@ -123,7 +123,7 @@ func (f *federator) AuthenticateFederatedRequest(ctx context.Context, requestedU
var err error
// thanks to signaturecheck.go in the security package, we should already have a signature verifier set on the context
- vi := ctx.Value(util.APRequestingPublicKeyVerifier)
+ vi := ctx.Value(ap.ContextRequestingPublicKeyVerifier)
if vi == nil {
l.Debug("request wasn't signed")
return nil, false, nil // request wasn't signed
@@ -136,7 +136,7 @@ func (f *federator) AuthenticateFederatedRequest(ctx context.Context, requestedU
}
// we should have the signature itself set too
- si := ctx.Value(util.APRequestingPublicKeySignature)
+ si := ctx.Value(ap.ContextRequestingPublicKeySignature)
if vi == nil {
l.Debug("request wasn't signed")
return nil, false, nil // request wasn't signed
diff --git a/internal/federation/dereferencing/thread.go b/internal/federation/dereferencing/thread.go
index 209df32c4..4ff061d93 100644
--- a/internal/federation/dereferencing/thread.go
+++ b/internal/federation/dereferencing/thread.go
@@ -27,7 +27,7 @@ import (
"github.com/spf13/viper"
"github.com/superseriousbusiness/gotosocial/internal/ap"
"github.com/superseriousbusiness/gotosocial/internal/config"
- "github.com/superseriousbusiness/gotosocial/internal/util"
+ "github.com/superseriousbusiness/gotosocial/internal/uris"
)
// DereferenceThread takes a statusable (something that has withReplies and withInReplyTo),
@@ -85,7 +85,7 @@ func (d *deref) iterateAncestors(ctx context.Context, username string, statusIRI
l.Debug("iri belongs to us, moving up to next ancestor")
// since this is our status, we know we can extract the id from the status path
- _, id, err := util.ParseStatusesPath(&statusIRI)
+ _, id, err := uris.ParseStatusesPath(&statusIRI)
if err != nil {
return err
}
diff --git a/internal/federation/federatingdb/accept.go b/internal/federation/federatingdb/accept.go
index 8efb29b53..34cdc4fb5 100644
--- a/internal/federation/federatingdb/accept.go
+++ b/internal/federation/federatingdb/accept.go
@@ -29,7 +29,7 @@ import (
"github.com/superseriousbusiness/gotosocial/internal/db"
"github.com/superseriousbusiness/gotosocial/internal/gtsmodel"
"github.com/superseriousbusiness/gotosocial/internal/messages"
- "github.com/superseriousbusiness/gotosocial/internal/util"
+ "github.com/superseriousbusiness/gotosocial/internal/uris"
)
func (f *federatingDB) Accept(ctx context.Context, accept vocab.ActivityStreamsAccept) error {
@@ -66,7 +66,7 @@ func (f *federatingDB) Accept(ctx context.Context, accept vocab.ActivityStreamsA
if iter.IsIRI() {
// we have just the URI of whatever is being accepted, so we need to find out what it is
acceptedObjectIRI := iter.GetIRI()
- if util.IsFollowPath(acceptedObjectIRI) {
+ if uris.IsFollowPath(acceptedObjectIRI) {
// ACCEPT FOLLOW
gtsFollowRequest := &gtsmodel.FollowRequest{}
if err := f.db.GetWhere(ctx, []db.Where{{Key: "uri", Value: acceptedObjectIRI.String()}}, gtsFollowRequest); err != nil {
diff --git a/internal/federation/federatingdb/federatingdb_test.go b/internal/federation/federatingdb/federatingdb_test.go
index d51e0a825..71cc739c4 100644
--- a/internal/federation/federatingdb/federatingdb_test.go
+++ b/internal/federation/federatingdb/federatingdb_test.go
@@ -22,12 +22,12 @@ import (
"context"
"github.com/stretchr/testify/suite"
+ "github.com/superseriousbusiness/gotosocial/internal/ap"
"github.com/superseriousbusiness/gotosocial/internal/db"
"github.com/superseriousbusiness/gotosocial/internal/federation/federatingdb"
"github.com/superseriousbusiness/gotosocial/internal/gtsmodel"
"github.com/superseriousbusiness/gotosocial/internal/messages"
"github.com/superseriousbusiness/gotosocial/internal/typeutils"
- "github.com/superseriousbusiness/gotosocial/internal/util"
"github.com/superseriousbusiness/gotosocial/testrig"
)
@@ -75,8 +75,8 @@ func (suite *FederatingDBTestSuite) TearDownTest() {
func createTestContext(receivingAccount *gtsmodel.Account, requestingAccount *gtsmodel.Account, fromFederatorChan chan messages.FromFederator) context.Context {
ctx := context.Background()
- ctx = context.WithValue(ctx, util.APReceivingAccount, receivingAccount)
- ctx = context.WithValue(ctx, util.APRequestingAccount, requestingAccount)
- ctx = context.WithValue(ctx, util.APFromFederatorChanKey, fromFederatorChan)
+ ctx = context.WithValue(ctx, ap.ContextReceivingAccount, receivingAccount)
+ ctx = context.WithValue(ctx, ap.ContextRequestingAccount, requestingAccount)
+ ctx = context.WithValue(ctx, ap.ContextFromFederatorChan, fromFederatorChan)
return ctx
}
diff --git a/internal/federation/federatingdb/get.go b/internal/federation/federatingdb/get.go
index a409b7b91..ac3920c78 100644
--- a/internal/federation/federatingdb/get.go
+++ b/internal/federation/federatingdb/get.go
@@ -25,7 +25,7 @@ import (
"github.com/sirupsen/logrus"
"github.com/superseriousbusiness/activity/streams/vocab"
- "github.com/superseriousbusiness/gotosocial/internal/util"
+ "github.com/superseriousbusiness/gotosocial/internal/uris"
)
// Get returns the database entry for the specified id.
@@ -40,7 +40,7 @@ func (f *federatingDB) Get(ctx context.Context, id *url.URL) (value vocab.Type,
)
l.Debug("entering Get")
- if util.IsUserPath(id) {
+ if uris.IsUserPath(id) {
acct, err := f.db.GetAccountByURI(ctx, id.String())
if err != nil {
return nil, err
@@ -48,7 +48,7 @@ func (f *federatingDB) Get(ctx context.Context, id *url.URL) (value vocab.Type,
return f.typeConverter.AccountToAS(ctx, acct)
}
- if util.IsStatusesPath(id) {
+ if uris.IsStatusesPath(id) {
status, err := f.db.GetStatusByURI(ctx, id.String())
if err != nil {
return nil, err
@@ -56,11 +56,11 @@ func (f *federatingDB) Get(ctx context.Context, id *url.URL) (value vocab.Type,
return f.typeConverter.StatusToAS(ctx, status)
}
- if util.IsFollowersPath(id) {
+ if uris.IsFollowersPath(id) {
return f.Followers(ctx, id)
}
- if util.IsFollowingPath(id) {
+ if uris.IsFollowingPath(id) {
return f.Following(ctx, id)
}
diff --git a/internal/federation/federatingdb/owns.go b/internal/federation/federatingdb/owns.go
index 2603c9aa2..15e3dea0a 100644
--- a/internal/federation/federatingdb/owns.go
+++ b/internal/federation/federatingdb/owns.go
@@ -28,7 +28,7 @@ import (
"github.com/superseriousbusiness/gotosocial/internal/config"
"github.com/superseriousbusiness/gotosocial/internal/db"
"github.com/superseriousbusiness/gotosocial/internal/gtsmodel"
- "github.com/superseriousbusiness/gotosocial/internal/util"
+ "github.com/superseriousbusiness/gotosocial/internal/uris"
)
// Owns returns true if the IRI belongs to this instance, and if
@@ -52,8 +52,8 @@ func (f *federatingDB) Owns(ctx context.Context, id *url.URL) (bool, error) {
// apparently it belongs to this host, so what *is* it?
// check if it's a status, eg /users/example_username/statuses/SOME_UUID_OF_A_STATUS
- if util.IsStatusesPath(id) {
- _, uid, err := util.ParseStatusesPath(id)
+ if uris.IsStatusesPath(id) {
+ _, uid, err := uris.ParseStatusesPath(id)
if err != nil {
return false, fmt.Errorf("error parsing statuses path for url %s: %s", id.String(), err)
}
@@ -69,8 +69,8 @@ func (f *federatingDB) Owns(ctx context.Context, id *url.URL) (bool, error) {
return status.Local, nil
}
- if util.IsUserPath(id) {
- username, err := util.ParseUserPath(id)
+ if uris.IsUserPath(id) {
+ username, err := uris.ParseUserPath(id)
if err != nil {
return false, fmt.Errorf("error parsing statuses path for url %s: %s", id.String(), err)
}
@@ -86,8 +86,8 @@ func (f *federatingDB) Owns(ctx context.Context, id *url.URL) (bool, error) {
return true, nil
}
- if util.IsFollowersPath(id) {
- username, err := util.ParseFollowersPath(id)
+ if uris.IsFollowersPath(id) {
+ username, err := uris.ParseFollowersPath(id)
if err != nil {
return false, fmt.Errorf("error parsing statuses path for url %s: %s", id.String(), err)
}
@@ -103,8 +103,8 @@ func (f *federatingDB) Owns(ctx context.Context, id *url.URL) (bool, error) {
return true, nil
}
- if util.IsFollowingPath(id) {
- username, err := util.ParseFollowingPath(id)
+ if uris.IsFollowingPath(id) {
+ username, err := uris.ParseFollowingPath(id)
if err != nil {
return false, fmt.Errorf("error parsing statuses path for url %s: %s", id.String(), err)
}
@@ -120,8 +120,8 @@ func (f *federatingDB) Owns(ctx context.Context, id *url.URL) (bool, error) {
return true, nil
}
- if util.IsLikePath(id) {
- username, likeID, err := util.ParseLikedPath(id)
+ if uris.IsLikePath(id) {
+ username, likeID, err := uris.ParseLikedPath(id)
if err != nil {
return false, fmt.Errorf("error parsing like path for url %s: %s", id.String(), err)
}
@@ -145,8 +145,8 @@ func (f *federatingDB) Owns(ctx context.Context, id *url.URL) (bool, error) {
return true, nil
}
- if util.IsBlockPath(id) {
- username, blockID, err := util.ParseBlockPath(id)
+ if uris.IsBlockPath(id) {
+ username, blockID, err := uris.ParseBlockPath(id)
if err != nil {
return false, fmt.Errorf("error parsing block path for url %s: %s", id.String(), err)
}
diff --git a/internal/federation/federatingdb/reject.go b/internal/federation/federatingdb/reject.go
index 15d4a87ae..2ecdc829e 100644
--- a/internal/federation/federatingdb/reject.go
+++ b/internal/federation/federatingdb/reject.go
@@ -28,7 +28,7 @@ import (
"github.com/superseriousbusiness/gotosocial/internal/ap"
"github.com/superseriousbusiness/gotosocial/internal/db"
"github.com/superseriousbusiness/gotosocial/internal/gtsmodel"
- "github.com/superseriousbusiness/gotosocial/internal/util"
+ "github.com/superseriousbusiness/gotosocial/internal/uris"
)
func (f *federatingDB) Reject(ctx context.Context, reject vocab.ActivityStreamsReject) error {
@@ -65,7 +65,7 @@ func (f *federatingDB) Reject(ctx context.Context, reject vocab.ActivityStreamsR
if iter.IsIRI() {
// we have just the URI of whatever is being rejected, so we need to find out what it is
rejectedObjectIRI := iter.GetIRI()
- if util.IsFollowPath(rejectedObjectIRI) {
+ if uris.IsFollowPath(rejectedObjectIRI) {
// REJECT FOLLOW
gtsFollowRequest := &gtsmodel.FollowRequest{}
if err := f.db.GetWhere(ctx, []db.Where{{Key: "uri", Value: rejectedObjectIRI.String()}}, gtsFollowRequest); err != nil {
diff --git a/internal/federation/federatingdb/reject_test.go b/internal/federation/federatingdb/reject_test.go
index 9930d83d2..700330c1f 100644
--- a/internal/federation/federatingdb/reject_test.go
+++ b/internal/federation/federatingdb/reject_test.go
@@ -27,7 +27,7 @@ import (
"github.com/superseriousbusiness/gotosocial/internal/db"
"github.com/superseriousbusiness/gotosocial/internal/gtsmodel"
"github.com/superseriousbusiness/gotosocial/internal/messages"
- "github.com/superseriousbusiness/gotosocial/internal/util"
+ "github.com/superseriousbusiness/gotosocial/internal/uris"
"github.com/superseriousbusiness/gotosocial/testrig"
)
@@ -48,7 +48,7 @@ func (suite *RejectTestSuite) TestRejectFollowRequest() {
ID: "01FJ1S8DX3STJJ6CEYPMZ1M0R3",
CreatedAt: time.Now(),
UpdatedAt: time.Now(),
- URI: util.GenerateURIForFollow(followingAccount.Username, "01FJ1S8DX3STJJ6CEYPMZ1M0R3"),
+ URI: uris.GenerateURIForFollow(followingAccount.Username, "01FJ1S8DX3STJJ6CEYPMZ1M0R3"),
AccountID: followingAccount.ID,
TargetAccountID: followedAccount.ID,
}
diff --git a/internal/federation/federatingdb/update.go b/internal/federation/federatingdb/update.go
index 1d56b931f..e95e128cd 100644
--- a/internal/federation/federatingdb/update.go
+++ b/internal/federation/federatingdb/update.go
@@ -30,7 +30,6 @@ import (
"github.com/superseriousbusiness/gotosocial/internal/config"
"github.com/superseriousbusiness/gotosocial/internal/gtsmodel"
"github.com/superseriousbusiness/gotosocial/internal/messages"
- "github.com/superseriousbusiness/gotosocial/internal/util"
)
// Update sets an existing entry to the database based on the value's
@@ -66,7 +65,7 @@ func (f *federatingDB) Update(ctx context.Context, asType vocab.Type) error {
return nil
}
- requestingAcctI := ctx.Value(util.APRequestingAccount)
+ requestingAcctI := ctx.Value(ap.ContextRequestingAccount)
if requestingAcctI == nil {
l.Error("UPDATE: requesting account wasn't set on context")
}
diff --git a/internal/federation/federatingdb/util.go b/internal/federation/federatingdb/util.go
index afa09e39d..56512e0af 100644
--- a/internal/federation/federatingdb/util.go
+++ b/internal/federation/federatingdb/util.go
@@ -35,7 +35,7 @@ import (
"github.com/superseriousbusiness/gotosocial/internal/gtsmodel"
"github.com/superseriousbusiness/gotosocial/internal/id"
"github.com/superseriousbusiness/gotosocial/internal/messages"
- "github.com/superseriousbusiness/gotosocial/internal/util"
+ "github.com/superseriousbusiness/gotosocial/internal/uris"
)
func sameActor(activityActor vocab.ActivityStreamsActorProperty, followActor vocab.ActivityStreamsActorProperty) bool {
@@ -106,7 +106,7 @@ func (f *federatingDB) NewID(ctx context.Context, t vocab.Type) (idURL *url.URL,
if err != nil {
return nil, err
}
- return url.Parse(util.GenerateURIForFollow(actorAccount.Username, newID))
+ return url.Parse(uris.GenerateURIForFollow(actorAccount.Username, newID))
}
}
}
@@ -241,7 +241,7 @@ func (f *federatingDB) ActorForInbox(ctx context.Context, inboxIRI *url.URL) (ac
func (f *federatingDB) getAccountForIRI(ctx context.Context, iri *url.URL) (account *gtsmodel.Account, err error) {
acct := &gtsmodel.Account{}
- if util.IsInboxPath(iri) {
+ if uris.IsInboxPath(iri) {
if err := f.db.GetWhere(ctx, []db.Where{{Key: "inbox_uri", Value: iri.String()}}, acct); err != nil {
if err == db.ErrNoEntries {
return nil, fmt.Errorf("no actor found that corresponds to inbox %s", iri.String())
@@ -251,7 +251,7 @@ func (f *federatingDB) getAccountForIRI(ctx context.Context, iri *url.URL) (acco
return acct, nil
}
- if util.IsOutboxPath(iri) {
+ if uris.IsOutboxPath(iri) {
if err := f.db.GetWhere(ctx, []db.Where{{Key: "outbox_uri", Value: iri.String()}}, acct); err != nil {
if err == db.ErrNoEntries {
return nil, fmt.Errorf("no actor found that corresponds to outbox %s", iri.String())
@@ -261,7 +261,7 @@ func (f *federatingDB) getAccountForIRI(ctx context.Context, iri *url.URL) (acco
return acct, nil
}
- if util.IsUserPath(iri) {
+ if uris.IsUserPath(iri) {
if err := f.db.GetWhere(ctx, []db.Where{{Key: "uri", Value: iri.String()}}, acct); err != nil {
if err == db.ErrNoEntries {
return nil, fmt.Errorf("no actor found that corresponds to uri %s", iri.String())
@@ -271,7 +271,7 @@ func (f *federatingDB) getAccountForIRI(ctx context.Context, iri *url.URL) (acco
return acct, nil
}
- if util.IsFollowersPath(iri) {
+ if uris.IsFollowersPath(iri) {
if err := f.db.GetWhere(ctx, []db.Where{{Key: "followers_uri", Value: iri.String()}}, acct); err != nil {
if err == db.ErrNoEntries {
return nil, fmt.Errorf("no actor found that corresponds to followers_uri %s", iri.String())
@@ -281,7 +281,7 @@ func (f *federatingDB) getAccountForIRI(ctx context.Context, iri *url.URL) (acco
return acct, nil
}
- if util.IsFollowingPath(iri) {
+ if uris.IsFollowingPath(iri) {
if err := f.db.GetWhere(ctx, []db.Where{{Key: "following_uri", Value: iri.String()}}, acct); err != nil {
if err == db.ErrNoEntries {
return nil, fmt.Errorf("no actor found that corresponds to following_uri %s", iri.String())
@@ -311,30 +311,30 @@ func (f *federatingDB) collectIRIs(ctx context.Context, iris []*url.URL) (vocab.
// - A channel that messages for the processor can be placed into.
// If a value is not present, nil will be returned for it. It's up to the caller to check this and respond appropriately.
func extractFromCtx(ctx context.Context) (receivingAccount, requestingAccount *gtsmodel.Account, fromFederatorChan chan messages.FromFederator) {
- receivingAccountI := ctx.Value(util.APReceivingAccount)
+ receivingAccountI := ctx.Value(ap.ContextReceivingAccount)
if receivingAccountI != nil {
var ok bool
receivingAccount, ok = receivingAccountI.(*gtsmodel.Account)
if !ok {
- logrus.Panicf("extractFromCtx: context entry with key %s could not be asserted to *gtsmodel.Account", util.APReceivingAccount)
+ logrus.Panicf("extractFromCtx: context entry with key %s could not be asserted to *gtsmodel.Account", ap.ContextReceivingAccount)
}
}
- requestingAcctI := ctx.Value(util.APRequestingAccount)
+ requestingAcctI := ctx.Value(ap.ContextRequestingAccount)
if requestingAcctI != nil {
var ok bool
requestingAccount, ok = requestingAcctI.(*gtsmodel.Account)
if !ok {
- logrus.Panicf("extractFromCtx: context entry with key %s could not be asserted to *gtsmodel.Account", util.APRequestingAccount)
+ logrus.Panicf("extractFromCtx: context entry with key %s could not be asserted to *gtsmodel.Account", ap.ContextRequestingAccount)
}
}
- fromFederatorChanI := ctx.Value(util.APFromFederatorChanKey)
+ fromFederatorChanI := ctx.Value(ap.ContextFromFederatorChan)
if fromFederatorChanI != nil {
var ok bool
fromFederatorChan, ok = fromFederatorChanI.(chan messages.FromFederator)
if !ok {
- logrus.Panicf("extractFromCtx: context entry with key %s could not be asserted to chan messages.FromFederator", util.APFromFederatorChanKey)
+ logrus.Panicf("extractFromCtx: context entry with key %s could not be asserted to chan messages.FromFederator", ap.ContextFromFederatorChan)
}
}
diff --git a/internal/federation/federatingprotocol.go b/internal/federation/federatingprotocol.go
index be5ab4d85..636fed3c5 100644
--- a/internal/federation/federatingprotocol.go
+++ b/internal/federation/federatingprotocol.go
@@ -29,9 +29,10 @@ import (
"github.com/superseriousbusiness/activity/pub"
"github.com/superseriousbusiness/activity/streams"
"github.com/superseriousbusiness/activity/streams/vocab"
+ "github.com/superseriousbusiness/gotosocial/internal/ap"
"github.com/superseriousbusiness/gotosocial/internal/db"
"github.com/superseriousbusiness/gotosocial/internal/gtsmodel"
- "github.com/superseriousbusiness/gotosocial/internal/util"
+ "github.com/superseriousbusiness/gotosocial/internal/uris"
)
/*
@@ -73,7 +74,7 @@ func (f *federator) PostInboxRequestBodyHook(ctx context.Context, r *http.Reques
return nil, err
}
// set the activity on the context for use later on
- return context.WithValue(ctx, util.APActivity, activity), nil
+ return context.WithValue(ctx, ap.ContextActivity, activity), nil
}
// AuthenticatePostInbox delegates the authentication of a POST to an
@@ -100,11 +101,11 @@ func (f *federator) AuthenticatePostInbox(ctx context.Context, w http.ResponseWr
})
l.Trace("received request to authenticate")
- if !util.IsInboxPath(r.URL) {
+ if !uris.IsInboxPath(r.URL) {
return nil, false, fmt.Errorf("path %s was not an inbox path", r.URL.String())
}
- username, err := util.ParseInboxPath(r.URL)
+ username, err := uris.ParseInboxPath(r.URL)
if err != nil {
return nil, false, fmt.Errorf("could not parse path %s: %s", r.URL.String(), err)
}
@@ -157,8 +158,8 @@ func (f *federator) AuthenticatePostInbox(ctx context.Context, w http.ResponseWr
return nil, false, fmt.Errorf("couldn't get requesting account %s: %s", publicKeyOwnerURI, err)
}
- withRequesting := context.WithValue(ctx, util.APRequestingAccount, requestingAccount)
- withReceiving := context.WithValue(withRequesting, util.APReceivingAccount, receivingAccount)
+ withRequesting := context.WithValue(ctx, ap.ContextRequestingAccount, requestingAccount)
+ withReceiving := context.WithValue(withRequesting, ap.ContextReceivingAccount, receivingAccount)
return withReceiving, true, nil
}
@@ -182,7 +183,7 @@ func (f *federator) Blocked(ctx context.Context, actorIRIs []*url.URL) (bool, er
})
l.Debugf("entering BLOCKED function with IRI list: %+v", actorIRIs)
- receivingAccountI := ctx.Value(util.APReceivingAccount)
+ receivingAccountI := ctx.Value(ap.ContextReceivingAccount)
receivingAccount, ok := receivingAccountI.(*gtsmodel.Account)
if !ok {
l.Errorf("receiving account not set on request context")
diff --git a/internal/federation/federator_test.go b/internal/federation/federator_test.go
index f907ac00b..20a0b7d46 100644
--- a/internal/federation/federator_test.go
+++ b/internal/federation/federator_test.go
@@ -30,11 +30,11 @@ import (
"github.com/stretchr/testify/suite"
"github.com/superseriousbusiness/activity/pub"
+ "github.com/superseriousbusiness/gotosocial/internal/ap"
"github.com/superseriousbusiness/gotosocial/internal/db"
"github.com/superseriousbusiness/gotosocial/internal/federation"
"github.com/superseriousbusiness/gotosocial/internal/gtsmodel"
"github.com/superseriousbusiness/gotosocial/internal/typeutils"
- "github.com/superseriousbusiness/gotosocial/internal/util"
"github.com/superseriousbusiness/gotosocial/testrig"
)
@@ -91,7 +91,7 @@ func (suite *ProtocolTestSuite) TestPostInboxRequestBodyHook() {
assert.NotNil(suite.T(), newContext)
// activity should be set on context now
- activityI := newContext.Value(util.APActivity)
+ activityI := newContext.Value(ap.ContextActivity)
assert.NotNil(suite.T(), activityI)
returnedActivity, ok := activityI.(pub.Activity)
assert.True(suite.T(), ok)
@@ -121,10 +121,10 @@ func (suite *ProtocolTestSuite) TestAuthenticatePostInbox() {
ctx := context.Background()
// by the time AuthenticatePostInbox is called, PostInboxRequestBodyHook should have already been called,
// which should have set the account and username onto the request. We can replicate that behavior here:
- ctxWithAccount := context.WithValue(ctx, util.APReceivingAccount, inboxAccount)
- ctxWithActivity := context.WithValue(ctxWithAccount, util.APActivity, activity)
- ctxWithVerifier := context.WithValue(ctxWithActivity, util.APRequestingPublicKeyVerifier, verifier)
- ctxWithSignature := context.WithValue(ctxWithVerifier, util.APRequestingPublicKeySignature, activity.SignatureHeader)
+ ctxWithAccount := context.WithValue(ctx, ap.ContextReceivingAccount, inboxAccount)
+ ctxWithActivity := context.WithValue(ctxWithAccount, ap.ContextActivity, activity)
+ ctxWithVerifier := context.WithValue(ctxWithActivity, ap.ContextRequestingPublicKeyVerifier, verifier)
+ ctxWithSignature := context.WithValue(ctxWithVerifier, ap.ContextRequestingPublicKeySignature, activity.SignatureHeader)
// we can pass this recorder as a writer and read it back after
recorder := httptest.NewRecorder()
@@ -135,7 +135,7 @@ func (suite *ProtocolTestSuite) TestAuthenticatePostInbox() {
assert.True(suite.T(), authed)
// since we know this account already it should be set on the context
- requestingAccountI := newContext.Value(util.APRequestingAccount)
+ requestingAccountI := newContext.Value(ap.ContextRequestingAccount)
assert.NotNil(suite.T(), requestingAccountI)
requestingAccount, ok := requestingAccountI.(*gtsmodel.Account)
assert.True(suite.T(), ok)
diff --git a/internal/federation/transport.go b/internal/federation/transport.go
index 3287f6952..1391b90d7 100644
--- a/internal/federation/transport.go
+++ b/internal/federation/transport.go
@@ -24,7 +24,7 @@ import (
"net/url"
"github.com/superseriousbusiness/activity/pub"
- "github.com/superseriousbusiness/gotosocial/internal/util"
+ "github.com/superseriousbusiness/gotosocial/internal/uris"
)
// NewTransport returns a new Transport on behalf of a specific actor.
@@ -55,13 +55,13 @@ func (f *federator) NewTransport(ctx context.Context, actorBoxIRI *url.URL, gofe
var err error
switch {
- case util.IsInboxPath(actorBoxIRI):
- username, err = util.ParseInboxPath(actorBoxIRI)
+ case uris.IsInboxPath(actorBoxIRI):
+ username, err = uris.ParseInboxPath(actorBoxIRI)
if err != nil {
return nil, fmt.Errorf("couldn't parse path %s as an inbox: %s", actorBoxIRI.String(), err)
}
- case util.IsOutboxPath(actorBoxIRI):
- username, err = util.ParseOutboxPath(actorBoxIRI)
+ case uris.IsOutboxPath(actorBoxIRI):
+ username, err = uris.ParseOutboxPath(actorBoxIRI)
if err != nil {
return nil, fmt.Errorf("couldn't parse path %s as an outbox: %s", actorBoxIRI.String(), err)
}