aboutsummaryrefslogtreecommitdiffstats
path: root/routers/api
diff options
context:
space:
mode:
authorLunny Xiao <xiaolunwen@gmail.com>2022-05-20 22:08:52 +0800
committerGitHub <noreply@github.com>2022-05-20 22:08:52 +0800
commitfd7d83ace60258acf7139c4c787aa8af75b7ba8c (patch)
tree50038348ec10485f72344f3ac80324e04abc1283 /routers/api
parentd81e31ad7826a81fc7139f329f250594610a274b (diff)
downloadgitea-fd7d83ace60258acf7139c4c787aa8af75b7ba8c.tar.gz
gitea-fd7d83ace60258acf7139c4c787aa8af75b7ba8c.zip
Move almost all functions' parameter db.Engine to context.Context (#19748)
* Move almost all functions' parameter db.Engine to context.Context * remove some unnecessary wrap functions
Diffstat (limited to 'routers/api')
-rw-r--r--routers/api/v1/admin/adopt.go8
-rw-r--r--routers/api/v1/admin/user.go2
-rw-r--r--routers/api/v1/api.go6
-rw-r--r--routers/api/v1/notify/notifications.go2
-rw-r--r--routers/api/v1/notify/repo.go4
-rw-r--r--routers/api/v1/notify/user.go4
-rw-r--r--routers/api/v1/org/hook.go2
-rw-r--r--routers/api/v1/org/label.go8
-rw-r--r--routers/api/v1/repo/branch.go18
-rw-r--r--routers/api/v1/repo/collaborators.go8
-rw-r--r--routers/api/v1/repo/hook.go2
-rw-r--r--routers/api/v1/repo/issue.go6
-rw-r--r--routers/api/v1/repo/issue_comment.go12
-rw-r--r--routers/api/v1/repo/issue_label.go6
-rw-r--r--routers/api/v1/repo/issue_reaction.go4
-rw-r--r--routers/api/v1/repo/issue_subscription.go6
-rw-r--r--routers/api/v1/repo/issue_tracked_time.go16
-rw-r--r--routers/api/v1/repo/label.go8
-rw-r--r--routers/api/v1/repo/language.go2
-rw-r--r--routers/api/v1/repo/migrate.go2
-rw-r--r--routers/api/v1/repo/mirror.go2
-rw-r--r--routers/api/v1/repo/pull.go22
-rw-r--r--routers/api/v1/repo/pull_review.go18
-rw-r--r--routers/api/v1/repo/release_attachment.go8
-rw-r--r--routers/api/v1/repo/repo.go6
-rw-r--r--routers/api/v1/repo/status.go2
-rw-r--r--routers/api/v1/repo/teams.go4
-rw-r--r--routers/api/v1/repo/transfer.go4
-rw-r--r--routers/api/v1/user/app.go4
-rw-r--r--routers/api/v1/user/helper.go2
-rw-r--r--routers/api/v1/user/settings.go2
-rw-r--r--routers/api/v1/user/star.go2
-rw-r--r--routers/api/v1/user/user.go2
-rw-r--r--routers/api/v1/user/watch.go4
34 files changed, 104 insertions, 104 deletions
diff --git a/routers/api/v1/admin/adopt.go b/routers/api/v1/admin/adopt.go
index 3c39d7c2bc..8f11ab67f0 100644
--- a/routers/api/v1/admin/adopt.go
+++ b/routers/api/v1/admin/adopt.go
@@ -85,7 +85,7 @@ func AdoptRepository(ctx *context.APIContext) {
ownerName := ctx.Params(":username")
repoName := ctx.Params(":reponame")
- ctxUser, err := user_model.GetUserByName(ownerName)
+ ctxUser, err := user_model.GetUserByName(ctx, ownerName)
if err != nil {
if user_model.IsErrUserNotExist(err) {
ctx.NotFound()
@@ -96,7 +96,7 @@ func AdoptRepository(ctx *context.APIContext) {
}
// check not a repo
- has, err := repo_model.IsRepositoryExist(ctxUser, repoName)
+ has, err := repo_model.IsRepositoryExist(ctx, ctxUser, repoName)
if err != nil {
ctx.InternalServerError(err)
return
@@ -147,7 +147,7 @@ func DeleteUnadoptedRepository(ctx *context.APIContext) {
ownerName := ctx.Params(":username")
repoName := ctx.Params(":reponame")
- ctxUser, err := user_model.GetUserByName(ownerName)
+ ctxUser, err := user_model.GetUserByName(ctx, ownerName)
if err != nil {
if user_model.IsErrUserNotExist(err) {
ctx.NotFound()
@@ -158,7 +158,7 @@ func DeleteUnadoptedRepository(ctx *context.APIContext) {
}
// check not a repo
- has, err := repo_model.IsRepositoryExist(ctxUser, repoName)
+ has, err := repo_model.IsRepositoryExist(ctx, ctxUser, repoName)
if err != nil {
ctx.InternalServerError(err)
return
diff --git a/routers/api/v1/admin/user.go b/routers/api/v1/admin/user.go
index 6263a67048..71932136b1 100644
--- a/routers/api/v1/admin/user.go
+++ b/routers/api/v1/admin/user.go
@@ -269,7 +269,7 @@ func EditUser(ctx *context.APIContext) {
ctx.ContextUser.IsRestricted = *form.Restricted
}
- if err := user_model.UpdateUser(ctx.ContextUser, emailChanged); err != nil {
+ if err := user_model.UpdateUser(ctx, ctx.ContextUser, emailChanged); err != nil {
if user_model.IsErrEmailAlreadyUsed(err) ||
user_model.IsErrEmailCharIsNotSupported(err) ||
user_model.IsErrEmailInvalid(err) {
diff --git a/routers/api/v1/api.go b/routers/api/v1/api.go
index 9db1d80f7f..62c4a8934c 100644
--- a/routers/api/v1/api.go
+++ b/routers/api/v1/api.go
@@ -108,7 +108,7 @@ func sudo() func(ctx *context.APIContext) {
if len(sudo) > 0 {
if ctx.IsSigned && ctx.Doer.IsAdmin {
- user, err := user_model.GetUserByName(sudo)
+ user, err := user_model.GetUserByName(ctx, sudo)
if err != nil {
if user_model.IsErrUserNotExist(err) {
ctx.NotFound()
@@ -143,7 +143,7 @@ func repoAssignment() func(ctx *context.APIContext) {
if ctx.IsSigned && ctx.Doer.LowerName == strings.ToLower(userName) {
owner = ctx.Doer
} else {
- owner, err = user_model.GetUserByName(userName)
+ owner, err = user_model.GetUserByName(ctx, userName)
if err != nil {
if user_model.IsErrUserNotExist(err) {
if redirectUserID, err := user_model.LookupUserRedirect(userName); err == nil {
@@ -467,7 +467,7 @@ func orgAssignment(args ...bool) func(ctx *context.APIContext) {
}
if assignTeam {
- ctx.Org.Team, err = organization.GetTeamByID(ctx.ParamsInt64(":teamid"))
+ ctx.Org.Team, err = organization.GetTeamByID(ctx, ctx.ParamsInt64(":teamid"))
if err != nil {
if organization.IsErrTeamNotExist(err) {
ctx.NotFound()
diff --git a/routers/api/v1/notify/notifications.go b/routers/api/v1/notify/notifications.go
index c707cf4524..0a3684fbe6 100644
--- a/routers/api/v1/notify/notifications.go
+++ b/routers/api/v1/notify/notifications.go
@@ -22,7 +22,7 @@ func NewAvailable(ctx *context.APIContext) {
// responses:
// "200":
// "$ref": "#/responses/NotificationCount"
- ctx.JSON(http.StatusOK, api.NotificationCount{New: models.CountUnread(ctx.Doer)})
+ ctx.JSON(http.StatusOK, api.NotificationCount{New: models.CountUnread(ctx, ctx.Doer.ID)})
}
func getFindNotificationOptions(ctx *context.APIContext) *models.FindNotificationOptions {
diff --git a/routers/api/v1/notify/repo.go b/routers/api/v1/notify/repo.go
index 0f6b90b05d..4e9dd806de 100644
--- a/routers/api/v1/notify/repo.go
+++ b/routers/api/v1/notify/repo.go
@@ -115,7 +115,7 @@ func ListRepoNotifications(ctx *context.APIContext) {
return
}
- nl, err := models.GetNotifications(opts)
+ nl, err := models.GetNotifications(ctx, opts)
if err != nil {
ctx.InternalServerError(err)
return
@@ -203,7 +203,7 @@ func ReadRepoNotifications(ctx *context.APIContext) {
opts.Status = statusStringsToNotificationStatuses(statuses, []string{"unread"})
log.Error("%v", opts.Status)
}
- nl, err := models.GetNotifications(opts)
+ nl, err := models.GetNotifications(ctx, opts)
if err != nil {
ctx.InternalServerError(err)
return
diff --git a/routers/api/v1/notify/user.go b/routers/api/v1/notify/user.go
index ac3d0591d0..b923307783 100644
--- a/routers/api/v1/notify/user.go
+++ b/routers/api/v1/notify/user.go
@@ -75,7 +75,7 @@ func ListNotifications(ctx *context.APIContext) {
return
}
- nl, err := models.GetNotifications(opts)
+ nl, err := models.GetNotifications(ctx, opts)
if err != nil {
ctx.InternalServerError(err)
return
@@ -148,7 +148,7 @@ func ReadNotifications(ctx *context.APIContext) {
statuses := ctx.FormStrings("status-types")
opts.Status = statusStringsToNotificationStatuses(statuses, []string{"unread"})
}
- nl, err := models.GetNotifications(opts)
+ nl, err := models.GetNotifications(ctx, opts)
if err != nil {
ctx.InternalServerError(err)
return
diff --git a/routers/api/v1/org/hook.go b/routers/api/v1/org/hook.go
index 67957430d1..ddf0ddefe6 100644
--- a/routers/api/v1/org/hook.go
+++ b/routers/api/v1/org/hook.go
@@ -51,7 +51,7 @@ func ListHooks(ctx *context.APIContext) {
return
}
- orgHooks, err := webhook.ListWebhooksByOpts(opts)
+ orgHooks, err := webhook.ListWebhooksByOpts(ctx, opts)
if err != nil {
ctx.InternalServerError(err)
return
diff --git a/routers/api/v1/org/label.go b/routers/api/v1/org/label.go
index d36b1d9a98..9844ea21d2 100644
--- a/routers/api/v1/org/label.go
+++ b/routers/api/v1/org/label.go
@@ -43,7 +43,7 @@ func ListLabels(ctx *context.APIContext) {
// "200":
// "$ref": "#/responses/LabelList"
- labels, err := models.GetLabelsByOrgID(ctx.Org.Organization.ID, ctx.FormString("sort"), utils.GetListOptions(ctx))
+ labels, err := models.GetLabelsByOrgID(ctx, ctx.Org.Organization.ID, ctx.FormString("sort"), utils.GetListOptions(ctx))
if err != nil {
ctx.Error(http.StatusInternalServerError, "GetLabelsByOrgID", err)
return
@@ -136,9 +136,9 @@ func GetLabel(ctx *context.APIContext) {
)
strID := ctx.Params(":id")
if intID, err2 := strconv.ParseInt(strID, 10, 64); err2 != nil {
- label, err = models.GetLabelInOrgByName(ctx.Org.Organization.ID, strID)
+ label, err = models.GetLabelInOrgByName(ctx, ctx.Org.Organization.ID, strID)
} else {
- label, err = models.GetLabelInOrgByID(ctx.Org.Organization.ID, intID)
+ label, err = models.GetLabelInOrgByID(ctx, ctx.Org.Organization.ID, intID)
}
if err != nil {
if models.IsErrOrgLabelNotExist(err) {
@@ -183,7 +183,7 @@ func EditLabel(ctx *context.APIContext) {
// "422":
// "$ref": "#/responses/validationError"
form := web.GetForm(ctx).(*api.EditLabelOption)
- label, err := models.GetLabelInOrgByID(ctx.Org.Organization.ID, ctx.ParamsInt64(":id"))
+ label, err := models.GetLabelInOrgByID(ctx, ctx.Org.Organization.ID, ctx.ParamsInt64(":id"))
if err != nil {
if models.IsErrOrgLabelNotExist(err) {
ctx.NotFound()
diff --git a/routers/api/v1/repo/branch.go b/routers/api/v1/repo/branch.go
index c030a896a7..09e6ccf238 100644
--- a/routers/api/v1/repo/branch.go
+++ b/routers/api/v1/repo/branch.go
@@ -70,7 +70,7 @@ func GetBranch(ctx *context.APIContext) {
return
}
- branchProtection, err := models.GetProtectedBranchBy(ctx.Repo.Repository.ID, branchName)
+ branchProtection, err := models.GetProtectedBranchBy(ctx, ctx.Repo.Repository.ID, branchName)
if err != nil {
ctx.Error(http.StatusInternalServerError, "GetBranchProtection", err)
return
@@ -206,7 +206,7 @@ func CreateBranch(ctx *context.APIContext) {
return
}
- branchProtection, err := models.GetProtectedBranchBy(ctx.Repo.Repository.ID, branch.Name)
+ branchProtection, err := models.GetProtectedBranchBy(ctx, ctx.Repo.Repository.ID, branch.Name)
if err != nil {
ctx.Error(http.StatusInternalServerError, "GetBranchProtection", err)
return
@@ -271,7 +271,7 @@ func ListBranches(ctx *context.APIContext) {
ctx.Error(http.StatusInternalServerError, "GetCommit", err)
return
}
- branchProtection, err := models.GetProtectedBranchBy(ctx.Repo.Repository.ID, branches[i].Name)
+ branchProtection, err := models.GetProtectedBranchBy(ctx, ctx.Repo.Repository.ID, branches[i].Name)
if err != nil {
ctx.Error(http.StatusInternalServerError, "GetBranchProtection", err)
return
@@ -320,7 +320,7 @@ func GetBranchProtection(ctx *context.APIContext) {
repo := ctx.Repo.Repository
bpName := ctx.Params(":name")
- bp, err := models.GetProtectedBranchBy(repo.ID, bpName)
+ bp, err := models.GetProtectedBranchBy(ctx, repo.ID, bpName)
if err != nil {
ctx.Error(http.StatusInternalServerError, "GetProtectedBranchByID", err)
return
@@ -412,7 +412,7 @@ func CreateBranchProtection(ctx *context.APIContext) {
return
}
- protectBranch, err := models.GetProtectedBranchBy(repo.ID, form.BranchName)
+ protectBranch, err := models.GetProtectedBranchBy(ctx, repo.ID, form.BranchName)
if err != nil {
ctx.Error(http.StatusInternalServerError, "GetProtectBranchOfRepoByName", err)
return
@@ -523,7 +523,7 @@ func CreateBranchProtection(ctx *context.APIContext) {
}
// Reload from db to get all whitelists
- bp, err := models.GetProtectedBranchBy(ctx.Repo.Repository.ID, form.BranchName)
+ bp, err := models.GetProtectedBranchBy(ctx, ctx.Repo.Repository.ID, form.BranchName)
if err != nil {
ctx.Error(http.StatusInternalServerError, "GetProtectedBranchByID", err)
return
@@ -575,7 +575,7 @@ func EditBranchProtection(ctx *context.APIContext) {
form := web.GetForm(ctx).(*api.EditBranchProtectionOption)
repo := ctx.Repo.Repository
bpName := ctx.Params(":name")
- protectBranch, err := models.GetProtectedBranchBy(repo.ID, bpName)
+ protectBranch, err := models.GetProtectedBranchBy(ctx, repo.ID, bpName)
if err != nil {
ctx.Error(http.StatusInternalServerError, "GetProtectedBranchByID", err)
return
@@ -758,7 +758,7 @@ func EditBranchProtection(ctx *context.APIContext) {
}
// Reload from db to ensure get all whitelists
- bp, err := models.GetProtectedBranchBy(repo.ID, bpName)
+ bp, err := models.GetProtectedBranchBy(ctx, repo.ID, bpName)
if err != nil {
ctx.Error(http.StatusInternalServerError, "GetProtectedBranchBy", err)
return
@@ -802,7 +802,7 @@ func DeleteBranchProtection(ctx *context.APIContext) {
repo := ctx.Repo.Repository
bpName := ctx.Params(":name")
- bp, err := models.GetProtectedBranchBy(repo.ID, bpName)
+ bp, err := models.GetProtectedBranchBy(ctx, repo.ID, bpName)
if err != nil {
ctx.Error(http.StatusInternalServerError, "GetProtectedBranchByID", err)
return
diff --git a/routers/api/v1/repo/collaborators.go b/routers/api/v1/repo/collaborators.go
index fed2d9f055..248497a561 100644
--- a/routers/api/v1/repo/collaborators.go
+++ b/routers/api/v1/repo/collaborators.go
@@ -103,7 +103,7 @@ func IsCollaborator(ctx *context.APIContext) {
// "422":
// "$ref": "#/responses/validationError"
- user, err := user_model.GetUserByName(ctx.Params(":collaborator"))
+ user, err := user_model.GetUserByName(ctx, ctx.Params(":collaborator"))
if err != nil {
if user_model.IsErrUserNotExist(err) {
ctx.Error(http.StatusUnprocessableEntity, "", err)
@@ -159,7 +159,7 @@ func AddCollaborator(ctx *context.APIContext) {
form := web.GetForm(ctx).(*api.AddCollaboratorOption)
- collaborator, err := user_model.GetUserByName(ctx.Params(":collaborator"))
+ collaborator, err := user_model.GetUserByName(ctx, ctx.Params(":collaborator"))
if err != nil {
if user_model.IsErrUserNotExist(err) {
ctx.Error(http.StatusUnprocessableEntity, "", err)
@@ -218,7 +218,7 @@ func DeleteCollaborator(ctx *context.APIContext) {
// "422":
// "$ref": "#/responses/validationError"
- collaborator, err := user_model.GetUserByName(ctx.Params(":collaborator"))
+ collaborator, err := user_model.GetUserByName(ctx, ctx.Params(":collaborator"))
if err != nil {
if user_model.IsErrUserNotExist(err) {
ctx.Error(http.StatusUnprocessableEntity, "", err)
@@ -271,7 +271,7 @@ func GetRepoPermissions(ctx *context.APIContext) {
return
}
- collaborator, err := user_model.GetUserByName(ctx.Params(":collaborator"))
+ collaborator, err := user_model.GetUserByName(ctx, ctx.Params(":collaborator"))
if err != nil {
if user_model.IsErrUserNotExist(err) {
ctx.Error(http.StatusNotFound, "GetUserByName", err)
diff --git a/routers/api/v1/repo/hook.go b/routers/api/v1/repo/hook.go
index 7ec6cd88ab..8a546e581a 100644
--- a/routers/api/v1/repo/hook.go
+++ b/routers/api/v1/repo/hook.go
@@ -60,7 +60,7 @@ func ListHooks(ctx *context.APIContext) {
return
}
- hooks, err := webhook.ListWebhooksByOpts(opts)
+ hooks, err := webhook.ListWebhooksByOpts(ctx, opts)
if err != nil {
ctx.InternalServerError(err)
return
diff --git a/routers/api/v1/repo/issue.go b/routers/api/v1/repo/issue.go
index b45069ad46..62959c3a76 100644
--- a/routers/api/v1/repo/issue.go
+++ b/routers/api/v1/repo/issue.go
@@ -145,7 +145,7 @@ func SearchIssues(ctx *context.APIContext) {
opts.AllLimited = true
}
if ctx.FormString("owner") != "" {
- owner, err := user_model.GetUserByName(ctx.FormString("owner"))
+ owner, err := user_model.GetUserByName(ctx, ctx.FormString("owner"))
if err != nil {
if user_model.IsErrUserNotExist(err) {
ctx.Error(http.StatusBadRequest, "Owner not found", err)
@@ -164,7 +164,7 @@ func SearchIssues(ctx *context.APIContext) {
ctx.Error(http.StatusBadRequest, "", "Owner organisation is required for filtering on team")
return
}
- team, err := organization.GetTeam(opts.OwnerID, ctx.FormString("team"))
+ team, err := organization.GetTeam(ctx, opts.OwnerID, ctx.FormString("team"))
if err != nil {
if organization.IsErrTeamNotExist(err) {
ctx.Error(http.StatusBadRequest, "Team not found", err)
@@ -502,7 +502,7 @@ func getUserIDForFilter(ctx *context.APIContext, queryName string) int64 {
return 0
}
- user, err := user_model.GetUserByName(userName)
+ user, err := user_model.GetUserByName(ctx, userName)
if user_model.IsErrUserNotExist(err) {
ctx.NotFound(err)
return 0
diff --git a/routers/api/v1/repo/issue_comment.go b/routers/api/v1/repo/issue_comment.go
index 6065adc27f..22533c3810 100644
--- a/routers/api/v1/repo/issue_comment.go
+++ b/routers/api/v1/repo/issue_comment.go
@@ -79,7 +79,7 @@ func ListIssueComments(ctx *context.APIContext) {
Type: models.CommentTypeComment,
}
- comments, err := models.FindComments(opts)
+ comments, err := models.FindComments(ctx, opts)
if err != nil {
ctx.Error(http.StatusInternalServerError, "FindComments", err)
return
@@ -172,7 +172,7 @@ func ListIssueCommentsAndTimeline(ctx *context.APIContext) {
Type: models.CommentTypeUnknown,
}
- comments, err := models.FindComments(opts)
+ comments, err := models.FindComments(ctx, opts)
if err != nil {
ctx.Error(http.StatusInternalServerError, "FindComments", err)
return
@@ -269,7 +269,7 @@ func ListRepoIssueComments(ctx *context.APIContext) {
Before: before,
}
- comments, err := models.FindComments(opts)
+ comments, err := models.FindComments(ctx, opts)
if err != nil {
ctx.Error(http.StatusInternalServerError, "FindComments", err)
return
@@ -399,7 +399,7 @@ func GetIssueComment(ctx *context.APIContext) {
// "404":
// "$ref": "#/responses/notFound"
- comment, err := models.GetCommentByID(ctx.ParamsInt64(":id"))
+ comment, err := models.GetCommentByID(ctx, ctx.ParamsInt64(":id"))
if err != nil {
if models.IsErrCommentNotExist(err) {
ctx.NotFound(err)
@@ -526,7 +526,7 @@ func EditIssueCommentDeprecated(ctx *context.APIContext) {
}
func editIssueComment(ctx *context.APIContext, form api.EditIssueCommentOption) {
- comment, err := models.GetCommentByID(ctx.ParamsInt64(":id"))
+ comment, err := models.GetCommentByID(ctx, ctx.ParamsInt64(":id"))
if err != nil {
if models.IsErrCommentNotExist(err) {
ctx.NotFound(err)
@@ -629,7 +629,7 @@ func DeleteIssueCommentDeprecated(ctx *context.APIContext) {
}
func deleteIssueComment(ctx *context.APIContext) {
- comment, err := models.GetCommentByID(ctx.ParamsInt64(":id"))
+ comment, err := models.GetCommentByID(ctx, ctx.ParamsInt64(":id"))
if err != nil {
if models.IsErrCommentNotExist(err) {
ctx.NotFound(err)
diff --git a/routers/api/v1/repo/issue_label.go b/routers/api/v1/repo/issue_label.go
index e314e756dd..0193eb4230 100644
--- a/routers/api/v1/repo/issue_label.go
+++ b/routers/api/v1/repo/issue_label.go
@@ -111,7 +111,7 @@ func AddIssueLabels(ctx *context.APIContext) {
return
}
- labels, err = models.GetLabelsByIssueID(issue.ID)
+ labels, err = models.GetLabelsByIssueID(ctx, issue.ID)
if err != nil {
ctx.Error(http.StatusInternalServerError, "GetLabelsByIssueID", err)
return
@@ -173,7 +173,7 @@ func DeleteIssueLabel(ctx *context.APIContext) {
return
}
- label, err := models.GetLabelByID(ctx.ParamsInt64(":id"))
+ label, err := models.GetLabelByID(ctx, ctx.ParamsInt64(":id"))
if err != nil {
if models.IsErrLabelNotExist(err) {
ctx.Error(http.StatusUnprocessableEntity, "", err)
@@ -237,7 +237,7 @@ func ReplaceIssueLabels(ctx *context.APIContext) {
return
}
- labels, err = models.GetLabelsByIssueID(issue.ID)
+ labels, err = models.GetLabelsByIssueID(ctx, issue.ID)
if err != nil {
ctx.Error(http.StatusInternalServerError, "GetLabelsByIssueID", err)
return
diff --git a/routers/api/v1/repo/issue_reaction.go b/routers/api/v1/repo/issue_reaction.go
index 5aa7366796..45be7a92dd 100644
--- a/routers/api/v1/repo/issue_reaction.go
+++ b/routers/api/v1/repo/issue_reaction.go
@@ -49,7 +49,7 @@ func GetIssueCommentReactions(ctx *context.APIContext) {
// "403":
// "$ref": "#/responses/forbidden"
- comment, err := models.GetCommentByID(ctx.ParamsInt64(":id"))
+ comment, err := models.GetCommentByID(ctx, ctx.ParamsInt64(":id"))
if err != nil {
if models.IsErrCommentNotExist(err) {
ctx.NotFound(err)
@@ -176,7 +176,7 @@ func DeleteIssueCommentReaction(ctx *context.APIContext) {
}
func changeIssueCommentReaction(ctx *context.APIContext, form api.EditReactionOption, isCreateType bool) {
- comment, err := models.GetCommentByID(ctx.ParamsInt64(":id"))
+ comment, err := models.GetCommentByID(ctx, ctx.ParamsInt64(":id"))
if err != nil {
if models.IsErrCommentNotExist(err) {
ctx.NotFound(err)
diff --git a/routers/api/v1/repo/issue_subscription.go b/routers/api/v1/repo/issue_subscription.go
index f00c85b126..a608ba2278 100644
--- a/routers/api/v1/repo/issue_subscription.go
+++ b/routers/api/v1/repo/issue_subscription.go
@@ -116,7 +116,7 @@ func setIssueSubscription(ctx *context.APIContext, watch bool) {
return
}
- user, err := user_model.GetUserByName(ctx.Params(":user"))
+ user, err := user_model.GetUserByName(ctx, ctx.Params(":user"))
if err != nil {
if user_model.IsErrUserNotExist(err) {
ctx.NotFound()
@@ -263,7 +263,7 @@ func GetIssueSubscribers(ctx *context.APIContext) {
return
}
- iwl, err := models.GetIssueWatchers(issue.ID, utils.GetListOptions(ctx))
+ iwl, err := models.GetIssueWatchers(ctx, issue.ID, utils.GetListOptions(ctx))
if err != nil {
ctx.Error(http.StatusInternalServerError, "GetIssueWatchers", err)
return
@@ -284,7 +284,7 @@ func GetIssueSubscribers(ctx *context.APIContext) {
apiUsers = append(apiUsers, convert.ToUser(v, ctx.Doer))
}
- count, err := models.CountIssueWatchers(issue.ID)
+ count, err := models.CountIssueWatchers(ctx, issue.ID)
if err != nil {
ctx.Error(http.StatusInternalServerError, "CountIssueWatchers", err)
return
diff --git a/routers/api/v1/repo/issue_tracked_time.go b/routers/api/v1/repo/issue_tracked_time.go
index 8ccad87838..19e1a82590 100644
--- a/routers/api/v1/repo/issue_tracked_time.go
+++ b/routers/api/v1/repo/issue_tracked_time.go
@@ -94,7 +94,7 @@ func ListTrackedTimes(ctx *context.APIContext) {
qUser := ctx.FormTrim("user")
if qUser != "" {
- user, err := user_model.GetUserByName(qUser)
+ user, err := user_model.GetUserByName(ctx, qUser)
if user_model.IsErrUserNotExist(err) {
ctx.Error(http.StatusNotFound, "User does not exist", err)
} else if err != nil {
@@ -128,7 +128,7 @@ func ListTrackedTimes(ctx *context.APIContext) {
return
}
- trackedTimes, err := models.GetTrackedTimes(opts)
+ trackedTimes, err := models.GetTrackedTimes(ctx, opts)
if err != nil {
ctx.Error(http.StatusInternalServerError, "GetTrackedTimes", err)
return
@@ -203,7 +203,7 @@ func AddTime(ctx *context.APIContext) {
if form.User != "" {
if (ctx.IsUserRepoAdmin() && ctx.Doer.Name != form.User) || ctx.Doer.IsAdmin {
// allow only RepoAdmin, Admin and User to add time
- user, err = user_model.GetUserByName(form.User)
+ user, err = user_model.GetUserByName(ctx, form.User)
if err != nil {
ctx.Error(http.StatusInternalServerError, "GetUserByName", err)
}
@@ -415,7 +415,7 @@ func ListTrackedTimesByUser(ctx *context.APIContext) {
ctx.Error(http.StatusBadRequest, "", "time tracking disabled")
return
}
- user, err := user_model.GetUserByName(ctx.Params(":timetrackingusername"))
+ user, err := user_model.GetUserByName(ctx, ctx.Params(":timetrackingusername"))
if err != nil {
if user_model.IsErrUserNotExist(err) {
ctx.NotFound(err)
@@ -439,7 +439,7 @@ func ListTrackedTimesByUser(ctx *context.APIContext) {
RepositoryID: ctx.Repo.Repository.ID,
}
- trackedTimes, err := models.GetTrackedTimes(opts)
+ trackedTimes, err := models.GetTrackedTimes(ctx, opts)
if err != nil {
ctx.Error(http.StatusInternalServerError, "GetTrackedTimes", err)
return
@@ -512,7 +512,7 @@ func ListTrackedTimesByRepository(ctx *context.APIContext) {
// Filters
qUser := ctx.FormTrim("user")
if qUser != "" {
- user, err := user_model.GetUserByName(qUser)
+ user, err := user_model.GetUserByName(ctx, qUser)
if user_model.IsErrUserNotExist(err) {
ctx.Error(http.StatusNotFound, "User does not exist", err)
} else if err != nil {
@@ -547,7 +547,7 @@ func ListTrackedTimesByRepository(ctx *context.APIContext) {
return
}
- trackedTimes, err := models.GetTrackedTimes(opts)
+ trackedTimes, err := models.GetTrackedTimes(ctx, opts)
if err != nil {
ctx.Error(http.StatusInternalServerError, "GetTrackedTimes", err)
return
@@ -609,7 +609,7 @@ func ListMyTrackedTimes(ctx *context.APIContext) {
return
}
- trackedTimes, err := models.GetTrackedTimes(opts)
+ trackedTimes, err := models.GetTrackedTimes(ctx, opts)
if err != nil {
ctx.Error(http.StatusInternalServerError, "GetTrackedTimesByUser", err)
return
diff --git a/routers/api/v1/repo/label.go b/routers/api/v1/repo/label.go
index ab559a2eed..4332b8e627 100644
--- a/routers/api/v1/repo/label.go
+++ b/routers/api/v1/repo/label.go
@@ -49,7 +49,7 @@ func ListLabels(ctx *context.APIContext) {
// "200":
// "$ref": "#/responses/LabelList"
- labels, err := models.GetLabelsByRepoID(ctx.Repo.Repository.ID, ctx.FormString("sort"), utils.GetListOptions(ctx))
+ labels, err := models.GetLabelsByRepoID(ctx, ctx.Repo.Repository.ID, ctx.FormString("sort"), utils.GetListOptions(ctx))
if err != nil {
ctx.Error(http.StatusInternalServerError, "GetLabelsByRepoID", err)
return
@@ -99,9 +99,9 @@ func GetLabel(ctx *context.APIContext) {
)
strID := ctx.Params(":id")
if intID, err2 := strconv.ParseInt(strID, 10, 64); err2 != nil {
- label, err = models.GetLabelInRepoByName(ctx.Repo.Repository.ID, strID)
+ label, err = models.GetLabelInRepoByName(ctx, ctx.Repo.Repository.ID, strID)
} else {
- label, err = models.GetLabelInRepoByID(ctx.Repo.Repository.ID, intID)
+ label, err = models.GetLabelInRepoByID(ctx, ctx.Repo.Repository.ID, intID)
}
if err != nil {
if models.IsErrRepoLabelNotExist(err) {
@@ -206,7 +206,7 @@ func EditLabel(ctx *context.APIContext) {
// "$ref": "#/responses/validationError"
form := web.GetForm(ctx).(*api.EditLabelOption)
- label, err := models.GetLabelInRepoByID(ctx.Repo.Repository.ID, ctx.ParamsInt64(":id"))
+ label, err := models.GetLabelInRepoByID(ctx, ctx.Repo.Repository.ID, ctx.ParamsInt64(":id"))
if err != nil {
if models.IsErrRepoLabelNotExist(err) {
ctx.NotFound()
diff --git a/routers/api/v1/repo/language.go b/routers/api/v1/repo/language.go
index f47b0a0e78..ca803cb68b 100644
--- a/routers/api/v1/repo/language.go
+++ b/routers/api/v1/repo/language.go
@@ -68,7 +68,7 @@ func GetLanguages(ctx *context.APIContext) {
// "200":
// "$ref": "#/responses/LanguageStatistics"
- langs, err := repo_model.GetLanguageStats(ctx.Repo.Repository)
+ langs, err := repo_model.GetLanguageStats(ctx, ctx.Repo.Repository)
if err != nil {
log.Error("GetLanguageStats failed: %v", err)
ctx.InternalServerError(err)
diff --git a/routers/api/v1/repo/migrate.go b/routers/api/v1/repo/migrate.go
index f5851bfcae..f868c53951 100644
--- a/routers/api/v1/repo/migrate.go
+++ b/routers/api/v1/repo/migrate.go
@@ -65,7 +65,7 @@ func Migrate(ctx *context.APIContext) {
err error
)
if len(form.RepoOwner) != 0 {
- repoOwner, err = user_model.GetUserByName(form.RepoOwner)
+ repoOwner, err = user_model.GetUserByName(ctx, form.RepoOwner)
} else if form.RepoOwnerID != 0 {
repoOwner, err = user_model.GetUserByID(form.RepoOwnerID)
} else {
diff --git a/routers/api/v1/repo/mirror.go b/routers/api/v1/repo/mirror.go
index d7facd24d9..1af63c55be 100644
--- a/routers/api/v1/repo/mirror.go
+++ b/routers/api/v1/repo/mirror.go
@@ -50,7 +50,7 @@ func MirrorSync(ctx *context.APIContext) {
return
}
- if _, err := repo_model.GetMirrorByRepoID(repo.ID); err != nil {
+ if _, err := repo_model.GetMirrorByRepoID(ctx, repo.ID); err != nil {
if errors.Is(err, repo_model.ErrMirrorNotExist) {
ctx.Error(http.StatusBadRequest, "MirrorSync", "Repository is not a mirror")
return
diff --git a/routers/api/v1/repo/pull.go b/routers/api/v1/repo/pull.go
index a01efda1bc..393f2d1576 100644
--- a/routers/api/v1/repo/pull.go
+++ b/routers/api/v1/repo/pull.go
@@ -160,7 +160,7 @@ func GetPullRequest(ctx *context.APIContext) {
// "404":
// "$ref": "#/responses/notFound"
- pr, err := models.GetPullRequestByIndex(ctx.Repo.Repository.ID, ctx.ParamsInt64(":index"))
+ pr, err := models.GetPullRequestByIndex(ctx, ctx.Repo.Repository.ID, ctx.ParamsInt64(":index"))
if err != nil {
if models.IsErrPullRequestNotExist(err) {
ctx.NotFound()
@@ -220,7 +220,7 @@ func DownloadPullDiffOrPatch(ctx *context.APIContext) {
// "$ref": "#/responses/string"
// "404":
// "$ref": "#/responses/notFound"
- pr, err := models.GetPullRequestByIndex(ctx.Repo.Repository.ID, ctx.ParamsInt64(":index"))
+ pr, err := models.GetPullRequestByIndex(ctx, ctx.Repo.Repository.ID, ctx.ParamsInt64(":index"))
if err != nil {
if models.IsErrPullRequestNotExist(err) {
ctx.NotFound()
@@ -470,7 +470,7 @@ func EditPullRequest(ctx *context.APIContext) {
// "$ref": "#/responses/validationError"
form := web.GetForm(ctx).(*api.EditPullRequestOption)
- pr, err := models.GetPullRequestByIndex(ctx.Repo.Repository.ID, ctx.ParamsInt64(":index"))
+ pr, err := models.GetPullRequestByIndex(ctx, ctx.Repo.Repository.ID, ctx.ParamsInt64(":index"))
if err != nil {
if models.IsErrPullRequestNotExist(err) {
ctx.NotFound()
@@ -632,7 +632,7 @@ func EditPullRequest(ctx *context.APIContext) {
}
// Refetch from database
- pr, err = models.GetPullRequestByIndex(ctx.Repo.Repository.ID, pr.Index)
+ pr, err = models.GetPullRequestByIndex(ctx, ctx.Repo.Repository.ID, pr.Index)
if err != nil {
if models.IsErrPullRequestNotExist(err) {
ctx.NotFound()
@@ -676,7 +676,7 @@ func IsPullRequestMerged(ctx *context.APIContext) {
// "404":
// description: pull request has not been merged
- pr, err := models.GetPullRequestByIndex(ctx.Repo.Repository.ID, ctx.ParamsInt64(":index"))
+ pr, err := models.GetPullRequestByIndex(ctx, ctx.Repo.Repository.ID, ctx.ParamsInt64(":index"))
if err != nil {
if models.IsErrPullRequestNotExist(err) {
ctx.NotFound()
@@ -730,7 +730,7 @@ func MergePullRequest(ctx *context.APIContext) {
form := web.GetForm(ctx).(*forms.MergePullRequestForm)
- pr, err := models.GetPullRequestByIndexCtx(ctx, ctx.Repo.Repository.ID, ctx.ParamsInt64(":index"))
+ pr, err := models.GetPullRequestByIndex(ctx, ctx.Repo.Repository.ID, ctx.ParamsInt64(":index"))
if err != nil {
if models.IsErrPullRequestNotExist(err) {
ctx.NotFound("GetPullRequestByIndex", err)
@@ -938,7 +938,7 @@ func parseCompareInfo(ctx *context.APIContext, form api.CreatePullRequestOption)
headBranch = headInfos[0]
} else if len(headInfos) == 2 {
- headUser, err = user_model.GetUserByName(headInfos[0])
+ headUser, err = user_model.GetUserByName(ctx, headInfos[0])
if err != nil {
if user_model.IsErrUserNotExist(err) {
ctx.NotFound("GetUserByName")
@@ -1079,7 +1079,7 @@ func UpdatePullRequest(ctx *context.APIContext) {
// "422":
// "$ref": "#/responses/validationError"
- pr, err := models.GetPullRequestByIndex(ctx.Repo.Repository.ID, ctx.ParamsInt64(":index"))
+ pr, err := models.GetPullRequestByIndex(ctx, ctx.Repo.Repository.ID, ctx.ParamsInt64(":index"))
if err != nil {
if models.IsErrPullRequestNotExist(err) {
ctx.NotFound()
@@ -1177,7 +1177,7 @@ func CancelScheduledAutoMerge(ctx *context.APIContext) {
// "$ref": "#/responses/notFound"
pullIndex := ctx.ParamsInt64(":index")
- pull, err := models.GetPullRequestByIndex(ctx.Repo.Repository.ID, pullIndex)
+ pull, err := models.GetPullRequestByIndex(ctx, ctx.Repo.Repository.ID, pullIndex)
if err != nil {
if models.IsErrPullRequestNotExist(err) {
ctx.NotFound()
@@ -1198,7 +1198,7 @@ func CancelScheduledAutoMerge(ctx *context.APIContext) {
}
if ctx.Doer.ID != autoMerge.DoerID {
- allowed, err := access_model.IsUserRepoAdminCtx(ctx, ctx.Repo.Repository, ctx.Doer)
+ allowed, err := access_model.IsUserRepoAdmin(ctx, ctx.Repo.Repository, ctx.Doer)
if err != nil {
ctx.InternalServerError(err)
return
@@ -1254,7 +1254,7 @@ func GetPullRequestCommits(ctx *context.APIContext) {
// "404":
// "$ref": "#/responses/notFound"
- pr, err := models.GetPullRequestByIndex(ctx.Repo.Repository.ID, ctx.ParamsInt64(":index"))
+ pr, err := models.GetPullRequestByIndex(ctx, ctx.Repo.Repository.ID, ctx.ParamsInt64(":index"))
if err != nil {
if models.IsErrPullRequestNotExist(err) {
ctx.NotFound()
diff --git a/routers/api/v1/repo/pull_review.go b/routers/api/v1/repo/pull_review.go
index 0cf540ce7e..5175fa921f 100644
--- a/routers/api/v1/repo/pull_review.go
+++ b/routers/api/v1/repo/pull_review.go
@@ -61,7 +61,7 @@ func ListPullReviews(ctx *context.APIContext) {
// "404":
// "$ref": "#/responses/notFound"
- pr, err := models.GetPullRequestByIndex(ctx.Repo.Repository.ID, ctx.ParamsInt64(":index"))
+ pr, err := models.GetPullRequestByIndex(ctx, ctx.Repo.Repository.ID, ctx.ParamsInt64(":index"))
if err != nil {
if models.IsErrPullRequestNotExist(err) {
ctx.NotFound("GetPullRequestByIndex", err)
@@ -87,7 +87,7 @@ func ListPullReviews(ctx *context.APIContext) {
IssueID: pr.IssueID,
}
- allReviews, err := models.FindReviews(opts)
+ allReviews, err := models.FindReviews(ctx, opts)
if err != nil {
ctx.InternalServerError(err)
return
@@ -307,7 +307,7 @@ func CreatePullReview(ctx *context.APIContext) {
// "$ref": "#/responses/validationError"
opts := web.GetForm(ctx).(*api.CreatePullReviewOptions)
- pr, err := models.GetPullRequestByIndex(ctx.Repo.Repository.ID, ctx.ParamsInt64(":index"))
+ pr, err := models.GetPullRequestByIndex(ctx, ctx.Repo.Repository.ID, ctx.ParamsInt64(":index"))
if err != nil {
if models.IsErrPullRequestNotExist(err) {
ctx.NotFound("GetPullRequestByIndex", err)
@@ -526,7 +526,7 @@ func preparePullReviewType(ctx *context.APIContext, pr *models.PullRequest, even
// prepareSingleReview return review, related pull and false or nil, nil and true if an error happen
func prepareSingleReview(ctx *context.APIContext) (*models.Review, *models.PullRequest, bool) {
- pr, err := models.GetPullRequestByIndex(ctx.Repo.Repository.ID, ctx.ParamsInt64(":index"))
+ pr, err := models.GetPullRequestByIndex(ctx, ctx.Repo.Repository.ID, ctx.ParamsInt64(":index"))
if err != nil {
if models.IsErrPullRequestNotExist(err) {
ctx.NotFound("GetPullRequestByIndex", err)
@@ -536,7 +536,7 @@ func prepareSingleReview(ctx *context.APIContext) (*models.Review, *models.PullR
return nil, nil, true
}
- review, err := models.GetReviewByID(ctx.ParamsInt64(":id"))
+ review, err := models.GetReviewByID(ctx, ctx.ParamsInt64(":id"))
if err != nil {
if models.IsErrReviewNotExist(err) {
ctx.NotFound("GetReviewByID", err)
@@ -648,7 +648,7 @@ func DeleteReviewRequests(ctx *context.APIContext) {
}
func apiReviewRequest(ctx *context.APIContext, opts api.PullReviewRequestOptions, isAdd bool) {
- pr, err := models.GetPullRequestByIndex(ctx.Repo.Repository.ID, ctx.ParamsInt64(":index"))
+ pr, err := models.GetPullRequestByIndex(ctx, ctx.Repo.Repository.ID, ctx.ParamsInt64(":index"))
if err != nil {
if models.IsErrPullRequestNotExist(err) {
ctx.NotFound("GetPullRequestByIndex", err)
@@ -676,7 +676,7 @@ func apiReviewRequest(ctx *context.APIContext, opts api.PullReviewRequestOptions
if strings.Contains(r, "@") {
reviewer, err = user_model.GetUserByEmail(r)
} else {
- reviewer, err = user_model.GetUserByName(r)
+ reviewer, err = user_model.GetUserByName(ctx, r)
}
if err != nil {
@@ -727,7 +727,7 @@ func apiReviewRequest(ctx *context.APIContext, opts api.PullReviewRequestOptions
teamReviewers := make([]*organization.Team, 0, len(opts.TeamReviewers))
for _, t := range opts.TeamReviewers {
var teamReviewer *organization.Team
- teamReviewer, err = organization.GetTeam(ctx.Repo.Owner.ID, t)
+ teamReviewer, err = organization.GetTeam(ctx, ctx.Repo.Owner.ID, t)
if err != nil {
if organization.IsErrTeamNotExist(err) {
ctx.NotFound("TeamNotExist", fmt.Sprintf("Team '%s' not exist", t))
@@ -892,7 +892,7 @@ func dismissReview(ctx *context.APIContext, msg string, isDismiss bool) {
return
}
- if review, err = models.GetReviewByID(review.ID); err != nil {
+ if review, err = models.GetReviewByID(ctx, review.ID); err != nil {
ctx.Error(http.StatusInternalServerError, "GetReviewByID", err)
return
}
diff --git a/routers/api/v1/repo/release_attachment.go b/routers/api/v1/repo/release_attachment.go
index c172b66127..b7807e5e8b 100644
--- a/routers/api/v1/repo/release_attachment.go
+++ b/routers/api/v1/repo/release_attachment.go
@@ -55,7 +55,7 @@ func GetReleaseAttachment(ctx *context.APIContext) {
releaseID := ctx.ParamsInt64(":id")
attachID := ctx.ParamsInt64(":asset")
- attach, err := repo_model.GetAttachmentByID(attachID)
+ attach, err := repo_model.GetAttachmentByID(ctx, attachID)
if err != nil {
ctx.Error(http.StatusInternalServerError, "GetAttachmentByID", err)
return
@@ -242,7 +242,7 @@ func EditReleaseAttachment(ctx *context.APIContext) {
// Check if release exists an load release
releaseID := ctx.ParamsInt64(":id")
attachID := ctx.ParamsInt64(":asset")
- attach, err := repo_model.GetAttachmentByID(attachID)
+ attach, err := repo_model.GetAttachmentByID(ctx, attachID)
if err != nil {
ctx.Error(http.StatusInternalServerError, "GetAttachmentByID", err)
return
@@ -257,7 +257,7 @@ func EditReleaseAttachment(ctx *context.APIContext) {
attach.Name = form.Name
}
- if err := repo_model.UpdateAttachment(attach); err != nil {
+ if err := repo_model.UpdateAttachment(ctx, attach); err != nil {
ctx.Error(http.StatusInternalServerError, "UpdateAttachment", attach)
}
ctx.JSON(http.StatusCreated, convert.ToReleaseAttachment(attach))
@@ -300,7 +300,7 @@ func DeleteReleaseAttachment(ctx *context.APIContext) {
// Check if release exists an load release
releaseID := ctx.ParamsInt64(":id")
attachID := ctx.ParamsInt64(":asset")
- attach, err := repo_model.GetAttachmentByID(attachID)
+ attach, err := repo_model.GetAttachmentByID(ctx, attachID)
if err != nil {
ctx.Error(http.StatusInternalServerError, "GetAttachmentByID", err)
return
diff --git a/routers/api/v1/repo/repo.go b/routers/api/v1/repo/repo.go
index a11f579ee1..8485ffbac2 100644
--- a/routers/api/v1/repo/repo.go
+++ b/routers/api/v1/repo/repo.go
@@ -365,7 +365,7 @@ func Generate(ctx *context.APIContext) {
ctxUser := ctx.Doer
var err error
if form.Owner != ctxUser.Name {
- ctxUser, err = user_model.GetUserByName(form.Owner)
+ ctxUser, err = user_model.GetUserByName(ctx, form.Owner)
if err != nil {
if user_model.IsErrUserNotExist(err) {
ctx.JSON(http.StatusNotFound, map[string]interface{}{
@@ -962,7 +962,7 @@ func updateMirror(ctx *context.APIContext, opts api.EditRepoOption) error {
}
// get the mirror from the repo
- mirror, err := repo_model.GetMirrorByRepoID(repo.ID)
+ mirror, err := repo_model.GetMirrorByRepoID(ctx, repo.ID)
if err != nil {
log.Error("Failed to get mirror: %s", err)
ctx.Error(http.StatusInternalServerError, "MirrorInterval", err)
@@ -1000,7 +1000,7 @@ func updateMirror(ctx *context.APIContext, opts api.EditRepoOption) error {
}
// finally update the mirror in the DB
- if err := repo_model.UpdateMirror(mirror); err != nil {
+ if err := repo_model.UpdateMirror(ctx, mirror); err != nil {
log.Error("Failed to Set Mirror Interval: %s", err)
ctx.Error(http.StatusUnprocessableEntity, "MirrorInterval", err)
return err
diff --git a/routers/api/v1/repo/status.go b/routers/api/v1/repo/status.go
index f4c0ebd38c..09597dc4e8 100644
--- a/routers/api/v1/repo/status.go
+++ b/routers/api/v1/repo/status.go
@@ -253,7 +253,7 @@ func GetCombinedCommitStatusByRef(ctx *context.APIContext) {
repo := ctx.Repo.Repository
- statuses, count, err := models.GetLatestCommitStatus(repo.ID, sha, utils.GetListOptions(ctx))
+ statuses, count, err := models.GetLatestCommitStatus(ctx, repo.ID, sha, utils.GetListOptions(ctx))
if err != nil {
ctx.Error(http.StatusInternalServerError, "GetLatestCommitStatus", fmt.Errorf("GetLatestCommitStatus[%s, %s]: %v", repo.FullName(), sha, err))
return
diff --git a/routers/api/v1/repo/teams.go b/routers/api/v1/repo/teams.go
index e414d8b60e..47c69d722b 100644
--- a/routers/api/v1/repo/teams.go
+++ b/routers/api/v1/repo/teams.go
@@ -41,7 +41,7 @@ func ListTeams(ctx *context.APIContext) {
return
}
- teams, err := organization.GetRepoTeams(ctx.Repo.Repository)
+ teams, err := organization.GetRepoTeams(ctx, ctx.Repo.Repository)
if err != nil {
ctx.InternalServerError(err)
return
@@ -216,7 +216,7 @@ func changeRepoTeam(ctx *context.APIContext, add bool) {
}
func getTeamByParam(ctx *context.APIContext) *organization.Team {
- team, err := organization.GetTeam(ctx.Repo.Owner.ID, ctx.Params(":team"))
+ team, err := organization.GetTeam(ctx, ctx.Repo.Owner.ID, ctx.Params(":team"))
if err != nil {
if organization.IsErrTeamNotExist(err) {
ctx.Error(http.StatusNotFound, "TeamNotExit", err)
diff --git a/routers/api/v1/repo/transfer.go b/routers/api/v1/repo/transfer.go
index 241c578e60..067a4ebe19 100644
--- a/routers/api/v1/repo/transfer.go
+++ b/routers/api/v1/repo/transfer.go
@@ -57,7 +57,7 @@ func Transfer(ctx *context.APIContext) {
opts := web.GetForm(ctx).(*api.TransferRepoOption)
- newOwner, err := user_model.GetUserByName(opts.NewOwner)
+ newOwner, err := user_model.GetUserByName(ctx, opts.NewOwner)
if err != nil {
if user_model.IsErrUserNotExist(err) {
ctx.Error(http.StatusNotFound, "", "The new owner does not exist or cannot be found")
@@ -84,7 +84,7 @@ func Transfer(ctx *context.APIContext) {
org := convert.ToOrganization(organization.OrgFromUser(newOwner))
for _, tID := range *opts.TeamIDs {
- team, err := organization.GetTeamByID(tID)
+ team, err := organization.GetTeamByID(ctx, tID)
if err != nil {
ctx.Error(http.StatusUnprocessableEntity, "team", fmt.Errorf("team %d not found", tID))
return
diff --git a/routers/api/v1/user/app.go b/routers/api/v1/user/app.go
index 165b8f005e..0d2e8401cc 100644
--- a/routers/api/v1/user/app.go
+++ b/routers/api/v1/user/app.go
@@ -213,7 +213,7 @@ func CreateOauth2Application(ctx *context.APIContext) {
data := web.GetForm(ctx).(*api.CreateOAuth2ApplicationOptions)
- app, err := auth.CreateOAuth2Application(auth.CreateOAuth2ApplicationOptions{
+ app, err := auth.CreateOAuth2Application(ctx, auth.CreateOAuth2ApplicationOptions{
Name: data.Name,
UserID: ctx.Doer.ID,
RedirectURIs: data.RedirectURIs,
@@ -320,7 +320,7 @@ func GetOauth2Application(ctx *context.APIContext) {
// "404":
// "$ref": "#/responses/notFound"
appID := ctx.ParamsInt64(":id")
- app, err := auth.GetOAuth2ApplicationByID(appID)
+ app, err := auth.GetOAuth2ApplicationByID(ctx, appID)
if err != nil {
if auth.IsErrOauthClientIDInvalid(err) || auth.IsErrOAuthApplicationNotFound(err) {
ctx.NotFound()
diff --git a/routers/api/v1/user/helper.go b/routers/api/v1/user/helper.go
index fab3ce2ae5..ae7fa5248e 100644
--- a/routers/api/v1/user/helper.go
+++ b/routers/api/v1/user/helper.go
@@ -14,7 +14,7 @@ import (
// GetUserByParamsName get user by name
func GetUserByParamsName(ctx *context.APIContext, name string) *user_model.User {
username := ctx.Params(name)
- user, err := user_model.GetUserByName(username)
+ user, err := user_model.GetUserByName(ctx, username)
if err != nil {
if user_model.IsErrUserNotExist(err) {
if redirectUserID, err2 := user_model.LookupUserRedirect(username); err2 == nil {
diff --git a/routers/api/v1/user/settings.go b/routers/api/v1/user/settings.go
index dc7e7f1160..f00bf8c268 100644
--- a/routers/api/v1/user/settings.go
+++ b/routers/api/v1/user/settings.go
@@ -74,7 +74,7 @@ func UpdateUserSettings(ctx *context.APIContext) {
ctx.Doer.KeepActivityPrivate = *form.HideActivity
}
- if err := user_model.UpdateUser(ctx.Doer, false); err != nil {
+ if err := user_model.UpdateUser(ctx, ctx.Doer, false); err != nil {
ctx.InternalServerError(err)
return
}
diff --git a/routers/api/v1/user/star.go b/routers/api/v1/user/star.go
index d2e4f36cd7..9cb9ec79b8 100644
--- a/routers/api/v1/user/star.go
+++ b/routers/api/v1/user/star.go
@@ -124,7 +124,7 @@ func IsStarring(ctx *context.APIContext) {
// "404":
// "$ref": "#/responses/notFound"
- if repo_model.IsStaring(ctx.Doer.ID, ctx.Repo.Repository.ID) {
+ if repo_model.IsStaring(ctx, ctx.Doer.ID, ctx.Repo.Repository.ID) {
ctx.Status(http.StatusNoContent)
} else {
ctx.NotFound()
diff --git a/routers/api/v1/user/user.go b/routers/api/v1/user/user.go
index 018f75762f..2a3cb15c0f 100644
--- a/routers/api/v1/user/user.go
+++ b/routers/api/v1/user/user.go
@@ -98,7 +98,7 @@ func GetInfo(ctx *context.APIContext) {
// "404":
// "$ref": "#/responses/notFound"
- if !user_model.IsUserVisibleToViewer(ctx.ContextUser, ctx.Doer) {
+ if !user_model.IsUserVisibleToViewer(ctx, ctx.ContextUser, ctx.Doer) {
// fake ErrUserNotExist error message to not leak information about existence
ctx.NotFound("GetUserByName", user_model.ErrUserNotExist{Name: ctx.Params(":username")})
return
diff --git a/routers/api/v1/user/watch.go b/routers/api/v1/user/watch.go
index 652ef3f8a6..83f23db15c 100644
--- a/routers/api/v1/user/watch.go
+++ b/routers/api/v1/user/watch.go
@@ -156,7 +156,7 @@ func Watch(ctx *context.APIContext) {
// "200":
// "$ref": "#/responses/WatchInfo"
- err := repo_model.WatchRepo(ctx.Doer.ID, ctx.Repo.Repository.ID, true)
+ err := repo_model.WatchRepo(ctx, ctx.Doer.ID, ctx.Repo.Repository.ID, true)
if err != nil {
ctx.Error(http.StatusInternalServerError, "WatchRepo", err)
return
@@ -191,7 +191,7 @@ func Unwatch(ctx *context.APIContext) {
// "204":
// "$ref": "#/responses/empty"
- err := repo_model.WatchRepo(ctx.Doer.ID, ctx.Repo.Repository.ID, false)
+ err := repo_model.WatchRepo(ctx, ctx.Doer.ID, ctx.Repo.Repository.ID, false)
if err != nil {
ctx.Error(http.StatusInternalServerError, "UnwatchRepo", err)
return