// 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 (
"context"
activities_model "code.gitea.io/gitea/models/activities"
issues_model "code.gitea.io/gitea/models/issues"
user_model "code.gitea.io/gitea/models/user"
"code.gitea.io/gitea/modules/container"
"code.gitea.io/gitea/modules/log"
"code.gitea.io/gitea/modules/setting"
)
// MailParticipantsComment sends new comment emails to repository watchers and mentioned people.
func MailParticipantsComment(ctx context.Context, c *issues_model.Comment, opType activities_model.ActionType, issue *issues_model.Issue, mentions []*user_model.User) error {
if setting.MailService == nil {
// No mail service configured
return nil
}
content := c.Content
if c.Type == issues_model.CommentTypePullRequestPush {
content = ""
if err := mailIssueCommentToParticipants(
&mailCommentContext{
Context: ctx,
Issue: issue,
Doer: c.Poster,
ActionType: opType,
Content: content,
Comment: c,
}, mentions); err != nil {
log.Error("mailIssueCommentToParticipants: %v", err)
// MailMentionsComment sends email to users mentioned in a code comment
func MailMentionsComment(ctx context.Context, pr *issues_model.PullRequest, c *issues_model.Comment, mentions []*user_model.User) (err error) {
visited := make(container.Set[int64], len(mentions)+1)
visited.Add(c.Poster.ID)
if err = mailIssueCommentBatch(
Issue: pr.Issue,
ActionType: activities_model.ActionCommentPull,
Content: c.Content,
}, mentions, visited, true); err != nil {
log.Error("mailIssueCommentBatch: %v", err)