mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2025-06-22 09:18:30 -04:00
[refactor] mailer service (#15072)
* Unexport SendUserMail * Instead of "[]*models.User" or "[]string" lists infent "[]*MailRecipient" for mailer * adopt * code format * TODOs for "i18n" * clean * no fallback for lang -> just use english * lint * exec testComposeIssueCommentMessage per lang and use only emails * rm MailRecipient * Dont reload from users from db if you alredy have in ram * nits * minimize diff Signed-off-by: 6543 <6543@obermui.de> * localize subjects * linter ... * Tr extend * start tmpl edit ... * Apply suggestions from code review * use translation.Locale * improve mailIssueCommentBatch Signed-off-by: Andrew Thornton <art27@cantab.net> * add i18n to datas Signed-off-by: Andrew Thornton <art27@cantab.net> * a comment Co-authored-by: Andrew Thornton <art27@cantab.net>
This commit is contained in:
parent
cc2d540092
commit
80d6c6d7de
15 changed files with 191 additions and 151 deletions
|
@ -9,25 +9,16 @@ import (
|
|||
"code.gitea.io/gitea/modules/log"
|
||||
)
|
||||
|
||||
// MailParticipantsComment sends new comment emails to repository watchers
|
||||
// and mentioned people.
|
||||
// MailParticipantsComment sends new comment emails to repository watchers and mentioned people.
|
||||
func MailParticipantsComment(c *models.Comment, opType models.ActionType, issue *models.Issue, mentions []*models.User) error {
|
||||
return mailParticipantsComment(c, opType, issue, mentions)
|
||||
}
|
||||
|
||||
func mailParticipantsComment(c *models.Comment, opType models.ActionType, issue *models.Issue, mentions []*models.User) (err error) {
|
||||
mentionedIDs := make([]int64, len(mentions))
|
||||
for i, u := range mentions {
|
||||
mentionedIDs[i] = u.ID
|
||||
}
|
||||
if err = mailIssueCommentToParticipants(
|
||||
if err := mailIssueCommentToParticipants(
|
||||
&mailCommentContext{
|
||||
Issue: issue,
|
||||
Doer: c.Poster,
|
||||
ActionType: opType,
|
||||
Content: c.Content,
|
||||
Comment: c,
|
||||
}, mentionedIDs); err != nil {
|
||||
}, mentions); err != nil {
|
||||
log.Error("mailIssueCommentToParticipants: %v", err)
|
||||
}
|
||||
return nil
|
||||
|
@ -35,10 +26,6 @@ func mailParticipantsComment(c *models.Comment, opType models.ActionType, issue
|
|||
|
||||
// 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(
|
||||
|
@ -48,7 +35,7 @@ func MailMentionsComment(pr *models.PullRequest, c *models.Comment, mentions []*
|
|||
ActionType: models.ActionCommentPull,
|
||||
Content: c.Content,
|
||||
Comment: c,
|
||||
}, mentionedIDs, visited, true); err != nil {
|
||||
}, mentions, visited, true); err != nil {
|
||||
log.Error("mailIssueCommentBatch: %v", err)
|
||||
}
|
||||
return nil
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue