forked from forgejo/forgejo
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
|
@ -51,7 +51,7 @@ func (ns *notificationService) Run() {
|
|||
}
|
||||
|
||||
func (ns *notificationService) NotifyCreateIssueComment(doer *models.User, repo *models.Repository,
|
||||
issue *models.Issue, comment *models.Comment) {
|
||||
issue *models.Issue, comment *models.Comment, mentions []*models.User) {
|
||||
var opts = issueNotificationOpts{
|
||||
IssueID: issue.ID,
|
||||
NotificationAuthorID: doer.ID,
|
||||
|
@ -60,13 +60,31 @@ func (ns *notificationService) NotifyCreateIssueComment(doer *models.User, repo
|
|||
opts.CommentID = comment.ID
|
||||
}
|
||||
_ = ns.issueQueue.Push(opts)
|
||||
for _, mention := range mentions {
|
||||
var opts = issueNotificationOpts{
|
||||
IssueID: issue.ID,
|
||||
NotificationAuthorID: doer.ID,
|
||||
ReceiverID: mention.ID,
|
||||
}
|
||||
if comment != nil {
|
||||
opts.CommentID = comment.ID
|
||||
}
|
||||
_ = ns.issueQueue.Push(opts)
|
||||
}
|
||||
}
|
||||
|
||||
func (ns *notificationService) NotifyNewIssue(issue *models.Issue) {
|
||||
func (ns *notificationService) NotifyNewIssue(issue *models.Issue, mentions []*models.User) {
|
||||
_ = ns.issueQueue.Push(issueNotificationOpts{
|
||||
IssueID: issue.ID,
|
||||
NotificationAuthorID: issue.Poster.ID,
|
||||
})
|
||||
for _, mention := range mentions {
|
||||
_ = ns.issueQueue.Push(issueNotificationOpts{
|
||||
IssueID: issue.ID,
|
||||
NotificationAuthorID: issue.Poster.ID,
|
||||
ReceiverID: mention.ID,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func (ns *notificationService) NotifyIssueChangeStatus(doer *models.User, issue *models.Issue, actionComment *models.Comment, isClosed bool) {
|
||||
|
@ -83,7 +101,7 @@ func (ns *notificationService) NotifyMergePullRequest(pr *models.PullRequest, do
|
|||
})
|
||||
}
|
||||
|
||||
func (ns *notificationService) NotifyNewPullRequest(pr *models.PullRequest) {
|
||||
func (ns *notificationService) NotifyNewPullRequest(pr *models.PullRequest, mentions []*models.User) {
|
||||
if err := pr.LoadIssue(); err != nil {
|
||||
log.Error("Unable to load issue: %d for pr: %d: Error: %v", pr.IssueID, pr.ID, err)
|
||||
return
|
||||
|
@ -92,9 +110,16 @@ func (ns *notificationService) NotifyNewPullRequest(pr *models.PullRequest) {
|
|||
IssueID: pr.Issue.ID,
|
||||
NotificationAuthorID: pr.Issue.PosterID,
|
||||
})
|
||||
for _, mention := range mentions {
|
||||
_ = ns.issueQueue.Push(issueNotificationOpts{
|
||||
IssueID: pr.Issue.ID,
|
||||
NotificationAuthorID: pr.Issue.PosterID,
|
||||
ReceiverID: mention.ID,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func (ns *notificationService) NotifyPullRequestReview(pr *models.PullRequest, r *models.Review, c *models.Comment) {
|
||||
func (ns *notificationService) NotifyPullRequestReview(pr *models.PullRequest, r *models.Review, c *models.Comment, mentions []*models.User) {
|
||||
var opts = issueNotificationOpts{
|
||||
IssueID: pr.Issue.ID,
|
||||
NotificationAuthorID: r.Reviewer.ID,
|
||||
|
@ -103,6 +128,28 @@ func (ns *notificationService) NotifyPullRequestReview(pr *models.PullRequest, r
|
|||
opts.CommentID = c.ID
|
||||
}
|
||||
_ = ns.issueQueue.Push(opts)
|
||||
for _, mention := range mentions {
|
||||
var opts = issueNotificationOpts{
|
||||
IssueID: pr.Issue.ID,
|
||||
NotificationAuthorID: r.Reviewer.ID,
|
||||
ReceiverID: mention.ID,
|
||||
}
|
||||
if c != nil {
|
||||
opts.CommentID = c.ID
|
||||
}
|
||||
_ = ns.issueQueue.Push(opts)
|
||||
}
|
||||
}
|
||||
|
||||
func (ns *notificationService) NotifyPullRequestCodeComment(pr *models.PullRequest, c *models.Comment, mentions []*models.User) {
|
||||
for _, mention := range mentions {
|
||||
_ = ns.issueQueue.Push(issueNotificationOpts{
|
||||
IssueID: pr.Issue.ID,
|
||||
NotificationAuthorID: c.Poster.ID,
|
||||
CommentID: c.ID,
|
||||
ReceiverID: mention.ID,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func (ns *notificationService) NotifyPullRequestPushCommits(doer *models.User, pr *models.PullRequest, comment *models.Comment) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue