summaryrefslogtreecommitdiffstats
path: root/app/license.go
diff options
context:
space:
mode:
authorChris <ccbrown112@gmail.com>2017-09-06 17:12:54 -0500
committerGitHub <noreply@github.com>2017-09-06 17:12:54 -0500
commit1adfd0e9be69a93c7f63bb7afc742c9fafe31aa3 (patch)
tree2766bacc1f045fa685ca3d8310cd6174d0311d09 /app/license.go
parentb84bd21089d305333fa4114b95be70f5ad94ad1b (diff)
downloadchat-1adfd0e9be69a93c7f63bb7afc742c9fafe31aa3.tar.gz
chat-1adfd0e9be69a93c7f63bb7afc742c9fafe31aa3.tar.bz2
chat-1adfd0e9be69a93c7f63bb7afc742c9fafe31aa3.zip
app type transition (#7167)
Diffstat (limited to 'app/license.go')
-rw-r--r--app/license.go28
1 files changed, 14 insertions, 14 deletions
diff --git a/app/license.go b/app/license.go
index 8cb76fd6e..da3f6d8d6 100644
--- a/app/license.go
+++ b/app/license.go
@@ -12,11 +12,11 @@ import (
"github.com/mattermost/platform/utils"
)
-func LoadLicense() {
+func (a *App) LoadLicense() {
utils.RemoveLicense()
licenseId := ""
- if result := <-Srv.Store.System().Get(); result.Err == nil {
+ if result := <-a.Srv.Store.System().Get(); result.Err == nil {
props := result.Data.(model.StringMap)
licenseId = props[model.SYSTEM_ACTIVE_LICENSE_ID]
}
@@ -26,7 +26,7 @@ func LoadLicense() {
license, licenseBytes := utils.GetAndValidateLicenseFileFromDisk()
if license != nil {
- if _, err := SaveLicense(licenseBytes); err != nil {
+ if _, err := a.SaveLicense(licenseBytes); err != nil {
l4g.Info("Failed to save license key loaded from disk err=%v", err.Error())
} else {
licenseId = license.Id
@@ -34,7 +34,7 @@ func LoadLicense() {
}
}
- if result := <-Srv.Store.License().Get(licenseId); result.Err == nil {
+ if result := <-a.Srv.Store.License().Get(licenseId); result.Err == nil {
record := result.Data.(*model.LicenseRecord)
utils.LoadLicense([]byte(record.Bytes))
l4g.Info("License key valid unlocking enterprise features.")
@@ -43,13 +43,13 @@ func LoadLicense() {
}
}
-func SaveLicense(licenseBytes []byte) (*model.License, *model.AppError) {
+func (a *App) SaveLicense(licenseBytes []byte) (*model.License, *model.AppError) {
var license *model.License
if success, licenseStr := utils.ValidateLicense(licenseBytes); success {
license = model.LicenseFromJson(strings.NewReader(licenseStr))
- if result := <-Srv.Store.User().AnalyticsUniqueUserCount(""); result.Err != nil {
+ if result := <-a.Srv.Store.User().AnalyticsUniqueUserCount(""); result.Err != nil {
return nil, model.NewAppError("addLicense", "api.license.add_license.invalid_count.app_error", nil, result.Err.Error(), http.StatusBadRequest)
} else {
uniqueUserCount := result.Data.(int64)
@@ -66,20 +66,20 @@ func SaveLicense(licenseBytes []byte) (*model.License, *model.AppError) {
record := &model.LicenseRecord{}
record.Id = license.Id
record.Bytes = string(licenseBytes)
- rchan := Srv.Store.License().Save(record)
+ rchan := a.Srv.Store.License().Save(record)
if result := <-rchan; result.Err != nil {
- RemoveLicense()
+ a.RemoveLicense()
return nil, model.NewAppError("addLicense", "api.license.add_license.save.app_error", nil, "err="+result.Err.Error(), http.StatusInternalServerError)
}
sysVar := &model.System{}
sysVar.Name = model.SYSTEM_ACTIVE_LICENSE_ID
sysVar.Value = license.Id
- schan := Srv.Store.System().SaveOrUpdate(sysVar)
+ schan := a.Srv.Store.System().SaveOrUpdate(sysVar)
if result := <-schan; result.Err != nil {
- RemoveLicense()
+ a.RemoveLicense()
return nil, model.NewAppError("addLicense", "api.license.add_license.save_active.app_error", nil, "", http.StatusInternalServerError)
}
} else {
@@ -87,26 +87,26 @@ func SaveLicense(licenseBytes []byte) (*model.License, *model.AppError) {
}
ReloadConfig()
- InvalidateAllCaches()
+ a.InvalidateAllCaches()
return license, nil
}
-func RemoveLicense() *model.AppError {
+func (a *App) RemoveLicense() *model.AppError {
utils.RemoveLicense()
sysVar := &model.System{}
sysVar.Name = model.SYSTEM_ACTIVE_LICENSE_ID
sysVar.Value = ""
- if result := <-Srv.Store.System().SaveOrUpdate(sysVar); result.Err != nil {
+ if result := <-a.Srv.Store.System().SaveOrUpdate(sysVar); result.Err != nil {
utils.RemoveLicense()
return result.Err
}
ReloadConfig()
- InvalidateAllCaches()
+ a.InvalidateAllCaches()
return nil
}