Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. // Copyright 2019 The Gitea Authors. All rights reserved.
  2. // Use of this source code is governed by a MIT-style
  3. // license that can be found in the LICENSE file.
  4. package mail
  5. import (
  6. "code.gitea.io/gitea/models"
  7. "code.gitea.io/gitea/modules/log"
  8. "code.gitea.io/gitea/modules/notification/base"
  9. )
  10. type mailNotifier struct {
  11. base.NullNotifier
  12. }
  13. var (
  14. _ base.Notifier = &mailNotifier{}
  15. )
  16. // NewNotifier create a new mailNotifier notifier
  17. func NewNotifier() base.Notifier {
  18. return &mailNotifier{}
  19. }
  20. func (m *mailNotifier) NotifyCreateIssueComment(doer *models.User, repo *models.Repository,
  21. issue *models.Issue, comment *models.Comment) {
  22. var act models.ActionType
  23. if comment.Type == models.CommentTypeClose {
  24. act = models.ActionCloseIssue
  25. } else if comment.Type == models.CommentTypeReopen {
  26. act = models.ActionReopenIssue
  27. } else if comment.Type == models.CommentTypeComment {
  28. act = models.ActionCommentIssue
  29. } else if comment.Type == models.CommentTypeCode {
  30. act = models.ActionCommentIssue
  31. }
  32. if err := comment.MailParticipants(act, issue); err != nil {
  33. log.Error("MailParticipants: %v", err)
  34. }
  35. }
  36. func (m *mailNotifier) NotifyNewIssue(issue *models.Issue) {
  37. if err := issue.MailParticipants(); err != nil {
  38. log.Error("MailParticipants: %v", err)
  39. }
  40. }
  41. func (m *mailNotifier) NotifyIssueChangeStatus(doer *models.User, issue *models.Issue, isClosed bool) {
  42. if err := issue.MailParticipants(); err != nil {
  43. log.Error("MailParticipants: %v", err)
  44. }
  45. }
  46. func (m *mailNotifier) NotifyNewPullRequest(pr *models.PullRequest) {
  47. if err := pr.Issue.MailParticipants(); err != nil {
  48. log.Error("MailParticipants: %v", err)
  49. }
  50. }
  51. func (m *mailNotifier) NotifyPullRequestReview(pr *models.PullRequest, r *models.Review, comment *models.Comment) {
  52. var act models.ActionType
  53. if comment.Type == models.CommentTypeClose {
  54. act = models.ActionCloseIssue
  55. } else if comment.Type == models.CommentTypeReopen {
  56. act = models.ActionReopenIssue
  57. } else if comment.Type == models.CommentTypeComment {
  58. act = models.ActionCommentIssue
  59. }
  60. if err := comment.MailParticipants(act, pr.Issue); err != nil {
  61. log.Error("MailParticipants: %v", err)
  62. }
  63. }