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,10 +42,14 @@ type displayName struct {
func GetProfile(
req *http.Request, accountDB *accounts.Database, userID string,
) util.JSONResponse {
if req.Method == "GET" {
if req.Method != "GET" {
return util.JSONResponse{
Code: 405,
JSON: jsonerror.NotFound("Bad method"),
}
}
localpart := getLocalPart(userID)
profile, err := accountDB.GetProfileByLocalpart(localpart)
if err == nil {
if profile, err := accountDB.GetProfileByLocalpart(localpart); err == nil {
res := profileResponse{
AvatarURL: profile.AvatarURL,
DisplayName: profile.DisplayName,
@ -60,11 +64,6 @@ func GetProfile(
JSON: jsonerror.Unknown("Failed to load user profile"),
}
}
return util.JSONResponse{
Code: 405,
JSON: jsonerror.NotFound("Bad method"),
}
}
// AvatarURL implements GET and PUT /profile/{userID}/avatar_url
func AvatarURL(