summaryrefslogtreecommitdiffstats
path: root/routers/private
diff options
context:
space:
mode:
authorLunny Xiao <xiaolunwen@gmail.com>2022-12-03 10:48:26 +0800
committerGitHub <noreply@github.com>2022-12-03 10:48:26 +0800
commit0a7d3ff786508284224ada17956a65bb759d9265 (patch)
tree4860fca95c1432ab59c6723ee2b053b1c7d6779d /routers/private
parent8698458f48eafeab21014db544aa7160368856e1 (diff)
downloadgitea-0a7d3ff786508284224ada17956a65bb759d9265.tar.gz
gitea-0a7d3ff786508284224ada17956a65bb759d9265.zip
refactor some functions to support ctx as first parameter (#21878)
Co-authored-by: KN4CK3R <admin@oldschoolhack.me> Co-authored-by: Lauris BH <lauris@nix.lv>
Diffstat (limited to 'routers/private')
-rw-r--r--routers/private/hook_post_receive.go2
-rw-r--r--routers/private/hook_pre_receive.go2
-rw-r--r--routers/private/internal_repo.go2
-rw-r--r--routers/private/serv.go4
4 files changed, 5 insertions, 5 deletions
diff --git a/routers/private/hook_post_receive.go b/routers/private/hook_post_receive.go
index 9c69f9c345..c62038899d 100644
--- a/routers/private/hook_post_receive.go
+++ b/routers/private/hook_post_receive.go
@@ -183,7 +183,7 @@ func HookPostReceive(ctx *gitea_context.PrivateContext) {
baseRepo = repo
if repo.IsFork {
- if err := repo.GetBaseRepo(); err != nil {
+ if err := repo.GetBaseRepo(ctx); err != nil {
log.Error("Failed to get Base Repository of Forked repository: %-v Error: %v", repo, err)
ctx.JSON(http.StatusInternalServerError, private.HookPostReceiveResult{
Err: fmt.Sprintf("Failed to get Base Repository of Forked repository: %-v Error: %v", repo, err),
diff --git a/routers/private/hook_pre_receive.go b/routers/private/hook_pre_receive.go
index 52a82bfa44..e49ae68a64 100644
--- a/routers/private/hook_pre_receive.go
+++ b/routers/private/hook_pre_receive.go
@@ -464,7 +464,7 @@ func (ctx *preReceiveContext) loadPusherAndPermission() bool {
return true
}
- user, err := user_model.GetUserByID(ctx.opts.UserID)
+ user, err := user_model.GetUserByID(ctx, ctx.opts.UserID)
if err != nil {
log.Error("Unable to get User id %d Error: %v", ctx.opts.UserID, err)
ctx.JSON(http.StatusInternalServerError, private.Response{
diff --git a/routers/private/internal_repo.go b/routers/private/internal_repo.go
index 2e6f87d6b0..bd8db0a185 100644
--- a/routers/private/internal_repo.go
+++ b/routers/private/internal_repo.go
@@ -68,7 +68,7 @@ func RepoAssignment(ctx *gitea_context.PrivateContext) context.CancelFunc {
}
func loadRepository(ctx *gitea_context.PrivateContext, ownerName, repoName string) *repo_model.Repository {
- repo, err := repo_model.GetRepositoryByOwnerAndName(ownerName, repoName)
+ repo, err := repo_model.GetRepositoryByOwnerAndName(ctx, ownerName, repoName)
if err != nil {
log.Error("Failed to get repository: %s/%s Error: %v", ownerName, repoName, err)
ctx.JSON(http.StatusInternalServerError, map[string]interface{}{
diff --git a/routers/private/serv.go b/routers/private/serv.go
index 676d83d9e1..a86f6c0579 100644
--- a/routers/private/serv.go
+++ b/routers/private/serv.go
@@ -51,7 +51,7 @@ func ServNoCommand(ctx *context.PrivateContext) {
results.Key = key
if key.Type == asymkey_model.KeyTypeUser || key.Type == asymkey_model.KeyTypePrincipal {
- user, err := user_model.GetUserByID(key.OwnerID)
+ user, err := user_model.GetUserByID(ctx, key.OwnerID)
if err != nil {
if user_model.IsErrUserNotExist(err) {
ctx.JSON(http.StatusUnauthorized, private.Response{
@@ -259,7 +259,7 @@ func ServCommand(ctx *context.PrivateContext) {
} else {
// Get the user represented by the Key
var err error
- user, err = user_model.GetUserByID(key.OwnerID)
+ user, err = user_model.GetUserByID(ctx, key.OwnerID)
if err != nil {
if user_model.IsErrUserNotExist(err) {
ctx.JSON(http.StatusUnauthorized, private.ErrServCommand{