mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2024-09-10 20:22:14 +02:00
parent
edd8ea0b0d
commit
64f6a5d113
4 changed files with 13 additions and 13 deletions
|
@ -1048,7 +1048,7 @@ func (opts *FindCommentsOptions) ToConds() builder.Cond {
|
||||||
}
|
}
|
||||||
|
|
||||||
// FindComments returns all comments according options
|
// FindComments returns all comments according options
|
||||||
func FindComments(ctx context.Context, opts *FindCommentsOptions) ([]*Comment, error) {
|
func FindComments(ctx context.Context, opts *FindCommentsOptions) (CommentList, error) {
|
||||||
comments := make([]*Comment, 0, 10)
|
comments := make([]*Comment, 0, 10)
|
||||||
sess := db.GetEngine(ctx).Where(opts.ToConds())
|
sess := db.GetEngine(ctx).Where(opts.ToConds())
|
||||||
if opts.RepoID > 0 {
|
if opts.RepoID > 0 {
|
||||||
|
|
|
@ -48,7 +48,7 @@ func fetchCodeCommentsByReview(ctx context.Context, issue *Issue, currentUser *u
|
||||||
}
|
}
|
||||||
|
|
||||||
func findCodeComments(ctx context.Context, opts FindCommentsOptions, issue *Issue, currentUser *user_model.User, review *Review) ([]*Comment, error) {
|
func findCodeComments(ctx context.Context, opts FindCommentsOptions, issue *Issue, currentUser *user_model.User, review *Review) ([]*Comment, error) {
|
||||||
var comments []*Comment
|
var comments CommentList
|
||||||
if review == nil {
|
if review == nil {
|
||||||
review = &Review{ID: 0}
|
review = &Review{ID: 0}
|
||||||
}
|
}
|
||||||
|
@ -68,7 +68,7 @@ func findCodeComments(ctx context.Context, opts FindCommentsOptions, issue *Issu
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := CommentList(comments).LoadPosters(ctx); err != nil {
|
if err := comments.LoadPosters(ctx); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -124,7 +124,7 @@ type Issue struct {
|
||||||
ClosedUnix timeutil.TimeStamp `xorm:"INDEX"`
|
ClosedUnix timeutil.TimeStamp `xorm:"INDEX"`
|
||||||
|
|
||||||
Attachments []*repo_model.Attachment `xorm:"-"`
|
Attachments []*repo_model.Attachment `xorm:"-"`
|
||||||
Comments []*Comment `xorm:"-"`
|
Comments CommentList `xorm:"-"`
|
||||||
Reactions ReactionList `xorm:"-"`
|
Reactions ReactionList `xorm:"-"`
|
||||||
TotalTrackedTime int64 `xorm:"-"`
|
TotalTrackedTime int64 `xorm:"-"`
|
||||||
Assignees []*user_model.User `xorm:"-"`
|
Assignees []*user_model.User `xorm:"-"`
|
||||||
|
@ -353,7 +353,7 @@ func (issue *Issue) LoadAttributes(ctx context.Context) (err error) {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
if err = CommentList(issue.Comments).loadAttributes(ctx); err != nil {
|
if err = issue.Comments.loadAttributes(ctx); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
if issue.IsTimetrackerEnabled(ctx) {
|
if issue.IsTimetrackerEnabled(ctx) {
|
||||||
|
|
|
@ -90,12 +90,12 @@ func ListIssueComments(ctx *context.APIContext) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := issues_model.CommentList(comments).LoadPosters(ctx); err != nil {
|
if err := comments.LoadPosters(ctx); err != nil {
|
||||||
ctx.Error(http.StatusInternalServerError, "LoadPosters", err)
|
ctx.Error(http.StatusInternalServerError, "LoadPosters", err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := issues_model.CommentList(comments).LoadAttachments(ctx); err != nil {
|
if err := comments.LoadAttachments(ctx); err != nil {
|
||||||
ctx.Error(http.StatusInternalServerError, "LoadAttachments", err)
|
ctx.Error(http.StatusInternalServerError, "LoadAttachments", err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -182,7 +182,7 @@ func ListIssueCommentsAndTimeline(ctx *context.APIContext) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := issues_model.CommentList(comments).LoadPosters(ctx); err != nil {
|
if err := comments.LoadPosters(ctx); err != nil {
|
||||||
ctx.Error(http.StatusInternalServerError, "LoadPosters", err)
|
ctx.Error(http.StatusInternalServerError, "LoadPosters", err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -285,25 +285,25 @@ func ListRepoIssueComments(ctx *context.APIContext) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if err = issues_model.CommentList(comments).LoadPosters(ctx); err != nil {
|
if err = comments.LoadPosters(ctx); err != nil {
|
||||||
ctx.Error(http.StatusInternalServerError, "LoadPosters", err)
|
ctx.Error(http.StatusInternalServerError, "LoadPosters", err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
apiComments := make([]*api.Comment, len(comments))
|
apiComments := make([]*api.Comment, len(comments))
|
||||||
if err := issues_model.CommentList(comments).LoadIssues(ctx); err != nil {
|
if err := comments.LoadIssues(ctx); err != nil {
|
||||||
ctx.Error(http.StatusInternalServerError, "LoadIssues", err)
|
ctx.Error(http.StatusInternalServerError, "LoadIssues", err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if err := issues_model.CommentList(comments).LoadPosters(ctx); err != nil {
|
if err := comments.LoadPosters(ctx); err != nil {
|
||||||
ctx.Error(http.StatusInternalServerError, "LoadPosters", err)
|
ctx.Error(http.StatusInternalServerError, "LoadPosters", err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if err := issues_model.CommentList(comments).LoadAttachments(ctx); err != nil {
|
if err := comments.LoadAttachments(ctx); err != nil {
|
||||||
ctx.Error(http.StatusInternalServerError, "LoadAttachments", err)
|
ctx.Error(http.StatusInternalServerError, "LoadAttachments", err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if _, err := issues_model.CommentList(comments).Issues().LoadRepositories(ctx); err != nil {
|
if _, err := comments.Issues().LoadRepositories(ctx); err != nil {
|
||||||
ctx.Error(http.StatusInternalServerError, "LoadRepositories", err)
|
ctx.Error(http.StatusInternalServerError, "LoadRepositories", err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue