diff options
author | KN4CK3R <admin@oldschoolhack.me> | 2023-08-30 08:55:25 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-08-30 06:55:25 +0000 |
commit | 5315153059529f03b06c8f25487ffcc21ae3163f (patch) | |
tree | b5f90daf2f1916f37656369865706d95872a7ae7 /services/auth | |
parent | 815d267c8031daa19b82b291a6393a54715567c0 (diff) | |
download | gitea-5315153059529f03b06c8f25487ffcc21ae3163f.tar.gz gitea-5315153059529f03b06c8f25487ffcc21ae3163f.zip |
Use `Set[Type]` instead of `map[Type]bool/struct{}`. (#26804)
Diffstat (limited to 'services/auth')
-rw-r--r-- | services/auth/source/ldap/source_sync.go | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/services/auth/source/ldap/source_sync.go b/services/auth/source/ldap/source_sync.go index 43ee32c84b..df5eb60393 100644 --- a/services/auth/source/ldap/source_sync.go +++ b/services/auth/source/ldap/source_sync.go @@ -13,6 +13,7 @@ import ( "code.gitea.io/gitea/models/organization" user_model "code.gitea.io/gitea/models/user" auth_module "code.gitea.io/gitea/modules/auth" + "code.gitea.io/gitea/modules/container" "code.gitea.io/gitea/modules/log" "code.gitea.io/gitea/modules/util" source_service "code.gitea.io/gitea/services/auth/source" @@ -41,7 +42,7 @@ func (source *Source) Sync(ctx context.Context, updateExisting bool) error { usernameUsers := make(map[string]*user_model.User, len(users)) mailUsers := make(map[string]*user_model.User, len(users)) - keepActiveUsers := make(map[int64]struct{}) + keepActiveUsers := make(container.Set[int64]) for _, u := range users { usernameUsers[u.LowerName] = u @@ -97,7 +98,7 @@ func (source *Source) Sync(ctx context.Context, updateExisting bool) error { } if usr != nil { - keepActiveUsers[usr.ID] = struct{}{} + keepActiveUsers.Add(usr.ID) } else if len(su.Username) == 0 { // we cannot create the user if su.Username is empty continue @@ -208,7 +209,7 @@ func (source *Source) Sync(ctx context.Context, updateExisting bool) error { // Deactivate users not present in LDAP if updateExisting { for _, usr := range users { - if _, ok := keepActiveUsers[usr.ID]; ok { + if keepActiveUsers.Contains(usr.ID) { continue } |