aboutsummaryrefslogtreecommitdiffstats
path: root/routers
diff options
context:
space:
mode:
authorJakobDev <jakobdev@gmx.de>2023-09-25 15:17:37 +0200
committerGitHub <noreply@github.com>2023-09-25 13:17:37 +0000
commit7047df36d4c39fefa6464b713c66302aa0038123 (patch)
treea5c471a3e8abf5cabac8de42c0fd8a814df7abf1 /routers
parent93bd4351bfb4a2f5f37ecb80d50496d044240e00 (diff)
downloadgitea-7047df36d4c39fefa6464b713c66302aa0038123.tar.gz
gitea-7047df36d4c39fefa6464b713c66302aa0038123.zip
Another round of `db.DefaultContext` refactor (#27103)
Part of #27065 --------- Co-authored-by: KN4CK3R <admin@oldschoolhack.me>
Diffstat (limited to 'routers')
-rw-r--r--routers/api/packages/alpine/alpine.go5
-rw-r--r--routers/api/packages/cargo/cargo.go1
-rw-r--r--routers/api/packages/chef/chef.go4
-rw-r--r--routers/api/packages/composer/composer.go1
-rw-r--r--routers/api/packages/conan/conan.go1
-rw-r--r--routers/api/packages/conda/conda.go1
-rw-r--r--routers/api/packages/container/container.go2
-rw-r--r--routers/api/packages/cran/cran.go1
-rw-r--r--routers/api/packages/debian/debian.go5
-rw-r--r--routers/api/packages/generic/generic.go4
-rw-r--r--routers/api/packages/goproxy/goproxy.go1
-rw-r--r--routers/api/packages/helm/helm.go1
-rw-r--r--routers/api/packages/maven/maven.go1
-rw-r--r--routers/api/packages/npm/npm.go4
-rw-r--r--routers/api/packages/nuget/nuget.go4
-rw-r--r--routers/api/packages/pub/pub.go1
-rw-r--r--routers/api/packages/pypi/pypi.go1
-rw-r--r--routers/api/packages/rpm/rpm.go3
-rw-r--r--routers/api/packages/rubygems/rubygems.go2
-rw-r--r--routers/api/packages/swift/swift.go1
-rw-r--r--routers/api/packages/vagrant/vagrant.go1
-rw-r--r--routers/api/v1/admin/user.go2
-rw-r--r--routers/api/v1/api.go4
-rw-r--r--routers/api/v1/org/team.go6
-rw-r--r--routers/api/v1/packages/package.go2
-rw-r--r--routers/api/v1/repo/issue_reaction.go12
-rw-r--r--routers/api/v1/repo/key.go2
-rw-r--r--routers/api/v1/repo/pull_review.go2
-rw-r--r--routers/api/v1/repo/release.go10
-rw-r--r--routers/api/v1/repo/release_tags.go4
-rw-r--r--routers/api/v1/repo/repo.go2
-rw-r--r--routers/api/v1/repo/tag.go2
-rw-r--r--routers/api/v1/user/gpg_key.go12
-rw-r--r--routers/api/v1/user/helper.go2
-rw-r--r--routers/api/v1/user/key.go2
-rw-r--r--routers/api/v1/user/user.go2
-rw-r--r--routers/init.go2
-rw-r--r--routers/web/admin/notice.go6
-rw-r--r--routers/web/admin/packages.go2
-rw-r--r--routers/web/auth/2fa.go2
-rw-r--r--routers/web/auth/linkaccount.go2
-rw-r--r--routers/web/auth/oauth.go2
-rw-r--r--routers/web/auth/webauthn.go2
-rw-r--r--routers/web/org/teams.go2
-rw-r--r--routers/web/repo/issue.go14
-rw-r--r--routers/web/repo/release.go16
-rw-r--r--routers/web/repo/repo.go2
-rw-r--r--routers/web/repo/setting/deploy_key.go2
-rw-r--r--routers/web/user/home.go2
-rw-r--r--routers/web/user/package.go2
-rw-r--r--routers/web/user/profile.go2
-rw-r--r--routers/web/user/setting/keys.go10
52 files changed, 104 insertions, 77 deletions
diff --git a/routers/api/packages/alpine/alpine.go b/routers/api/packages/alpine/alpine.go
index d499244dc3..c261eee2d2 100644
--- a/routers/api/packages/alpine/alpine.go
+++ b/routers/api/packages/alpine/alpine.go
@@ -62,7 +62,7 @@ func GetRepositoryKey(ctx *context.Context) {
}
func GetRepositoryFile(ctx *context.Context) {
- pv, err := alpine_service.GetOrCreateRepositoryVersion(ctx.Package.Owner.ID)
+ pv, err := alpine_service.GetOrCreateRepositoryVersion(ctx, ctx.Package.Owner.ID)
if err != nil {
apiError(ctx, http.StatusInternalServerError, err)
return
@@ -134,6 +134,7 @@ func UploadPackageFile(ctx *context.Context) {
}
_, _, err = packages_service.CreatePackageOrAddFileToExisting(
+ ctx,
&packages_service.PackageCreationInfo{
PackageInfo: packages_service.PackageInfo{
Owner: ctx.Package.Owner,
@@ -227,7 +228,7 @@ func DeletePackageFile(ctx *context.Context) {
return
}
- if err := packages_service.RemovePackageFileAndVersionIfUnreferenced(ctx.Doer, pfs[0]); err != nil {
+ if err := packages_service.RemovePackageFileAndVersionIfUnreferenced(ctx, ctx.Doer, pfs[0]); err != nil {
if errors.Is(err, util.ErrNotExist) {
apiError(ctx, http.StatusNotFound, err)
} else {
diff --git a/routers/api/packages/cargo/cargo.go b/routers/api/packages/cargo/cargo.go
index 8c370339cd..225b6b5ade 100644
--- a/routers/api/packages/cargo/cargo.go
+++ b/routers/api/packages/cargo/cargo.go
@@ -214,6 +214,7 @@ func UploadPackage(ctx *context.Context) {
}
pv, _, err := packages_service.CreatePackageAndAddFile(
+ ctx,
&packages_service.PackageCreationInfo{
PackageInfo: packages_service.PackageInfo{
Owner: ctx.Package.Owner,
diff --git a/routers/api/packages/chef/chef.go b/routers/api/packages/chef/chef.go
index 908f9fc4be..a1f5f49bd8 100644
--- a/routers/api/packages/chef/chef.go
+++ b/routers/api/packages/chef/chef.go
@@ -286,6 +286,7 @@ func UploadPackage(ctx *context.Context) {
}
_, _, err = packages_service.CreatePackageAndAddFile(
+ ctx,
&packages_service.PackageCreationInfo{
PackageInfo: packages_service.PackageInfo{
Owner: ctx.Package.Owner,
@@ -356,6 +357,7 @@ func DeletePackageVersion(ctx *context.Context) {
packageVersion := ctx.Params("version")
err := packages_service.RemovePackageVersionByNameAndVersion(
+ ctx,
ctx.Doer,
&packages_service.PackageInfo{
Owner: ctx.Package.Owner,
@@ -390,7 +392,7 @@ func DeletePackage(ctx *context.Context) {
}
for _, pv := range pvs {
- if err := packages_service.RemovePackageVersion(ctx.Doer, pv); err != nil {
+ if err := packages_service.RemovePackageVersion(ctx, ctx.Doer, pv); err != nil {
apiError(ctx, http.StatusInternalServerError, err)
return
}
diff --git a/routers/api/packages/composer/composer.go b/routers/api/packages/composer/composer.go
index 75bbfdf4d3..313631d7d7 100644
--- a/routers/api/packages/composer/composer.go
+++ b/routers/api/packages/composer/composer.go
@@ -220,6 +220,7 @@ func UploadPackage(ctx *context.Context) {
}
_, _, err = packages_service.CreatePackageAndAddFile(
+ ctx,
&packages_service.PackageCreationInfo{
PackageInfo: packages_service.PackageInfo{
Owner: ctx.Package.Owner,
diff --git a/routers/api/packages/conan/conan.go b/routers/api/packages/conan/conan.go
index 8edbe98b30..f440f83b24 100644
--- a/routers/api/packages/conan/conan.go
+++ b/routers/api/packages/conan/conan.go
@@ -408,6 +408,7 @@ func uploadFile(ctx *context.Context, fileFilter container.Set[string], fileKey
}
_, _, err = packages_service.CreatePackageOrAddFileToExisting(
+ ctx,
pci,
pfci,
)
diff --git a/routers/api/packages/conda/conda.go b/routers/api/packages/conda/conda.go
index 0bf0fc1f62..0bee7baa96 100644
--- a/routers/api/packages/conda/conda.go
+++ b/routers/api/packages/conda/conda.go
@@ -229,6 +229,7 @@ func UploadPackageFile(ctx *context.Context) {
}
_, _, err = packages_service.CreatePackageOrAddFileToExisting(
+ ctx,
&packages_service.PackageCreationInfo{
PackageInfo: packages_service.PackageInfo{
Owner: ctx.Package.Owner,
diff --git a/routers/api/packages/container/container.go b/routers/api/packages/container/container.go
index 7bd5cadaaf..62eec3064c 100644
--- a/routers/api/packages/container/container.go
+++ b/routers/api/packages/container/container.go
@@ -653,7 +653,7 @@ func DeleteManifest(ctx *context.Context) {
}
for _, pv := range pvs {
- if err := packages_service.RemovePackageVersion(ctx.Doer, pv); err != nil {
+ if err := packages_service.RemovePackageVersion(ctx, ctx.Doer, pv); err != nil {
apiError(ctx, http.StatusInternalServerError, err)
return
}
diff --git a/routers/api/packages/cran/cran.go b/routers/api/packages/cran/cran.go
index 0ef6eff88d..ae43df7c9a 100644
--- a/routers/api/packages/cran/cran.go
+++ b/routers/api/packages/cran/cran.go
@@ -183,6 +183,7 @@ func uploadPackageFile(ctx *context.Context, compositeKey string, properties map
}
_, _, err = packages_service.CreatePackageOrAddFileToExisting(
+ ctx,
&packages_service.PackageCreationInfo{
PackageInfo: packages_service.PackageInfo{
Owner: ctx.Package.Owner,
diff --git a/routers/api/packages/debian/debian.go b/routers/api/packages/debian/debian.go
index 869bc1e901..dc7ebab096 100644
--- a/routers/api/packages/debian/debian.go
+++ b/routers/api/packages/debian/debian.go
@@ -45,7 +45,7 @@ func GetRepositoryKey(ctx *context.Context) {
// https://wiki.debian.org/DebianRepository/Format#A.22Release.22_files
// https://wiki.debian.org/DebianRepository/Format#A.22Packages.22_Indices
func GetRepositoryFile(ctx *context.Context) {
- pv, err := debian_service.GetOrCreateRepositoryVersion(ctx.Package.Owner.ID)
+ pv, err := debian_service.GetOrCreateRepositoryVersion(ctx, ctx.Package.Owner.ID)
if err != nil {
apiError(ctx, http.StatusInternalServerError, err)
return
@@ -81,7 +81,7 @@ func GetRepositoryFile(ctx *context.Context) {
// https://wiki.debian.org/DebianRepository/Format#indices_acquisition_via_hashsums_.28by-hash.29
func GetRepositoryFileByHash(ctx *context.Context) {
- pv, err := debian_service.GetOrCreateRepositoryVersion(ctx.Package.Owner.ID)
+ pv, err := debian_service.GetOrCreateRepositoryVersion(ctx, ctx.Package.Owner.ID)
if err != nil {
apiError(ctx, http.StatusInternalServerError, err)
return
@@ -159,6 +159,7 @@ func UploadPackageFile(ctx *context.Context) {
}
_, _, err = packages_service.CreatePackageOrAddFileToExisting(
+ ctx,
&packages_service.PackageCreationInfo{
PackageInfo: packages_service.PackageInfo{
Owner: ctx.Package.Owner,
diff --git a/routers/api/packages/generic/generic.go b/routers/api/packages/generic/generic.go
index c5866ef9c3..30854335c0 100644
--- a/routers/api/packages/generic/generic.go
+++ b/routers/api/packages/generic/generic.go
@@ -89,6 +89,7 @@ func UploadPackage(ctx *context.Context) {
defer buf.Close()
_, _, err = packages_service.CreatePackageOrAddFileToExisting(
+ ctx,
&packages_service.PackageCreationInfo{
PackageInfo: packages_service.PackageInfo{
Owner: ctx.Package.Owner,
@@ -125,6 +126,7 @@ func UploadPackage(ctx *context.Context) {
// DeletePackage deletes the specific generic package.
func DeletePackage(ctx *context.Context) {
err := packages_service.RemovePackageVersionByNameAndVersion(
+ ctx,
ctx.Doer,
&packages_service.PackageInfo{
Owner: ctx.Package.Owner,
@@ -176,7 +178,7 @@ func DeletePackageFile(ctx *context.Context) {
}
if len(pfs) == 1 {
- if err := packages_service.RemovePackageVersion(ctx.Doer, pv); err != nil {
+ if err := packages_service.RemovePackageVersion(ctx, ctx.Doer, pv); err != nil {
apiError(ctx, http.StatusInternalServerError, err)
return
}
diff --git a/routers/api/packages/goproxy/goproxy.go b/routers/api/packages/goproxy/goproxy.go
index bacdc4ec62..18e0074ab4 100644
--- a/routers/api/packages/goproxy/goproxy.go
+++ b/routers/api/packages/goproxy/goproxy.go
@@ -185,6 +185,7 @@ func UploadPackage(ctx *context.Context) {
}
_, _, err = packages_service.CreatePackageAndAddFile(
+ ctx,
&packages_service.PackageCreationInfo{
PackageInfo: packages_service.PackageInfo{
Owner: ctx.Package.Owner,
diff --git a/routers/api/packages/helm/helm.go b/routers/api/packages/helm/helm.go
index 9097adf29e..a8daa69dc3 100644
--- a/routers/api/packages/helm/helm.go
+++ b/routers/api/packages/helm/helm.go
@@ -174,6 +174,7 @@ func UploadPackage(ctx *context.Context) {
}
_, _, err = packages_service.CreatePackageOrAddFileToExisting(
+ ctx,
&packages_service.PackageCreationInfo{
PackageInfo: packages_service.PackageInfo{
Owner: ctx.Package.Owner,
diff --git a/routers/api/packages/maven/maven.go b/routers/api/packages/maven/maven.go
index 6328e226ab..52e31e8033 100644
--- a/routers/api/packages/maven/maven.go
+++ b/routers/api/packages/maven/maven.go
@@ -356,6 +356,7 @@ func UploadPackageFile(ctx *context.Context) {
}
_, _, err = packages_service.CreatePackageOrAddFileToExisting(
+ ctx,
pvci,
pfci,
)
diff --git a/routers/api/packages/npm/npm.go b/routers/api/packages/npm/npm.go
index d1e271f23f..dd6b3f148b 100644
--- a/routers/api/packages/npm/npm.go
+++ b/routers/api/packages/npm/npm.go
@@ -190,6 +190,7 @@ func UploadPackage(ctx *context.Context) {
defer buf.Close()
pv, _, err := packages_service.CreatePackageAndAddFile(
+ ctx,
&packages_service.PackageCreationInfo{
PackageInfo: packages_service.PackageInfo{
Owner: ctx.Package.Owner,
@@ -255,6 +256,7 @@ func DeletePackageVersion(ctx *context.Context) {
packageVersion := ctx.Params("version")
err := packages_service.RemovePackageVersionByNameAndVersion(
+ ctx,
ctx.Doer,
&packages_service.PackageInfo{
Owner: ctx.Package.Owner,
@@ -291,7 +293,7 @@ func DeletePackage(ctx *context.Context) {
}
for _, pv := range pvs {
- if err := packages_service.RemovePackageVersion(ctx.Doer, pv); err != nil {
+ if err := packages_service.RemovePackageVersion(ctx, ctx.Doer, pv); err != nil {
apiError(ctx, http.StatusInternalServerError, err)
return
}
diff --git a/routers/api/packages/nuget/nuget.go b/routers/api/packages/nuget/nuget.go
index 6f63c1d4c2..769c4c1824 100644
--- a/routers/api/packages/nuget/nuget.go
+++ b/routers/api/packages/nuget/nuget.go
@@ -431,6 +431,7 @@ func UploadPackage(ctx *context.Context) {
}
_, _, err := packages_service.CreatePackageAndAddFile(
+ ctx,
&packages_service.PackageCreationInfo{
PackageInfo: packages_service.PackageInfo{
Owner: ctx.Package.Owner,
@@ -503,6 +504,7 @@ func UploadSymbolPackage(ctx *context.Context) {
}
_, err = packages_service.AddFileToExistingPackage(
+ ctx,
pi,
&packages_service.PackageFileCreationInfo{
PackageFileInfo: packages_service.PackageFileInfo{
@@ -529,6 +531,7 @@ func UploadSymbolPackage(ctx *context.Context) {
for _, pdb := range pdbs {
_, err := packages_service.AddFileToExistingPackage(
+ ctx,
pi,
&packages_service.PackageFileCreationInfo{
PackageFileInfo: packages_service.PackageFileInfo{
@@ -647,6 +650,7 @@ func DeletePackage(ctx *context.Context) {
packageVersion := ctx.Params("version")
err := packages_service.RemovePackageVersionByNameAndVersion(
+ ctx,
ctx.Doer,
&packages_service.PackageInfo{
Owner: ctx.Package.Owner,
diff --git a/routers/api/packages/pub/pub.go b/routers/api/packages/pub/pub.go
index ef07836b88..8460f861cb 100644
--- a/routers/api/packages/pub/pub.go
+++ b/routers/api/packages/pub/pub.go
@@ -189,6 +189,7 @@ func UploadPackageFile(ctx *context.Context) {
}
_, _, err = packages_service.CreatePackageAndAddFile(
+ ctx,
&packages_service.PackageCreationInfo{
PackageInfo: packages_service.PackageInfo{
Owner: ctx.Package.Owner,
diff --git a/routers/api/packages/pypi/pypi.go b/routers/api/packages/pypi/pypi.go
index d97b894bbe..8c7f9bbf38 100644
--- a/routers/api/packages/pypi/pypi.go
+++ b/routers/api/packages/pypi/pypi.go
@@ -145,6 +145,7 @@ func UploadPackageFile(ctx *context.Context) {
}
_, _, err = packages_service.CreatePackageOrAddFileToExisting(
+ ctx,
&packages_service.PackageCreationInfo{
PackageInfo: packages_service.PackageInfo{
Owner: ctx.Package.Owner,
diff --git a/routers/api/packages/rpm/rpm.go b/routers/api/packages/rpm/rpm.go
index 65b7c74bdd..f5d8b67e16 100644
--- a/routers/api/packages/rpm/rpm.go
+++ b/routers/api/packages/rpm/rpm.go
@@ -59,7 +59,7 @@ func GetRepositoryKey(ctx *context.Context) {
// Gets a pre-generated repository metadata file
func GetRepositoryFile(ctx *context.Context) {
- pv, err := rpm_service.GetOrCreateRepositoryVersion(ctx.Package.Owner.ID)
+ pv, err := rpm_service.GetOrCreateRepositoryVersion(ctx, ctx.Package.Owner.ID)
if err != nil {
apiError(ctx, http.StatusInternalServerError, err)
return
@@ -123,6 +123,7 @@ func UploadPackageFile(ctx *context.Context) {
}
_, _, err = packages_service.CreatePackageOrAddFileToExisting(
+ ctx,
&packages_service.PackageCreationInfo{
PackageInfo: packages_service.PackageInfo{
Owner: ctx.Package.Owner,
diff --git a/routers/api/packages/rubygems/rubygems.go b/routers/api/packages/rubygems/rubygems.go
index 88d70f10bd..061fb0871b 100644
--- a/routers/api/packages/rubygems/rubygems.go
+++ b/routers/api/packages/rubygems/rubygems.go
@@ -234,6 +234,7 @@ func UploadPackageFile(ctx *context.Context) {
}
_, _, err = packages_service.CreatePackageAndAddFile(
+ ctx,
&packages_service.PackageCreationInfo{
PackageInfo: packages_service.PackageInfo{
Owner: ctx.Package.Owner,
@@ -280,6 +281,7 @@ func DeletePackage(ctx *context.Context) {
packageVersion := ctx.FormString("version")
err := packages_service.RemovePackageVersionByNameAndVersion(
+ ctx,
ctx.Doer,
&packages_service.PackageInfo{
Owner: ctx.Package.Owner,
diff --git a/routers/api/packages/swift/swift.go b/routers/api/packages/swift/swift.go
index bd4b8095c2..427e262d06 100644
--- a/routers/api/packages/swift/swift.go
+++ b/routers/api/packages/swift/swift.go
@@ -329,6 +329,7 @@ func UploadPackageFile(ctx *context.Context) {
}
pv, _, err := packages_service.CreatePackageAndAddFile(
+ ctx,
&packages_service.PackageCreationInfo{
PackageInfo: packages_service.PackageInfo{
Owner: ctx.Package.Owner,
diff --git a/routers/api/packages/vagrant/vagrant.go b/routers/api/packages/vagrant/vagrant.go
index 9fe7ab56f6..af9cd08a62 100644
--- a/routers/api/packages/vagrant/vagrant.go
+++ b/routers/api/packages/vagrant/vagrant.go
@@ -177,6 +177,7 @@ func UploadPackageFile(ctx *context.Context) {
}
_, _, err = packages_service.CreatePackageOrAddFileToExisting(
+ ctx,
&packages_service.PackageCreationInfo{
PackageInfo: packages_service.PackageInfo{
Owner: ctx.Package.Owner,
diff --git a/routers/api/v1/admin/user.go b/routers/api/v1/admin/user.go
index 66946e5797..610eba1749 100644
--- a/routers/api/v1/admin/user.go
+++ b/routers/api/v1/admin/user.go
@@ -402,7 +402,7 @@ func DeleteUserPublicKey(ctx *context.APIContext) {
// "404":
// "$ref": "#/responses/notFound"
- if err := asymkey_service.DeletePublicKey(ctx.ContextUser, ctx.ParamsInt64(":id")); err != nil {
+ if err := asymkey_service.DeletePublicKey(ctx, ctx.ContextUser, ctx.ParamsInt64(":id")); err != nil {
if asymkey_model.IsErrKeyNotExist(err) {
ctx.NotFound()
} else if asymkey_model.IsErrKeyAccessDenied(err) {
diff --git a/routers/api/v1/api.go b/routers/api/v1/api.go
index dc1f914922..441801885f 100644
--- a/routers/api/v1/api.go
+++ b/routers/api/v1/api.go
@@ -148,7 +148,7 @@ func repoAssignment() func(ctx *context.APIContext) {
owner, err = user_model.GetUserByName(ctx, userName)
if err != nil {
if user_model.IsErrUserNotExist(err) {
- if redirectUserID, err := user_model.LookupUserRedirect(userName); err == nil {
+ if redirectUserID, err := user_model.LookupUserRedirect(ctx, userName); err == nil {
context.RedirectToUser(ctx.Base, userName, redirectUserID)
} else if user_model.IsErrUserRedirectNotExist(err) {
ctx.NotFound("GetUserByName", err)
@@ -564,7 +564,7 @@ func orgAssignment(args ...bool) func(ctx *context.APIContext) {
ctx.Org.Organization, err = organization.GetOrgByName(ctx, ctx.Params(":org"))
if err != nil {
if organization.IsErrOrgNotExist(err) {
- redirectUserID, err := user_model.LookupUserRedirect(ctx.Params(":org"))
+ redirectUserID, err := user_model.LookupUserRedirect(ctx, ctx.Params(":org"))
if err == nil {
context.RedirectToUser(ctx.Base, ctx.Params(":org"), redirectUserID)
} else if user_model.IsErrUserRedirectNotExist(err) {
diff --git a/routers/api/v1/org/team.go b/routers/api/v1/org/team.go
index 83cbfe68d0..9b68253623 100644
--- a/routers/api/v1/org/team.go
+++ b/routers/api/v1/org/team.go
@@ -53,7 +53,7 @@ func ListTeams(ctx *context.APIContext) {
// "404":
// "$ref": "#/responses/notFound"
- teams, count, err := organization.SearchTeam(&organization.SearchTeamOptions{
+ teams, count, err := organization.SearchTeam(ctx, &organization.SearchTeamOptions{
ListOptions: utils.GetListOptions(ctx),
OrgID: ctx.Org.Organization.ID,
})
@@ -92,7 +92,7 @@ func ListUserTeams(ctx *context.APIContext) {
// "200":
// "$ref": "#/responses/TeamList"
- teams, count, err := organization.SearchTeam(&organization.SearchTeamOptions{
+ teams, count, err := organization.SearchTeam(ctx, &organization.SearchTeamOptions{
ListOptions: utils.GetListOptions(ctx),
UserID: ctx.Doer.ID,
})
@@ -810,7 +810,7 @@ func SearchTeam(ctx *context.APIContext) {
opts.UserID = ctx.Doer.ID
}
- teams, maxResults, err := organization.SearchTeam(opts)
+ teams, maxResults, err := organization.SearchTeam(ctx, opts)
if err != nil {
log.Error("SearchTeam failed: %v", err)
ctx.JSON(http.StatusInternalServerError, map[string]any{
diff --git a/routers/api/v1/packages/package.go b/routers/api/v1/packages/package.go
index 53724179a2..a79ba315be 100644
--- a/routers/api/v1/packages/package.go
+++ b/routers/api/v1/packages/package.go
@@ -164,7 +164,7 @@ func DeletePackage(ctx *context.APIContext) {
// "404":
// "$ref": "#/responses/notFound"
- err := packages_service.RemovePackageVersion(ctx.Doer, ctx.Package.Descriptor.Version)
+ err := packages_service.RemovePackageVersion(ctx, ctx.Doer, ctx.Package.Descriptor.Version)
if err != nil {
ctx.Error(http.StatusInternalServerError, "RemovePackageVersion", err)
return
diff --git a/routers/api/v1/repo/issue_reaction.go b/routers/api/v1/repo/issue_reaction.go
index 5210d4cced..29c99184e7 100644
--- a/routers/api/v1/repo/issue_reaction.go
+++ b/routers/api/v1/repo/issue_reaction.go
@@ -68,7 +68,7 @@ func GetIssueCommentReactions(ctx *context.APIContext) {
return
}
- reactions, _, err := issues_model.FindCommentReactions(comment.IssueID, comment.ID)
+ reactions, _, err := issues_model.FindCommentReactions(ctx, comment.IssueID, comment.ID)
if err != nil {
ctx.Error(http.StatusInternalServerError, "FindCommentReactions", err)
return
@@ -202,7 +202,7 @@ func changeIssueCommentReaction(ctx *context.APIContext, form api.EditReactionOp
if isCreateType {
// PostIssueCommentReaction part
- reaction, err := issues_model.CreateCommentReaction(ctx.Doer.ID, comment.Issue.ID, comment.ID, form.Reaction)
+ reaction, err := issues_model.CreateCommentReaction(ctx, ctx.Doer.ID, comment.Issue.ID, comment.ID, form.Reaction)
if err != nil {
if issues_model.IsErrForbiddenIssueReaction(err) {
ctx.Error(http.StatusForbidden, err.Error(), err)
@@ -225,7 +225,7 @@ func changeIssueCommentReaction(ctx *context.APIContext, form api.EditReactionOp
})
} else {
// DeleteIssueCommentReaction part
- err = issues_model.DeleteCommentReaction(ctx.Doer.ID, comment.Issue.ID, comment.ID, form.Reaction)
+ err = issues_model.DeleteCommentReaction(ctx, ctx.Doer.ID, comment.Issue.ID, comment.ID, form.Reaction)
if err != nil {
ctx.Error(http.StatusInternalServerError, "DeleteCommentReaction", err)
return
@@ -292,7 +292,7 @@ func GetIssueReactions(ctx *context.APIContext) {
return
}
- reactions, count, err := issues_model.FindIssueReactions(issue.ID, utils.GetListOptions(ctx))
+ reactions, count, err := issues_model.FindIssueReactions(ctx, issue.ID, utils.GetListOptions(ctx))
if err != nil {
ctx.Error(http.StatusInternalServerError, "FindIssueReactions", err)
return
@@ -418,7 +418,7 @@ func changeIssueReaction(ctx *context.APIContext, form api.EditReactionOption, i
if isCreateType {
// PostIssueReaction part
- reaction, err := issues_model.CreateIssueReaction(ctx.Doer.ID, issue.ID, form.Reaction)
+ reaction, err := issues_model.CreateIssueReaction(ctx, ctx.Doer.ID, issue.ID, form.Reaction)
if err != nil {
if issues_model.IsErrForbiddenIssueReaction(err) {
ctx.Error(http.StatusForbidden, err.Error(), err)
@@ -441,7 +441,7 @@ func changeIssueReaction(ctx *context.APIContext, form api.EditReactionOption, i
})
} else {
// DeleteIssueReaction part
- err = issues_model.DeleteIssueReaction(ctx.Doer.ID, issue.ID, form.Reaction)
+ err = issues_model.DeleteIssueReaction(ctx, ctx.Doer.ID, issue.ID, form.Reaction)
if err != nil {
ctx.Error(http.StatusInternalServerError, "DeleteIssueReaction", err)
return
diff --git a/routers/api/v1/repo/key.go b/routers/api/v1/repo/key.go
index b7d820d1d8..7d97f5f5e2 100644
--- a/routers/api/v1/repo/key.go
+++ b/routers/api/v1/repo/key.go
@@ -279,7 +279,7 @@ func DeleteDeploykey(ctx *context.APIContext) {
// "404":
// "$ref": "#/responses/notFound"
- if err := asymkey_service.DeleteDeployKey(ctx.Doer, ctx.ParamsInt64(":id")); err != nil {
+ if err := asymkey_service.DeleteDeployKey(ctx, ctx.Doer, ctx.ParamsInt64(":id")); err != nil {
if asymkey_model.IsErrKeyAccessDenied(err) {
ctx.Error(http.StatusForbidden, "", "You do not have access to this key")
} else {
diff --git a/routers/api/v1/repo/pull_review.go b/routers/api/v1/repo/pull_review.go
index 82cbb3e763..43379821c9 100644
--- a/routers/api/v1/repo/pull_review.go
+++ b/routers/api/v1/repo/pull_review.go
@@ -92,7 +92,7 @@ func ListPullReviews(ctx *context.APIContext) {
return
}
- count, err := issues_model.CountReviews(opts)
+ count, err := issues_model.CountReviews(ctx, opts)
if err != nil {
ctx.InternalServerError(err)
return
diff --git a/routers/api/v1/repo/release.go b/routers/api/v1/repo/release.go
index be9c0cd00a..61e5bdd679 100644
--- a/routers/api/v1/repo/release.go
+++ b/routers/api/v1/repo/release.go
@@ -90,7 +90,7 @@ func GetLatestRelease(ctx *context.APIContext) {
// "$ref": "#/responses/Release"
// "404":
// "$ref": "#/responses/notFound"
- release, err := repo_model.GetLatestReleaseByRepoID(ctx.Repo.Repository.ID)
+ release, err := repo_model.GetLatestReleaseByRepoID(ctx, ctx.Repo.Repository.ID)
if err != nil && !repo_model.IsErrReleaseNotExist(err) {
ctx.Error(http.StatusInternalServerError, "GetLatestRelease", err)
return
@@ -179,7 +179,7 @@ func ListReleases(ctx *context.APIContext) {
rels[i] = convert.ToAPIRelease(ctx, ctx.Repo.Repository, release)
}
- filteredCount, err := repo_model.CountReleasesByRepoID(ctx.Repo.Repository.ID, opts)
+ filteredCount, err := repo_model.CountReleasesByRepoID(ctx, ctx.Repo.Repository.ID, opts)
if err != nil {
ctx.InternalServerError(err)
return
@@ -222,7 +222,7 @@ func CreateRelease(ctx *context.APIContext) {
// "409":
// "$ref": "#/responses/error"
form := web.GetForm(ctx).(*api.CreateReleaseOption)
- rel, err := repo_model.GetRelease(ctx.Repo.Repository.ID, form.TagName)
+ rel, err := repo_model.GetRelease(ctx, ctx.Repo.Repository.ID, form.TagName)
if err != nil {
if !repo_model.IsErrReleaseNotExist(err) {
ctx.Error(http.StatusInternalServerError, "GetRelease", err)
@@ -269,7 +269,7 @@ func CreateRelease(ctx *context.APIContext) {
rel.Publisher = ctx.Doer
rel.Target = form.Target
- if err = release_service.UpdateRelease(ctx.Doer, ctx.Repo.GitRepo, rel, nil, nil, nil); err != nil {
+ if err = release_service.UpdateRelease(ctx, ctx.Doer, ctx.Repo.GitRepo, rel, nil, nil, nil); err != nil {
ctx.Error(http.StatusInternalServerError, "UpdateRelease", err)
return
}
@@ -344,7 +344,7 @@ func EditRelease(ctx *context.APIContext) {
if form.IsPrerelease != nil {
rel.IsPrerelease = *form.IsPrerelease
}
- if err := release_service.UpdateRelease(ctx.Doer, ctx.Repo.GitRepo, rel, nil, nil, nil); err != nil {
+ if err := release_service.UpdateRelease(ctx, ctx.Doer, ctx.Repo.GitRepo, rel, nil, nil, nil); err != nil {
ctx.Error(http.StatusInternalServerError, "UpdateRelease", err)
return
}
diff --git a/routers/api/v1/repo/release_tags.go b/routers/api/v1/repo/release_tags.go
index a03edfafcf..926a713c94 100644
--- a/routers/api/v1/repo/release_tags.go
+++ b/routers/api/v1/repo/release_tags.go
@@ -44,7 +44,7 @@ func GetReleaseByTag(ctx *context.APIContext) {
tag := ctx.Params(":tag")
- release, err := repo_model.GetRelease(ctx.Repo.Repository.ID, tag)
+ release, err := repo_model.GetRelease(ctx, ctx.Repo.Repository.ID, tag)
if err != nil {
if repo_model.IsErrReleaseNotExist(err) {
ctx.NotFound()
@@ -97,7 +97,7 @@ func DeleteReleaseByTag(ctx *context.APIContext) {
tag := ctx.Params(":tag")
- release, err := repo_model.GetRelease(ctx.Repo.Repository.ID, tag)
+ release, err := repo_model.GetRelease(ctx, ctx.Repo.Repository.ID, tag)
if err != nil {
if repo_model.IsErrReleaseNotExist(err) {
ctx.NotFound()
diff --git a/routers/api/v1/repo/repo.go b/routers/api/v1/repo/repo.go
index 5f25fdce14..9769668f47 100644
--- a/routers/api/v1/repo/repo.go
+++ b/routers/api/v1/repo/repo.go
@@ -1114,7 +1114,7 @@ func Delete(ctx *context.APIContext) {
owner := ctx.Repo.Owner
repo := ctx.Repo.Repository
- canDelete, err := repo_module.CanUserDelete(repo, ctx.Doer)
+ canDelete, err := repo_module.CanUserDelete(ctx, repo, ctx.Doer)
if err != nil {
ctx.Error(http.StatusInternalServerError, "CanUserDelete", err)
return
diff --git a/routers/api/v1/repo/tag.go b/routers/api/v1/repo/tag.go
index cd29937cb8..dbc8df0ef8 100644
--- a/routers/api/v1/repo/tag.go
+++ b/routers/api/v1/repo/tag.go
@@ -257,7 +257,7 @@ func DeleteTag(ctx *context.APIContext) {
// "$ref": "#/responses/repoArchivedError"
tagName := ctx.Params("*")
- tag, err := repo_model.GetRelease(ctx.Repo.Repository.ID, tagName)
+ tag, err := repo_model.GetRelease(ctx, ctx.Repo.Repository.ID, tagName)
if err != nil {
if repo_model.IsErrReleaseNotExist(err) {
ctx.NotFound()
diff --git a/routers/api/v1/user/gpg_key.go b/routers/api/v1/user/gpg_key.go
index 4aebbaf314..8578e09054 100644
--- a/routers/api/v1/user/gpg_key.go
+++ b/routers/api/v1/user/gpg_key.go
@@ -29,7 +29,7 @@ func listGPGKeys(ctx *context.APIContext, uid int64, listOptions db.ListOptions)
apiKeys[i] = convert.ToGPGKey(keys[i])
}
- total, err := asymkey_model.CountUserGPGKeys(uid)
+ total, err := asymkey_model.CountUserGPGKeys(ctx, uid)
if err != nil {
ctx.InternalServerError(err)
return
@@ -112,7 +112,7 @@ func GetGPGKey(ctx *context.APIContext) {
// "404":
// "$ref": "#/responses/notFound"
- key, err := asymkey_model.GetGPGKeyByID(ctx.ParamsInt64(":id"))
+ key, err := asymkey_model.GetGPGKeyByID(ctx, ctx.ParamsInt64(":id"))
if err != nil {
if asymkey_model.IsErrGPGKeyNotExist(err) {
ctx.NotFound()
@@ -129,9 +129,9 @@ func CreateUserGPGKey(ctx *context.APIContext, form api.CreateGPGKeyOption, uid
token := asymkey_model.VerificationToken(ctx.Doer, 1)
lastToken := asymkey_model.VerificationToken(ctx.Doer, 0)
- keys, err := asymkey_model.AddGPGKey(uid, form.ArmoredKey, token, form.Signature)
+ keys, err := asymkey_model.AddGPGKey(ctx, uid, form.ArmoredKey, token, form.Signature)
if err != nil && asymkey_model.IsErrGPGInvalidTokenSignature(err) {
- keys, err = asymkey_model.AddGPGKey(uid, form.ArmoredKey, lastToken, form.Signature)
+ keys, err = asymkey_model.AddGPGKey(ctx, uid, form.ArmoredKey, lastToken, form.Signature)
}
if err != nil {
HandleAddGPGKeyError(ctx, err, token)
@@ -198,7 +198,7 @@ func VerifyUserGPGKey(ctx *context.APIContext) {
ctx.Error(http.StatusInternalServerError, "VerifyUserGPGKey", err)
}
- key, err := asymkey_model.GetGPGKeysByKeyID(form.KeyID)
+ key, err := asymkey_model.GetGPGKeysByKeyID(ctx, form.KeyID)
if err != nil {
if asymkey_model.IsErrGPGKeyNotExist(err) {
ctx.NotFound()
@@ -259,7 +259,7 @@ func DeleteGPGKey(ctx *context.APIContext) {
// "404":
// "$ref": "#/responses/notFound"
- if err := asymkey_model.DeleteGPGKey(ctx.Doer, ctx.ParamsInt64(":id")); err != nil {
+ if err := asymkey_model.DeleteGPGKey(ctx, ctx.Doer, ctx.ParamsInt64(":id")); err != nil {
if asymkey_model.IsErrGPGKeyAccessDenied(err) {
ctx.Error(http.StatusForbidden, "", "You do not have access to this key")
} else {
diff --git a/routers/api/v1/user/helper.go b/routers/api/v1/user/helper.go
index 4b642910b1..392b266ebd 100644
--- a/routers/api/v1/user/helper.go
+++ b/routers/api/v1/user/helper.go
@@ -16,7 +16,7 @@ func GetUserByParamsName(ctx *context.APIContext, name string) *user_model.User
user, err := user_model.GetUserByName(ctx, username)
if err != nil {
if user_model.IsErrUserNotExist(err) {
- if redirectUserID, err2 := user_model.LookupUserRedirect(username); err2 == nil {
+ if redirectUserID, err2 := user_model.LookupUserRedirect(ctx, username); err2 == nil {
context.RedirectToUser(ctx.Base, username, redirectUserID)
} else {
ctx.NotFound("GetUserByName", err)
diff --git a/routers/api/v1/user/key.go b/routers/api/v1/user/key.go
index 21cc560847..7fc10e82f2 100644
--- a/routers/api/v1/user/key.go
+++ b/routers/api/v1/user/key.go
@@ -277,7 +277,7 @@ func DeletePublicKey(ctx *context.APIContext) {
return
}
- if err := asymkey_service.DeletePublicKey(ctx.Doer, id); err != nil {
+ if err := asymkey_service.DeletePublicKey(ctx, ctx.Doer, id); err != nil {
if asymkey_model.IsErrKeyAccessDenied(err) {
ctx.Error(http.StatusForbidden, "", "You do not have access to this key")
} else {
diff --git a/routers/api/v1/user/user.go b/routers/api/v1/user/user.go
index 251e7a6013..6359138369 100644
--- a/routers/api/v1/user/user.go
+++ b/routers/api/v1/user/user.go
@@ -138,7 +138,7 @@ func GetUserHeatmapData(ctx *context.APIContext) {
// "404":
// "$ref": "#/responses/notFound"
- heatmap, err := activities_model.GetUserHeatmapDataByUser(ctx.ContextUser, ctx.Doer)
+ heatmap, err := activities_model.GetUserHeatmapDataByUser(ctx, ctx.ContextUser, ctx.Doer)
if err != nil {
ctx.Error(http.StatusInternalServerError, "GetUserHeatmapDataByUser", err)
return
diff --git a/routers/init.go b/routers/init.go
index 150a5c56f2..3cd63eb9ae 100644
--- a/routers/init.go
+++ b/routers/init.go
@@ -93,7 +93,7 @@ func syncAppConfForGit(ctx context.Context) error {
mustInitCtx(ctx, repo_service.SyncRepositoryHooks)
log.Info("re-write ssh public keys ...")
- mustInit(asymkey_model.RewriteAllPublicKeys)
+ mustInitCtx(ctx, asymkey_model.RewriteAllPublicKeys)
return system.AppState.Set(runtimeState)
}
diff --git a/routers/web/admin/notice.go b/routers/web/admin/notice.go
index 9e4588dd75..ca85c96e10 100644
--- a/routers/web/admin/notice.go
+++ b/routers/web/admin/notice.go
@@ -30,7 +30,7 @@ func Notices(ctx *context.Context) {
page = 1
}
- notices, err := system_model.Notices(page, setting.UI.Admin.NoticePagingNum)
+ notices, err := system_model.Notices(ctx, page, setting.UI.Admin.NoticePagingNum)
if err != nil {
ctx.ServerError("Notices", err)
return
@@ -55,7 +55,7 @@ func DeleteNotices(ctx *context.Context) {
}
}
- if err := system_model.DeleteNoticesByIDs(ids); err != nil {
+ if err := system_model.DeleteNoticesByIDs(ctx, ids); err != nil {
ctx.Flash.Error("DeleteNoticesByIDs: " + err.Error())
ctx.Status(http.StatusInternalServerError)
} else {
@@ -66,7 +66,7 @@ func DeleteNotices(ctx *context.Context) {
// EmptyNotices delete all the notices
func EmptyNotices(ctx *context.Context) {
- if err := system_model.DeleteNotices(0, 0); err != nil {
+ if err := system_model.DeleteNotices(ctx, 0, 0); err != nil {
ctx.ServerError("DeleteNotices", err)
return
}
diff --git a/routers/web/admin/packages.go b/routers/web/admin/packages.go
index 8d4c29813e..f4e1a93a22 100644
--- a/routers/web/admin/packages.go
+++ b/routers/web/admin/packages.go
@@ -93,7 +93,7 @@ func DeletePackageVersion(ctx *context.Context) {
return
}
- if err := packages_service.RemovePackageVersion(ctx.Doer, pv); err != nil {
+ if err := packages_service.RemovePackageVersion(ctx, ctx.Doer, pv); err != nil {
ctx.ServerError("RemovePackageVersion", err)
return
}
diff --git a/routers/web/auth/2fa.go b/routers/web/auth/2fa.go
index 31ede82f01..bc3cb4907c 100644
--- a/routers/web/auth/2fa.go
+++ b/routers/web/auth/2fa.go
@@ -75,7 +75,7 @@ func TwoFactorPost(ctx *context.Context) {
}
if ctx.Session.Get("linkAccount") != nil {
- err = externalaccount.LinkAccountFromStore(ctx.Session, u)
+ err = externalaccount.LinkAccountFromStore(ctx, ctx.Session, u)
if err != nil {
ctx.ServerError("UserSignIn", err)
return
diff --git a/routers/web/auth/linkaccount.go b/routers/web/auth/linkaccount.go
index c6e3d1231b..42d846180d 100644
--- a/routers/web/auth/linkaccount.go
+++ b/routers/web/auth/linkaccount.go
@@ -164,7 +164,7 @@ func linkAccount(ctx *context.Context, u *user_model.User, gothUser goth.User, r
return
}
- err = externalaccount.LinkAccountToUser(u, gothUser)
+ err = externalaccount.LinkAccountToUser(ctx, u, gothUser)
if err != nil {
ctx.ServerError("UserLinkAccount", err)
return
diff --git a/routers/web/auth/oauth.go b/routers/web/auth/oauth.go
index 40c91b3f85..79f4711c26 100644
--- a/routers/web/auth/oauth.go
+++ b/routers/web/auth/oauth.go
@@ -941,7 +941,7 @@ func SignInOAuthCallback(ctx *context.Context) {
if u == nil {
if ctx.Doer != nil {
// attach user to already logged in user
- err = externalaccount.LinkAccountToUser(ctx.Doer, gothUser)
+ err = externalaccount.LinkAccountToUser(ctx, ctx.Doer, gothUser)
if err != nil {
ctx.ServerError("UserLinkAccount", err)
return
diff --git a/routers/web/auth/webauthn.go b/routers/web/auth/webauthn.go
index b19e18aa8e..88413caea6 100644
--- a/routers/web/auth/webauthn.go
+++ b/routers/web/auth/webauthn.go
@@ -141,7 +141,7 @@ func WebAuthnLoginAssertionPost(ctx *context.Context) {
// Now handle account linking if that's requested
if ctx.Session.Get("linkAccount") != nil {
- if err := externalaccount.LinkAccountFromStore(ctx.Session, user); err != nil {
+ if err := externalaccount.LinkAccountFromStore(ctx, ctx.Session, user); err != nil {
ctx.ServerError("LinkAccountFromStore", err)
return
}
diff --git a/routers/web/org/teams.go b/routers/web/org/teams.go
index dfb87b28f8..90029009fe 100644
--- a/routers/web/org/teams.go
+++ b/routers/web/org/teams.go
@@ -428,7 +428,7 @@ func SearchTeam(ctx *context.Context) {
ListOptions: listOptions,
}
- teams, maxResults, err := org_model.SearchTeam(opts)
+ teams, maxResults, err := org_model.SearchTeam(ctx, opts)
if err != nil {
log.Error("SearchTeam failed: %v", err)
ctx.JSON(http.StatusInternalServerError, map[string]any{
diff --git a/routers/web/repo/issue.go b/routers/web/repo/issue.go
index f4aa357fac..c360578f1f 100644
--- a/routers/web/repo/issue.go
+++ b/routers/web/repo/issue.go
@@ -231,7 +231,7 @@ func issues(ctx *context.Context, milestoneID, projectID int64, isPullOption uti
} else {
// So it did search with the keyword, and found some issues. It needs to get issueStats of these issues.
// Or the keyword is empty, so it doesn't need issueIDs as filter, just get issueStats with statsOpts.
- issueStats, err = issues_model.GetIssueStats(statsOpts)
+ issueStats, err = issues_model.GetIssueStats(ctx, statsOpts)
if err != nil {
ctx.ServerError("GetIssueStats", err)
return
@@ -611,14 +611,14 @@ type repoReviewerSelection struct {
func RetrieveRepoReviewers(ctx *context.Context, repo *repo_model.Repository, issue *issues_model.Issue, canChooseReviewer bool) {
ctx.Data["CanChooseReviewer"] = canChooseReviewer
- originalAuthorReviews, err := issues_model.GetReviewersFromOriginalAuthorsByIssueID(issue.ID)
+ originalAuthorReviews, err := issues_model.GetReviewersFromOriginalAuthorsByIssueID(ctx, issue.ID)
if err != nil {
ctx.ServerError("GetReviewersFromOriginalAuthorsByIssueID", err)
return
}
ctx.Data["OriginalReviews"] = originalAuthorReviews
- reviews, err := issues_model.GetReviewsByIssueID(issue.ID)
+ reviews, err := issues_model.GetReviewsByIssueID(ctx, issue.ID)
if err != nil {
ctx.ServerError("GetReviewersByIssueID", err)
return
@@ -3206,7 +3206,7 @@ func ChangeIssueReaction(ctx *context.Context) {
switch ctx.Params(":action") {
case "react":
- reaction, err := issues_model.CreateIssueReaction(ctx.Doer.ID, issue.ID, form.Content)
+ reaction, err := issues_model.CreateIssueReaction(ctx, ctx.Doer.ID, issue.ID, form.Content)
if err != nil {
if issues_model.IsErrForbiddenIssueReaction(err) {
ctx.ServerError("ChangeIssueReaction", err)
@@ -3224,7 +3224,7 @@ func ChangeIssueReaction(ctx *context.Context) {
log.Trace("Reaction for issue created: %d/%d/%d", ctx.Repo.Repository.ID, issue.ID, reaction.ID)
case "unreact":
- if err := issues_model.DeleteIssueReaction(ctx.Doer.ID, issue.ID, form.Content); err != nil {
+ if err := issues_model.DeleteIssueReaction(ctx, ctx.Doer.ID, issue.ID, form.Content); err != nil {
ctx.ServerError("DeleteIssueReaction", err)
return
}
@@ -3308,7 +3308,7 @@ func ChangeCommentReaction(ctx *context.Context) {
switch ctx.Params(":action") {
case "react":
- reaction, err := issues_model.CreateCommentReaction(ctx.Doer.ID, comment.Issue.ID, comment.ID, form.Content)
+ reaction, err := issues_model.CreateCommentReaction(ctx, ctx.Doer.ID, comment.Issue.ID, comment.ID, form.Content)
if err != nil {
if issues_model.IsErrForbiddenIssueReaction(err) {
ctx.ServerError("ChangeIssueReaction", err)
@@ -3326,7 +3326,7 @@ func ChangeCommentReaction(ctx *context.Context) {
log.Trace("Reaction for comment created: %d/%d/%d/%d", ctx.Repo.Repository.ID, comment.Issue.ID, comment.ID, reaction.ID)
case "unreact":
- if err := issues_model.DeleteCommentReaction(ctx.Doer.ID, comment.Issue.ID, comment.ID, form.Content); err != nil {
+ if err := issues_model.DeleteCommentReaction(ctx, ctx.Doer.ID, comment.Issue.ID, comment.ID, form.Content); err != nil {
ctx.ServerError("DeleteCommentReaction", err)
return
}
diff --git a/routers/web/repo/release.go b/routers/web/repo/release.go
index 138df45857..91ade32ccc 100644
--- a/routers/web/repo/release.go
+++ b/routers/web/repo/release.go
@@ -241,7 +241,7 @@ func SingleRelease(ctx *context.Context) {
writeAccess := ctx.Repo.CanWrite(unit.TypeReleases)
ctx.Data["CanCreateRelease"] = writeAccess && !ctx.Repo.Repository.IsArchived
- release, err := repo_model.GetRelease(ctx.Repo.Repository.ID, ctx.Params("*"))
+ release, err := repo_model.GetRelease(ctx, ctx.Repo.Repository.ID, ctx.Params("*"))
if err != nil {
if repo_model.IsErrReleaseNotExist(err) {
ctx.NotFound("GetRelease", err)
@@ -297,7 +297,7 @@ func SingleRelease(ctx *context.Context) {
// LatestRelease redirects to the latest release
func LatestRelease(ctx *context.Context) {
- release, err := repo_model.GetLatestReleaseByRepoID(ctx.Repo.Repository.ID)
+ release, err := repo_model.GetLatestReleaseByRepoID(ctx, ctx.Repo.Repository.ID)
if err != nil {
if repo_model.IsErrReleaseNotExist(err) {
ctx.NotFound("LatestRelease", err)
@@ -321,7 +321,7 @@ func NewRelease(ctx *context.Context) {
ctx.Data["PageIsReleaseList"] = true
ctx.Data["tag_target"] = ctx.Repo.Repository.DefaultBranch
if tagName := ctx.FormString("tag"); len(tagName) > 0 {
- rel, err := repo_model.GetRelease(ctx.Repo.Repository.ID, tagName)
+ rel, err := repo_model.GetRelease(ctx, ctx.Repo.Repository.ID, tagName)
if err != nil && !repo_model.IsErrReleaseNotExist(err) {
ctx.ServerError("GetRelease", err)
return
@@ -403,7 +403,7 @@ func NewReleasePost(ctx *context.Context) {
attachmentUUIDs = form.Files
}
- rel, err := repo_model.GetRelease(ctx.Repo.Repository.ID, form.TagName)
+ rel, err := repo_model.GetRelease(ctx, ctx.Repo.Repository.ID, form.TagName)
if err != nil {
if !repo_model.IsErrReleaseNotExist(err) {
ctx.ServerError("GetRelease", err)
@@ -488,7 +488,7 @@ func NewReleasePost(ctx *context.Context) {
rel.PublisherID = ctx.Doer.ID
rel.IsTag = false
- if err = releaseservice.UpdateRelease(ctx.Doer, ctx.Repo.GitRepo, rel, attachmentUUIDs, nil, nil); err != nil {
+ if err = releaseservice.UpdateRelease(ctx, ctx.Doer, ctx.Repo.GitRepo, rel, attachmentUUIDs, nil, nil); err != nil {
ctx.Data["Err_TagName"] = true
ctx.ServerError("UpdateRelease", err)
return
@@ -508,7 +508,7 @@ func EditRelease(ctx *context.Context) {
upload.AddUploadContext(ctx, "release")
tagName := ctx.Params("*")
- rel, err := repo_model.GetRelease(ctx.Repo.Repository.ID, tagName)
+ rel, err := repo_model.GetRelease(ctx, ctx.Repo.Repository.ID, tagName)
if err != nil {
if repo_model.IsErrReleaseNotExist(err) {
ctx.NotFound("GetRelease", err)
@@ -551,7 +551,7 @@ func EditReleasePost(ctx *context.Context) {
ctx.Data["PageIsEditRelease"] = true
tagName := ctx.Params("*")
- rel, err := repo_model.GetRelease(ctx.Repo.Repository.ID, tagName)
+ rel, err := repo_model.GetRelease(ctx, ctx.Repo.Repository.ID, tagName)
if err != nil {
if repo_model.IsErrReleaseNotExist(err) {
ctx.NotFound("GetRelease", err)
@@ -594,7 +594,7 @@ func EditReleasePost(ctx *context.Context) {
rel.Note = form.Content
rel.IsDraft = len(form.Draft) > 0
rel.IsPrerelease = form.Prerelease
- if err = releaseservice.UpdateRelease(ctx.Doer, ctx.Repo.GitRepo,
+ if err = releaseservice.UpdateRelease(ctx, ctx.Doer, ctx.Repo.GitRepo,
rel, addAttachmentUUIDs, delAttachmentUUIDs, editAttachments); err != nil {
ctx.ServerError("UpdateRelease", err)
return
diff --git a/routers/web/repo/repo.go b/routers/web/repo/repo.go
index b31ebb1971..88cbd701d2 100644
--- a/routers/web/repo/repo.go
+++ b/routers/web/repo/repo.go
@@ -396,7 +396,7 @@ func RedirectDownload(ctx *context.Context) {
} else if len(releases) == 0 && vTag == "latest" {
// GitHub supports the alias "latest" for the latest release
// We only fetch the latest release if the tag is "latest" and no release with the tag "latest" exists
- release, err := repo_model.GetLatestReleaseByRepoID(ctx.Repo.Repository.ID)
+ release, err := repo_model.GetLatestReleaseByRepoID(ctx, ctx.Repo.Repository.ID)
if err != nil {
ctx.Error(http.StatusNotFound)
return
diff --git a/routers/web/repo/setting/deploy_key.go b/routers/web/repo/setting/deploy_key.go
index 577706d454..70e31e1256 100644
--- a/routers/web/repo/setting/deploy_key.go
+++ b/routers/web/repo/setting/deploy_key.go
@@ -99,7 +99,7 @@ func DeployKeysPost(ctx *context.Context) {
// DeleteDeployKey response for deleting a deploy key
func DeleteDeployKey(ctx *context.Context) {
- if err := asymkey_service.DeleteDeployKey(ctx.Doer, ctx.FormInt64("id")); err != nil {
+ if err := asymkey_service.DeleteDeployKey(ctx, ctx.Doer, ctx.FormInt64("id")); err != nil {
ctx.Flash.Error("DeleteDeployKey: " + err.Error())
} else {
ctx.Flash.Success(ctx.Tr("repo.settings.deploy_key_deletion_success"))
diff --git a/routers/web/user/home.go b/routers/web/user/home.go
index 9efb536a7f..76b9262ead 100644
--- a/routers/web/user/home.go
+++ b/routers/web/user/home.go
@@ -105,7 +105,7 @@ func Dashboard(ctx *context.Context) {
}
if setting.Service.EnableUserHeatmap {
- data, err := activities_model.GetUserHeatmapDataByUserTeam(ctxUser, ctx.Org.Team, ctx.Doer)
+ data, err := activities_model.GetUserHeatmapDataByUserTeam(ctx, ctxUser, ctx.Org.Team, ctx.Doer)
if err != nil {
ctx.ServerError("GetUserHeatmapDataByUserTeam", err)
return
diff --git a/routers/web/user/package.go b/routers/web/user/package.go
index 57770b2b1a..146b94dfdf 100644
--- a/routers/web/user/package.go
+++ b/routers/web/user/package.go
@@ -439,7 +439,7 @@ func PackageSettingsPost(ctx *context.Context) {
ctx.Redirect(ctx.Link)
return
case "delete":
- err := packages_service.RemovePackageVersion(ctx.Doer, ctx.Package.Descriptor.Version)
+ err := packages_service.RemovePackageVersion(ctx, ctx.Doer, ctx.Package.Descriptor.Version)
if err != nil {
log.Error("Error deleting package: %v", err)
ctx.Flash.Error(ctx.Tr("packages.settings.delete.error"))
diff --git a/routers/web/user/profile.go b/routers/web/user/profile.go
index d9a0124020..f52ceb1a64 100644
--- a/routers/web/user/profile.go
+++ b/routers/web/user/profile.go
@@ -56,7 +56,7 @@ func userProfile(ctx *context.Context) {
// prepare heatmap data
if setting.Service.EnableUserHeatmap {
- data, err := activities_model.GetUserHeatmapDataByUser(ctx.ContextUser, ctx.Doer)
+ data, err := activities_model.GetUserHeatmapDataByUser(ctx, ctx.ContextUser, ctx.Doer)
if err != nil {
ctx.ServerError("GetUserHeatmapDataByUser", err)
return
diff --git a/routers/web/user/setting/keys.go b/routers/web/user/setting/keys.go
index 2c274f4c1c..160c5ee0c0 100644
--- a/routers/web/user/setting/keys.go
+++ b/routers/web/user/setting/keys.go
@@ -80,9 +80,9 @@ func KeysPost(ctx *context.Context) {
token := asymkey_model.VerificationToken(ctx.Doer, 1)
lastToken := asymkey_model.VerificationToken(ctx.Doer, 0)
- keys, err := asymkey_model.AddGPGKey(ctx.Doer.ID, form.Content, token, form.Signature)
+ keys, err := asymkey_model.AddGPGKey(ctx, ctx.Doer.ID, form.Content, token, form.Signature)
if err != nil && asymkey_model.IsErrGPGInvalidTokenSignature(err) {
- keys, err = asymkey_model.AddGPGKey(ctx.Doer.ID, form.Content, lastToken, form.Signature)
+ keys, err = asymkey_model.AddGPGKey(ctx, ctx.Doer.ID, form.Content, lastToken, form.Signature)
}
if err != nil {
ctx.Data["HasGPGError"] = true
@@ -224,7 +224,7 @@ func KeysPost(ctx *context.Context) {
func DeleteKey(ctx *context.Context) {
switch ctx.FormString("type") {
case "gpg":
- if err := asymkey_model.DeleteGPGKey(ctx.Doer, ctx.FormInt64("id")); err != nil {
+ if err := asymkey_model.DeleteGPGKey(ctx, ctx.Doer, ctx.FormInt64("id")); err != nil {
ctx.Flash.Error("DeleteGPGKey: " + err.Error())
} else {
ctx.Flash.Success(ctx.Tr("settings.gpg_key_deletion_success"))
@@ -241,13 +241,13 @@ func DeleteKey(ctx *context.Context) {
ctx.Redirect(setting.AppSubURL + "/user/settings/keys")
return
}
- if err := asymkey_service.DeletePublicKey(ctx.Doer, keyID); err != nil {
+ if err := asymkey_service.DeletePublicKey(ctx, ctx.Doer, keyID); err != nil {
ctx.Flash.Error("DeletePublicKey: " + err.Error())
} else {
ctx.Flash.Success(ctx.Tr("settings.ssh_key_deletion_success"))
}
case "principal":
- if err := asymkey_service.DeletePublicKey(ctx.Doer, ctx.FormInt64("id")); err != nil {
+ if err := asymkey_service.DeletePublicKey(ctx, ctx.Doer, ctx.FormInt64("id")); err != nil {
ctx.Flash.Error("DeletePublicKey: " + err.Error())
} else {
ctx.Flash.Success(ctx.Tr("settings.ssh_principal_deletion_success"))