[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,7 +11,6 @@ import (
|
|||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
|
||||||
"github.com/mattermost/mattermost-server/v5/app"
|
|
||||||
"github.com/mattermost/mattermost-server/v5/audit"
|
"github.com/mattermost/mattermost-server/v5/audit"
|
||||||
"github.com/mattermost/mattermost-server/v5/model"
|
"github.com/mattermost/mattermost-server/v5/model"
|
||||||
)
|
)
|
||||||
@@ -229,12 +228,11 @@ func requestRenewalLink(c *Context, w http.ResponseWriter, r *http.Request) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
renewalToken, err := c.App.Srv().GenerateRenewalToken(app.JWTDefaultTokenExpiration)
|
renewalLink, err := c.App.Srv().GenerateLicenseRenewalLink()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
c.Err = err
|
c.Err = err
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
renewalLink := app.LicenseRenewalURL + "?token=" + renewalToken
|
|
||||||
|
|
||||||
auditRec.Success()
|
auditRec.Success()
|
||||||
c.LogAudit("success")
|
c.LogAudit("success")
|
||||||
|
|||||||
11
app/email.go
11
app/email.go
@@ -520,7 +520,14 @@ func (es *EmailService) SendDeactivateAccountEmail(email string, locale, siteURL
|
|||||||
return nil
|
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)
|
T := utils.GetUserTranslations(locale)
|
||||||
subject := T("api.templates.remove_expired_license.subject",
|
subject := T("api.templates.remove_expired_license.subject",
|
||||||
map[string]interface{}{"SiteName": es.srv.Config().TeamSettings.SiteName})
|
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 := es.newEmailTemplate("remove_expired_license", locale)
|
||||||
bodyPage.Props["SiteURL"] = siteURL
|
bodyPage.Props["SiteURL"] = siteURL
|
||||||
bodyPage.Props["Title"] = T("api.templates.remove_expired_license.body.title")
|
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")
|
bodyPage.Props["LinkButton"] = T("api.templates.remove_expired_license.body.renew_button")
|
||||||
|
|
||||||
if err := es.sendMail(email, subject, bodyPage.Render()); err != nil {
|
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
|
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))
|
mlog.Debug("Sending license expired email.", mlog.String("user_email", user.Email))
|
||||||
a.Srv().Go(func() {
|
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))
|
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",
|
"id": "api.templates.remove_expired_license.body.renew_button",
|
||||||
"translation": "Renew License"
|
"translation": "Renew License Now"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"id": "api.templates.remove_expired_license.body.title",
|
"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",
|
"id": "api.templates.remove_expired_license.subject",
|
||||||
|
|||||||
@@ -5808,7 +5808,7 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"id": "api.templates.remove_expired_license.body.renew_button",
|
"id": "api.templates.remove_expired_license.body.renew_button",
|
||||||
"translation": "Renovar Licencia"
|
"translation": "Renovar Licencia ahora"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"id": "api.templates.invite_guest_subject",
|
"id": "api.templates.invite_guest_subject",
|
||||||
|
|||||||
@@ -5853,11 +5853,11 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"id": "api.templates.remove_expired_license.body.title",
|
"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",
|
"id": "api.templates.remove_expired_license.body.renew_button",
|
||||||
"translation": "Renew License"
|
"translation": "Renew License Now"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"id": "api.templates.invite_guest_subject",
|
"id": "api.templates.invite_guest_subject",
|
||||||
|
|||||||
Ссылка в новой задаче
Block a user