Can sync update from 2nd DB.

This commit is contained in:
Yang Luo
2021-05-08 22:04:45 +08:00
parent c76a432003
commit de67ee9014
6 changed files with 57 additions and 23 deletions

View File

@ -15,8 +15,6 @@
package object
import (
"crypto/md5"
"encoding/hex"
"fmt"
"reflect"
"strings"
@ -237,17 +235,16 @@ func GetMaskedUsers(users []*User) []*User {
return users
}
func getMd5Hash(text string) string {
hash := md5.Sum([]byte(text))
return hex.EncodeToString(hash[:])
}
func calculateHash(user *User) string {
s := strings.Join([]string{user.Id, user.Password, user.DisplayName, user.Avatar, user.Phone}, "|")
return getMd5Hash(s)
return util.GetMd5Hash(s)
}
func (user *User) UpdateUserHash() {
hash := calculateHash(user)
user.Hash = hash
}
func (user *User) GetId() string {
return fmt.Sprintf("%s/%s", user.Owner, user.Name)
}