[CLD-6894] Add 60, 30, and 7 day reminder emails for Cloud Renewals (#25883)
* Add email notifications for Cloud Renewals * Updates * Updates * Update app-layers * make build-templates * Add ability to set an env variable as a unix timestamp in s as the current date when getting DaysToExpiration * Add a mechanism to ensure at least one admin receives every email --------- Co-authored-by: Mattermost Build <build@mattermost.com> Co-authored-by: Gabe Jackson <3694686+gabrieljackson@users.noreply.github.com>
Этот коммит содержится в:
@@ -5,7 +5,10 @@ package model
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"os"
|
||||
"strconv"
|
||||
"strings"
|
||||
"time"
|
||||
)
|
||||
|
||||
const (
|
||||
@@ -184,6 +187,21 @@ type Subscription struct {
|
||||
WillRenew string `json:"will_renew"`
|
||||
}
|
||||
|
||||
func (s *Subscription) DaysToExpiration() int64 {
|
||||
now := time.Now().UnixMilli()
|
||||
// Allows us to base the current time off of an environment variable for testing purposes
|
||||
if GetServiceEnvironment() == ServiceEnvironmentTest {
|
||||
if currTime, set := os.LookupEnv("CLOUD_MOCK_CURRENT_TIME"); set {
|
||||
timeInt, err := strconv.ParseInt(currTime, 10, 64)
|
||||
if err == nil {
|
||||
now = time.Unix(timeInt, 0).UnixMilli()
|
||||
}
|
||||
}
|
||||
}
|
||||
daysToExpiry := (s.EndAt - now) / (1000 * 60 * 60 * 24)
|
||||
return daysToExpiry
|
||||
}
|
||||
|
||||
// Subscription History model represents true up event in a yearly subscription
|
||||
type SubscriptionHistory struct {
|
||||
ID string `json:"id"`
|
||||
|
||||
@@ -38,6 +38,7 @@ const (
|
||||
SystemHostedPurchaseNeedsScreening = "HostedPurchaseNeedsScreening"
|
||||
AwsMeteringReportInterval = 1
|
||||
AwsMeteringDimensionUsageHrs = "UsageHrs"
|
||||
CloudRenewalEmail = "CloudRenewalEmail"
|
||||
)
|
||||
|
||||
const (
|
||||
|
||||
Ссылка в новой задаче
Block a user