aboutsummaryrefslogtreecommitdiffstats
path: root/services/issue/comments.go
diff options
context:
space:
mode:
Diffstat (limited to 'services/issue/comments.go')
-rw-r--r--services/issue/comments.go9
1 files changed, 8 insertions, 1 deletions
diff --git a/services/issue/comments.go b/services/issue/comments.go
index 46f92f7cd2..9442701029 100644
--- a/services/issue/comments.go
+++ b/services/issue/comments.go
@@ -5,6 +5,7 @@ package issue
import (
"context"
+ "errors"
"fmt"
"code.gitea.io/gitea/models/db"
@@ -22,7 +23,7 @@ import (
// CreateRefComment creates a commit reference comment to issue.
func CreateRefComment(ctx context.Context, doer *user_model.User, repo *repo_model.Repository, issue *issues_model.Issue, content, commitSHA string) error {
if len(commitSHA) == 0 {
- return fmt.Errorf("cannot create reference with empty commit SHA")
+ return errors.New("cannot create reference with empty commit SHA")
}
if user_model.IsUserBlockedBy(ctx, doer, issue.PosterID, repo.OwnerID) {
@@ -79,6 +80,12 @@ func CreateIssueComment(ctx context.Context, doer *user_model.User, repo *repo_m
return nil, err
}
+ // reload issue to ensure it has the latest data, especially the number of comments
+ issue, err = issues_model.GetIssueByID(ctx, issue.ID)
+ if err != nil {
+ return nil, err
+ }
+
notify_service.CreateIssueComment(ctx, doer, repo, issue, comment, mentions)
return comment, nil