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
|
return
|
||||||
} else {
|
} else {
|
||||||
if len(users) == 0 {
|
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]
|
user := users[0]
|
||||||
|
|||||||
@@ -834,6 +834,9 @@ func TestGetProfileImage(t *testing.T) {
|
|||||||
_, resp = Client.GetProfileImage("junk", "")
|
_, resp = Client.GetProfileImage("junk", "")
|
||||||
CheckBadRequestStatus(t, resp)
|
CheckBadRequestStatus(t, resp)
|
||||||
|
|
||||||
|
_, resp = Client.GetProfileImage(model.NewId(), "")
|
||||||
|
CheckNotFoundStatus(t, resp)
|
||||||
|
|
||||||
Client.Logout()
|
Client.Logout()
|
||||||
_, resp = Client.GetProfileImage(user.Id, "")
|
_, resp = Client.GetProfileImage(user.Id, "")
|
||||||
CheckUnauthorizedStatus(t, resp)
|
CheckUnauthorizedStatus(t, resp)
|
||||||
|
|||||||
@@ -3094,6 +3094,10 @@
|
|||||||
"id": "api.user.upload_profile_user.parse.app_error",
|
"id": "api.user.upload_profile_user.parse.app_error",
|
||||||
"translation": "Could not parse multipart form"
|
"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",
|
"id": "api.user.upload_profile_user.storage.app_error",
|
||||||
"translation": "Unable to upload file. Image storage is not configured."
|
"translation": "Unable to upload file. Image storage is not configured."
|
||||||
|
|||||||
Ссылка в новой задаче
Block a user