diff options
author | Lunny Xiao <xiaolunwen@gmail.com> | 2021-09-19 19:49:59 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-09-19 19:49:59 +0800 |
commit | a4bfef265d9e512830350635a0489c2cdcd6508f (patch) | |
tree | 1e3c2ec94276dfcb2f8ba73a2ac075ba39c4a34a /models/userlist.go | |
parent | 462306e263db5a809dbe2cdf62e99307aeff28de (diff) | |
download | gitea-a4bfef265d9e512830350635a0489c2cdcd6508f.tar.gz gitea-a4bfef265d9e512830350635a0489c2cdcd6508f.zip |
Move db related basic functions to models/db (#17075)
* Move db related basic functions to models/db
* Fix lint
* Fix lint
* Fix test
* Fix lint
* Fix lint
* revert unnecessary change
* Fix test
* Fix wrong replace string
* Use *Context
* Correct committer spelling and fix wrong replaced words
Co-authored-by: zeripath <art27@cantab.net>
Diffstat (limited to 'models/userlist.go')
-rw-r--r-- | models/userlist.go | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/models/userlist.go b/models/userlist.go index 53e380cd72..9741c90ccf 100644 --- a/models/userlist.go +++ b/models/userlist.go @@ -7,6 +7,7 @@ package models import ( "fmt" + "code.gitea.io/gitea/models/db" "code.gitea.io/gitea/modules/log" ) @@ -28,7 +29,7 @@ func (users UserList) IsUserOrgOwner(orgID int64) map[int64]bool { for _, user := range users { results[user.ID] = false // Set default to false } - ownerMaps, err := users.loadOrganizationOwners(x, orgID) + ownerMaps, err := users.loadOrganizationOwners(db.DefaultContext().Engine(), orgID) if err == nil { for _, owner := range ownerMaps { results[owner.UID] = true @@ -37,7 +38,7 @@ func (users UserList) IsUserOrgOwner(orgID int64) map[int64]bool { return results } -func (users UserList) loadOrganizationOwners(e Engine, orgID int64) (map[int64]*TeamUser, error) { +func (users UserList) loadOrganizationOwners(e db.Engine, orgID int64) (map[int64]*TeamUser, error) { if len(users) == 0 { return nil, nil } @@ -68,7 +69,7 @@ func (users UserList) GetTwoFaStatus() map[int64]bool { for _, user := range users { results[user.ID] = false // Set default to false } - tokenMaps, err := users.loadTwoFactorStatus(x) + tokenMaps, err := users.loadTwoFactorStatus(db.DefaultContext().Engine()) if err == nil { for _, token := range tokenMaps { results[token.UID] = true @@ -78,7 +79,7 @@ func (users UserList) GetTwoFaStatus() map[int64]bool { return results } -func (users UserList) loadTwoFactorStatus(e Engine) (map[int64]*TwoFactor, error) { +func (users UserList) loadTwoFactorStatus(e db.Engine) (map[int64]*TwoFactor, error) { if len(users) == 0 { return nil, nil } |