diff options
author | Bo-Yi Wu <appleboy.tw@gmail.com> | 2021-03-15 02:52:12 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-03-14 19:52:12 +0100 |
commit | 167b0f46ef946fad3ca13976c3b87598f505e2ea (patch) | |
tree | 8b6a4a47a2a0149899b3eb49b296677c2dba4d36 /models/user.go | |
parent | 164e35ead3c1b9b82d4a23644f6fe96652a747eb (diff) | |
download | gitea-167b0f46ef946fad3ca13976c3b87598f505e2ea.tar.gz gitea-167b0f46ef946fad3ca13976c3b87598f505e2ea.zip |
chore(models): rewrite code format. (#14754)
* chore: rewrite format.
* chore: update format
Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com>
* chore: update format
Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com>
* chore: Adjacent parameters with the same type should be grouped together
* chore: update format.
Diffstat (limited to 'models/user.go')
-rw-r--r-- | models/user.go | 11 |
1 files changed, 5 insertions, 6 deletions
diff --git a/models/user.go b/models/user.go index 8b3dd00430..51c1bb0ce1 100644 --- a/models/user.go +++ b/models/user.go @@ -1307,7 +1307,6 @@ func DeleteInactiveUsers(ctx context.Context, olderThan time.Duration) (err erro Find(&users); err != nil { return fmt.Errorf("get all inactive users: %v", err) } - } // FIXME: should only update authorized_keys file once after all deletions. for _, u := range users { @@ -1572,7 +1571,6 @@ type SearchUserOptions struct { func (opts *SearchUserOptions) toConds() builder.Cond { var cond builder.Cond = builder.Eq{"type": opts.Type} - if len(opts.Keyword) > 0 { lowerKeyword := strings.ToLower(opts.Keyword) keywordCond := builder.Or( @@ -1601,7 +1599,8 @@ func (opts *SearchUserOptions) toConds() builder.Cond { } else { exprCond = builder.Expr("org_user.org_id = \"user\".id") } - var accessCond = builder.NewCond() + + var accessCond builder.Cond if !opts.Actor.IsRestricted { accessCond = builder.Or( builder.In("id", builder.Select("org_id").From("org_user").LeftJoin("`user`", exprCond).Where(builder.And(builder.Eq{"uid": opts.Actor.ID}, builder.Eq{"visibility": structs.VisibleTypePrivate}))), @@ -1847,7 +1846,7 @@ func SyncExternalUsers(ctx context.Context, updateExisting bool) error { log.Trace("Doing: SyncExternalUsers[%s]", s.Name) var existingUsers []int64 - var isAttributeSSHPublicKeySet = len(strings.TrimSpace(s.LDAP().AttributeSSHPublicKey)) > 0 + isAttributeSSHPublicKeySet := len(strings.TrimSpace(s.LDAP().AttributeSSHPublicKey)) > 0 var sshKeysNeedUpdate bool // Find all users with this login type @@ -2021,9 +2020,9 @@ func SyncExternalUsers(ctx context.Context, updateExisting bool) error { // IterateUser iterate users func IterateUser(f func(user *User) error) error { var start int - var batchSize = setting.Database.IterateBufferSize + batchSize := setting.Database.IterateBufferSize for { - var users = make([]*User, 0, batchSize) + users := make([]*User, 0, batchSize) if err := x.Limit(batchSize, start).Find(&users); err != nil { return err } |