MCPcopy Create free account
hub / github.com/gogs/gogs / UseCustomAvatar

Method UseCustomAvatar

internal/database/users.go:1004–1018  ·  view source on GitHub ↗

UseCustomAvatar uses the given avatar as the user custom avatar.

(ctx context.Context, userID int64, avatar []byte)

Source from the content-addressed store, hash-verified

1002
1003// UseCustomAvatar uses the given avatar as the user custom avatar.
1004func (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.

Callers 3

usersDeleteCustomAvatarFunction · 0.80
usersUseCustomAvatarFunction · 0.80
UpdateAvatarSettingFunction · 0.80

Calls 2

SaveAvatarFunction · 0.92
WhereMethod · 0.80

Tested by 2

usersDeleteCustomAvatarFunction · 0.64
usersUseCustomAvatarFunction · 0.64