Skip to content

Commit 4eca76e

Browse files
committed
realod issue when sending webhook to make num comments is right.
1 parent c4c1a4b commit 4eca76e

File tree

2 files changed

+7
-0
lines changed

2 files changed

+7
-0
lines changed

services/issue/comments.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,12 @@ func CreateIssueComment(ctx context.Context, doer *user_model.User, repo *repo_m
8080
return nil, err
8181
}
8282

83+
// reaload issue to ensure it has the latest data, especially the number of comments
84+
issue, err = issues_model.GetIssueByID(ctx, issue.ID)
85+
if err != nil {
86+
return nil, err
87+
}
88+
8389
notify_service.CreateIssueComment(ctx, doer, repo, issue, comment, mentions)
8490

8591
return comment, nil

services/webhook/notifier.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -481,6 +481,7 @@ func (m *webhookNotifier) DeleteComment(ctx context.Context, doer *user_model.Us
481481
log.Error("LoadPoster: %v", err)
482482
return
483483
}
484+
comment.Issue = nil // reload issue to ensure it has the latest data, especially the number of comments
484485
if err = comment.LoadIssue(ctx); err != nil {
485486
log.Error("LoadIssue: %v", err)
486487
return

0 commit comments

Comments
 (0)