"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "services/mailer/mail_comment.go" between
gitea-1.13.1.tar.gz and gitea-1.13.2.tar.gz

About: Gitea allows to set up a self-hosted code hosting Git service (a fork of Gogs).

mail_comment.go  (gitea-1.13.1):mail_comment.go  (gitea-1.13.2)
// Copyright 2019 The Gitea Authors. All rights reserved. // Copyright 2019 The Gitea Authors. All rights reserved.
// Use of this source code is governed by a MIT-style // Use of this source code is governed by a MIT-style
// license that can be found in the LICENSE file. // license that can be found in the LICENSE file.
package mailer package mailer
import ( import (
"fmt"
"code.gitea.io/gitea/models" "code.gitea.io/gitea/models"
"code.gitea.io/gitea/modules/log" "code.gitea.io/gitea/modules/log"
"code.gitea.io/gitea/modules/references"
) )
// MailParticipantsComment sends new comment emails to repository watchers // MailParticipantsComment sends new comment emails to repository watchers
// and mentioned people. // and mentioned people.
func MailParticipantsComment(c *models.Comment, opType models.ActionType, issue func MailParticipantsComment(c *models.Comment, opType models.ActionType, issue
*models.Issue) error { *models.Issue, mentions []*models.User) error {
return mailParticipantsComment(models.DefaultDBContext(), c, opType, issu return mailParticipantsComment(c, opType, issue, mentions)
e)
} }
func mailParticipantsComment(ctx models.DBContext, c *models.Comment, opType mod func mailParticipantsComment(c *models.Comment, opType models.ActionType, issue
els.ActionType, issue *models.Issue) (err error) { *models.Issue, mentions []*models.User) (err error) {
rawMentions := references.FindAllMentionsMarkdown(c.Content) mentionedIDs := make([]int64, len(mentions))
userMentions, err := issue.ResolveMentionsByVisibility(ctx, c.Poster, raw for i, u := range mentions {
Mentions) mentionedIDs[i] = u.ID
if err != nil {
return fmt.Errorf("ResolveMentionsByVisibility [%d]: %v", c.Issue
ID, err)
}
if err = models.UpdateIssueMentions(ctx, c.IssueID, userMentions); err !=
nil {
return fmt.Errorf("UpdateIssueMentions [%d]: %v", c.IssueID, err)
}
mentions := make([]int64, len(userMentions))
for i, u := range userMentions {
mentions[i] = u.ID
} }
if err = mailIssueCommentToParticipants( if err = mailIssueCommentToParticipants(
&mailCommentContext{ &mailCommentContext{
Issue: issue, Issue: issue,
Doer: c.Poster, Doer: c.Poster,
ActionType: opType, ActionType: opType,
Content: c.Content, Content: c.Content,
Comment: c, Comment: c,
}, mentions); err != nil { }, mentionedIDs); err != nil {
log.Error("mailIssueCommentToParticipants: %v", err) log.Error("mailIssueCommentToParticipants: %v", err)
} }
return nil return nil
} }
// MailMentionsComment sends email to users mentioned in a code comment
func MailMentionsComment(pr *models.PullRequest, c *models.Comment, mentions []*
models.User) (err error) {
mentionedIDs := make([]int64, len(mentions))
for i, u := range mentions {
mentionedIDs[i] = u.ID
}
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,
}, mentionedIDs, visited, true); err != nil {
log.Error("mailIssueCommentBatch: %v", err)
}
return nil
}
 End of changes. 6 change blocks. 
24 lines changed or deleted 9 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)