From 24fbdf2b0a820684b69b10893e82cdb1a76ca14d Mon Sep 17 00:00:00 2001 From: tobi <31960611+tsmethurst@users.noreply.github.com> Date: Tue, 13 Jun 2023 16:47:56 +0200 Subject: [chore] Refactor AP authentication, other small bits of tidying up (#1874) --- internal/web/thread.go | 21 +++++---------------- 1 file changed, 5 insertions(+), 16 deletions(-) (limited to 'internal/web/thread.go') diff --git a/internal/web/thread.go b/internal/web/thread.go index 8d4e99bef..41f81eb14 100644 --- a/internal/web/thread.go +++ b/internal/web/thread.go @@ -26,7 +26,6 @@ import ( "strings" "github.com/gin-gonic/gin" - "github.com/superseriousbusiness/gotosocial/internal/ap" apimodel "github.com/superseriousbusiness/gotosocial/internal/api/model" apiutil "github.com/superseriousbusiness/gotosocial/internal/api/util" "github.com/superseriousbusiness/gotosocial/internal/config" @@ -92,7 +91,7 @@ func (m *Module) threadGETHandler(c *gin.Context) { // should render the status's AP representation instead accept := apiutil.NegotiateFormat(c, string(apiutil.TextHTML), string(apiutil.AppActivityJSON), string(apiutil.AppActivityLDJSON)) if accept == string(apiutil.AppActivityJSON) || accept == string(apiutil.AppActivityLDJSON) { - m.returnAPStatus(ctx, c, username, statusID, accept) + m.returnAPStatus(c, username, statusID, accept) return } @@ -120,27 +119,17 @@ func (m *Module) threadGETHandler(c *gin.Context) { }) } -func (m *Module) returnAPStatus(ctx context.Context, c *gin.Context, username string, statusID string, accept string) { - verifier, signed := c.Get(string(ap.ContextRequestingPublicKeyVerifier)) - if signed { - ctx = context.WithValue(ctx, ap.ContextRequestingPublicKeyVerifier, verifier) - } - - signature, signed := c.Get(string(ap.ContextRequestingPublicKeySignature)) - if signed { - ctx = context.WithValue(ctx, ap.ContextRequestingPublicKeySignature, signature) - } - - status, errWithCode := m.processor.Fedi().StatusGet(ctx, username, statusID) +func (m *Module) returnAPStatus(c *gin.Context, username string, statusID string, accept string) { + status, errWithCode := m.processor.Fedi().StatusGet(c.Request.Context(), username, statusID) if errWithCode != nil { - apiutil.WebErrorHandler(c, errWithCode, m.processor.InstanceGetV1) //nolint:contextcheck + apiutil.WebErrorHandler(c, errWithCode, m.processor.InstanceGetV1) return } b, mErr := json.Marshal(status) if mErr != nil { err := fmt.Errorf("could not marshal json: %s", mErr) - apiutil.WebErrorHandler(c, gtserror.NewErrorInternalError(err), m.processor.InstanceGetV1) //nolint:contextcheck + apiutil.WebErrorHandler(c, gtserror.NewErrorInternalError(err), m.processor.InstanceGetV1) return } -- cgit v1.2.3