From e45282deaa1d78d7ff3a125e9fd11e3fdc120b07 Mon Sep 17 00:00:00 2001 From: JoramWilander Date: Thu, 4 Feb 2016 13:00:03 -0500 Subject: Move license storage to database --- mattermost.go | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) (limited to 'mattermost.go') diff --git a/mattermost.go b/mattermost.go index 43fa06601..5a18e2f40 100644 --- a/mattermost.go +++ b/mattermost.go @@ -69,7 +69,7 @@ func main() { web.InitWeb() if model.BuildEnterpriseReady == "true" { - utils.LoadLicense() + loadLicense() } if flagRunCmds { @@ -95,6 +95,26 @@ func main() { } } +func loadLicense() { + licenseId := "" + if result := <-api.Srv.Store.System().Get(); result.Err == nil { + props := result.Data.(model.StringMap) + licenseId = props[model.SYSTEM_ACTIVE_LICENSE_ID] + } + + if len(licenseId) != 26 { + l4g.Warn(utils.T("mattermost.load_license.find.warn")) + return + } + + if result := <-api.Srv.Store.License().Get(licenseId); result.Err == nil { + record := result.Data.(*model.LicenseRecord) + utils.LoadLicense([]byte(record.Bytes)) + } else { + l4g.Warn(utils.T("mattermost.load_license.find.warn")) + } +} + func setDiagnosticId() { if result := <-api.Srv.Store.System().Get(); result.Err == nil { props := result.Data.(model.StringMap) -- cgit v1.2.3-1-g7c22