UseCustomAvatar uses the given avatar as the user custom avatar.
(ctx context.Context, userID int64, avatar []byte)
| 1002 | |
| 1003 | // UseCustomAvatar uses the given avatar as the user custom avatar. |
| 1004 | func (s *UsersStore) UseCustomAvatar(ctx context.Context, userID int64, avatar []byte) error { |
| 1005 | err := userutil.SaveAvatar(userID, avatar) |
| 1006 | if err != nil { |
| 1007 | return errors.Wrap(err, "save avatar") |
| 1008 | } |
| 1009 | |
| 1010 | return s.db.WithContext(ctx). |
| 1011 | Model(&User{}). |
| 1012 | Where("id = ?", userID). |
| 1013 | Updates(map[string]any{ |
| 1014 | "use_custom_avatar": true, |
| 1015 | "updated_unix": s.db.NowFunc().Unix(), |
| 1016 | }). |
| 1017 | Error |
| 1018 | } |
| 1019 | |
| 1020 | // AddEmail adds a new email address to given user. It returns |
| 1021 | // ErrEmailAlreadyUsed if the email has been verified by another user. |