diff options
author | 赵智超 <1012112796@qq.com> | 2020-10-13 03:55:13 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-10-12 20:55:13 +0100 |
commit | 8be3e439c2b3a90fcb639b732008486b85314b8d (patch) | |
tree | 0d941779b1c545c4bfa41d8d54c1bf0f219a43eb /services | |
parent | b546eda7a8fa17d86cf9722c9f7bcca009d40443 (diff) | |
download | gitea-8be3e439c2b3a90fcb639b732008486b85314b8d.tar.gz gitea-8be3e439c2b3a90fcb639b732008486b85314b8d.zip |
Add team support for review request (#12039)
Add team support for review request
Block #11355
Signed-off-by: a1012112796 <1012112796@qq.com>
Signed-off-by: Andrew Thornton <art27@cantab.net>
Co-authored-by: Lauris BH <lauris@nix.lv>
Co-authored-by: Andrew Thornton <art27@cantab.net>
Diffstat (limited to 'services')
-rw-r--r-- | services/issue/assignee.go | 39 | ||||
-rw-r--r-- | services/pull/review.go | 5 |
2 files changed, 40 insertions, 4 deletions
diff --git a/services/issue/assignee.go b/services/issue/assignee.go index d63c7bf032..f48e55e53c 100644 --- a/services/issue/assignee.go +++ b/services/issue/assignee.go @@ -52,7 +52,7 @@ func ToggleAssignee(issue *models.Issue, doer *models.User, assigneeID int64) (r return } -// ReviewRequest add or remove a review for this PR, and make comment for it. +// ReviewRequest add or remove a review request from a user for this PR, and make comment for it. func ReviewRequest(issue *models.Issue, doer *models.User, reviewer *models.User, isAdd bool) (err error) { var comment *models.Comment if isAdd { @@ -71,3 +71,40 @@ func ReviewRequest(issue *models.Issue, doer *models.User, reviewer *models.User return nil } + +// TeamReviewRequest add or remove a review request from a team for this PR, and make comment for it. +func TeamReviewRequest(issue *models.Issue, doer *models.User, reviewer *models.Team, isAdd bool) (err error) { + var comment *models.Comment + if isAdd { + comment, err = models.AddTeamReviewRequest(issue, reviewer, doer) + } else { + comment, err = models.RemoveTeamReviewRequest(issue, reviewer, doer) + } + + if err != nil { + return + } + + if comment == nil || !isAdd { + return + } + + // notify all user in this team + if err = comment.LoadIssue(); err != nil { + return + } + + if err = reviewer.GetMembers(&models.SearchMembersOptions{}); err != nil { + return + } + + for _, member := range reviewer.Members { + if member.ID == comment.Issue.PosterID { + continue + } + comment.AssigneeID = member.ID + notification.NotifyPullReviewRequest(doer, issue, member, isAdd, comment) + } + + return nil +} diff --git a/services/pull/review.go b/services/pull/review.go index 09ab3ff567..99afdd73c2 100644 --- a/services/pull/review.go +++ b/services/pull/review.go @@ -68,14 +68,13 @@ func CreateCodeComment(doer *models.User, gitRepo *git.Repository, issue *models return nil, err } - review, err = models.CreateReview(models.CreateReviewOptions{ + if review, err = models.CreateReview(models.CreateReviewOptions{ Type: models.ReviewTypePending, Reviewer: doer, Issue: issue, Official: false, CommitID: latestCommitID, - }) - if err != nil { + }); err != nil { return nil, err } } |