[MM-43337] Updating email templates for trial will end and trial ended emails (#19976)
* Updating email templates for trial will end and trial will end emails * put back variable * Rebuilding * fix tests * Updates * [MM-43339] Add Cloud Subscription Upgrade Confirmation Email (#19989) * Add Cloud Upgrade Confirmation email * Updates * String change * i18n-extract * Updates * make email-mocks * Appease linter * Add a test * GMAIL NEVER RENDERS RIGHT * Important EVERYWHERE because gmail just cant deal * l * Last one * Update image * Update tests * Fix tests Co-authored-by: Mattermod <mattermod@users.noreply.github.com>
Этот коммит содержится в:
46
app/cloud.go
46
app/cloud.go
@@ -4,7 +4,9 @@
|
||||
package app
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"net/http"
|
||||
"time"
|
||||
|
||||
"github.com/mattermost/mattermost-server/v6/model"
|
||||
"github.com/mattermost/mattermost-server/v6/shared/mlog"
|
||||
@@ -35,6 +37,50 @@ func (a *App) SendPaymentFailedEmail(failedPayment *model.FailedPayment) *model.
|
||||
return nil
|
||||
}
|
||||
|
||||
func (a *App) SendUpgradeConfirmationEmail() *model.AppError {
|
||||
sysAdmins, e := a.getSysAdminsEmailRecipients()
|
||||
if e != nil {
|
||||
return e
|
||||
}
|
||||
|
||||
if len(sysAdmins) == 0 {
|
||||
return model.NewAppError("app.SendCloudUpgradeConfirmationEmail", "app.user.send_emails.app_error", nil, "", http.StatusInternalServerError)
|
||||
}
|
||||
|
||||
subscription, err := a.Cloud().GetSubscription("")
|
||||
if err != nil {
|
||||
return model.NewAppError("app.SendCloudUpgradeConfirmationEmail", "app.user.send_emails.app_error", nil, "", http.StatusInternalServerError)
|
||||
}
|
||||
|
||||
// Build readable trial end date
|
||||
endTimeStamp := subscription.TrialEndAt
|
||||
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
|
||||
countNotOks := 0
|
||||
|
||||
for _, admin := range sysAdmins {
|
||||
name := admin.FirstName
|
||||
if name == "" {
|
||||
name = admin.Username
|
||||
}
|
||||
|
||||
err := a.Srv().EmailService.SendCloudUpgradeConfirmationEmail(admin.Email, name, trialEndDate, admin.Locale, *a.Config().ServiceSettings.SiteURL, subscription.GetWorkSpaceNameFromDNS())
|
||||
if err != nil {
|
||||
a.Log().Error("Error sending trial ended email to", mlog.String("email", admin.Email), mlog.Err(err))
|
||||
countNotOks++
|
||||
}
|
||||
}
|
||||
|
||||
// if not even one admin got an email, we consider that this operation errored
|
||||
if countNotOks == len(sysAdmins) {
|
||||
return model.NewAppError("app.SendCloudUpgradeConfirmationEmail", "app.user.send_emails.app_error", nil, "", http.StatusInternalServerError)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// SendNoCardPaymentFailedEmail
|
||||
func (a *App) SendNoCardPaymentFailedEmail() *model.AppError {
|
||||
sysAdmins, err := a.getSysAdminsEmailRecipients()
|
||||
|
||||
Ссылка в новой задаче
Block a user