|
| 1 | +// Copyright 2018 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 | + |
| 5 | +package mail |
| 6 | + |
| 7 | +import ( |
| 8 | + "code.gitea.io/git" |
| 9 | + "code.gitea.io/gitea/models" |
| 10 | + "code.gitea.io/gitea/modules/log" |
| 11 | + "code.gitea.io/gitea/modules/notification/base" |
| 12 | +) |
| 13 | + |
| 14 | +type mailNotifier struct { |
| 15 | +} |
| 16 | + |
| 17 | +var ( |
| 18 | + _ base.Notifier = &mailNotifier{} |
| 19 | +) |
| 20 | + |
| 21 | +// NewNotifier create a new mailNotifier notifier |
| 22 | +func NewNotifier() base.Notifier { |
| 23 | + return &mailNotifier{} |
| 24 | +} |
| 25 | + |
| 26 | +func (m *mailNotifier) Run() { |
| 27 | +} |
| 28 | + |
| 29 | +func (m *mailNotifier) NotifyCreateIssueComment(doer *models.User, repo *models.Repository, |
| 30 | + issue *models.Issue, comment *models.Comment) { |
| 31 | + var act models.ActionType |
| 32 | + if comment.Type == models.CommentTypeClose { |
| 33 | + act = models.ActionCloseIssue |
| 34 | + } else if comment.Type == models.CommentTypeReopen { |
| 35 | + act = models.ActionReopenIssue |
| 36 | + } else if comment.Type == models.CommentTypeComment { |
| 37 | + act = models.ActionCommentIssue |
| 38 | + } else if comment.Type == models.CommentTypeCode { |
| 39 | + act = models.ActionCommentIssue |
| 40 | + } |
| 41 | + |
| 42 | + if err := comment.MailParticipants(act, issue); err != nil { |
| 43 | + log.Error(4, "MailParticipants: %v", err) |
| 44 | + } |
| 45 | +} |
| 46 | + |
| 47 | +func (m *mailNotifier) NotifyNewIssue(issue *models.Issue) { |
| 48 | + if err := issue.MailParticipants(); err != nil { |
| 49 | + log.Error(4, "MailParticipants: %v", err) |
| 50 | + } |
| 51 | +} |
| 52 | + |
| 53 | +func (m *mailNotifier) NotifyIssueChangeStatus(doer *models.User, issue *models.Issue, isClosed bool) { |
| 54 | + if err := issue.MailParticipants(); err != nil { |
| 55 | + log.Error(4, "MailParticipants: %v", err) |
| 56 | + } |
| 57 | +} |
| 58 | + |
| 59 | +func (m *mailNotifier) NotifyNewPullRequest(pr *models.PullRequest) { |
| 60 | + if err := pr.Issue.MailParticipants(); err != nil { |
| 61 | + log.Error(4, "MailParticipants: %v", err) |
| 62 | + } |
| 63 | +} |
| 64 | + |
| 65 | +func (m *mailNotifier) NotifyPullRequestReview(pr *models.PullRequest, r *models.Review, comment *models.Comment) { |
| 66 | + var act models.ActionType |
| 67 | + if comment.Type == models.CommentTypeClose { |
| 68 | + act = models.ActionCloseIssue |
| 69 | + } else if comment.Type == models.CommentTypeReopen { |
| 70 | + act = models.ActionReopenIssue |
| 71 | + } else if comment.Type == models.CommentTypeComment { |
| 72 | + act = models.ActionCommentIssue |
| 73 | + } |
| 74 | + if err := comment.MailParticipants(act, pr.Issue); err != nil { |
| 75 | + log.Error(4, "MailParticipants: %v", err) |
| 76 | + } |
| 77 | +} |
| 78 | + |
| 79 | +func (m *mailNotifier) NotifyMergePullRequest(pr *models.PullRequest, doer *models.User, baseRepo *git.Repository) { |
| 80 | +} |
| 81 | + |
| 82 | +func (m *mailNotifier) NotifyUpdateComment(doer *models.User, c *models.Comment, oldContent string) { |
| 83 | +} |
| 84 | + |
| 85 | +func (m *mailNotifier) NotifyDeleteComment(doer *models.User, c *models.Comment) { |
| 86 | +} |
| 87 | + |
| 88 | +func (m *mailNotifier) NotifyDeleteRepository(doer *models.User, repo *models.Repository) { |
| 89 | +} |
| 90 | + |
| 91 | +func (m *mailNotifier) NotifyForkRepository(doer *models.User, oldRepo, repo *models.Repository) { |
| 92 | +} |
| 93 | + |
| 94 | +func (m *mailNotifier) NotifyNewRelease(rel *models.Release) { |
| 95 | +} |
| 96 | + |
| 97 | +func (m *mailNotifier) NotifyUpdateRelease(doer *models.User, rel *models.Release) { |
| 98 | +} |
| 99 | + |
| 100 | +func (m *mailNotifier) NotifyDeleteRelease(doer *models.User, rel *models.Release) { |
| 101 | +} |
| 102 | + |
| 103 | +func (m *mailNotifier) NotifyIssueChangeMilestone(doer *models.User, issue *models.Issue) { |
| 104 | +} |
| 105 | + |
| 106 | +func (m *mailNotifier) NotifyIssueChangeContent(doer *models.User, issue *models.Issue, oldContent string) { |
| 107 | +} |
| 108 | + |
| 109 | +func (m *mailNotifier) NotifyIssueChangeAssignee(doer *models.User, issue *models.Issue, removed bool) { |
| 110 | +} |
| 111 | + |
| 112 | +func (m *mailNotifier) NotifyIssueClearLabels(doer *models.User, issue *models.Issue) { |
| 113 | +} |
| 114 | + |
| 115 | +func (m *mailNotifier) NotifyIssueChangeTitle(doer *models.User, issue *models.Issue, oldTitle string) { |
| 116 | +} |
| 117 | + |
| 118 | +func (m *mailNotifier) NotifyIssueChangeLabels(doer *models.User, issue *models.Issue, |
| 119 | + addedLabels []*models.Label, removedLabels []*models.Label) { |
| 120 | +} |
| 121 | + |
| 122 | +func (m *mailNotifier) NotifyCreateRepository(doer *models.User, u *models.User, repo *models.Repository) { |
| 123 | +} |
| 124 | + |
| 125 | +func (m *mailNotifier) NotifyMigrateRepository(doer *models.User, u *models.User, repo *models.Repository) { |
| 126 | +} |
0 commit comments