diff options
author | Jimmy Praet <jimmy.praet@telenet.be> | 2021-06-23 06:14:22 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-06-23 00:14:22 -0400 |
commit | 17030ced75059ec21f6fb1945a751c3ebef29a32 (patch) | |
tree | 6d7d79c766335728961e02eb80da4ae08fbf7d9b /services | |
parent | 66f8da538a8b1bd63ea1a0f97202ee0d46c15c4f (diff) | |
download | gitea-17030ced75059ec21f6fb1945a751c3ebef29a32.tar.gz gitea-17030ced75059ec21f6fb1945a751c3ebef29a32.zip |
Improve notifications for WIP draft PR's (#14663)
* #14559 Reduce amount of email notifications for WIP draft PR's
don't notify repo watchers of WIP draft PR's
* #13190 Notification when WIP Pull Request is ready for review
* Send email notification to repo watchers when WIP PR is created
* Send ui notification to repo watchers when WIP PR is created
* send specific email notification when PR is marked ready for review
instead of reusing the CreatePullRequest action
* Fix lint error
Co-authored-by: techknowlogick <techknowlogick@gitea.io>
Diffstat (limited to 'services')
-rw-r--r-- | services/mailer/mail.go | 2 | ||||
-rw-r--r-- | services/mailer/mail_issue.go | 12 |
2 files changed, 9 insertions, 5 deletions
diff --git a/services/mailer/mail.go b/services/mailer/mail.go index ea3edaa90d..fdc070e4be 100644 --- a/services/mailer/mail.go +++ b/services/mailer/mail.go @@ -377,6 +377,8 @@ func actionToTemplate(issue *models.Issue, actionType models.ActionType, name = "merge" case models.ActionPullReviewDismissed: name = "review_dismissed" + case models.ActionPullRequestReadyForReview: + name = "ready_for_review" default: switch commentType { case models.CommentTypeReview: diff --git a/services/mailer/mail_issue.go b/services/mailer/mail_issue.go index 867aa32517..6ffc08c8c0 100644 --- a/services/mailer/mail_issue.go +++ b/services/mailer/mail_issue.go @@ -30,7 +30,7 @@ const ( // mailIssueCommentToParticipants can be used for both new issue creation and comment. // This function sends two list of emails: -// 1. Repository watchers and users who are participated in comments. +// 1. Repository watchers (except for WIP pull requests) and users who are participated in comments. // 2. Users who are not in 1. but get mentioned in current issue/comment. func mailIssueCommentToParticipants(ctx *mailCommentContext, mentions []*models.User) error { @@ -74,11 +74,13 @@ func mailIssueCommentToParticipants(ctx *mailCommentContext, mentions []*models. // =========== Repo watchers =========== // Make repo watchers last, since it's likely the list with the most users - ids, err = models.GetRepoWatchersIDs(ctx.Issue.RepoID) - if err != nil { - return fmt.Errorf("GetRepoWatchersIDs(%d): %v", ctx.Issue.RepoID, err) + if !(ctx.Issue.IsPull && ctx.Issue.PullRequest.IsWorkInProgress() && ctx.ActionType != models.ActionCreatePullRequest) { + ids, err = models.GetRepoWatchersIDs(ctx.Issue.RepoID) + if err != nil { + return fmt.Errorf("GetRepoWatchersIDs(%d): %v", ctx.Issue.RepoID, err) + } + unfiltered = append(ids, unfiltered...) } - unfiltered = append(ids, unfiltered...) visited := make(map[int64]bool, len(unfiltered)+len(mentions)+1) |