2019-09-24 10:32:49 +05:30
|
|
|
// Copyright 2019 The Gitea Authors. All rights reserved.
|
|
|
|
// Use of this source code is governed by a MIT-style
|
|
|
|
// license that can be found in the LICENSE file.
|
|
|
|
|
|
|
|
package mailer
|
|
|
|
|
|
|
|
import (
|
|
|
|
"code.gitea.io/gitea/models"
|
|
|
|
"code.gitea.io/gitea/modules/log"
|
|
|
|
)
|
|
|
|
|
2021-04-02 15:55:13 +05:30
|
|
|
// MailParticipantsComment sends new comment emails to repository watchers and mentioned people.
|
2021-01-02 22:34:02 +05:30
|
|
|
func MailParticipantsComment(c *models.Comment, opType models.ActionType, issue *models.Issue, mentions []*models.User) error {
|
2021-04-02 15:55:13 +05:30
|
|
|
if err := mailIssueCommentToParticipants(
|
2019-11-18 13:38:20 +05:30
|
|
|
&mailCommentContext{
|
|
|
|
Issue: issue,
|
|
|
|
Doer: c.Poster,
|
|
|
|
ActionType: opType,
|
|
|
|
Content: c.Content,
|
|
|
|
Comment: c,
|
2021-04-02 15:55:13 +05:30
|
|
|
}, mentions); err != nil {
|
2019-11-07 19:04:28 +05:30
|
|
|
log.Error("mailIssueCommentToParticipants: %v", err)
|
2019-09-24 10:32:49 +05:30
|
|
|
}
|
|
|
|
return nil
|
|
|
|
}
|
2021-01-02 22:34:02 +05:30
|
|
|
|
|
|
|
// MailMentionsComment sends email to users mentioned in a code comment
|
|
|
|
func MailMentionsComment(pr *models.PullRequest, c *models.Comment, mentions []*models.User) (err error) {
|
|
|
|
visited := make(map[int64]bool, len(mentions)+1)
|
|
|
|
visited[c.Poster.ID] = true
|
|
|
|
if err = mailIssueCommentBatch(
|
|
|
|
&mailCommentContext{
|
|
|
|
Issue: pr.Issue,
|
|
|
|
Doer: c.Poster,
|
|
|
|
ActionType: models.ActionCommentPull,
|
|
|
|
Content: c.Content,
|
|
|
|
Comment: c,
|
2021-04-02 15:55:13 +05:30
|
|
|
}, mentions, visited, true); err != nil {
|
2021-01-02 22:34:02 +05:30
|
|
|
log.Error("mailIssueCommentBatch: %v", err)
|
|
|
|
}
|
|
|
|
return nil
|
|
|
|
}
|