summaryrefslogtreecommitdiffstats
path: root/modules/convert/issue_comment.go
diff options
context:
space:
mode:
authorKN4CK3R <admin@oldschoolhack.me>2022-11-19 09:12:33 +0100
committerGitHub <noreply@github.com>2022-11-19 16:12:33 +0800
commit044c754ea53f5b81f451451df53aea366f6f700a (patch)
tree45688c28a84f87f71ec3f99eb0e8456eb7d19c42 /modules/convert/issue_comment.go
parentfefdb7ffd11bbfbff66dae8e88681ec840dedfde (diff)
downloadgitea-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 'modules/convert/issue_comment.go')
-rw-r--r--modules/convert/issue_comment.go27
1 files changed, 14 insertions, 13 deletions
diff --git a/modules/convert/issue_comment.go b/modules/convert/issue_comment.go
index 73ad345fa4..c33cf5c111 100644
--- a/modules/convert/issue_comment.go
+++ b/modules/convert/issue_comment.go
@@ -5,7 +5,8 @@
package convert
import (
- "code.gitea.io/gitea/models/db"
+ "context"
+
issues_model "code.gitea.io/gitea/models/issues"
repo_model "code.gitea.io/gitea/models/repo"
user_model "code.gitea.io/gitea/models/user"
@@ -28,8 +29,8 @@ func ToComment(c *issues_model.Comment) *api.Comment {
}
// ToTimelineComment converts a issues_model.Comment to the api.TimelineComment format
-func ToTimelineComment(c *issues_model.Comment, doer *user_model.User) *api.TimelineComment {
- err := c.LoadMilestone()
+func ToTimelineComment(ctx context.Context, c *issues_model.Comment, doer *user_model.User) *api.TimelineComment {
+ err := c.LoadMilestone(ctx)
if err != nil {
log.Error("LoadMilestone: %v", err)
return nil
@@ -107,25 +108,25 @@ func ToTimelineComment(c *issues_model.Comment, doer *user_model.User) *api.Time
return nil
}
- comment.TrackedTime = ToTrackedTime(c.Time)
+ comment.TrackedTime = ToTrackedTime(ctx, c.Time)
}
if c.RefIssueID != 0 {
- issue, err := issues_model.GetIssueByID(db.DefaultContext, c.RefIssueID)
+ issue, err := issues_model.GetIssueByID(ctx, c.RefIssueID)
if err != nil {
log.Error("GetIssueByID(%d): %v", c.RefIssueID, err)
return nil
}
- comment.RefIssue = ToAPIIssue(issue)
+ comment.RefIssue = ToAPIIssue(ctx, issue)
}
if c.RefCommentID != 0 {
- com, err := issues_model.GetCommentByID(db.DefaultContext, c.RefCommentID)
+ com, err := issues_model.GetCommentByID(ctx, c.RefCommentID)
if err != nil {
log.Error("GetCommentByID(%d): %v", c.RefCommentID, err)
return nil
}
- err = com.LoadPoster()
+ err = com.LoadPoster(ctx)
if err != nil {
log.Error("LoadPoster: %v", err)
return nil
@@ -138,17 +139,17 @@ func ToTimelineComment(c *issues_model.Comment, doer *user_model.User) *api.Time
var repo *repo_model.Repository
if c.Label.BelongsToOrg() {
var err error
- org, err = user_model.GetUserByID(c.Label.OrgID)
+ org, err = user_model.GetUserByIDCtx(ctx, c.Label.OrgID)
if err != nil {
- log.Error("GetUserByID(%d): %v", c.Label.OrgID, err)
+ log.Error("GetUserByIDCtx(%d): %v", c.Label.OrgID, err)
return nil
}
}
if c.Label.BelongsToRepo() {
var err error
- repo, err = repo_model.GetRepositoryByID(c.Label.RepoID)
+ repo, err = repo_model.GetRepositoryByIDCtx(ctx, c.Label.RepoID)
if err != nil {
- log.Error("GetRepositoryByID(%d): %v", c.Label.RepoID, err)
+ log.Error("GetRepositoryByIDCtx(%d): %v", c.Label.RepoID, err)
return nil
}
}
@@ -167,7 +168,7 @@ func ToTimelineComment(c *issues_model.Comment, doer *user_model.User) *api.Time
}
if c.DependentIssue != nil {
- comment.DependentIssue = ToAPIIssue(c.DependentIssue)
+ comment.DependentIssue = ToAPIIssue(ctx, c.DependentIssue)
}
return comment