Fix error handling when requesting profile image for bad user ID (#8618)
Этот коммит содержится в:
коммит произвёл
Christopher Speller
родитель
ae5e324be8
Коммит
21b1cd44e0
@@ -199,7 +199,8 @@ func getProfileImage(c *Context, w http.ResponseWriter, r *http.Request) {
|
||||
return
|
||||
} else {
|
||||
if len(users) == 0 {
|
||||
c.Err = err
|
||||
c.Err = model.NewAppError("getProfileImage", "api.user.get_profile_image.not_found.app_error", nil, "", http.StatusNotFound)
|
||||
return
|
||||
}
|
||||
|
||||
user := users[0]
|
||||
|
||||
@@ -834,6 +834,9 @@ func TestGetProfileImage(t *testing.T) {
|
||||
_, resp = Client.GetProfileImage("junk", "")
|
||||
CheckBadRequestStatus(t, resp)
|
||||
|
||||
_, resp = Client.GetProfileImage(model.NewId(), "")
|
||||
CheckNotFoundStatus(t, resp)
|
||||
|
||||
Client.Logout()
|
||||
_, resp = Client.GetProfileImage(user.Id, "")
|
||||
CheckUnauthorizedStatus(t, resp)
|
||||
|
||||
@@ -3094,6 +3094,10 @@
|
||||
"id": "api.user.upload_profile_user.parse.app_error",
|
||||
"translation": "Could not parse multipart form"
|
||||
},
|
||||
{
|
||||
"id": "api.user.get_profile_image.not_found.app_error",
|
||||
"translation": "Unable to get profile image, user not found."
|
||||
},
|
||||
{
|
||||
"id": "api.user.upload_profile_user.storage.app_error",
|
||||
"translation": "Unable to upload file. Image storage is not configured."
|
||||
|
||||
Ссылка в новой задаче
Block a user