fix: no notification for replies to pending comments (#7167)
- Replies to pending review comments no longer generate a notification, this was caused by an incomplete determination if the comment was part of the pending review or not. - The logic was reworked to do the following if it's part of a pending review: It is not a single review and if it's a reply then the comment it is replying to is part of a pending review. - Added integration test. - Resolves forgejo/forgejo#7151 Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/7167 Reviewed-by: 0ko <0ko@noreply.codeberg.org> Co-authored-by: Gusted <postmaster@gusted.xyz> Co-committed-by: Gusted <postmaster@gusted.xyz>
This commit is contained in:
parent
9073ca8128
commit
f015c00ecb
5 changed files with 174 additions and 2 deletions
|
@ -82,6 +82,24 @@ func CreateCodeComment(ctx *context.Context) {
|
|||
attachments = form.Files
|
||||
}
|
||||
|
||||
// If the reply is made to a comment that is part of a pending review, then
|
||||
// this comment also should be seen as part of that pending review. Consider
|
||||
// it to be a pending review by default, except when `single_review` was
|
||||
// passed.
|
||||
pendingReview := !form.SingleReview
|
||||
if form.Reply > 0 {
|
||||
r, err := issues_model.GetReviewByID(ctx, form.Reply)
|
||||
if err != nil {
|
||||
ctx.ServerError("GetReviewByID", err)
|
||||
return
|
||||
}
|
||||
if r.IssueID != issue.ID {
|
||||
ctx.NotFound("Review does not belong to pull request", nil)
|
||||
return
|
||||
}
|
||||
pendingReview = r.Type == issues_model.ReviewTypePending
|
||||
}
|
||||
|
||||
comment, err := pull_service.CreateCodeComment(ctx,
|
||||
ctx.Doer,
|
||||
ctx.Repo.GitRepo,
|
||||
|
@ -89,7 +107,7 @@ func CreateCodeComment(ctx *context.Context) {
|
|||
signedLine,
|
||||
form.Content,
|
||||
form.TreePath,
|
||||
!form.SingleReview,
|
||||
pendingReview,
|
||||
form.Reply,
|
||||
form.LatestCommitID,
|
||||
attachments,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue