mirror of
https://codeberg.org/davrot/forgejo.git
synced 2025-05-28 12:00:01 +02:00
Add context.Context
to more methods (#21546)
This PR adds a context parameter to a bunch of methods. Some helper `xxxCtx()` methods got replaced with the normal name now. Co-authored-by: delvh <dev.lh@web.de> Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
This commit is contained in:
parent
fefdb7ffd1
commit
044c754ea5
148 changed files with 1411 additions and 1564 deletions
|
@ -179,7 +179,7 @@ func SearchIssues(ctx *context.APIContext) {
|
|||
repoCond := repo_model.SearchRepositoryCondition(opts)
|
||||
repoIDs, _, err := repo_model.SearchRepositoryIDs(opts)
|
||||
if err != nil {
|
||||
ctx.Error(http.StatusInternalServerError, "SearchRepositoryByName", err)
|
||||
ctx.Error(http.StatusInternalServerError, "SearchRepositoryIDs", err)
|
||||
return
|
||||
}
|
||||
|
||||
|
@ -268,7 +268,7 @@ func SearchIssues(ctx *context.APIContext) {
|
|||
issuesOpt.ReviewRequestedID = ctxUserID
|
||||
}
|
||||
|
||||
if issues, err = issues_model.Issues(issuesOpt); err != nil {
|
||||
if issues, err = issues_model.Issues(ctx, issuesOpt); err != nil {
|
||||
ctx.Error(http.StatusInternalServerError, "Issues", err)
|
||||
return
|
||||
}
|
||||
|
@ -276,7 +276,7 @@ func SearchIssues(ctx *context.APIContext) {
|
|||
issuesOpt.ListOptions = db.ListOptions{
|
||||
Page: -1,
|
||||
}
|
||||
if filteredCount, err = issues_model.CountIssues(issuesOpt); err != nil {
|
||||
if filteredCount, err = issues_model.CountIssues(ctx, issuesOpt); err != nil {
|
||||
ctx.Error(http.StatusInternalServerError, "CountIssues", err)
|
||||
return
|
||||
}
|
||||
|
@ -284,7 +284,7 @@ func SearchIssues(ctx *context.APIContext) {
|
|||
|
||||
ctx.SetLinkHeader(int(filteredCount), limit)
|
||||
ctx.SetTotalCountHeader(filteredCount)
|
||||
ctx.JSON(http.StatusOK, convert.ToAPIIssueList(issues))
|
||||
ctx.JSON(http.StatusOK, convert.ToAPIIssueList(ctx, issues))
|
||||
}
|
||||
|
||||
// ListIssues list the issues of a repository
|
||||
|
@ -477,7 +477,7 @@ func ListIssues(ctx *context.APIContext) {
|
|||
MentionedID: mentionedByID,
|
||||
}
|
||||
|
||||
if issues, err = issues_model.Issues(issuesOpt); err != nil {
|
||||
if issues, err = issues_model.Issues(ctx, issuesOpt); err != nil {
|
||||
ctx.Error(http.StatusInternalServerError, "Issues", err)
|
||||
return
|
||||
}
|
||||
|
@ -485,7 +485,7 @@ func ListIssues(ctx *context.APIContext) {
|
|||
issuesOpt.ListOptions = db.ListOptions{
|
||||
Page: -1,
|
||||
}
|
||||
if filteredCount, err = issues_model.CountIssues(issuesOpt); err != nil {
|
||||
if filteredCount, err = issues_model.CountIssues(ctx, issuesOpt); err != nil {
|
||||
ctx.Error(http.StatusInternalServerError, "CountIssues", err)
|
||||
return
|
||||
}
|
||||
|
@ -493,7 +493,7 @@ func ListIssues(ctx *context.APIContext) {
|
|||
|
||||
ctx.SetLinkHeader(int(filteredCount), listOptions.PageSize)
|
||||
ctx.SetTotalCountHeader(filteredCount)
|
||||
ctx.JSON(http.StatusOK, convert.ToAPIIssueList(issues))
|
||||
ctx.JSON(http.StatusOK, convert.ToAPIIssueList(ctx, issues))
|
||||
}
|
||||
|
||||
func getUserIDForFilter(ctx *context.APIContext, queryName string) int64 {
|
||||
|
@ -555,7 +555,7 @@ func GetIssue(ctx *context.APIContext) {
|
|||
}
|
||||
return
|
||||
}
|
||||
ctx.JSON(http.StatusOK, convert.ToAPIIssue(issue))
|
||||
ctx.JSON(http.StatusOK, convert.ToAPIIssue(ctx, issue))
|
||||
}
|
||||
|
||||
// CreateIssue create an issue of a repository
|
||||
|
@ -612,7 +612,7 @@ func CreateIssue(ctx *context.APIContext) {
|
|||
var err error
|
||||
if ctx.Repo.CanWrite(unit.TypeIssues) {
|
||||
issue.MilestoneID = form.Milestone
|
||||
assigneeIDs, err = issues_model.MakeIDsFromAPIAssigneesToAdd(form.Assignee, form.Assignees)
|
||||
assigneeIDs, err = issues_model.MakeIDsFromAPIAssigneesToAdd(ctx, form.Assignee, form.Assignees)
|
||||
if err != nil {
|
||||
if user_model.IsErrUserNotExist(err) {
|
||||
ctx.Error(http.StatusUnprocessableEntity, "", fmt.Sprintf("Assignee does not exist: [name: %s]", err))
|
||||
|
@ -671,7 +671,7 @@ func CreateIssue(ctx *context.APIContext) {
|
|||
ctx.Error(http.StatusInternalServerError, "GetIssueByID", err)
|
||||
return
|
||||
}
|
||||
ctx.JSON(http.StatusCreated, convert.ToAPIIssue(issue))
|
||||
ctx.JSON(http.StatusCreated, convert.ToAPIIssue(ctx, issue))
|
||||
}
|
||||
|
||||
// EditIssue modify an issue of a repository
|
||||
|
@ -823,11 +823,11 @@ func EditIssue(ctx *context.APIContext) {
|
|||
}
|
||||
|
||||
if titleChanged {
|
||||
notification.NotifyIssueChangeTitle(ctx.Doer, issue, oldTitle)
|
||||
notification.NotifyIssueChangeTitle(ctx, ctx.Doer, issue, oldTitle)
|
||||
}
|
||||
|
||||
if statusChangeComment != nil {
|
||||
notification.NotifyIssueChangeStatus(ctx.Doer, issue, statusChangeComment, issue.IsClosed)
|
||||
notification.NotifyIssueChangeStatus(ctx, ctx.Doer, issue, statusChangeComment, issue.IsClosed)
|
||||
}
|
||||
|
||||
// Refetch from database to assign some automatic values
|
||||
|
@ -836,11 +836,11 @@ func EditIssue(ctx *context.APIContext) {
|
|||
ctx.InternalServerError(err)
|
||||
return
|
||||
}
|
||||
if err = issue.LoadMilestone(); err != nil {
|
||||
if err = issue.LoadMilestone(ctx); err != nil {
|
||||
ctx.InternalServerError(err)
|
||||
return
|
||||
}
|
||||
ctx.JSON(http.StatusCreated, convert.ToAPIIssue(issue))
|
||||
ctx.JSON(http.StatusCreated, convert.ToAPIIssue(ctx, issue))
|
||||
}
|
||||
|
||||
func DeleteIssue(ctx *context.APIContext) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue