Extracting email functions into a service (#14802)
* Extracting email functions into a service * Fixing two shadowing errors * Address PR review comments Co-authored-by: Mattermod <mattermod@users.noreply.github.com>
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
10f5a8890c
Коммит
b977017ca7
@@ -57,7 +57,7 @@ func (a *App) sendNotificationEmail(notification *PostNotification, user *model.
|
||||
}
|
||||
|
||||
if sendBatched {
|
||||
if err := a.AddNotificationEmailToBatch(user, post, team); err == nil {
|
||||
if err := a.Srv().EmailService.AddNotificationEmailToBatch(user, post, team); err == nil {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
@@ -99,7 +99,7 @@ func (a *App) sendNotificationEmail(notification *PostNotification, user *model.
|
||||
var bodyText = a.getNotificationEmailBody(user, post, channel, channelName, senderName, team.Name, landingURL, emailNotificationContentsType, useMilitaryTime, translateFunc)
|
||||
|
||||
a.Srv().Go(func() {
|
||||
if err := a.sendNotificationMail(user.Email, html.UnescapeString(subjectText), bodyText); err != nil {
|
||||
if err := a.Srv().EmailService.sendNotificationMail(user.Email, html.UnescapeString(subjectText), bodyText); err != nil {
|
||||
mlog.Error("Error while sending the email", mlog.String("user_email", user.Email), mlog.Err(err))
|
||||
}
|
||||
})
|
||||
@@ -166,13 +166,13 @@ func (a *App) getNotificationEmailBody(recipient *model.User, post *model.Post,
|
||||
// only include message contents in notification email if email notification contents type is set to full
|
||||
var bodyPage *utils.HTMLTemplate
|
||||
if emailNotificationContentsType == model.EMAIL_NOTIFICATION_CONTENTS_FULL {
|
||||
bodyPage = a.newEmailTemplate("post_body_full", recipient.Locale)
|
||||
bodyPage = a.Srv().EmailService.newEmailTemplate("post_body_full", recipient.Locale)
|
||||
postMessage := a.GetMessageForNotification(post, translateFunc)
|
||||
postMessage = html.EscapeString(postMessage)
|
||||
normalizedPostMessage := a.generateHyperlinkForChannels(postMessage, teamName, landingURL)
|
||||
bodyPage.Props["PostMessage"] = template.HTML(normalizedPostMessage)
|
||||
} else {
|
||||
bodyPage = a.newEmailTemplate("post_body_generic", recipient.Locale)
|
||||
bodyPage = a.Srv().EmailService.newEmailTemplate("post_body_generic", recipient.Locale)
|
||||
}
|
||||
|
||||
bodyPage.Props["SiteURL"] = a.GetSiteURL()
|
||||
|
||||
Ссылка в новой задаче
Block a user