1
0
Fork 0
forked from forgejo/forgejo

fix API usage of a PR index in place of issue index and vice versa

(cherry picked from commit 7b95266de083c8de0ff224530a9b69e82c52c344)
This commit is contained in:
Loïc Dachary 2023-11-02 13:51:33 +01:00
parent fec0754995
commit f78e9cb74b
No known key found for this signature in database
GPG key ID: 992D23B392F9E4F2
3 changed files with 59 additions and 1 deletions

View file

@ -1021,6 +1021,7 @@ type FindCommentsOptions struct {
Type CommentType
IssueIDs []int64
Invalidated util.OptionalBool
IsPull util.OptionalBool
}
// ToConds implements FindOptions interface
@ -1055,6 +1056,9 @@ func (opts *FindCommentsOptions) ToConds() builder.Cond {
if !opts.Invalidated.IsNone() {
cond = cond.And(builder.Eq{"comment.invalidated": opts.Invalidated.IsTrue()})
}
if opts.IsPull != util.OptionalBoolNone {
cond = cond.And(builder.Eq{"issue.is_pull": opts.IsPull.IsTrue()})
}
return cond
}
@ -1062,7 +1066,7 @@ func (opts *FindCommentsOptions) ToConds() builder.Cond {
func FindComments(ctx context.Context, opts *FindCommentsOptions) (CommentList, error) {
comments := make([]*Comment, 0, 10)
sess := db.GetEngine(ctx).Where(opts.ToConds())
if opts.RepoID > 0 {
if opts.RepoID > 0 || opts.IsPull != util.OptionalBoolNone {
sess.Join("INNER", "issue", "issue.id = comment.issue_id")
}