summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGusted <williamzijl7@hotmail.com>2021-11-09 09:54:46 +0100
committerGitHub <noreply@github.com>2021-11-09 08:54:46 +0000
commit3a693bd18c6274b62aa7bcde69e9a0d86e43c534 (patch)
tree4ad993db8b2853cda70810db07f17bf2b3e22bba
parent03de5934027ee5fcfb517016f27a4471f2bdd846 (diff)
downloadgitea-3a693bd18c6274b62aa7bcde69e9a0d86e43c534.tar.gz
gitea-3a693bd18c6274b62aa7bcde69e9a0d86e43c534.zip
Use provided database Engine (#17595)
- Don't get the engine from `db.DefaultContext`, instead use the provided one which is passed as paramater `e`.
-rw-r--r--models/org.go2
-rw-r--r--models/user.go2
2 files changed, 2 insertions, 2 deletions
diff --git a/models/org.go b/models/org.go
index 8cba485a89..d2801a30ce 100644
--- a/models/org.go
+++ b/models/org.go
@@ -412,7 +412,7 @@ func GetUsersWhoCanCreateOrgRepo(orgID int64) ([]*User, error) {
func getUsersWhoCanCreateOrgRepo(e db.Engine, orgID int64) ([]*User, error) {
users := make([]*User, 0, 10)
- return users, db.GetEngine(db.DefaultContext).
+ return users, e.
Join("INNER", "`team_user`", "`team_user`.uid=`user`.id").
Join("INNER", "`team`", "`team`.id=`team_user`.team_id").
Where(builder.Eq{"team.can_create_org_repo": true}.Or(builder.Eq{"team.authorize": AccessModeOwner})).
diff --git a/models/user.go b/models/user.go
index 3ce23ef2ed..dbd4f12b8a 100644
--- a/models/user.go
+++ b/models/user.go
@@ -468,7 +468,7 @@ func (u *User) isVisibleToUser(e db.Engine, viewer *User) bool {
}
// Now we need to check if they in some organization together
- count, err := db.GetEngine(db.DefaultContext).Table("team_user").
+ count, err := e.Table("team_user").
Where(
builder.And(
builder.Eq{"uid": viewer.ID},