diff options
Diffstat (limited to 'internal/api/activitypub/publickey')
| -rw-r--r-- | internal/api/activitypub/publickey/publickey.go | 9 | ||||
| -rw-r--r-- | internal/api/activitypub/publickey/publickeyget.go | 14 |
2 files changed, 12 insertions, 11 deletions
diff --git a/internal/api/activitypub/publickey/publickey.go b/internal/api/activitypub/publickey/publickey.go index 161123048..eaca9a39b 100644 --- a/internal/api/activitypub/publickey/publickey.go +++ b/internal/api/activitypub/publickey/publickey.go @@ -20,17 +20,14 @@ package publickey import ( "net/http" + apiutil "code.superseriousbusiness.org/gotosocial/internal/api/util" + "code.superseriousbusiness.org/gotosocial/internal/processing" "code.superseriousbusiness.org/gotosocial/internal/uris" "github.com/gin-gonic/gin" ) -const ( - // UsernameKey is for account usernames. - UsernameKey = "username" - // PublicKeyPath is a path to a user's public key, for serving bare minimum AP representations. - PublicKeyPath = "users/:" + UsernameKey + "/" + uris.PublicKeyPath -) +const PublicKeyPath = "users/:" + apiutil.UsernameKey + "/" + uris.PublicKeyPath type Module struct { processor *processing.Processor diff --git a/internal/api/activitypub/publickey/publickeyget.go b/internal/api/activitypub/publickey/publickeyget.go index 6e050a3b5..f1b07c2d2 100644 --- a/internal/api/activitypub/publickey/publickeyget.go +++ b/internal/api/activitypub/publickey/publickeyget.go @@ -34,8 +34,8 @@ import ( // public key, username, and type of the account. func (m *Module) PublicKeyGETHandler(c *gin.Context) { // usernames on our instance are always lowercase - requestedUsername := strings.ToLower(c.Param(UsernameKey)) - if requestedUsername == "" { + requestedUser := strings.ToLower(c.Param(apiutil.UsernameKey)) + if requestedUser == "" { err := errors.New("no username specified in request") apiutil.ErrorHandler(c, gtserror.NewErrorBadRequest(err, err.Error()), m.processor.InstanceGetV1) return @@ -47,13 +47,17 @@ func (m *Module) PublicKeyGETHandler(c *gin.Context) { return } + // If HTML is requested, redirect + // to user's profile instead. if contentType == string(apiutil.TextHTML) { - // redirect to the user's profile - c.Redirect(http.StatusSeeOther, "/@"+requestedUsername) + c.Redirect(http.StatusSeeOther, "/@"+requestedUser) return } - resp, errWithCode := m.processor.Fedi().UserGet(c.Request.Context(), requestedUsername, c.Request.URL) + resp, errWithCode := m.processor.Fedi().UserGetMinimal( + c.Request.Context(), + requestedUser, + ) if errWithCode != nil { apiutil.ErrorHandler(c, errWithCode, m.processor.InstanceGetV1) return |
