Achieve consistency by using a single Image type
This commit is contained in:
@ -55,6 +55,7 @@ type User struct {
|
||||
IP string `json:"ip" private:"true"`
|
||||
UserAgent string `json:"agent" private:"true"`
|
||||
Balance int `json:"balance" private:"true"`
|
||||
Image Image `json:"image"`
|
||||
Avatar UserAvatar `json:"avatar"`
|
||||
Cover UserCover `json:"cover"`
|
||||
Accounts UserAccounts `json:"accounts" private:"true"`
|
||||
@ -138,7 +139,7 @@ func RegisterUser(user *User) {
|
||||
|
||||
if err == nil && response.StatusCode() == http.StatusOK {
|
||||
data := response.Bytes()
|
||||
err = user.SetAvatarBytes(data)
|
||||
err = user.SetImageBytes(data)
|
||||
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
|
@ -65,8 +65,8 @@ type UserAvatar struct {
|
||||
LastModified int64 `json:"lastModified"`
|
||||
}
|
||||
|
||||
// SetAvatarBytes accepts a byte buffer that represents an image file and updates the avatar.
|
||||
func (user *User) SetAvatarBytes(data []byte) error {
|
||||
// SetImageBytes accepts a byte buffer that represents an image file and updates the avatar.
|
||||
func (user *User) SetImageBytes(data []byte) error {
|
||||
// Decode
|
||||
img, format, err := image.Decode(bytes.NewReader(data))
|
||||
|
||||
|
Reference in New Issue
Block a user