summaryrefslogtreecommitdiffstats
path: root/services/pull/review.go
diff options
context:
space:
mode:
Diffstat (limited to 'services/pull/review.go')
-rw-r--r--services/pull/review.go47
1 files changed, 6 insertions, 41 deletions
diff --git a/services/pull/review.go b/services/pull/review.go
index ffb7be82b2..e4aae3c0d5 100644
--- a/services/pull/review.go
+++ b/services/pull/review.go
@@ -7,8 +7,7 @@ package pull
import (
"code.gitea.io/gitea/models"
- api "code.gitea.io/gitea/modules/structs"
- "code.gitea.io/gitea/modules/webhook"
+ "code.gitea.io/gitea/modules/notification"
)
// CreateReview creates a new review based on opts
@@ -18,7 +17,9 @@ func CreateReview(opts models.CreateReviewOptions) (*models.Review, error) {
return nil, err
}
- return review, reviewHook(review)
+ notification.NotifyPullRequestReview(review.Issue.PullRequest, review, nil)
+
+ return review, nil
}
// UpdateReview updates a review
@@ -28,43 +29,7 @@ func UpdateReview(review *models.Review) error {
return err
}
- return reviewHook(review)
-}
-
-func reviewHook(review *models.Review) error {
- var reviewHookType models.HookEventType
-
- switch review.Type {
- case models.ReviewTypeApprove:
- reviewHookType = models.HookEventPullRequestApproved
- case models.ReviewTypeComment:
- reviewHookType = models.HookEventPullRequestComment
- case models.ReviewTypeReject:
- reviewHookType = models.HookEventPullRequestRejected
- default:
- // unsupported review webhook type here
- return nil
- }
-
- pr := review.Issue.PullRequest
+ notification.NotifyPullRequestReview(review.Issue.PullRequest, review, nil)
- if err := pr.LoadIssue(); err != nil {
- return err
- }
-
- mode, err := models.AccessLevel(review.Issue.Poster, review.Issue.Repo)
- if err != nil {
- return err
- }
- return webhook.PrepareWebhooks(review.Issue.Repo, reviewHookType, &api.PullRequestPayload{
- Action: api.HookIssueSynchronized,
- Index: review.Issue.Index,
- PullRequest: pr.APIFormat(),
- Repository: review.Issue.Repo.APIFormat(mode),
- Sender: review.Reviewer.APIFormat(),
- Review: &api.ReviewPayload{
- Type: string(reviewHookType),
- Content: review.Content,
- },
- })
+ return nil
}