MM24459: Implement ldap picture sync (#14540)
* implement ldap picture sync * add testing timeout, and no change * Revert "add testing timeout, and no change" This reverts commit 765621a7290074e5664c4ca2a2843c84e01f4cf1. * update app-layer * updates from code review * update app-layers * remove debug statements Co-authored-by: mattermod <mattermod@users.noreply.github.com>
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
d7cb890f34
Коммит
e8081b7a0f
15
app/user.go
15
app/user.go
@@ -855,12 +855,11 @@ func (a *App) SetProfileImageFromMultiPartFile(userId string, file multipart.Fil
|
||||
return a.SetProfileImageFromFile(userId, file)
|
||||
}
|
||||
|
||||
func (a *App) SetProfileImageFromFile(userId string, file io.Reader) *model.AppError {
|
||||
|
||||
func (a *App) AdjustImage(file io.Reader) (*bytes.Buffer, *model.AppError) {
|
||||
// Decode image into Image object
|
||||
img, _, err := image.Decode(file)
|
||||
if err != nil {
|
||||
return model.NewAppError("SetProfileImage", "api.user.upload_profile_user.decode.app_error", nil, err.Error(), http.StatusBadRequest)
|
||||
return nil, model.NewAppError("SetProfileImage", "api.user.upload_profile_user.decode.app_error", nil, err.Error(), http.StatusBadRequest)
|
||||
}
|
||||
|
||||
orientation, _ := getImageOrientation(file)
|
||||
@@ -873,9 +872,17 @@ func (a *App) SetProfileImageFromFile(userId string, file io.Reader) *model.AppE
|
||||
buf := new(bytes.Buffer)
|
||||
err = png.Encode(buf, img)
|
||||
if err != nil {
|
||||
return model.NewAppError("SetProfileImage", "api.user.upload_profile_user.encode.app_error", nil, err.Error(), http.StatusInternalServerError)
|
||||
return nil, model.NewAppError("SetProfileImage", "api.user.upload_profile_user.encode.app_error", nil, err.Error(), http.StatusInternalServerError)
|
||||
}
|
||||
return buf, nil
|
||||
}
|
||||
|
||||
func (a *App) SetProfileImageFromFile(userId string, file io.Reader) *model.AppError {
|
||||
|
||||
buf, err := a.AdjustImage(file)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
path := "users/" + userId + "/profile.png"
|
||||
|
||||
if _, err := a.WriteFile(buf, path); err != nil {
|
||||
|
||||
Ссылка в новой задаче
Block a user