diff options
author | KN4CK3R <admin@oldschoolhack.me> | 2022-11-19 09:12:33 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-11-19 16:12:33 +0800 |
commit | 044c754ea53f5b81f451451df53aea366f6f700a (patch) | |
tree | 45688c28a84f87f71ec3f99eb0e8456eb7d19c42 /services/issue | |
parent | fefdb7ffd11bbfbff66dae8e88681ec840dedfde (diff) | |
download | gitea-044c754ea53f5b81f451451df53aea366f6f700a.tar.gz gitea-044c754ea53f5b81f451451df53aea366f6f700a.zip |
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>
Diffstat (limited to 'services/issue')
-rw-r--r-- | services/issue/assignee.go | 10 | ||||
-rw-r--r-- | services/issue/content.go | 3 | ||||
-rw-r--r-- | services/issue/issue.go | 18 | ||||
-rw-r--r-- | services/issue/label.go | 10 | ||||
-rw-r--r-- | services/issue/milestone.go | 2 | ||||
-rw-r--r-- | services/issue/status.go | 2 |
6 files changed, 23 insertions, 22 deletions
diff --git a/services/issue/assignee.go b/services/issue/assignee.go index e24f8500c9..291fc31637 100644 --- a/services/issue/assignee.go +++ b/services/issue/assignee.go @@ -51,13 +51,13 @@ func ToggleAssignee(issue *issues_model.Issue, doer *user_model.User, assigneeID return } - assignee, err1 := user_model.GetUserByID(assigneeID) + assignee, err1 := user_model.GetUserByIDCtx(db.DefaultContext, assigneeID) if err1 != nil { err = err1 return } - notification.NotifyIssueChangeAssignee(doer, issue, assignee, removed, comment) + notification.NotifyIssueChangeAssignee(db.DefaultContext, doer, issue, assignee, removed, comment) return removed, comment, err } @@ -75,7 +75,7 @@ func ReviewRequest(issue *issues_model.Issue, doer, reviewer *user_model.User, i } if comment != nil { - notification.NotifyPullReviewRequest(doer, issue, reviewer, isAdd, comment) + notification.NotifyPullReviewRequest(db.DefaultContext, doer, issue, reviewer, isAdd, comment) } return comment, err @@ -246,7 +246,7 @@ func TeamReviewRequest(issue *issues_model.Issue, doer *user_model.User, reviewe } // notify all user in this team - if err = comment.LoadIssue(); err != nil { + if err = comment.LoadIssue(db.DefaultContext); err != nil { return } @@ -262,7 +262,7 @@ func TeamReviewRequest(issue *issues_model.Issue, doer *user_model.User, reviewe continue } comment.AssigneeID = member.ID - notification.NotifyPullReviewRequest(doer, issue, member, isAdd, comment) + notification.NotifyPullReviewRequest(db.DefaultContext, doer, issue, member, isAdd, comment) } return comment, err diff --git a/services/issue/content.go b/services/issue/content.go index 6f493892f4..851d986de3 100644 --- a/services/issue/content.go +++ b/services/issue/content.go @@ -5,6 +5,7 @@ package issue import ( + "code.gitea.io/gitea/models/db" issues_model "code.gitea.io/gitea/models/issues" user_model "code.gitea.io/gitea/models/user" "code.gitea.io/gitea/modules/notification" @@ -18,7 +19,7 @@ func ChangeContent(issue *issues_model.Issue, doer *user_model.User, content str return err } - notification.NotifyIssueChangeContent(doer, issue, oldContent) + notification.NotifyIssueChangeContent(db.DefaultContext, doer, issue, oldContent) return nil } diff --git a/services/issue/issue.go b/services/issue/issue.go index 8342d7f5d2..ba9b17a0c8 100644 --- a/services/issue/issue.go +++ b/services/issue/issue.go @@ -38,12 +38,12 @@ func NewIssue(repo *repo_model.Repository, issue *issues_model.Issue, labelIDs [ return err } - notification.NotifyNewIssue(issue, mentions) + notification.NotifyNewIssue(db.DefaultContext, issue, mentions) if len(issue.Labels) > 0 { - notification.NotifyIssueChangeLabels(issue.Poster, issue, issue.Labels, nil) + notification.NotifyIssueChangeLabels(db.DefaultContext, issue.Poster, issue, issue.Labels, nil) } if issue.Milestone != nil { - notification.NotifyIssueChangeMilestone(issue.Poster, issue, 0) + notification.NotifyIssueChangeMilestone(db.DefaultContext, issue.Poster, issue, 0) } return nil @@ -58,7 +58,7 @@ func ChangeTitle(issue *issues_model.Issue, doer *user_model.User, title string) return } - notification.NotifyIssueChangeTitle(doer, issue, oldTitle) + notification.NotifyIssueChangeTitle(db.DefaultContext, doer, issue, oldTitle) return nil } @@ -72,7 +72,7 @@ func ChangeIssueRef(issue *issues_model.Issue, doer *user_model.User, ref string return err } - notification.NotifyIssueChangeRef(doer, issue, oldRef) + notification.NotifyIssueChangeRef(db.DefaultContext, doer, issue, oldRef) return nil } @@ -135,10 +135,10 @@ func UpdateAssignees(issue *issues_model.Issue, oneAssignee string, multipleAssi // DeleteIssue deletes an issue func DeleteIssue(doer *user_model.User, gitRepo *git.Repository, issue *issues_model.Issue) error { // load issue before deleting it - if err := issue.LoadAttributes(db.DefaultContext); err != nil { + if err := issue.LoadAttributes(gitRepo.Ctx); err != nil { return err } - if err := issue.LoadPullRequest(); err != nil { + if err := issue.LoadPullRequest(gitRepo.Ctx); err != nil { return err } @@ -154,7 +154,7 @@ func DeleteIssue(doer *user_model.User, gitRepo *git.Repository, issue *issues_m } } - notification.NotifyDeleteIssue(doer, issue) + notification.NotifyDeleteIssue(gitRepo.Ctx, doer, issue) return nil } @@ -162,7 +162,7 @@ func DeleteIssue(doer *user_model.User, gitRepo *git.Repository, issue *issues_m // AddAssigneeIfNotAssigned adds an assignee only if he isn't already assigned to the issue. // Also checks for access of assigned user func AddAssigneeIfNotAssigned(issue *issues_model.Issue, doer *user_model.User, assigneeID int64) (err error) { - assignee, err := user_model.GetUserByID(assigneeID) + assignee, err := user_model.GetUserByIDCtx(db.DefaultContext, assigneeID) if err != nil { return err } diff --git a/services/issue/label.go b/services/issue/label.go index a9a0c20b01..cd29fcebae 100644 --- a/services/issue/label.go +++ b/services/issue/label.go @@ -18,7 +18,7 @@ func ClearLabels(issue *issues_model.Issue, doer *user_model.User) (err error) { return } - notification.NotifyIssueClearLabels(doer, issue) + notification.NotifyIssueClearLabels(db.DefaultContext, doer, issue) return nil } @@ -29,7 +29,7 @@ func AddLabel(issue *issues_model.Issue, doer *user_model.User, label *issues_mo return err } - notification.NotifyIssueChangeLabels(doer, issue, []*issues_model.Label{label}, nil) + notification.NotifyIssueChangeLabels(db.DefaultContext, doer, issue, []*issues_model.Label{label}, nil) return nil } @@ -39,7 +39,7 @@ func AddLabels(issue *issues_model.Issue, doer *user_model.User, labels []*issue return err } - notification.NotifyIssueChangeLabels(doer, issue, labels, nil) + notification.NotifyIssueChangeLabels(db.DefaultContext, doer, issue, labels, nil) return nil } @@ -74,7 +74,7 @@ func RemoveLabel(issue *issues_model.Issue, doer *user_model.User, label *issues return err } - notification.NotifyIssueChangeLabels(doer, issue, nil, []*issues_model.Label{label}) + notification.NotifyIssueChangeLabels(db.DefaultContext, doer, issue, nil, []*issues_model.Label{label}) return nil } @@ -89,6 +89,6 @@ func ReplaceLabels(issue *issues_model.Issue, doer *user_model.User, labels []*i return err } - notification.NotifyIssueChangeLabels(doer, issue, labels, old) + notification.NotifyIssueChangeLabels(db.DefaultContext, doer, issue, labels, old) return nil } diff --git a/services/issue/milestone.go b/services/issue/milestone.go index 965b07556d..2be4a9e70a 100644 --- a/services/issue/milestone.go +++ b/services/issue/milestone.go @@ -79,7 +79,7 @@ func ChangeMilestoneAssign(issue *issues_model.Issue, doer *user_model.User, old return fmt.Errorf("Commit: %w", err) } - notification.NotifyIssueChangeMilestone(doer, issue, oldMilestoneID) + notification.NotifyIssueChangeMilestone(db.DefaultContext, doer, issue, oldMilestoneID) return nil } diff --git a/services/issue/status.go b/services/issue/status.go index 0da5c88762..2d4622324c 100644 --- a/services/issue/status.go +++ b/services/issue/status.go @@ -38,7 +38,7 @@ func changeStatusCtx(ctx context.Context, issue *issues_model.Issue, doer *user_ } } - notification.NotifyIssueChangeStatus(doer, issue, comment, closed) + notification.NotifyIssueChangeStatus(ctx, doer, issue, comment, closed) return nil } |