2019-08-14 11:32:19 -04:00
|
|
|
// 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"
|
2019-11-05 06:04:08 -05:00
|
|
|
"code.gitea.io/gitea/modules/notification"
|
2019-08-14 11:32:19 -04:00
|
|
|
)
|
|
|
|
|
|
|
|
// 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
|
|
|
|
}
|
|
|
|
|
2019-11-13 13:36:04 -05:00
|
|
|
if opts.Type != models.ReviewTypePending {
|
|
|
|
notification.NotifyPullRequestReview(review.Issue.PullRequest, review, nil)
|
|
|
|
}
|
2019-11-05 06:04:08 -05:00
|
|
|
|
|
|
|
return review, nil
|
2019-10-18 04:33:19 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
// UpdateReview updates a review
|
|
|
|
func UpdateReview(review *models.Review) error {
|
|
|
|
err := models.UpdateReview(review)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
2019-11-05 06:04:08 -05:00
|
|
|
notification.NotifyPullRequestReview(review.Issue.PullRequest, review, nil)
|
2019-08-14 11:32:19 -04:00
|
|
|
|
2019-11-05 06:04:08 -05:00
|
|
|
return nil
|
2019-08-14 11:32:19 -04:00
|
|
|
}
|