diff options
author | Martin Kraft <martinkraft@gmail.com> | 2018-05-28 10:35:27 -0400 |
---|---|---|
committer | Martin Kraft <martinkraft@gmail.com> | 2018-05-28 10:35:27 -0400 |
commit | c180cdbd1cba584c6e74cae7042de2290b51feb6 (patch) | |
tree | 19002d12a212d0bcc0e09d31410df548b93d77ef /app/email.go | |
parent | 7225abddeefb569f1f2da739211d7797b63814a2 (diff) | |
parent | c37d153ffb276e501660133de836a61eec25e544 (diff) | |
download | chat-c180cdbd1cba584c6e74cae7042de2290b51feb6.tar.gz chat-c180cdbd1cba584c6e74cae7042de2290b51feb6.tar.bz2 chat-c180cdbd1cba584c6e74cae7042de2290b51feb6.zip |
Merge remote-tracking branch 'origin/master' into advanced-permissions-phase-2
Diffstat (limited to 'app/email.go')
-rw-r--r-- | app/email.go | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/app/email.go b/app/email.go index aa05cefdb..206c48aaa 100644 --- a/app/email.go +++ b/app/email.go @@ -322,6 +322,28 @@ func (a *App) NewEmailTemplate(name, locale string) *utils.HTMLTemplate { return t } +func (a *App) SendDeactivateAccountEmail(email string, locale, siteURL string) *model.AppError { + T := utils.GetUserTranslations(locale) + + rawUrl, _ := url.Parse(siteURL) + + subject := T("api.templates.deactivate_subject", + map[string]interface{}{"SiteName": a.ClientConfig()["SiteName"], + "ServerURL": rawUrl.Host}) + + bodyPage := a.NewEmailTemplate("deactivate_body", locale) + bodyPage.Props["SiteURL"] = siteURL + bodyPage.Props["Title"] = T("api.templates.deactivate_body.title", map[string]interface{}{"ServerURL": rawUrl.Host}) + bodyPage.Html["Info"] = utils.TranslateAsHtml(T, "api.templates.deactivate_body.info", + map[string]interface{}{"SiteURL": siteURL}) + + if err := a.SendMail(email, subject, bodyPage.Render()); err != nil { + return model.NewAppError("SendDeactivateEmail", "api.user.send_deactivate_email_and_forget.failed.error", nil, err.Error(), http.StatusInternalServerError) + } + + return nil +} + func (a *App) SendMail(to, subject, htmlBody string) *model.AppError { license := a.License() return utils.SendMailUsingConfig(to, subject, htmlBody, a.Config(), license != nil && *license.Features.Compliance) |