summaryrefslogtreecommitdiffstats
path: root/services/mailer/mail_issue.go
diff options
context:
space:
mode:
Diffstat (limited to 'services/mailer/mail_issue.go')
-rw-r--r--services/mailer/mail_issue.go36
1 files changed, 6 insertions, 30 deletions
diff --git a/services/mailer/mail_issue.go b/services/mailer/mail_issue.go
index a5f3251807..32b21b1324 100644
--- a/services/mailer/mail_issue.go
+++ b/services/mailer/mail_issue.go
@@ -14,7 +14,7 @@ import (
"github.com/unknwon/com"
)
-func mailSubject(issue *models.Issue) string {
+func fallbackMailSubject(issue *models.Issue) string {
return fmt.Sprintf("[%s] %s (#%d)", issue.Repo.FullName(), issue.Title, issue.Index)
}
@@ -22,7 +22,7 @@ func mailSubject(issue *models.Issue) string {
// This function sends two list of emails:
// 1. Repository watchers and users who are participated in comments.
// 2. Users who are not in 1. but get mentioned in current issue/comment.
-func mailIssueCommentToParticipants(issue *models.Issue, doer *models.User, content string, comment *models.Comment, mentions []string) error {
+func mailIssueCommentToParticipants(issue *models.Issue, doer *models.User, actionType models.ActionType, content string, comment *models.Comment, mentions []string) error {
watchers, err := models.GetWatchers(issue.RepoID)
if err != nil {
@@ -89,7 +89,7 @@ func mailIssueCommentToParticipants(issue *models.Issue, doer *models.User, cont
}
for _, to := range tos {
- SendIssueCommentMail(issue, doer, content, comment, []string{to})
+ SendIssueCommentMail(issue, doer, actionType, content, comment, []string{to})
}
// Mail mentioned people and exclude watchers.
@@ -106,7 +106,7 @@ func mailIssueCommentToParticipants(issue *models.Issue, doer *models.User, cont
emails := models.GetUserEmailsByNames(tos)
for _, to := range emails {
- SendIssueMentionMail(issue, doer, content, comment, []string{to})
+ SendIssueMentionMail(issue, doer, actionType, content, comment, []string{to})
}
return nil
@@ -131,32 +131,8 @@ func mailParticipants(ctx models.DBContext, issue *models.Issue, doer *models.Us
for i, u := range userMentions {
mentions[i] = u.LowerName
}
-
- if len(issue.Content) > 0 {
- if err = mailIssueCommentToParticipants(issue, doer, issue.Content, nil, mentions); err != nil {
- log.Error("mailIssueCommentToParticipants: %v", err)
- }
- }
-
- switch opType {
- case models.ActionCreateIssue, models.ActionCreatePullRequest:
- if len(issue.Content) == 0 {
- ct := fmt.Sprintf("Created #%d.", issue.Index)
- if err = mailIssueCommentToParticipants(issue, doer, ct, nil, mentions); err != nil {
- log.Error("mailIssueCommentToParticipants: %v", err)
- }
- }
- case models.ActionCloseIssue, models.ActionClosePullRequest:
- ct := fmt.Sprintf("Closed #%d.", issue.Index)
- if err = mailIssueCommentToParticipants(issue, doer, ct, nil, mentions); err != nil {
- log.Error("mailIssueCommentToParticipants: %v", err)
- }
- case models.ActionReopenIssue, models.ActionReopenPullRequest:
- ct := fmt.Sprintf("Reopened #%d.", issue.Index)
- if err = mailIssueCommentToParticipants(issue, doer, ct, nil, mentions); err != nil {
- log.Error("mailIssueCommentToParticipants: %v", err)
- }
+ if err = mailIssueCommentToParticipants(issue, doer, opType, issue.Content, nil, mentions); err != nil {
+ log.Error("mailIssueCommentToParticipants: %v", err)
}
-
return nil
}