mirror of
https://github.com/superseriousbusiness/gotosocial.git
synced 2025-11-15 20:57:29 -06:00
start refactoring return codes from fedi endpoints, remove some cruft
This commit is contained in:
parent
c6044d0142
commit
47051a26d6
28 changed files with 346 additions and 291 deletions
|
|
@ -34,7 +34,7 @@ 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))
|
||||
requestedUsername := strings.ToLower(c.Param(apiutil.UsernameKey))
|
||||
if requestedUsername == "" {
|
||||
err := errors.New("no username specified in request")
|
||||
apiutil.ErrorHandler(c, gtserror.NewErrorBadRequest(err, err.Error()), m.processor.InstanceGetV1)
|
||||
|
|
@ -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)
|
||||
return
|
||||
}
|
||||
|
||||
resp, errWithCode := m.processor.Fedi().UserGet(c.Request.Context(), requestedUsername, c.Request.URL)
|
||||
resp, errWithCode := m.processor.Fedi().UserGetMinimal(
|
||||
c.Request.Context(),
|
||||
requestedUsername,
|
||||
)
|
||||
if errWithCode != nil {
|
||||
apiutil.ErrorHandler(c, errWithCode, m.processor.InstanceGetV1)
|
||||
return
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue