mirror of
https://codeberg.org/davrot/forgejo.git
synced 2025-05-23 05:00:02 +02:00
Send notifications for mentions in pulls, issues, (code-)comments (#14218)
Fixes #14187: mention handling extracted from email notification code Fixes #14013: add notification for mentions in pull request code comments Fixes #13450: Not receiving any emails with setting "Only Email on Mention"
This commit is contained in:
parent
ac88b0ee83
commit
e6acce649b
15 changed files with 205 additions and 88 deletions
|
@ -27,7 +27,7 @@ func NewNotifier() base.Notifier {
|
|||
}
|
||||
|
||||
func (m *mailNotifier) NotifyCreateIssueComment(doer *models.User, repo *models.Repository,
|
||||
issue *models.Issue, comment *models.Comment) {
|
||||
issue *models.Issue, comment *models.Comment, mentions []*models.User) {
|
||||
var act models.ActionType
|
||||
if comment.Type == models.CommentTypeClose {
|
||||
act = models.ActionCloseIssue
|
||||
|
@ -41,13 +41,13 @@ func (m *mailNotifier) NotifyCreateIssueComment(doer *models.User, repo *models.
|
|||
act = 0
|
||||
}
|
||||
|
||||
if err := mailer.MailParticipantsComment(comment, act, issue); err != nil {
|
||||
if err := mailer.MailParticipantsComment(comment, act, issue, mentions); err != nil {
|
||||
log.Error("MailParticipantsComment: %v", err)
|
||||
}
|
||||
}
|
||||
|
||||
func (m *mailNotifier) NotifyNewIssue(issue *models.Issue) {
|
||||
if err := mailer.MailParticipants(issue, issue.Poster, models.ActionCreateIssue); err != nil {
|
||||
func (m *mailNotifier) NotifyNewIssue(issue *models.Issue, mentions []*models.User) {
|
||||
if err := mailer.MailParticipants(issue, issue.Poster, models.ActionCreateIssue, mentions); err != nil {
|
||||
log.Error("MailParticipants: %v", err)
|
||||
}
|
||||
}
|
||||
|
@ -69,18 +69,18 @@ func (m *mailNotifier) NotifyIssueChangeStatus(doer *models.User, issue *models.
|
|||
}
|
||||
}
|
||||
|
||||
if err := mailer.MailParticipants(issue, doer, actionType); err != nil {
|
||||
if err := mailer.MailParticipants(issue, doer, actionType, nil); err != nil {
|
||||
log.Error("MailParticipants: %v", err)
|
||||
}
|
||||
}
|
||||
|
||||
func (m *mailNotifier) NotifyNewPullRequest(pr *models.PullRequest) {
|
||||
if err := mailer.MailParticipants(pr.Issue, pr.Issue.Poster, models.ActionCreatePullRequest); err != nil {
|
||||
func (m *mailNotifier) NotifyNewPullRequest(pr *models.PullRequest, mentions []*models.User) {
|
||||
if err := mailer.MailParticipants(pr.Issue, pr.Issue.Poster, models.ActionCreatePullRequest, mentions); err != nil {
|
||||
log.Error("MailParticipants: %v", err)
|
||||
}
|
||||
}
|
||||
|
||||
func (m *mailNotifier) NotifyPullRequestReview(pr *models.PullRequest, r *models.Review, comment *models.Comment) {
|
||||
func (m *mailNotifier) NotifyPullRequestReview(pr *models.PullRequest, r *models.Review, comment *models.Comment, mentions []*models.User) {
|
||||
var act models.ActionType
|
||||
if comment.Type == models.CommentTypeClose {
|
||||
act = models.ActionCloseIssue
|
||||
|
@ -89,11 +89,17 @@ func (m *mailNotifier) NotifyPullRequestReview(pr *models.PullRequest, r *models
|
|||
} else if comment.Type == models.CommentTypeComment {
|
||||
act = models.ActionCommentPull
|
||||
}
|
||||
if err := mailer.MailParticipantsComment(comment, act, pr.Issue); err != nil {
|
||||
if err := mailer.MailParticipantsComment(comment, act, pr.Issue, mentions); err != nil {
|
||||
log.Error("MailParticipantsComment: %v", err)
|
||||
}
|
||||
}
|
||||
|
||||
func (m *mailNotifier) NotifyPullRequestCodeComment(pr *models.PullRequest, comment *models.Comment, mentions []*models.User) {
|
||||
if err := mailer.MailMentionsComment(pr, comment, mentions); err != nil {
|
||||
log.Error("MailMentionsComment: %v", err)
|
||||
}
|
||||
}
|
||||
|
||||
func (m *mailNotifier) NotifyIssueChangeAssignee(doer *models.User, issue *models.Issue, assignee *models.User, removed bool, comment *models.Comment) {
|
||||
// mail only sent to added assignees and not self-assignee
|
||||
if !removed && doer.ID != assignee.ID && assignee.EmailNotifications() == models.EmailNotificationsEnabled {
|
||||
|
@ -115,7 +121,7 @@ func (m *mailNotifier) NotifyMergePullRequest(pr *models.PullRequest, doer *mode
|
|||
return
|
||||
}
|
||||
pr.Issue.Content = ""
|
||||
if err := mailer.MailParticipants(pr.Issue, doer, models.ActionMergePullRequest); err != nil {
|
||||
if err := mailer.MailParticipants(pr.Issue, doer, models.ActionMergePullRequest, nil); err != nil {
|
||||
log.Error("MailParticipants: %v", err)
|
||||
}
|
||||
}
|
||||
|
@ -143,7 +149,7 @@ func (m *mailNotifier) NotifyPullRequestPushCommits(doer *models.User, pr *model
|
|||
}
|
||||
comment.Content = ""
|
||||
|
||||
m.NotifyCreateIssueComment(doer, comment.Issue.Repo, comment.Issue, comment)
|
||||
m.NotifyCreateIssueComment(doer, comment.Issue.Repo, comment.Issue, comment, nil)
|
||||
}
|
||||
|
||||
func (m *mailNotifier) NotifyNewRelease(rel *models.Release) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue