[MM-31112] - Update license renewal email (#16747)
* [MM-31112] - Update license renewal email * Feedback impl-1 * Update app/license.go Co-authored-by: Maria A Nunez <maria.nunez@mattermost.com> * Feedback impl-2 Co-authored-by: Maria A Nunez <maria.nunez@mattermost.com>
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
c31b5f2375
Коммит
a7e212566d
11
app/email.go
11
app/email.go
@@ -520,7 +520,14 @@ func (es *EmailService) SendDeactivateAccountEmail(email string, locale, siteURL
|
||||
return nil
|
||||
}
|
||||
|
||||
func (es *EmailService) SendRemoveExpiredLicenseEmail(email string, locale, siteURL string, licenseId string) *model.AppError {
|
||||
// SendRemoveExpiredLicenseEmail formats an email and uses the email service to send the email to user with link pointing to CWS
|
||||
// to renew the user license
|
||||
func (es *EmailService) SendRemoveExpiredLicenseEmail(email string, locale, siteURL string) *model.AppError {
|
||||
renewalLink, err := es.srv.GenerateLicenseRenewalLink()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
T := utils.GetUserTranslations(locale)
|
||||
subject := T("api.templates.remove_expired_license.subject",
|
||||
map[string]interface{}{"SiteName": es.srv.Config().TeamSettings.SiteName})
|
||||
@@ -528,7 +535,7 @@ func (es *EmailService) SendRemoveExpiredLicenseEmail(email string, locale, site
|
||||
bodyPage := es.newEmailTemplate("remove_expired_license", locale)
|
||||
bodyPage.Props["SiteURL"] = siteURL
|
||||
bodyPage.Props["Title"] = T("api.templates.remove_expired_license.body.title")
|
||||
bodyPage.Props["Link"] = fmt.Sprintf("%s?id=%s", model.LICENSE_RENEWAL_LINK, licenseId)
|
||||
bodyPage.Props["Link"] = renewalLink
|
||||
bodyPage.Props["LinkButton"] = T("api.templates.remove_expired_license.body.renew_button")
|
||||
|
||||
if err := es.sendMail(email, subject, bodyPage.Render()); err != nil {
|
||||
|
||||
@@ -331,3 +331,13 @@ func (s *Server) renewalTokenValid(tokenString, signingKey string) (bool, error)
|
||||
}
|
||||
return true, nil
|
||||
}
|
||||
|
||||
// GenerateLicenseRenewalLink returns a link that points to the CWS where clients can renew license
|
||||
func (s *Server) GenerateLicenseRenewalLink() (string, *model.AppError) {
|
||||
renewalToken, err := s.GenerateRenewalToken(JWTDefaultTokenExpiration)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
renewalLink := LicenseRenewalURL + "?token=" + renewalToken
|
||||
return renewalLink, nil
|
||||
}
|
||||
|
||||
@@ -1456,7 +1456,7 @@ func doLicenseExpirationCheck(a *App) {
|
||||
|
||||
mlog.Debug("Sending license expired email.", mlog.String("user_email", user.Email))
|
||||
a.Srv().Go(func() {
|
||||
if err := a.Srv().EmailService.SendRemoveExpiredLicenseEmail(user.Email, user.Locale, *a.Config().ServiceSettings.SiteURL, license.Id); err != nil {
|
||||
if err := a.Srv().EmailService.SendRemoveExpiredLicenseEmail(user.Email, user.Locale, *a.Config().ServiceSettings.SiteURL); err != nil {
|
||||
mlog.Error("Error while sending the license expired email.", mlog.String("user_email", user.Email), mlog.Err(err))
|
||||
}
|
||||
})
|
||||
|
||||
Ссылка в новой задаче
Block a user