Check license expiration, disable license and notify administrator (#14420)
* Check license expiration and notify administrator
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
5ad3eaf7ee
Коммит
58305b080f
@@ -348,6 +348,9 @@ func NewServer(options ...Option) (*Server, error) {
|
||||
s.Go(func() {
|
||||
runCommandWebhookCleanupJob(s)
|
||||
})
|
||||
s.Go(func() {
|
||||
runLicenseExpirationCheckJob(s)
|
||||
})
|
||||
|
||||
if complianceI := s.Compliance; complianceI != nil {
|
||||
complianceI.StartComplianceDailyJob()
|
||||
@@ -777,6 +780,13 @@ func runSessionCleanupJob(s *Server) {
|
||||
}, time.Hour*24)
|
||||
}
|
||||
|
||||
func runLicenseExpirationCheckJob(s *Server) {
|
||||
doLicenseExpirationCheck(s)
|
||||
model.CreateRecurringTask("License Expiration Check", func() {
|
||||
doLicenseExpirationCheck(s)
|
||||
}, time.Hour*24)
|
||||
}
|
||||
|
||||
func doSecurity(s *Server) {
|
||||
s.DoSecurityUpdateCheck()
|
||||
}
|
||||
@@ -804,6 +814,46 @@ func doSessionCleanup(s *Server) {
|
||||
s.Store.Session().Cleanup(model.GetMillis(), SESSIONS_CLEANUP_BATCH_SIZE)
|
||||
}
|
||||
|
||||
func doLicenseExpirationCheck(s *Server) {
|
||||
s.FakeApp().LoadLicense()
|
||||
license := s.License()
|
||||
|
||||
if license == nil {
|
||||
mlog.Debug("License cannot be found.")
|
||||
return
|
||||
}
|
||||
|
||||
if !license.IsPastGracePeriod() {
|
||||
mlog.Debug("License is not past the grace period.")
|
||||
return
|
||||
}
|
||||
|
||||
users, err := s.Store.User().GetSystemAdminProfiles()
|
||||
if err != nil {
|
||||
mlog.Error("Failed to get system admins for license expired message from Mattermost.")
|
||||
return
|
||||
}
|
||||
|
||||
//send email to admin(s)
|
||||
for _, user := range users {
|
||||
user := user
|
||||
if user.Email == "" {
|
||||
mlog.Error("Invalid system admin email.", mlog.String("user_email", user.Email))
|
||||
continue
|
||||
}
|
||||
|
||||
mlog.Debug("Sending license expired email.", mlog.String("user_email", user.Email))
|
||||
s.Go(func() {
|
||||
if err := s.FakeApp().SendRemoveExpiredLicenseEmail(user.Email, user.Locale, *s.Config().ServiceSettings.SiteURL, license.Id); err != nil {
|
||||
mlog.Error("Error while sending the license expired email.", mlog.String("user_email", user.Email), mlog.Err(err))
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
//remove the license
|
||||
s.FakeApp().RemoveLicense()
|
||||
}
|
||||
|
||||
func (s *Server) StartSearchEngine() (string, string) {
|
||||
if s.SearchEngine.ElasticsearchEngine != nil && s.SearchEngine.ElasticsearchEngine.IsActive() {
|
||||
s.Go(func() {
|
||||
|
||||
Ссылка в новой задаче
Block a user