Skip to content

Commit

Permalink
implement NotifyPullRequestReview for ui notification
Browse files Browse the repository at this point in the history
  • Loading branch information
lunny committed Oct 18, 2018
1 parent d608022 commit ef91809
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 1 deletion.
4 changes: 4 additions & 0 deletions models/issue.go
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,10 @@ func (issue *Issue) GetPullRequest() (pr *PullRequest, err error) {
}

pr, err = getPullRequestByIssueID(x, issue.ID)
if err != nil {
return nil, err
}
pr.Issue = issue
return
}

Expand Down
2 changes: 2 additions & 0 deletions models/review.go
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,8 @@ func getCurrentReview(e Engine, reviewer *User, issue *Issue) (*Review, error) {
if len(reviews) == 0 {
return nil, ErrReviewNotExist{}
}
reviews[0].Reviewer = reviewer
reviews[0].Issue = issue
return reviews[0], nil
}

Expand Down
6 changes: 5 additions & 1 deletion modules/notification/ui/ui.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,11 @@ func (ns *notificationService) NotifyNewPullRequest(pr *models.PullRequest) {
}
}

func (ns *notificationService) NotifyPullRequestReview(*models.PullRequest, *models.Review, *models.Comment) {
func (ns *notificationService) NotifyPullRequestReview(pr *models.PullRequest, r *models.Review, c *models.Comment) {
ns.issueQueue <- issueNotificationOpts{
pr.Issue,
r.Reviewer.ID,
}
}

func (ns *notificationService) NotifyUpdateComment(doer *models.User, c *models.Comment, oldContent string) {
Expand Down
8 changes: 8 additions & 0 deletions routers/repo/pull_review.go
Original file line number Diff line number Diff line change
Expand Up @@ -184,5 +184,13 @@ func SubmitReview(ctx *context.Context, form auth.SubmitReviewForm) {
ctx.ServerError("Publish", err)
return
}

pr, err := issue.GetPullRequest()
if err != nil {
ctx.ServerError("GetPullRequest", err)
return
}
notification.NotifyPullRequestReview(pr, review, comm)

ctx.Redirect(fmt.Sprintf("%s/pulls/%d#%s", ctx.Repo.RepoLink, issue.Index, comm.HashTag()))
}

0 comments on commit ef91809

Please sign in to comment.