Skip to content

Commit ef91809

Browse files
committed
implement NotifyPullRequestReview for ui notification
1 parent d608022 commit ef91809

File tree

4 files changed

+19
-1
lines changed

4 files changed

+19
-1
lines changed

models/issue.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,10 @@ func (issue *Issue) GetPullRequest() (pr *PullRequest, err error) {
112112
}
113113

114114
pr, err = getPullRequestByIssueID(x, issue.ID)
115+
if err != nil {
116+
return nil, err
117+
}
118+
pr.Issue = issue
115119
return
116120
}
117121

models/review.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -239,6 +239,8 @@ func getCurrentReview(e Engine, reviewer *User, issue *Issue) (*Review, error) {
239239
if len(reviews) == 0 {
240240
return nil, ErrReviewNotExist{}
241241
}
242+
reviews[0].Reviewer = reviewer
243+
reviews[0].Issue = issue
242244
return reviews[0], nil
243245
}
244246

modules/notification/ui/ui.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,11 @@ func (ns *notificationService) NotifyNewPullRequest(pr *models.PullRequest) {
8080
}
8181
}
8282

83-
func (ns *notificationService) NotifyPullRequestReview(*models.PullRequest, *models.Review, *models.Comment) {
83+
func (ns *notificationService) NotifyPullRequestReview(pr *models.PullRequest, r *models.Review, c *models.Comment) {
84+
ns.issueQueue <- issueNotificationOpts{
85+
pr.Issue,
86+
r.Reviewer.ID,
87+
}
8488
}
8589

8690
func (ns *notificationService) NotifyUpdateComment(doer *models.User, c *models.Comment, oldContent string) {

routers/repo/pull_review.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,5 +184,13 @@ func SubmitReview(ctx *context.Context, form auth.SubmitReviewForm) {
184184
ctx.ServerError("Publish", err)
185185
return
186186
}
187+
188+
pr, err := issue.GetPullRequest()
189+
if err != nil {
190+
ctx.ServerError("GetPullRequest", err)
191+
return
192+
}
193+
notification.NotifyPullRequestReview(pr, review, comm)
194+
187195
ctx.Redirect(fmt.Sprintf("%s/pulls/%d#%s", ctx.Repo.RepoLink, issue.Index, comm.HashTag()))
188196
}

0 commit comments

Comments
 (0)