diff options
author | 6543 <6543@obermui.de> | 2024-03-02 16:42:31 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-03-02 16:42:31 +0100 |
commit | a3f05d0d98408bb47333b19f505b21afcefa9e7c (patch) | |
tree | e4a1f8c48b45668ccdcb84fabc7fa77b47990bfa /models/user | |
parent | 3f081d4b54261c1b4ee4f1df40c610fdd9581ef2 (diff) | |
download | gitea-a3f05d0d98408bb47333b19f505b21afcefa9e7c.tar.gz gitea-a3f05d0d98408bb47333b19f505b21afcefa9e7c.zip |
remove util.OptionalBool and related functions (#29513)
and migrate affected code
_last refactoring bits to replace **util.OptionalBool** with
**optional.Option[bool]**_
Diffstat (limited to 'models/user')
-rw-r--r-- | models/user/user.go | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/models/user/user.go b/models/user/user.go index e92bbd4d0b..a898e71a2d 100644 --- a/models/user/user.go +++ b/models/user/user.go @@ -715,7 +715,7 @@ func CreateUser(ctx context.Context, u *User, overwriteDefault ...*CreateUserOve // IsLastAdminUser check whether user is the last admin func IsLastAdminUser(ctx context.Context, user *User) bool { - if user.IsAdmin && CountUsers(ctx, &CountUserFilter{IsAdmin: util.OptionalBoolTrue}) <= 1 { + if user.IsAdmin && CountUsers(ctx, &CountUserFilter{IsAdmin: optional.Some(true)}) <= 1 { return true } return false @@ -724,7 +724,7 @@ func IsLastAdminUser(ctx context.Context, user *User) bool { // CountUserFilter represent optional filters for CountUsers type CountUserFilter struct { LastLoginSince *int64 - IsAdmin util.OptionalBool + IsAdmin optional.Option[bool] } // CountUsers returns number of users. @@ -742,8 +742,8 @@ func countUsers(ctx context.Context, opts *CountUserFilter) int64 { cond = cond.And(builder.Gte{"last_login_unix": *opts.LastLoginSince}) } - if !opts.IsAdmin.IsNone() { - cond = cond.And(builder.Eq{"is_admin": opts.IsAdmin.IsTrue()}) + if opts.IsAdmin.Has() { + cond = cond.And(builder.Eq{"is_admin": opts.IsAdmin.Value()}) } } |