summaryrefslogtreecommitdiffstats
path: root/models/issue_mail.go
diff options
context:
space:
mode:
authorsilverwind <me@silverwind.io>2019-06-11 21:27:38 +0200
committerzeripath <art27@cantab.net>2019-06-11 20:27:38 +0100
commit499a8a1cdd815cc25554371598140f5fb01e216f (patch)
tree8ad6b181036488f3054cb4326aed84c93a0d5d37 /models/issue_mail.go
parent74690f64514424ac643a8007828de1a785705793 (diff)
downloadgitea-499a8a1cdd815cc25554371598140f5fb01e216f.tar.gz
gitea-499a8a1cdd815cc25554371598140f5fb01e216f.zip
Various fixes for issue mail notifications (#7165)
- Send individual mails for actions and comments - Send mail for new issues/prs without a comment - Use correct sender for reopen/close actions - Hopefully fixed all bugs related to missing mails Fixes: https://github.com/go-gitea/gitea/issues/7124 Fixes: https://github.com/go-gitea/gitea/issues/5977
Diffstat (limited to 'models/issue_mail.go')
-rw-r--r--models/issue_mail.go35
1 files changed, 25 insertions, 10 deletions
diff --git a/models/issue_mail.go b/models/issue_mail.go
index 16f85ba378..01a12b16d2 100644
--- a/models/issue_mail.go
+++ b/models/issue_mail.go
@@ -118,26 +118,41 @@ func mailIssueCommentToParticipants(e Engine, issue *Issue, doer *User, content
// MailParticipants sends new issue thread created emails to repository watchers
// and mentioned people.
-func (issue *Issue) MailParticipants(opType ActionType) (err error) {
- return issue.mailParticipants(x, opType)
+func (issue *Issue) MailParticipants(doer *User, opType ActionType) (err error) {
+ return issue.mailParticipants(x, doer, opType)
}
-func (issue *Issue) mailParticipants(e Engine, opType ActionType) (err error) {
+func (issue *Issue) mailParticipants(e Engine, doer *User, opType ActionType) (err error) {
mentions := markup.FindAllMentions(issue.Content)
+
if err = UpdateIssueMentions(e, issue.ID, mentions); err != nil {
return fmt.Errorf("UpdateIssueMentions [%d]: %v", issue.ID, err)
}
- var content = issue.Content
+ if len(issue.Content) > 0 {
+ if err = mailIssueCommentToParticipants(e, issue, doer, issue.Content, nil, mentions); err != nil {
+ log.Error("mailIssueCommentToParticipants: %v", err)
+ }
+ }
+
switch opType {
+ case ActionCreateIssue, ActionCreatePullRequest:
+ if len(issue.Content) == 0 {
+ ct := fmt.Sprintf("Created #%d.", issue.Index)
+ if err = mailIssueCommentToParticipants(e, issue, doer, ct, nil, mentions); err != nil {
+ log.Error("mailIssueCommentToParticipants: %v", err)
+ }
+ }
case ActionCloseIssue, ActionClosePullRequest:
- content = fmt.Sprintf("Closed #%d", issue.Index)
+ ct := fmt.Sprintf("Closed #%d.", issue.Index)
+ if err = mailIssueCommentToParticipants(e, issue, doer, ct, nil, mentions); err != nil {
+ log.Error("mailIssueCommentToParticipants: %v", err)
+ }
case ActionReopenIssue, ActionReopenPullRequest:
- content = fmt.Sprintf("Reopened #%d", issue.Index)
- }
-
- if err = mailIssueCommentToParticipants(e, issue, issue.Poster, content, nil, mentions); err != nil {
- log.Error("mailIssueCommentToParticipants: %v", err)
+ ct := fmt.Sprintf("Reopened #%d.", issue.Index)
+ if err = mailIssueCommentToParticipants(e, issue, doer, ct, nil, mentions); err != nil {
+ log.Error("mailIssueCommentToParticipants: %v", err)
+ }
}
return nil