From a2f13eae559c71d35662b7767a8b8347a26eb53e Mon Sep 17 00:00:00 2001 From: Unknwon Date: Sat, 5 Mar 2016 00:51:51 -0500 Subject: #1157 some avatar setting changes - Allow to delete current avatar --- models/user.go | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) (limited to 'models') diff --git a/models/user.go b/models/user.go index 6e7c2729..3c87c4a6 100644 --- a/models/user.go +++ b/models/user.go @@ -617,7 +617,7 @@ func ChangeUserName(u *User, newUserName string) (err error) { } func updateUser(e Engine, u *User) error { - // Organization does not need e-mail. + // Organization does not need email if !u.IsOrganization() { u.Email = strings.ToLower(u.Email) has, err := e.Where("id!=?", u.Id).And("type=?", u.Type).And("email=?", u.Email).Get(new(User)) @@ -634,16 +634,9 @@ func updateUser(e Engine, u *User) error { } u.LowerName = strings.ToLower(u.Name) - - if len(u.Location) > 255 { - u.Location = u.Location[:255] - } - if len(u.Website) > 255 { - u.Website = u.Website[:255] - } - if len(u.Description) > 255 { - u.Description = u.Description[:255] - } + u.Location = base.TruncateString(u.Location, 255) + u.Website = base.TruncateString(u.Website, 255) + u.Description = base.TruncateString(u.Description, 255) u.FullName = markdown.Sanitizer.Sanitize(u.FullName) _, err := e.Id(u.Id).AllCols().Update(u) -- cgit v1.2.3