Refactor mail notification (#5110)

* mail notification implement interface

* fix file comment year

* use NullNotifier as parent struct of notifiers
This commit is contained in:
Lunny Xiao 2019-01-13 22:42:55 +08:00 committed by Lauris BH
parent e5228b8369
commit beab2df122
8 changed files with 190 additions and 55 deletions

View file

@ -1121,9 +1121,6 @@ func NewIssue(repo *Repository, issue *Issue, labelIDs []int64, assigneeIDs []in
}); err != nil {
log.Error(4, "NotifyWatchers: %v", err)
}
if err = issue.MailParticipants(); err != nil {
log.Error(4, "MailParticipants: %v", err)
}
mode, _ := AccessLevel(issue.Poster, issue.Repo)
if err = PrepareWebhooks(repo, HookEventIssues, &api.IssuePayload{

View file

@ -361,7 +361,11 @@ func (c *Comment) LoadDepIssueDetails() (err error) {
// MailParticipants sends new comment emails to repository watchers
// and mentioned people.
func (c *Comment) MailParticipants(e Engine, opType ActionType, issue *Issue) (err error) {
func (c *Comment) MailParticipants(opType ActionType, issue *Issue) (err error) {
return c.mailParticipants(x, opType, issue)
}
func (c *Comment) mailParticipants(e Engine, opType ActionType, issue *Issue) (err error) {
mentions := markup.FindAllMentions(c.Content)
if err = UpdateIssueMentions(e, c.IssueID, mentions); err != nil {
return fmt.Errorf("UpdateIssueMentions [%d]: %v", c.IssueID, err)
@ -632,9 +636,6 @@ func sendCreateCommentAction(e *xorm.Session, opts *CreateCommentOptions, commen
if err = notifyWatchers(e, act); err != nil {
log.Error(4, "notifyWatchers: %v", err)
}
if err = comment.MailParticipants(e, act.OpType, opts.Issue); err != nil {
log.Error(4, "MailParticipants: %v", err)
}
}
return nil
}

View file

@ -845,8 +845,6 @@ func NewPullRequest(repo *Repository, pull *Issue, labelIDs []int64, uuids []str
IsPrivate: repo.IsPrivate,
}); err != nil {
log.Error(4, "NotifyWatchers: %v", err)
} else if err = pull.MailParticipants(); err != nil {
log.Error(4, "MailParticipants: %v", err)
}
pr.Issue = pull