[MM-44887] Consistency in "next billing date" (#20423)
* if there is no trial end date, use the current date for the upgrade confirmation email * changes Co-authored-by: Mattermod <mattermod@users.noreply.github.com>
Этот коммит содержится в:
14
app/cloud.go
14
app/cloud.go
@@ -48,6 +48,12 @@ func (a *App) AdjustInProductLimits(limits *model.ProductLimits, subscription *m
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func getNextBillingDateString() string {
|
||||||
|
now := time.Now()
|
||||||
|
t := time.Date(now.Year(), now.Month()+1, 1, 0, 0, 0, 0, time.UTC)
|
||||||
|
return fmt.Sprintf("%s %d, %d", t.Month(), t.Day(), t.Year())
|
||||||
|
}
|
||||||
|
|
||||||
func (a *App) SendUpgradeConfirmationEmail() *model.AppError {
|
func (a *App) SendUpgradeConfirmationEmail() *model.AppError {
|
||||||
sysAdmins, e := a.getSysAdminsEmailRecipients()
|
sysAdmins, e := a.getSysAdminsEmailRecipients()
|
||||||
if e != nil {
|
if e != nil {
|
||||||
@@ -63,11 +69,7 @@ func (a *App) SendUpgradeConfirmationEmail() *model.AppError {
|
|||||||
return model.NewAppError("app.SendCloudUpgradeConfirmationEmail", "app.user.send_emails.app_error", nil, "", http.StatusInternalServerError)
|
return model.NewAppError("app.SendCloudUpgradeConfirmationEmail", "app.user.send_emails.app_error", nil, "", http.StatusInternalServerError)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Build readable trial end date
|
billingDate := getNextBillingDateString()
|
||||||
// Trial end is passed as unix timestamp in ms
|
|
||||||
endTimeStamp := subscription.TrialEndAt / 1000
|
|
||||||
t := time.Unix(endTimeStamp, 0)
|
|
||||||
trialEndDate := fmt.Sprintf("%s %d, %d", t.Month(), t.Day(), t.Year())
|
|
||||||
|
|
||||||
// we want to at least have one email sent out to an admin
|
// we want to at least have one email sent out to an admin
|
||||||
countNotOks := 0
|
countNotOks := 0
|
||||||
@@ -78,7 +80,7 @@ func (a *App) SendUpgradeConfirmationEmail() *model.AppError {
|
|||||||
name = admin.Username
|
name = admin.Username
|
||||||
}
|
}
|
||||||
|
|
||||||
err := a.Srv().EmailService.SendCloudUpgradeConfirmationEmail(admin.Email, name, trialEndDate, admin.Locale, *a.Config().ServiceSettings.SiteURL, subscription.GetWorkSpaceNameFromDNS())
|
err := a.Srv().EmailService.SendCloudUpgradeConfirmationEmail(admin.Email, name, billingDate, admin.Locale, *a.Config().ServiceSettings.SiteURL, subscription.GetWorkSpaceNameFromDNS())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
a.Log().Error("Error sending trial ended email to", mlog.String("email", admin.Email), mlog.Err(err))
|
a.Log().Error("Error sending trial ended email to", mlog.String("email", admin.Email), mlog.Err(err))
|
||||||
countNotOks++
|
countNotOks++
|
||||||
|
|||||||
@@ -230,13 +230,13 @@ func (es *Service) SendWelcomeEmail(userID string, email string, verified bool,
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (es *Service) SendCloudUpgradeConfirmationEmail(userEmail, name, trialEndDate, locale, siteURL, workspaceName string) error {
|
func (es *Service) SendCloudUpgradeConfirmationEmail(userEmail, name, date, locale, siteURL, workspaceName string) error {
|
||||||
T := i18n.GetUserTranslations(locale)
|
T := i18n.GetUserTranslations(locale)
|
||||||
subject := T("api.templates.cloud_upgrade_confirmation.subject")
|
subject := T("api.templates.cloud_upgrade_confirmation.subject")
|
||||||
|
|
||||||
data := es.NewEmailTemplateData(locale)
|
data := es.NewEmailTemplateData(locale)
|
||||||
data.Props["Title"] = T("api.templates.cloud_upgrade_confirmation.title")
|
data.Props["Title"] = T("api.templates.cloud_upgrade_confirmation.title")
|
||||||
data.Props["SubTitle"] = T("api.templates.cloud_upgrade_confirmation.subtitle", map[string]interface{}{"WorkspaceName": workspaceName, "TrialEnd": trialEndDate})
|
data.Props["SubTitle"] = T("api.templates.cloud_upgrade_confirmation.subtitle", map[string]interface{}{"WorkspaceName": workspaceName, "Date": date})
|
||||||
data.Props["SiteURL"] = siteURL
|
data.Props["SiteURL"] = siteURL
|
||||||
data.Props["ButtonURL"] = siteURL
|
data.Props["ButtonURL"] = siteURL
|
||||||
data.Props["Button"] = T("api.templates.cloud_welcome_email.button")
|
data.Props["Button"] = T("api.templates.cloud_welcome_email.button")
|
||||||
|
|||||||
@@ -3173,7 +3173,7 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"id": "api.templates.cloud_upgrade_confirmation.subtitle",
|
"id": "api.templates.cloud_upgrade_confirmation.subtitle",
|
||||||
"translation": "Your {{.WorkspaceName}} workspace has now been upgraded. You will be billed starting {{.TrialEnd}}"
|
"translation": "Your {{.WorkspaceName}} workspace has now been upgraded. You'll be billed from {{.Date}}"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"id": "api.templates.cloud_upgrade_confirmation.title",
|
"id": "api.templates.cloud_upgrade_confirmation.title",
|
||||||
|
|||||||
Ссылка в новой задаче
Block a user