diff --git a/object/user.go b/object/user.go index 1c7a2b7d..818b7359 100644 --- a/object/user.go +++ b/object/user.go @@ -32,6 +32,7 @@ type User struct { Password string `xorm:"varchar(100)" json:"password"` DisplayName string `xorm:"varchar(100)" json:"displayName"` Avatar string `xorm:"varchar(255)" json:"avatar"` + PermanentAvatar string `xorm:"varchar(255)" json:"permanentAvatar"` Email string `xorm:"varchar(100)" json:"email"` Phone string `xorm:"varchar(100)" json:"phone"` Location string `xorm:"varchar(100)" json:"location"` @@ -146,7 +147,8 @@ func GetLastUser(owner string) *User { func UpdateUser(id string, user *User) bool { owner, name := util.GetOwnerAndNameFromId(id) - if getUser(owner, name) == nil { + oldUser := getUser(owner, name) + if oldUser == nil { return false } @@ -162,9 +164,10 @@ func UpdateUser(id string, user *User) bool { return affected != 0 } -func UpdateUserInternal(id string, user *User) bool { +func UpdateUserForAllFields(id string, user *User) bool { owner, name := util.GetOwnerAndNameFromId(id) - if getUser(owner, name) == nil { + oldUser := getUser(owner, name) + if oldUser == nil { return false } @@ -178,7 +181,13 @@ func UpdateUserInternal(id string, user *User) bool { return affected != 0 } -func UpdateUserForOriginal(user *User) bool { +func UpdateUserForOriginalFields(user *User) bool { + owner, name := util.GetOwnerAndNameFromId(user.GetId()) + oldUser := getUser(owner, name) + if oldUser == nil { + return false + } + affected, err := adapter.Engine.ID(core.PK{user.Owner, user.Name}).Cols("display_name", "password", "phone", "avatar", "affiliation", "score", "is_forbidden", "hash", "pre_hash").Update(user) if err != nil { panic(err) diff --git a/object/user_util.go b/object/user_util.go index 17021f61..482ba652 100644 --- a/object/user_util.go +++ b/object/user_util.go @@ -135,7 +135,7 @@ func SetUserOAuthProperties(organization *Organization, user *User, providerType } } - affected := UpdateUserInternal(user.GetId(), user) + affected := UpdateUserForAllFields(user.GetId(), user) return affected } diff --git a/original/sync.go b/original/sync.go index 030fc2a9..73b8a8b6 100644 --- a/original/sync.go +++ b/original/sync.go @@ -112,7 +112,7 @@ func syncUsers() { updatedUser := createUserFromOriginalUser(oUser, affiliationMap) updatedUser.Hash = oHash updatedUser.PreHash = oHash - object.UpdateUserForOriginal(updatedUser) + object.UpdateUserForOriginalFields(updatedUser) fmt.Printf("Update from oUser to user: %v\n", updatedUser) } } else { @@ -133,7 +133,7 @@ func syncUsers() { updatedUser := createUserFromOriginalUser(oUser, affiliationMap) updatedUser.Hash = oHash updatedUser.PreHash = oHash - object.UpdateUserForOriginal(updatedUser) + object.UpdateUserForOriginalFields(updatedUser) fmt.Printf("Update from oUser to user (2nd condition): %v\n", updatedUser) } }