MM-12067: Add SetDefaultProfileImage to reset the user profile image to a generated one (#9449)
* MM-12067: Add SetDefaultProfileImage to reset the user profile image to a generated one * Allow to get the default profile image for my user * Allowing to reset the last update image date to 0 * PR reviews
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
3e462713de
Коммит
c82a84ed76
@@ -723,7 +723,23 @@ func (c *Client4) AutocompleteUsers(username string, etag string) (*UserAutocomp
|
||||
}
|
||||
}
|
||||
|
||||
// GetProfileImage gets user's profile image. Must be logged in or be a system administrator.
|
||||
// GetDefaultProfileImage gets the default user's profile image. Must be logged in.
|
||||
func (c *Client4) GetDefaultProfileImage(userId string) ([]byte, *Response) {
|
||||
r, appErr := c.DoApiGet(c.GetUserRoute(userId)+"/image/default", "")
|
||||
if appErr != nil {
|
||||
return nil, BuildErrorResponse(r, appErr)
|
||||
}
|
||||
defer closeBody(r)
|
||||
|
||||
data, err := ioutil.ReadAll(r.Body)
|
||||
if err != nil {
|
||||
return nil, BuildErrorResponse(r, NewAppError("GetDefaultProfileImage", "model.client.read_file.app_error", nil, err.Error(), r.StatusCode))
|
||||
}
|
||||
|
||||
return data, BuildResponse(r)
|
||||
}
|
||||
|
||||
// GetProfileImage gets user's profile image. Must be logged in.
|
||||
func (c *Client4) GetProfileImage(userId, etag string) ([]byte, *Response) {
|
||||
if r, err := c.DoApiGet(c.GetUserRoute(userId)+"/image", etag); err != nil {
|
||||
return nil, BuildErrorResponse(r, err)
|
||||
@@ -1105,6 +1121,15 @@ func (c *Client4) SendVerificationEmail(email string) (bool, *Response) {
|
||||
}
|
||||
}
|
||||
|
||||
// SetDefaultProfileImage resets the profile image to a default generated one
|
||||
func (c *Client4) SetDefaultProfileImage(userId string) (bool, *Response) {
|
||||
r, err := c.DoApiDelete(c.GetUserRoute(userId) + "/image")
|
||||
if err != nil {
|
||||
return false, BuildErrorResponse(r, err)
|
||||
}
|
||||
return CheckStatusOK(r), BuildResponse(r)
|
||||
}
|
||||
|
||||
// SetProfileImage sets profile image of the user
|
||||
func (c *Client4) SetProfileImage(userId string, data []byte) (bool, *Response) {
|
||||
body := &bytes.Buffer{}
|
||||
|
||||
Ссылка в новой задаче
Block a user