1
1
// Copyright 2019 The Gitea Authors. All rights reserved.
2
2
// SPDX-License-Identifier: MIT
3
3
4
- package mail
4
+ package mailer
5
5
6
6
import (
7
7
"context"
@@ -13,7 +13,6 @@ import (
13
13
user_model "code.gitea.io/gitea/models/user"
14
14
"code.gitea.io/gitea/modules/log"
15
15
"code.gitea.io/gitea/modules/notification/base"
16
- "code.gitea.io/gitea/services/mailer"
17
16
)
18
17
19
18
type mailNotifier struct {
@@ -43,13 +42,13 @@ func (m *mailNotifier) NotifyCreateIssueComment(ctx context.Context, doer *user_
43
42
act = 0
44
43
}
45
44
46
- if err := mailer . MailParticipantsComment (ctx , comment , act , issue , mentions ); err != nil {
45
+ if err := MailParticipantsComment (ctx , comment , act , issue , mentions ); err != nil {
47
46
log .Error ("MailParticipantsComment: %v" , err )
48
47
}
49
48
}
50
49
51
50
func (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 {
53
52
log .Error ("MailParticipants: %v" , err )
54
53
}
55
54
}
@@ -70,7 +69,7 @@ func (m *mailNotifier) NotifyIssueChangeStatus(ctx context.Context, doer *user_m
70
69
}
71
70
}
72
71
73
- if err := mailer . MailParticipants (ctx , issue , doer , actionType , nil ); err != nil {
72
+ if err := MailParticipants (ctx , issue , doer , actionType , nil ); err != nil {
74
73
log .Error ("MailParticipants: %v" , err )
75
74
}
76
75
}
@@ -81,14 +80,14 @@ func (m *mailNotifier) NotifyIssueChangeTitle(ctx context.Context, doer *user_mo
81
80
return
82
81
}
83
82
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 {
85
84
log .Error ("MailParticipants: %v" , err )
86
85
}
87
86
}
88
87
}
89
88
90
89
func (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 {
92
91
log .Error ("MailParticipants: %v" , err )
93
92
}
94
93
}
@@ -102,13 +101,13 @@ func (m *mailNotifier) NotifyPullRequestReview(ctx context.Context, pr *issues_m
102
101
} else if comment .Type == issues_model .CommentTypeComment {
103
102
act = activities_model .ActionCommentPull
104
103
}
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 {
106
105
log .Error ("MailParticipantsComment: %v" , err )
107
106
}
108
107
}
109
108
110
109
func (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 {
112
111
log .Error ("MailMentionsComment: %v" , err )
113
112
}
114
113
}
@@ -117,7 +116,7 @@ func (m *mailNotifier) NotifyIssueChangeAssignee(ctx context.Context, doer *user
117
116
// mail only sent to added assignees and not self-assignee
118
117
if ! removed && doer .ID != assignee .ID && assignee .EmailNotifications () != user_model .EmailNotificationsDisabled {
119
118
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 {
121
120
log .Error ("Error in SendIssueAssignedMail for issue[%d] to assignee[%d]: %v" , issue .ID , assignee .ID , err )
122
121
}
123
122
}
@@ -126,7 +125,7 @@ func (m *mailNotifier) NotifyIssueChangeAssignee(ctx context.Context, doer *user
126
125
func (m * mailNotifier ) NotifyPullRequestReviewRequest (ctx context.Context , doer * user_model.User , issue * issues_model.Issue , reviewer * user_model.User , isRequest bool , comment * issues_model.Comment ) {
127
126
if isRequest && doer .ID != reviewer .ID && reviewer .EmailNotifications () != user_model .EmailNotificationsDisabled {
128
127
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 {
130
129
log .Error ("Error in SendIssueAssignedMail for issue[%d] to reviewer[%d]: %v" , issue .ID , reviewer .ID , err )
131
130
}
132
131
}
@@ -137,7 +136,7 @@ func (m *mailNotifier) NotifyMergePullRequest(ctx context.Context, doer *user_mo
137
136
log .Error ("LoadIssue: %v" , err )
138
137
return
139
138
}
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 {
141
140
log .Error ("MailParticipants: %v" , err )
142
141
}
143
142
}
@@ -147,7 +146,7 @@ func (m *mailNotifier) NotifyAutoMergePullRequest(ctx context.Context, doer *use
147
146
log .Error ("pr.LoadIssue: %v" , err )
148
147
return
149
148
}
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 {
151
150
log .Error ("MailParticipants: %v" , err )
152
151
}
153
152
}
@@ -177,7 +176,7 @@ func (m *mailNotifier) NotifyPullRequestPushCommits(ctx context.Context, doer *u
177
176
}
178
177
179
178
func (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 {
181
180
log .Error ("MailParticipantsComment: %v" , err )
182
181
}
183
182
}
@@ -192,11 +191,11 @@ func (m *mailNotifier) NotifyNewRelease(ctx context.Context, rel *repo_model.Rel
192
191
return
193
192
}
194
193
195
- mailer . MailNewRelease (ctx , rel )
194
+ MailNewRelease (ctx , rel )
196
195
}
197
196
198
197
func (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 {
200
199
log .Error ("SendRepoTransferNotifyMail: %v" , err )
201
200
}
202
201
}
0 commit comments