11// Copyright 2019 The Gitea Authors. All rights reserved.
22// SPDX-License-Identifier: MIT
33
4- package mail
4+ package mailer
55
66import (
77 "context"
@@ -13,7 +13,6 @@ import (
1313 user_model "code.gitea.io/gitea/models/user"
1414 "code.gitea.io/gitea/modules/log"
1515 "code.gitea.io/gitea/modules/notification/base"
16- "code.gitea.io/gitea/services/mailer"
1716)
1817
1918type mailNotifier struct {
@@ -43,13 +42,13 @@ func (m *mailNotifier) NotifyCreateIssueComment(ctx context.Context, doer *user_
4342 act = 0
4443 }
4544
46- if err := mailer . MailParticipantsComment (ctx , comment , act , issue , mentions ); err != nil {
45+ if err := MailParticipantsComment (ctx , comment , act , issue , mentions ); err != nil {
4746 log .Error ("MailParticipantsComment: %v" , err )
4847 }
4948}
5049
5150func (m * mailNotifier ) NotifyNewIssue (ctx context.Context , issue * issues_model.Issue , mentions []* user_model.User ) {
52- if err := mailer . MailParticipants (ctx , issue , issue .Poster , activities_model .ActionCreateIssue , mentions ); err != nil {
51+ if err := MailParticipants (ctx , issue , issue .Poster , activities_model .ActionCreateIssue , mentions ); err != nil {
5352 log .Error ("MailParticipants: %v" , err )
5453 }
5554}
@@ -70,7 +69,7 @@ func (m *mailNotifier) NotifyIssueChangeStatus(ctx context.Context, doer *user_m
7069 }
7170 }
7271
73- if err := mailer . MailParticipants (ctx , issue , doer , actionType , nil ); err != nil {
72+ if err := MailParticipants (ctx , issue , doer , actionType , nil ); err != nil {
7473 log .Error ("MailParticipants: %v" , err )
7574 }
7675}
@@ -81,14 +80,14 @@ func (m *mailNotifier) NotifyIssueChangeTitle(ctx context.Context, doer *user_mo
8180 return
8281 }
8382 if issue .IsPull && issues_model .HasWorkInProgressPrefix (oldTitle ) && ! issue .PullRequest .IsWorkInProgress () {
84- if err := mailer . MailParticipants (ctx , issue , doer , activities_model .ActionPullRequestReadyForReview , nil ); err != nil {
83+ if err := MailParticipants (ctx , issue , doer , activities_model .ActionPullRequestReadyForReview , nil ); err != nil {
8584 log .Error ("MailParticipants: %v" , err )
8685 }
8786 }
8887}
8988
9089func (m * mailNotifier ) NotifyNewPullRequest (ctx context.Context , pr * issues_model.PullRequest , mentions []* user_model.User ) {
91- if err := mailer . MailParticipants (ctx , pr .Issue , pr .Issue .Poster , activities_model .ActionCreatePullRequest , mentions ); err != nil {
90+ if err := MailParticipants (ctx , pr .Issue , pr .Issue .Poster , activities_model .ActionCreatePullRequest , mentions ); err != nil {
9291 log .Error ("MailParticipants: %v" , err )
9392 }
9493}
@@ -102,13 +101,13 @@ func (m *mailNotifier) NotifyPullRequestReview(ctx context.Context, pr *issues_m
102101 } else if comment .Type == issues_model .CommentTypeComment {
103102 act = activities_model .ActionCommentPull
104103 }
105- if err := mailer . MailParticipantsComment (ctx , comment , act , pr .Issue , mentions ); err != nil {
104+ if err := MailParticipantsComment (ctx , comment , act , pr .Issue , mentions ); err != nil {
106105 log .Error ("MailParticipantsComment: %v" , err )
107106 }
108107}
109108
110109func (m * mailNotifier ) NotifyPullRequestCodeComment (ctx context.Context , pr * issues_model.PullRequest , comment * issues_model.Comment , mentions []* user_model.User ) {
111- if err := mailer . MailMentionsComment (ctx , pr , comment , mentions ); err != nil {
110+ if err := MailMentionsComment (ctx , pr , comment , mentions ); err != nil {
112111 log .Error ("MailMentionsComment: %v" , err )
113112 }
114113}
@@ -117,7 +116,7 @@ func (m *mailNotifier) NotifyIssueChangeAssignee(ctx context.Context, doer *user
117116 // mail only sent to added assignees and not self-assignee
118117 if ! removed && doer .ID != assignee .ID && assignee .EmailNotifications () != user_model .EmailNotificationsDisabled {
119118 ct := fmt .Sprintf ("Assigned #%d." , issue .Index )
120- if err := mailer . SendIssueAssignedMail (ctx , issue , doer , ct , comment , []* user_model.User {assignee }); err != nil {
119+ if err := SendIssueAssignedMail (ctx , issue , doer , ct , comment , []* user_model.User {assignee }); err != nil {
121120 log .Error ("Error in SendIssueAssignedMail for issue[%d] to assignee[%d]: %v" , issue .ID , assignee .ID , err )
122121 }
123122 }
@@ -126,7 +125,7 @@ func (m *mailNotifier) NotifyIssueChangeAssignee(ctx context.Context, doer *user
126125func (m * mailNotifier ) NotifyPullRequestReviewRequest (ctx context.Context , doer * user_model.User , issue * issues_model.Issue , reviewer * user_model.User , isRequest bool , comment * issues_model.Comment ) {
127126 if isRequest && doer .ID != reviewer .ID && reviewer .EmailNotifications () != user_model .EmailNotificationsDisabled {
128127 ct := fmt .Sprintf ("Requested to review %s." , issue .HTMLURL ())
129- if err := mailer . SendIssueAssignedMail (ctx , issue , doer , ct , comment , []* user_model.User {reviewer }); err != nil {
128+ if err := SendIssueAssignedMail (ctx , issue , doer , ct , comment , []* user_model.User {reviewer }); err != nil {
130129 log .Error ("Error in SendIssueAssignedMail for issue[%d] to reviewer[%d]: %v" , issue .ID , reviewer .ID , err )
131130 }
132131 }
@@ -137,7 +136,7 @@ func (m *mailNotifier) NotifyMergePullRequest(ctx context.Context, doer *user_mo
137136 log .Error ("LoadIssue: %v" , err )
138137 return
139138 }
140- if err := mailer . MailParticipants (ctx , pr .Issue , doer , activities_model .ActionMergePullRequest , nil ); err != nil {
139+ if err := MailParticipants (ctx , pr .Issue , doer , activities_model .ActionMergePullRequest , nil ); err != nil {
141140 log .Error ("MailParticipants: %v" , err )
142141 }
143142}
@@ -147,7 +146,7 @@ func (m *mailNotifier) NotifyAutoMergePullRequest(ctx context.Context, doer *use
147146 log .Error ("pr.LoadIssue: %v" , err )
148147 return
149148 }
150- if err := mailer . MailParticipants (ctx , pr .Issue , doer , activities_model .ActionAutoMergePullRequest , nil ); err != nil {
149+ if err := MailParticipants (ctx , pr .Issue , doer , activities_model .ActionAutoMergePullRequest , nil ); err != nil {
151150 log .Error ("MailParticipants: %v" , err )
152151 }
153152}
@@ -177,7 +176,7 @@ func (m *mailNotifier) NotifyPullRequestPushCommits(ctx context.Context, doer *u
177176}
178177
179178func (m * mailNotifier ) NotifyPullReviewDismiss (ctx context.Context , doer * user_model.User , review * issues_model.Review , comment * issues_model.Comment ) {
180- if err := mailer . MailParticipantsComment (ctx , comment , activities_model .ActionPullReviewDismissed , review .Issue , nil ); err != nil {
179+ if err := MailParticipantsComment (ctx , comment , activities_model .ActionPullReviewDismissed , review .Issue , nil ); err != nil {
181180 log .Error ("MailParticipantsComment: %v" , err )
182181 }
183182}
@@ -192,11 +191,11 @@ func (m *mailNotifier) NotifyNewRelease(ctx context.Context, rel *repo_model.Rel
192191 return
193192 }
194193
195- mailer . MailNewRelease (ctx , rel )
194+ MailNewRelease (ctx , rel )
196195}
197196
198197func (m * mailNotifier ) NotifyRepoPendingTransfer (ctx context.Context , doer , newOwner * user_model.User , repo * repo_model.Repository ) {
199- if err := mailer . SendRepoTransferNotifyMail (ctx , doer , newOwner , repo ); err != nil {
198+ if err := SendRepoTransferNotifyMail (ctx , doer , newOwner , repo ); err != nil {
200199 log .Error ("SendRepoTransferNotifyMail: %v" , err )
201200 }
202201}
0 commit comments