Skip to content

Commit 8184bfd

Browse files
Update notify.go
1 parent 370284c commit 8184bfd

File tree

1 file changed

+12
-15
lines changed

1 file changed

+12
-15
lines changed

services/mailer/notify.go

Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -198,19 +198,11 @@ func (m *mailNotifier) NewRelease(ctx context.Context, rel *repo_model.Release)
198198
MailNewRelease(ctx, rel)
199199
}
200200

201-
func (m *mailNotifier) RepoPendingTransfer(ctx context.Context, doer, newOwner *user_model.User, repo *repo_model.Repository) {
202-
if err := SendRepoTransferNotifyMail(ctx, doer, newOwner, repo); err != nil {
203-
log.Error("SendRepoTransferNotifyMail: %v", err)
204-
}
205-
}
206-
207201
func (m *mailNotifier) ActionRunFinished(ctx context.Context, run *actions_model.ActionRun) {
208-
// Check status first to avoid unnecessary processing
209202
if run.Status != actions_model.StatusSuccess && run.Status != actions_model.StatusFailure {
210203
return
211204
}
212205

213-
// Load required attributes after status check
214206
if err := run.LoadAttributes(ctx); err != nil {
215207
log.Error("LoadAttributes: %v", err)
216208
return
@@ -222,19 +214,16 @@ func (m *mailNotifier) ActionRunFinished(ctx context.Context, run *actions_model
222214
run.Status,
223215
)
224216

225-
// Safely handle short commit SHA
226217
commitSHA := run.CommitSHA
227218
if len(commitSHA) > 7 {
228219
commitSHA = commitSHA[:7]
229220
}
230221

231222
body := fmt.Sprintf(`Workflow "%s" run #%d has completed with status: %s
232-
233223
Repository: %s
234224
Branch: %s
235225
Commit: %s
236226
Triggered by: %s
237-
238227
View the run details here: %s`,
239228
run.WorkflowID,
240229
run.Index,
@@ -246,19 +235,27 @@ View the run details here: %s`,
246235
run.HTMLURL(),
247236
)
248237

249-
// Send to repo owner if notifications enabled and email present
238+
// Send to repo owner
250239
if run.Repo.Owner.Email != "" &&
251240
run.Repo.Owner.EmailNotificationsPreference != user_model.EmailNotificationsDisabled {
252-
if err := SendMailFrom(ctx, run.Repo.Owner.Email, subject, body); err != nil {
241+
if err := mailer.SendAsyncEmail(ctx, mailer.Mail{
242+
To: []string{run.Repo.Owner.Email},
243+
Subject: subject,
244+
Body: body,
245+
}); err != nil {
253246
log.Error("Failed to send email to repo owner %s: %v", run.Repo.Owner.Email, err)
254247
}
255248
}
256249

257-
// Send to trigger user if different from owner and notifications enabled
250+
// Send to trigger user
258251
if run.TriggerUser.ID != run.Repo.Owner.ID &&
259252
run.TriggerUser.Email != "" &&
260253
run.TriggerUser.EmailNotificationsPreference != user_model.EmailNotificationsDisabled {
261-
if err := SendMailFrom(ctx, run.TriggerUser.Email, subject, body); err != nil {
254+
if err := mailer.SendAsyncEmail(ctx, mailer.Mail{
255+
To: []string{run.TriggerUser.Email},
256+
Subject: subject,
257+
Body: body,
258+
}); err != nil {
262259
log.Error("Failed to send email to trigger user %s: %v", run.TriggerUser.Email, err)
263260
}
264261
}

0 commit comments

Comments
 (0)