From 74774a41c322db8c78cc0dc9ce92402e673bda13 Mon Sep 17 00:00:00 2001 From: Jonas Franz Date: Thu, 4 May 2017 17:58:40 +0200 Subject: [PATCH 1/8] Added comment's hashtag to url for mail notifications. Signed-off-by: Jonas --- models/issue_comment.go | 2 +- models/issue_mail.go | 84 ++++++++++++++++++++++++++++++----------- models/mail.go | 40 ++++++++++++++++++-- 3 files changed, 100 insertions(+), 26 deletions(-) diff --git a/models/issue_comment.go b/models/issue_comment.go index e133cc049bdcb..430bbdfa26508 100644 --- a/models/issue_comment.go +++ b/models/issue_comment.go @@ -289,7 +289,7 @@ func (c *Comment) MailParticipants(e Engine, opType ActionType, issue *Issue) (e case ActionReopenIssue: issue.Content = fmt.Sprintf("Reopened #%d", issue.Index) } - if err = mailIssueCommentToParticipants(issue, c.Poster, mentions); err != nil { + if err = mailIssueCommentToParticipants(issue, c.Poster, c, mentions); err != nil { log.Error(4, "mailIssueCommentToParticipants: %v", err) } diff --git a/models/issue_mail.go b/models/issue_mail.go index 4b6542ddb4c15..1ff407e0f2933 100644 --- a/models/issue_mail.go +++ b/models/issue_mail.go @@ -18,22 +18,73 @@ func (issue *Issue) mailSubject() string { return fmt.Sprintf("[%s] %s (#%d)", issue.Repo.Name, issue.Title, issue.Index) } -// mailIssueCommentToParticipants can be used for both new issue creation and comment. + +// mailIssueCommentToParticipants can be used for only for comment. // 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 *Issue, doer *User, mentions []string) error { +func mailIssueCommentToParticipants(issue *Issue, doer *User, comment *Comment, mentions []string) error { + + names, tos, err := prepareMailToParticipants(issue, doer) + + if(err != nil) { + return fmt.Errorf("PrepareMailToParticipants: %v", err) + } + + SendIssueCommentMail(issue, doer, comment, tos) + + // Mail mentioned people and exclude watchers. + names = append(names, doer.Name) + tos = make([]string, 0, len(mentions)) // list of user names. + for i := range mentions { + if com.IsSliceContainsStr(names, mentions[i]) { + continue + } + + tos = append(tos, mentions[i]) + } + SendIssueMentionMail(issue, doer, comment, GetUserEmailsByNames(tos)) + + return nil +} + +func mailIssueActionToParticipants(issue *Issue, doer *User, mentions []string) error { + names, tos, err := prepareMailToParticipants(issue, doer) + + if(err != nil) { + return fmt.Errorf("PrepareMailToParticipants: %v", err) + } + + SendIssueActionMail(issue, doer, tos) + + // Mail mentioned people and exclude watchers. + names = append(names, doer.Name) + tos = make([]string, 0, len(mentions)) // list of user names. + for i := range mentions { + if com.IsSliceContainsStr(names, mentions[i]) { + continue + } + + tos = append(tos, mentions[i]) + } + SendIssueMentionInActionMail(issue, doer, GetUserEmailsByNames(tos)) + + return nil +} + +// prepareMailToParticipants creates the tos and names list for an issue and the issue's creator. +func prepareMailToParticipants(issue *Issue, doer *User) ([]string, []string, error) { if !setting.Service.EnableNotifyMail { - return nil + return nil, nil, nil } watchers, err := GetWatchers(issue.RepoID) if err != nil { - return fmt.Errorf("GetWatchers [repo_id: %d]: %v", issue.RepoID, err) + return nil, nil, err } participants, err := GetParticipantsByIssueID(issue.ID) if err != nil { - return fmt.Errorf("GetParticipantsByIssueID [issue_id: %d]: %v", issue.ID, err) + return nil, nil, err } // In case the issue poster is not watching the repository, @@ -51,7 +102,7 @@ func mailIssueCommentToParticipants(issue *Issue, doer *User, mentions []string) to, err := GetUserByID(watchers[i].UserID) if err != nil { - return fmt.Errorf("GetUserByID [%d]: %v", watchers[i].UserID, err) + return nil, nil, err } if to.IsOrganization() { continue @@ -70,23 +121,10 @@ func mailIssueCommentToParticipants(issue *Issue, doer *User, mentions []string) tos = append(tos, participants[i].Email) names = append(names, participants[i].Name) } - SendIssueCommentMail(issue, doer, tos) - - // Mail mentioned people and exclude watchers. - names = append(names, doer.Name) - tos = make([]string, 0, len(mentions)) // list of user names. - for i := range mentions { - if com.IsSliceContainsStr(names, mentions[i]) { - continue - } - - tos = append(tos, mentions[i]) - } - SendIssueMentionMail(issue, doer, GetUserEmailsByNames(tos)) - - return nil + return tos, names, nil } + // MailParticipants sends new issue thread created emails to repository watchers // and mentioned people. func (issue *Issue) MailParticipants() (err error) { @@ -95,9 +133,11 @@ func (issue *Issue) MailParticipants() (err error) { return fmt.Errorf("UpdateIssueMentions [%d]: %v", issue.ID, err) } - if err = mailIssueCommentToParticipants(issue, issue.Poster, mentions); err != nil { + if err = mailIssueActionToParticipants(issue, issue.Poster, mentions); err != nil { log.Error(4, "mailIssueCommentToParticipants: %v", err) } return nil } + + diff --git a/models/mail.go b/models/mail.go index 16e8c9e2efbb1..165db65698cd5 100644 --- a/models/mail.go +++ b/models/mail.go @@ -148,6 +148,24 @@ func composeTplData(subject, body, link string) map[string]interface{} { return data } +func composeIssueCommentMessage(issue *Issue, doer *User, comment *Comment, tplName base.TplName, tos []string, info string) *mailer.Message { + subject := issue.mailSubject() + body := string(markdown.RenderString(issue.Content, issue.Repo.HTMLURL(), issue.Repo.ComposeMetas())) + data := composeTplData(subject, body, issue.HTMLURL() + comment.HashTag()) + + data["Doer"] = doer + + var content bytes.Buffer + + if err := templates.ExecuteTemplate(&content, string(tplName), data); err != nil { + log.Error(3, "Template: %v", err) + } + + msg := mailer.NewMessageFrom(tos, fmt.Sprintf(`"%s" <%s>`, doer.DisplayName(), setting.MailService.FromEmail), subject, content.String()) + msg.Info = fmt.Sprintf("Subject: %s, %s", subject, info) + return msg +} + func composeIssueMessage(issue *Issue, doer *User, tplName base.TplName, tos []string, info string) *mailer.Message { subject := issue.mailSubject() body := string(markdown.RenderString(issue.Content, issue.Repo.HTMLURL(), issue.Repo.ComposeMetas())) @@ -166,16 +184,32 @@ func composeIssueMessage(issue *Issue, doer *User, tplName base.TplName, tos []s } // SendIssueCommentMail composes and sends issue comment emails to target receivers. -func SendIssueCommentMail(issue *Issue, doer *User, tos []string) { +func SendIssueCommentMail(issue *Issue, doer *User, comment *Comment, tos []string) { if len(tos) == 0 { return } - mailer.SendAsync(composeIssueMessage(issue, doer, mailIssueComment, tos, "issue comment")) + mailer.SendAsync(composeIssueCommentMessage(issue, doer, comment, mailIssueComment, tos, "issue comment")) } // SendIssueMentionMail composes and sends issue mention emails to target receivers. -func SendIssueMentionMail(issue *Issue, doer *User, tos []string) { +func SendIssueMentionMail(issue *Issue, doer *User, comment *Comment, tos []string) { + if len(tos) == 0 { + return + } + mailer.SendAsync(composeIssueCommentMessage(issue, doer, comment, mailIssueMention, tos, "issue mention")) +} +// SendIssueActionMail composes and sends issue action emails to target receivers. +func SendIssueActionMail(issue *Issue, doer *User, tos []string) { + if len(tos) == 0 { + return + } + + mailer.SendAsync(composeIssueMessage(issue, doer, mailIssueComment, tos, "issue comment")) +} + +// SendIssueMentionInActionMail composes and sends issue mention emails to target receivers. Only applies if no comment is given. +func SendIssueMentionInActionMail(issue *Issue, doer *User, tos []string) { if len(tos) == 0 { return } From f385727aef6f0a777d7fedba56d701ff8b2a0b9e Mon Sep 17 00:00:00 2001 From: Jonas Franz Date: Thu, 4 May 2017 18:00:40 +0200 Subject: [PATCH 2/8] Added comment's hashtag to url for mail notifications. Added explanation to return statement. Signed-off-by: Jonas --- models/issue_mail.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/models/issue_mail.go b/models/issue_mail.go index 1ff407e0f2933..1fabde489a653 100644 --- a/models/issue_mail.go +++ b/models/issue_mail.go @@ -73,7 +73,7 @@ func mailIssueActionToParticipants(issue *Issue, doer *User, mentions []string) } // prepareMailToParticipants creates the tos and names list for an issue and the issue's creator. -func prepareMailToParticipants(issue *Issue, doer *User) ([]string, []string, error) { +func prepareMailToParticipants(issue *Issue, doer *User) (tos []string, names []string, error error) { if !setting.Service.EnableNotifyMail { return nil, nil, nil } From e05eb960a89631c6986c3f4a5096ff6a35b45c38 Mon Sep 17 00:00:00 2001 From: Jonas Franz Date: Thu, 4 May 2017 18:13:31 +0200 Subject: [PATCH 3/8] Added comment's hashtag to url for mail notifications. Added explanation to return statement + documentation. Signed-off-by: Jonas --- models/issue_mail.go | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/models/issue_mail.go b/models/issue_mail.go index 1fabde489a653..bb41f228834ee 100644 --- a/models/issue_mail.go +++ b/models/issue_mail.go @@ -19,7 +19,7 @@ func (issue *Issue) mailSubject() string { } -// mailIssueCommentToParticipants can be used for only for comment. +// mailIssueCommentToParticipants can be used only for comment. // 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. @@ -48,6 +48,10 @@ func mailIssueCommentToParticipants(issue *Issue, doer *User, comment *Comment, return nil } +// mailIssueActionToParticipants can be used for creation or pull requests. +// 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 mailIssueActionToParticipants(issue *Issue, doer *User, mentions []string) error { names, tos, err := prepareMailToParticipants(issue, doer) @@ -93,8 +97,8 @@ func prepareMailToParticipants(issue *Issue, doer *User) (tos []string, names [] participants = append(participants, issue.Poster) } - tos := make([]string, 0, len(watchers)) // List of email addresses. - names := make([]string, 0, len(watchers)) + tos = make([]string, 0, len(watchers)) // List of email addresses. + names = make([]string, 0, len(watchers)) for i := range watchers { if watchers[i].UserID == doer.ID { continue From 5cb36ca7bd650fda84a361febf3c26c77ef7f753 Mon Sep 17 00:00:00 2001 From: Jonas Franz Date: Thu, 4 May 2017 18:30:37 +0200 Subject: [PATCH 4/8] Added comment's hashtag to url for mail notifications. Signed-off-by: Jonas Franz --- models/mail.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/models/mail.go b/models/mail.go index 165db65698cd5..8ac941a26747c 100644 --- a/models/mail.go +++ b/models/mail.go @@ -151,7 +151,7 @@ func composeTplData(subject, body, link string) map[string]interface{} { func composeIssueCommentMessage(issue *Issue, doer *User, comment *Comment, tplName base.TplName, tos []string, info string) *mailer.Message { subject := issue.mailSubject() body := string(markdown.RenderString(issue.Content, issue.Repo.HTMLURL(), issue.Repo.ComposeMetas())) - data := composeTplData(subject, body, issue.HTMLURL() + comment.HashTag()) + data := composeTplData(subject, body, issue.HTMLURL() + "#" + comment.HashTag()) data["Doer"] = doer From 2dd674e51dc120c70ca04f3153d246af35d5080b Mon Sep 17 00:00:00 2001 From: Jonas Franz Date: Thu, 4 May 2017 21:29:55 +0200 Subject: [PATCH 5/8] Replacing in-line link generation with HTMLURL. (+gofmt) Signed-off-by: Jonas Franz --- models/issue_mail.go | 10 +++------- models/mail.go | 3 ++- 2 files changed, 5 insertions(+), 8 deletions(-) diff --git a/models/issue_mail.go b/models/issue_mail.go index bb41f228834ee..fc58b6f613795 100644 --- a/models/issue_mail.go +++ b/models/issue_mail.go @@ -18,7 +18,6 @@ func (issue *Issue) mailSubject() string { return fmt.Sprintf("[%s] %s (#%d)", issue.Repo.Name, issue.Title, issue.Index) } - // mailIssueCommentToParticipants can be used only for comment. // This function sends two list of emails: // 1. Repository watchers and users who are participated in comments. @@ -27,7 +26,7 @@ func mailIssueCommentToParticipants(issue *Issue, doer *User, comment *Comment, names, tos, err := prepareMailToParticipants(issue, doer) - if(err != nil) { + if err != nil { return fmt.Errorf("PrepareMailToParticipants: %v", err) } @@ -55,7 +54,7 @@ func mailIssueCommentToParticipants(issue *Issue, doer *User, comment *Comment, func mailIssueActionToParticipants(issue *Issue, doer *User, mentions []string) error { names, tos, err := prepareMailToParticipants(issue, doer) - if(err != nil) { + if err != nil { return fmt.Errorf("PrepareMailToParticipants: %v", err) } @@ -77,7 +76,7 @@ func mailIssueActionToParticipants(issue *Issue, doer *User, mentions []string) } // prepareMailToParticipants creates the tos and names list for an issue and the issue's creator. -func prepareMailToParticipants(issue *Issue, doer *User) (tos []string, names []string, error error) { +func prepareMailToParticipants(issue *Issue, doer *User) (tos []string, names []string, error error) { if !setting.Service.EnableNotifyMail { return nil, nil, nil } @@ -128,7 +127,6 @@ func prepareMailToParticipants(issue *Issue, doer *User) (tos []string, names [] return tos, names, nil } - // MailParticipants sends new issue thread created emails to repository watchers // and mentioned people. func (issue *Issue) MailParticipants() (err error) { @@ -143,5 +141,3 @@ func (issue *Issue) MailParticipants() (err error) { return nil } - - diff --git a/models/mail.go b/models/mail.go index 8ac941a26747c..4b1b32b1e9e9e 100644 --- a/models/mail.go +++ b/models/mail.go @@ -151,7 +151,7 @@ func composeTplData(subject, body, link string) map[string]interface{} { func composeIssueCommentMessage(issue *Issue, doer *User, comment *Comment, tplName base.TplName, tos []string, info string) *mailer.Message { subject := issue.mailSubject() body := string(markdown.RenderString(issue.Content, issue.Repo.HTMLURL(), issue.Repo.ComposeMetas())) - data := composeTplData(subject, body, issue.HTMLURL() + "#" + comment.HashTag()) + data := composeTplData(subject, body, comment.HTMLURL()) data["Doer"] = doer @@ -199,6 +199,7 @@ func SendIssueMentionMail(issue *Issue, doer *User, comment *Comment, tos []stri } mailer.SendAsync(composeIssueCommentMessage(issue, doer, comment, mailIssueMention, tos, "issue mention")) } + // SendIssueActionMail composes and sends issue action emails to target receivers. func SendIssueActionMail(issue *Issue, doer *User, tos []string) { if len(tos) == 0 { From 716bf811b4249215a49ac151f66d626cc32c4e44 Mon Sep 17 00:00:00 2001 From: Jonas Franz Date: Thu, 4 May 2017 22:28:01 +0200 Subject: [PATCH 6/8] Replaced action-based model with nil-based model. (+gofmt) Signed-off-by: Jonas Franz --- models/issue_comment.go | 2 +- models/issue_mail.go | 91 ++++++++++++++--------------------------- models/mail.go | 39 +++--------------- 3 files changed, 36 insertions(+), 96 deletions(-) diff --git a/models/issue_comment.go b/models/issue_comment.go index 430bbdfa26508..a65abfe0124cb 100644 --- a/models/issue_comment.go +++ b/models/issue_comment.go @@ -153,7 +153,7 @@ func (c *Comment) HTMLURL() string { log.Error(4, "GetIssueByID(%d): %v", c.IssueID, err) return "" } - return fmt.Sprintf("%s#issuecomment-%d", issue.HTMLURL(), c.ID) + return fmt.Sprintf("%s#%s", issue.HTMLURL(), c.HashTag()) } // IssueURL formats a URL-string to the issue diff --git a/models/issue_mail.go b/models/issue_mail.go index fc58b6f613795..528a629f3d064 100644 --- a/models/issue_mail.go +++ b/models/issue_mail.go @@ -23,71 +23,17 @@ func (issue *Issue) mailSubject() string { // 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 *Issue, doer *User, comment *Comment, mentions []string) error { - - names, tos, err := prepareMailToParticipants(issue, doer) - - if err != nil { - return fmt.Errorf("PrepareMailToParticipants: %v", err) - } - - SendIssueCommentMail(issue, doer, comment, tos) - - // Mail mentioned people and exclude watchers. - names = append(names, doer.Name) - tos = make([]string, 0, len(mentions)) // list of user names. - for i := range mentions { - if com.IsSliceContainsStr(names, mentions[i]) { - continue - } - - tos = append(tos, mentions[i]) - } - SendIssueMentionMail(issue, doer, comment, GetUserEmailsByNames(tos)) - - return nil -} - -// mailIssueActionToParticipants can be used for creation or pull requests. -// 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 mailIssueActionToParticipants(issue *Issue, doer *User, mentions []string) error { - names, tos, err := prepareMailToParticipants(issue, doer) - - if err != nil { - return fmt.Errorf("PrepareMailToParticipants: %v", err) - } - - SendIssueActionMail(issue, doer, tos) - - // Mail mentioned people and exclude watchers. - names = append(names, doer.Name) - tos = make([]string, 0, len(mentions)) // list of user names. - for i := range mentions { - if com.IsSliceContainsStr(names, mentions[i]) { - continue - } - - tos = append(tos, mentions[i]) - } - SendIssueMentionInActionMail(issue, doer, GetUserEmailsByNames(tos)) - - return nil -} - -// prepareMailToParticipants creates the tos and names list for an issue and the issue's creator. -func prepareMailToParticipants(issue *Issue, doer *User) (tos []string, names []string, error error) { if !setting.Service.EnableNotifyMail { - return nil, nil, nil + return nil } watchers, err := GetWatchers(issue.RepoID) if err != nil { - return nil, nil, err + return fmt.Errorf("GetWatchers [repo_id: %d]: %v", issue.RepoID, err) } participants, err := GetParticipantsByIssueID(issue.ID) if err != nil { - return nil, nil, err + return fmt.Errorf("GetParticipantsByIssueID [issue_id: %d]: %v", issue.ID, err) } // In case the issue poster is not watching the repository, @@ -96,8 +42,8 @@ func prepareMailToParticipants(issue *Issue, doer *User) (tos []string, names [] participants = append(participants, issue.Poster) } - tos = make([]string, 0, len(watchers)) // List of email addresses. - names = make([]string, 0, len(watchers)) + tos := make([]string, 0, len(watchers)) // List of email addresses. + names := make([]string, 0, len(watchers)) for i := range watchers { if watchers[i].UserID == doer.ID { continue @@ -105,7 +51,7 @@ func prepareMailToParticipants(issue *Issue, doer *User) (tos []string, names [] to, err := GetUserByID(watchers[i].UserID) if err != nil { - return nil, nil, err + return fmt.Errorf("GetUserByID [%d]: %v", watchers[i].UserID, err) } if to.IsOrganization() { continue @@ -124,7 +70,30 @@ func prepareMailToParticipants(issue *Issue, doer *User) (tos []string, names [] tos = append(tos, participants[i].Email) names = append(names, participants[i].Name) } - return tos, names, nil + + SendIssueCommentMail(issue, doer, comment, tos) + + // Mail mentioned people and exclude watchers. + names = append(names, doer.Name) + tos = make([]string, 0, len(mentions)) // list of user names. + for i := range mentions { + if com.IsSliceContainsStr(names, mentions[i]) { + continue + } + + tos = append(tos, mentions[i]) + } + SendIssueMentionMail(issue, doer, comment, GetUserEmailsByNames(tos)) + + return nil +} + +// mailIssueActionToParticipants can be used for creation or pull requests. +// 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 mailIssueActionToParticipants(issue *Issue, doer *User, mentions []string) error { + return mailIssueCommentToParticipants(issue, doer, nil, mentions) } // MailParticipants sends new issue thread created emails to repository watchers diff --git a/models/mail.go b/models/mail.go index 4b1b32b1e9e9e..43536380d8e12 100644 --- a/models/mail.go +++ b/models/mail.go @@ -151,25 +151,13 @@ func composeTplData(subject, body, link string) map[string]interface{} { func composeIssueCommentMessage(issue *Issue, doer *User, comment *Comment, tplName base.TplName, tos []string, info string) *mailer.Message { subject := issue.mailSubject() body := string(markdown.RenderString(issue.Content, issue.Repo.HTMLURL(), issue.Repo.ComposeMetas())) - data := composeTplData(subject, body, comment.HTMLURL()) - data["Doer"] = doer - - var content bytes.Buffer - - if err := templates.ExecuteTemplate(&content, string(tplName), data); err != nil { - log.Error(3, "Template: %v", err) + data := make(map[string]interface{}, 10) + if comment != nil { + data = composeTplData(subject, body, issue.HTMLURL()+"#"+comment.HashTag()) + } else { + data = composeTplData(subject, body, issue.HTMLURL()) } - - msg := mailer.NewMessageFrom(tos, fmt.Sprintf(`"%s" <%s>`, doer.DisplayName(), setting.MailService.FromEmail), subject, content.String()) - msg.Info = fmt.Sprintf("Subject: %s, %s", subject, info) - return msg -} - -func composeIssueMessage(issue *Issue, doer *User, tplName base.TplName, tos []string, info string) *mailer.Message { - subject := issue.mailSubject() - body := string(markdown.RenderString(issue.Content, issue.Repo.HTMLURL(), issue.Repo.ComposeMetas())) - data := composeTplData(subject, body, issue.HTMLURL()) data["Doer"] = doer var content bytes.Buffer @@ -199,20 +187,3 @@ func SendIssueMentionMail(issue *Issue, doer *User, comment *Comment, tos []stri } mailer.SendAsync(composeIssueCommentMessage(issue, doer, comment, mailIssueMention, tos, "issue mention")) } - -// SendIssueActionMail composes and sends issue action emails to target receivers. -func SendIssueActionMail(issue *Issue, doer *User, tos []string) { - if len(tos) == 0 { - return - } - - mailer.SendAsync(composeIssueMessage(issue, doer, mailIssueComment, tos, "issue comment")) -} - -// SendIssueMentionInActionMail composes and sends issue mention emails to target receivers. Only applies if no comment is given. -func SendIssueMentionInActionMail(issue *Issue, doer *User, tos []string) { - if len(tos) == 0 { - return - } - mailer.SendAsync(composeIssueMessage(issue, doer, mailIssueMention, tos, "issue mention")) -} From edaa5761a6811eedde033d97f62c06aa96d591b1 Mon Sep 17 00:00:00 2001 From: Jonas Franz Date: Thu, 4 May 2017 22:35:45 +0200 Subject: [PATCH 7/8] Replaced mailIssueActionToParticipants with mailIssueCommentToParticipants. Signed-off-by: Jonas Franz --- models/issue_mail.go | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/models/issue_mail.go b/models/issue_mail.go index 528a629f3d064..a9c5570c298cd 100644 --- a/models/issue_mail.go +++ b/models/issue_mail.go @@ -88,14 +88,6 @@ func mailIssueCommentToParticipants(issue *Issue, doer *User, comment *Comment, return nil } -// mailIssueActionToParticipants can be used for creation or pull requests. -// 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 mailIssueActionToParticipants(issue *Issue, doer *User, mentions []string) error { - return mailIssueCommentToParticipants(issue, doer, nil, mentions) -} - // MailParticipants sends new issue thread created emails to repository watchers // and mentioned people. func (issue *Issue) MailParticipants() (err error) { @@ -104,7 +96,7 @@ func (issue *Issue) MailParticipants() (err error) { return fmt.Errorf("UpdateIssueMentions [%d]: %v", issue.ID, err) } - if err = mailIssueActionToParticipants(issue, issue.Poster, mentions); err != nil { + if err = mailIssueCommentToParticipants(issue, issue.Poster, nil, mentions); err != nil { log.Error(4, "mailIssueCommentToParticipants: %v", err) } From b0e22aba71e4988c42d6598c5da18d3110e64cd3 Mon Sep 17 00:00:00 2001 From: Jonas Franz Date: Fri, 5 May 2017 00:06:21 +0200 Subject: [PATCH 8/8] Updating comment for mailIssueCommentToParticipants Signed-off-by: Jonas Franz --- models/issue_mail.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/models/issue_mail.go b/models/issue_mail.go index a9c5570c298cd..615aa82f06090 100644 --- a/models/issue_mail.go +++ b/models/issue_mail.go @@ -18,7 +18,7 @@ func (issue *Issue) mailSubject() string { return fmt.Sprintf("[%s] %s (#%d)", issue.Repo.Name, issue.Title, issue.Index) } -// mailIssueCommentToParticipants can be used only for comment. +// mailIssueCommentToParticipants can be used for both new issue creation and comment. // 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.