mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2025-06-22 07:18:31 -04:00
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>
This commit is contained in:
parent
462306e263
commit
a4bfef265d
335 changed files with 4191 additions and 3654 deletions
|
@ -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
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue