Applied requested changes

This commit is contained in:
Brendan Abolivier 2017-07-10 11:35:26 +01:00
parent 0dd83746d1
commit 54bc5129ff
No known key found for this signature in database
GPG key ID: 8EF1500759F70623

View file

@ -42,27 +42,26 @@ type displayName struct {
func GetProfile( func GetProfile(
req *http.Request, accountDB *accounts.Database, userID string, req *http.Request, accountDB *accounts.Database, userID string,
) util.JSONResponse { ) util.JSONResponse {
if req.Method == "GET" { if req.Method != "GET" {
localpart := getLocalPart(userID) return util.JSONResponse{
profile, err := accountDB.GetProfileByLocalpart(localpart) Code: 405,
if err == nil { JSON: jsonerror.NotFound("Bad method"),
res := profileResponse{ }
AvatarURL: profile.AvatarURL, }
DisplayName: profile.DisplayName, localpart := getLocalPart(userID)
} if profile, err := accountDB.GetProfileByLocalpart(localpart); err == nil {
return util.JSONResponse{ res := profileResponse{
Code: 200, AvatarURL: profile.AvatarURL,
JSON: res, DisplayName: profile.DisplayName,
}
} }
return util.JSONResponse{ return util.JSONResponse{
Code: 500, Code: 200,
JSON: jsonerror.Unknown("Failed to load user profile"), JSON: res,
} }
} }
return util.JSONResponse{ return util.JSONResponse{
Code: 405, Code: 500,
JSON: jsonerror.NotFound("Bad method"), JSON: jsonerror.Unknown("Failed to load user profile"),
} }
} }