aboutsummaryrefslogtreecommitdiffstats
path: root/models/issues/pull.go
diff options
context:
space:
mode:
authorAndré Rosenhammer <andre.rosenhammer@gmail.com>2024-05-26 06:08:13 +0200
committerGitHub <noreply@github.com>2024-05-26 04:08:13 +0000
commit14f6105ce0c5802518b46d0af337b4e5f1af4f87 (patch)
tree2d2b8f59033d8f157187a584dacb130193d37f4d /models/issues/pull.go
parent2ced31e81dd9e45659660c1abff529d0192fd8ed (diff)
downloadgitea-14f6105ce0c5802518b46d0af337b4e5f1af4f87.tar.gz
gitea-14f6105ce0c5802518b46d0af337b4e5f1af4f87.zip
Make gitea webhooks openproject compatible (#28435)
This PR adds some fields to the gitea webhook payload that [openproject](https://www.openproject.org/) expects to exists in order to process the webhooks. These fields do exists in Github's webhook payload so adding them makes Gitea's native webhook more compatible towards Github's.
Diffstat (limited to 'models/issues/pull.go')
-rw-r--r--models/issues/pull.go15
1 files changed, 15 insertions, 0 deletions
diff --git a/models/issues/pull.go b/models/issues/pull.go
index 4194df2e3d..014fcd9fd0 100644
--- a/models/issues/pull.go
+++ b/models/issues/pull.go
@@ -430,6 +430,21 @@ func (pr *PullRequest) GetGitHeadBranchRefName() string {
return fmt.Sprintf("%s%s", git.BranchPrefix, pr.HeadBranch)
}
+// GetReviewCommentsCount returns the number of review comments made on the diff of a PR review (not including comments on commits or issues in a PR)
+func (pr *PullRequest) GetReviewCommentsCount(ctx context.Context) int {
+ opts := FindCommentsOptions{
+ Type: CommentTypeReview,
+ IssueID: pr.IssueID,
+ }
+ conds := opts.ToConds()
+
+ count, err := db.GetEngine(ctx).Where(conds).Count(new(Comment))
+ if err != nil {
+ return 0
+ }
+ return int(count)
+}
+
// IsChecking returns true if this pull request is still checking conflict.
func (pr *PullRequest) IsChecking() bool {
return pr.Status == PullRequestStatusChecking