[MM-36457] - Send email when license is up for renewal (#17816)

* [MM-36457] - Send email when license is up for renewal

* i18n-extract

* feedback impl

* feedback impl

* fix translations

* Change license key to test for testing purposes

* Revert license key

* Trying test license key once more

* revert license change

Co-authored-by: marianunez <maria.nunez@mattermost.com>
Co-authored-by: Mattermod <mattermod@users.noreply.github.com>
Этот коммит содержится в:
Allan Guwatudde
2021-07-06 18:50:19 +03:00
коммит произвёл GitHub
родитель e1f8c62ac8
Коммит 98d170894d
6 изменённых файлов: 694 добавлений и 5 удалений

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

@@ -5,6 +5,7 @@ package model
import (
"encoding/json"
"fmt"
"io"
"net/http"
"time"
@@ -17,6 +18,12 @@ const (
LICENSE_RENEWAL_LINK = "https://mattermost.com/renew/"
)
const (
SIXTY_DAYS = 60
FIFTY_EIGHT = 58
LICENSE_UP_FOR_RENEWAL_EMAIL_SENT = "LicenseUpForRenewalEmailSent"
)
var (
trialDuration = 30*(time.Hour*24) + (time.Hour * 8) // 720 hours (30 days) + 8 hours is trial license duration
adminTrialDuration = 30*(time.Hour*24) + (time.Hour * 23) + (time.Minute * 59) + (time.Second * 59) // 720 hours (30 days) + 23 hours, 59 mins and 59 seconds
@@ -265,6 +272,18 @@ func (l *License) IsPastGracePeriod() bool {
return timeDiff > LICENSE_GRACE_PERIOD
}
func (l *License) IsWithinExpirationPeriod() bool {
days := l.DaysToExpiration()
return days <= SIXTY_DAYS && days >= FIFTY_EIGHT
}
func (l *License) DaysToExpiration() int {
dif := l.ExpiresAt - GetMillis()
d, _ := time.ParseDuration(fmt.Sprint(dif) + "ms")
days := d.Hours() / 24
return int(days)
}
func (l *License) IsStarted() bool {
return l.StartsAt < GetMillis()
}