diff options
Diffstat (limited to 'internal/processing')
-rw-r--r-- | internal/processing/federation/getfollowers.go | 7 | ||||
-rw-r--r-- | internal/processing/federation/getfollowing.go | 7 | ||||
-rw-r--r-- | internal/processing/federation/getoutbox.go | 7 | ||||
-rw-r--r-- | internal/processing/federation/getstatus.go | 7 | ||||
-rw-r--r-- | internal/processing/federation/getstatusreplies.go | 7 | ||||
-rw-r--r-- | internal/processing/federation/getuser.go | 11 |
6 files changed, 18 insertions, 28 deletions
diff --git a/internal/processing/federation/getfollowers.go b/internal/processing/federation/getfollowers.go index c15b2b6c4..a49037397 100644 --- a/internal/processing/federation/getfollowers.go +++ b/internal/processing/federation/getfollowers.go @@ -20,7 +20,6 @@ package federation import ( "context" - "errors" "fmt" "net/url" @@ -36,9 +35,9 @@ func (p *processor) GetFollowers(ctx context.Context, requestedUsername string, } // authenticate the request - requestingAccountURI, authenticated, err := p.federator.AuthenticateFederatedRequest(ctx, requestedUsername) - if err != nil || !authenticated { - return nil, gtserror.NewErrorNotAuthorized(errors.New("not authorized"), "not authorized") + requestingAccountURI, errWithCode := p.federator.AuthenticateFederatedRequest(ctx, requestedUsername) + if errWithCode != nil { + return nil, errWithCode } requestingAccount, err := p.federator.GetRemoteAccount(ctx, requestedUsername, requestingAccountURI, false, false) diff --git a/internal/processing/federation/getfollowing.go b/internal/processing/federation/getfollowing.go index d2beaada0..a38c049fd 100644 --- a/internal/processing/federation/getfollowing.go +++ b/internal/processing/federation/getfollowing.go @@ -20,7 +20,6 @@ package federation import ( "context" - "errors" "fmt" "net/url" @@ -36,9 +35,9 @@ func (p *processor) GetFollowing(ctx context.Context, requestedUsername string, } // authenticate the request - requestingAccountURI, authenticated, err := p.federator.AuthenticateFederatedRequest(ctx, requestedUsername) - if err != nil || !authenticated { - return nil, gtserror.NewErrorNotAuthorized(errors.New("not authorized"), "not authorized") + requestingAccountURI, errWithCode := p.federator.AuthenticateFederatedRequest(ctx, requestedUsername) + if errWithCode != nil { + return nil, errWithCode } requestingAccount, err := p.federator.GetRemoteAccount(ctx, requestedUsername, requestingAccountURI, false, false) diff --git a/internal/processing/federation/getoutbox.go b/internal/processing/federation/getoutbox.go index 2c7511e45..455f427f3 100644 --- a/internal/processing/federation/getoutbox.go +++ b/internal/processing/federation/getoutbox.go @@ -20,7 +20,6 @@ package federation import ( "context" - "errors" "fmt" "net/url" @@ -37,9 +36,9 @@ func (p *processor) GetOutbox(ctx context.Context, requestedUsername string, pag } // authenticate the request - requestingAccountURI, authenticated, err := p.federator.AuthenticateFederatedRequest(ctx, requestedUsername) - if err != nil || !authenticated { - return nil, gtserror.NewErrorNotAuthorized(errors.New("not authorized"), "not authorized") + requestingAccountURI, errWithCode := p.federator.AuthenticateFederatedRequest(ctx, requestedUsername) + if errWithCode != nil { + return nil, errWithCode } requestingAccount, err := p.federator.GetRemoteAccount(ctx, requestedUsername, requestingAccountURI, false, false) diff --git a/internal/processing/federation/getstatus.go b/internal/processing/federation/getstatus.go index 3a32ffa59..820f1a19b 100644 --- a/internal/processing/federation/getstatus.go +++ b/internal/processing/federation/getstatus.go @@ -20,7 +20,6 @@ package federation import ( "context" - "errors" "fmt" "net/url" @@ -38,9 +37,9 @@ func (p *processor) GetStatus(ctx context.Context, requestedUsername string, req } // authenticate the request - requestingAccountURI, authenticated, err := p.federator.AuthenticateFederatedRequest(ctx, requestedUsername) - if err != nil || !authenticated { - return nil, gtserror.NewErrorNotAuthorized(errors.New("not authorized"), "not authorized") + requestingAccountURI, errWithCode := p.federator.AuthenticateFederatedRequest(ctx, requestedUsername) + if errWithCode != nil { + return nil, errWithCode } requestingAccount, err := p.federator.GetRemoteAccount(ctx, requestedUsername, requestingAccountURI, false, false) diff --git a/internal/processing/federation/getstatusreplies.go b/internal/processing/federation/getstatusreplies.go index c6db4dd3e..984f3a407 100644 --- a/internal/processing/federation/getstatusreplies.go +++ b/internal/processing/federation/getstatusreplies.go @@ -20,7 +20,6 @@ package federation import ( "context" - "errors" "fmt" "net/url" @@ -38,9 +37,9 @@ func (p *processor) GetStatusReplies(ctx context.Context, requestedUsername stri } // authenticate the request - requestingAccountURI, authenticated, err := p.federator.AuthenticateFederatedRequest(ctx, requestedUsername) - if err != nil || !authenticated { - return nil, gtserror.NewErrorNotAuthorized(errors.New("not authorized"), "not authorized") + requestingAccountURI, errWithCode := p.federator.AuthenticateFederatedRequest(ctx, requestedUsername) + if errWithCode != nil { + return nil, errWithCode } requestingAccount, err := p.federator.GetRemoteAccount(ctx, requestedUsername, requestingAccountURI, false, false) diff --git a/internal/processing/federation/getuser.go b/internal/processing/federation/getuser.go index b201bea4b..f870baa12 100644 --- a/internal/processing/federation/getuser.go +++ b/internal/processing/federation/getuser.go @@ -20,7 +20,6 @@ package federation import ( "context" - "errors" "fmt" "net/url" @@ -46,13 +45,9 @@ func (p *processor) GetUser(ctx context.Context, requestedUsername string, reque } } else { // if it's any other path, we want to fully authenticate the request before we serve any data, and then we can serve a more complete profile - requestingAccountURI, authenticated, err := p.federator.AuthenticateFederatedRequest(ctx, requestedUsername) - if err != nil { - return nil, gtserror.NewErrorNotAuthorized(err, "not authorized") - } - - if !authenticated { - return nil, gtserror.NewErrorNotAuthorized(errors.New("not authorized"), "not authorized") + requestingAccountURI, errWithCode := p.federator.AuthenticateFederatedRequest(ctx, requestedUsername) + if errWithCode != nil { + return nil, errWithCode } // if we're not already handshaking/dereferencing a remote account, dereference it now |