aboutsummaryrefslogtreecommitdiffstats
path: root/services/pull/review.go
blob: 294297f956dacc3a6b97a0756a0d94df052d43d6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
// Copyright 2019 The Gitea Authors.
// All rights reserved.
// Use of this source code is governed by a MIT-style
// license that can be found in the LICENSE file.

package pull

import (
	"code.gitea.io/gitea/models"
	"code.gitea.io/gitea/modules/notification"
)

// CreateReview creates a new review based on opts
func CreateReview(opts models.CreateReviewOptions) (*models.Review, error) {
	review, err := models.CreateReview(opts)
	if err != nil {
		return nil, err
	}

	if opts.Type != models.ReviewTypePending {
		notification.NotifyPullRequestReview(review.Issue.PullRequest, review, nil)
	}

	return review, nil
}

// UpdateReview updates a review
func UpdateReview(review *models.Review) error {
	err := models.UpdateReview(review)
	if err != nil {
		return err
	}

	notification.NotifyPullRequestReview(review.Issue.PullRequest, review, nil)

	return nil
}