summaryrefslogtreecommitdiffstats
path: root/app/user.go
diff options
context:
space:
mode:
authorSaturnino Abril <saturnino.abril@gmail.com>2017-06-29 22:39:57 +0800
committerHarrison Healey <harrisonmhealey@gmail.com>2017-06-29 10:39:57 -0400
commit648f333850163efeac486c4b07eb47da415a9c98 (patch)
tree1b441666d3a58f39efb0cb5396ede217ed841c9a /app/user.go
parente1168ab7cc9770ab71fda6994ee80ef0e64e15d7 (diff)
downloadchat-648f333850163efeac486c4b07eb47da415a9c98.tar.gz
chat-648f333850163efeac486c4b07eb47da415a9c98.tar.bz2
chat-648f333850163efeac486c4b07eb47da415a9c98.zip
[PLT-6496] Remove System Console and config settings for image height and width (#6688)
* remove System Console and config settings for image height and width * add constants and update config.json * updated as per review
Diffstat (limited to 'app/user.go')
-rw-r--r--app/user.go20
1 files changed, 10 insertions, 10 deletions
diff --git a/app/user.go b/app/user.go
index de5881d00..eaeed53a5 100644
--- a/app/user.go
+++ b/app/user.go
@@ -31,10 +31,11 @@ import (
)
const (
- TOKEN_TYPE_PASSWORD_RECOVERY = "password_recovery"
- TOKEN_TYPE_VERIFY_EMAIL = "verify_email"
- PASSWORD_RECOVER_EXPIRY_TIME = 1000 * 60 * 60 // 1 hour
- VERIFY_EMAIL_EXPIRY_TIME = 1000 * 60 * 60 // 1 hour
+ TOKEN_TYPE_PASSWORD_RECOVERY = "password_recovery"
+ TOKEN_TYPE_VERIFY_EMAIL = "verify_email"
+ PASSWORD_RECOVER_EXPIRY_TIME = 1000 * 60 * 60 // 1 hour
+ VERIFY_EMAIL_EXPIRY_TIME = 1000 * 60 * 60 // 1 hour
+ IMAGE_PROFILE_PIXEL_DIMENSION = 128
)
func CreateUserWithHash(user *model.User, hash string, data string) (*model.User, *model.AppError) {
@@ -717,13 +718,11 @@ func CreateProfileImage(username string, userId string) ([]byte, *model.AppError
return nil, model.NewLocAppError("CreateProfileImage", "api.user.create_profile_image.default_font.app_error", nil, err.Error())
}
- width := int(utils.Cfg.FileSettings.ProfileWidth)
- height := int(utils.Cfg.FileSettings.ProfileHeight)
color := colors[int64(seed)%int64(len(colors))]
- dstImg := image.NewRGBA(image.Rect(0, 0, width, height))
+ dstImg := image.NewRGBA(image.Rect(0, 0, IMAGE_PROFILE_PIXEL_DIMENSION, IMAGE_PROFILE_PIXEL_DIMENSION))
srcImg := image.White
draw.Draw(dstImg, dstImg.Bounds(), &image.Uniform{color}, image.ZP, draw.Src)
- size := float64((width + height) / 4)
+ size := float64(IMAGE_PROFILE_PIXEL_DIMENSION / 2)
c := freetype.NewContext()
c.SetFont(font)
@@ -732,7 +731,7 @@ func CreateProfileImage(username string, userId string) ([]byte, *model.AppError
c.SetDst(dstImg)
c.SetSrc(srcImg)
- pt := freetype.Pt(width/6, height*2/3)
+ pt := freetype.Pt(IMAGE_PROFILE_PIXEL_DIMENSION/6, IMAGE_PROFILE_PIXEL_DIMENSION*2/3)
_, err = c.DrawString(initial, pt)
if err != nil {
return nil, model.NewLocAppError("CreateProfileImage", "api.user.create_profile_image.initial.app_error", nil, err.Error())
@@ -809,7 +808,8 @@ func SetProfileImage(userId string, imageData *multipart.FileHeader) *model.AppE
img = makeImageUpright(img, orientation)
// Scale profile image
- img = imaging.Fill(img, utils.Cfg.FileSettings.ProfileWidth, utils.Cfg.FileSettings.ProfileHeight, imaging.Center, imaging.Lanczos)
+ profileWidthAndHeight := 128
+ img = imaging.Fill(img, profileWidthAndHeight, profileWidthAndHeight, imaging.Center, imaging.Lanczos)
buf := new(bytes.Buffer)
err = png.Encode(buf, img)