[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>
Этот коммит содержится в:
Allan Guwatudde
2021-01-20 19:57:29 +03:00
коммит произвёл GitHub
родитель c31b5f2375
Коммит a7e212566d
7 изменённых файлов: 26 добавлений и 11 удалений

Просмотреть файл

@@ -11,7 +11,6 @@ import (
"io/ioutil"
"net/http"
"github.com/mattermost/mattermost-server/v5/app"
"github.com/mattermost/mattermost-server/v5/audit"
"github.com/mattermost/mattermost-server/v5/model"
)
@@ -229,12 +228,11 @@ func requestRenewalLink(c *Context, w http.ResponseWriter, r *http.Request) {
return
}
renewalToken, err := c.App.Srv().GenerateRenewalToken(app.JWTDefaultTokenExpiration)
renewalLink, err := c.App.Srv().GenerateLicenseRenewalLink()
if err != nil {
c.Err = err
return
}
renewalLink := app.LicenseRenewalURL + "?token=" + renewalToken
auditRec.Success()
c.LogAudit("success")

Просмотреть файл

@@ -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))
}
})

Просмотреть файл

@@ -2896,11 +2896,11 @@
},
{
"id": "api.templates.remove_expired_license.body.renew_button",
"translation": "Renew License"
"translation": "Renew License Now"
},
{
"id": "api.templates.remove_expired_license.body.title",
"translation": "Enterprise license has expired and some features may be disabled. Please renew."
"translation": "Your Enterprise Edition license has expired and some features may be disabled. Please renew your license now."
},
{
"id": "api.templates.remove_expired_license.subject",

Просмотреть файл

@@ -5808,7 +5808,7 @@
},
{
"id": "api.templates.remove_expired_license.body.renew_button",
"translation": "Renovar Licencia"
"translation": "Renovar Licencia ahora"
},
{
"id": "api.templates.invite_guest_subject",

Просмотреть файл

@@ -5853,11 +5853,11 @@
},
{
"id": "api.templates.remove_expired_license.body.title",
"translation": "Enterprise license has expired and some features may be disabled. Please renew."
"translation": "Your Enterprise Edition license has expired and some features may be disabled. Please renew your license now."
},
{
"id": "api.templates.remove_expired_license.body.renew_button",
"translation": "Renew License"
"translation": "Renew License Now"
},
{
"id": "api.templates.invite_guest_subject",