[MM-63436] Replace Exif parser dependency (#30479)
* Replace Exif parser dependency * Improve forward seeking logic * Fix linting * Stop decoding upon finding tag * Use latest version of imagemeta dependency * Don't skip TIFF reader tests * Log improvements --------- Co-authored-by: Mattermost Build <build@mattermost.com>
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
2454de5b4a
Коммит
f8e16780ef
@@ -882,14 +882,18 @@ func (a *App) SetProfileImageFromMultiPartFile(c request.CTX, userID string, fil
|
||||
return a.SetProfileImageFromFile(c, userID, file)
|
||||
}
|
||||
|
||||
func (a *App) AdjustImage(file io.Reader) (*bytes.Buffer, *model.AppError) {
|
||||
func (a *App) AdjustImage(rctx request.CTX, file io.ReadSeeker) (*bytes.Buffer, *model.AppError) {
|
||||
// Decode image into Image object
|
||||
img, _, err := a.ch.imgDecoder.Decode(file)
|
||||
img, format, err := a.ch.imgDecoder.Decode(file)
|
||||
if err != nil {
|
||||
return nil, model.NewAppError("SetProfileImage", "api.user.upload_profile_user.decode.app_error", nil, "", http.StatusBadRequest).Wrap(err)
|
||||
}
|
||||
|
||||
orientation, _ := imaging.GetImageOrientation(file)
|
||||
orientation, err := imaging.GetImageOrientation(file, format)
|
||||
if err != nil {
|
||||
rctx.Logger().Warn("Failed to get image orientation", mlog.Err(err))
|
||||
}
|
||||
|
||||
img = imaging.MakeImageUpright(img, orientation)
|
||||
|
||||
// Scale profile image
|
||||
@@ -904,8 +908,8 @@ func (a *App) AdjustImage(file io.Reader) (*bytes.Buffer, *model.AppError) {
|
||||
return buf, nil
|
||||
}
|
||||
|
||||
func (a *App) SetProfileImageFromFile(c request.CTX, userID string, file io.Reader) *model.AppError {
|
||||
buf, err := a.AdjustImage(file)
|
||||
func (a *App) SetProfileImageFromFile(c request.CTX, userID string, file io.ReadSeeker) *model.AppError {
|
||||
buf, err := a.AdjustImage(c, file)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -1363,7 +1367,6 @@ func (a *App) UpdateUser(c request.CTX, user *model.User, sendNotifications bool
|
||||
|
||||
func (a *App) UpdateUserActive(c request.CTX, userID string, active bool) *model.AppError {
|
||||
user, err := a.GetUser(userID)
|
||||
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -1671,7 +1674,6 @@ func (a *App) GetPasswordRecoveryToken(token string) (*model.Token, *model.AppEr
|
||||
|
||||
func (a *App) GetTokenById(token string) (*model.Token, *model.AppError) {
|
||||
rtoken, err := a.Srv().Store().Token().GetByToken(token)
|
||||
|
||||
if err != nil {
|
||||
var status int
|
||||
|
||||
@@ -2043,7 +2045,6 @@ func (a *App) VerifyUserEmail(userID, email string) *model.AppError {
|
||||
a.InvalidateCacheForUser(userID)
|
||||
|
||||
user, err := a.GetUser(userID)
|
||||
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -2788,7 +2789,6 @@ func (a *App) UpdateThreadFollowForUserFromChannelAdd(c request.CTX, userID, tea
|
||||
|
||||
message := model.NewWebSocketEvent(model.WebsocketEventThreadUpdated, teamID, "", userID, nil, "")
|
||||
userThread, err := a.Srv().Store().Thread().GetThreadForUser(tm, true, a.IsPostPriorityEnabled())
|
||||
|
||||
if err != nil {
|
||||
var errNotFound *store.ErrNotFound
|
||||
if errors.As(err, &errNotFound) {
|
||||
|
||||
Ссылка в новой задаче
Block a user