diff options
author | Joram Wilander <jwawilander@gmail.com> | 2017-01-13 13:53:37 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-01-13 13:53:37 -0500 |
commit | 97558f6a6ec4c53fa69035fb430ead209d9c222d (patch) | |
tree | 6fc57f5b75b15a025348c6e295cea6aedb9e69ae /api/license.go | |
parent | 07bad4d6d518a9012a20fec8309cd625f57c7a8c (diff) | |
download | chat-97558f6a6ec4c53fa69035fb430ead209d9c222d.tar.gz chat-97558f6a6ec4c53fa69035fb430ead209d9c222d.tar.bz2 chat-97558f6a6ec4c53fa69035fb430ead209d9c222d.zip |
PLT-4938 Add app package and move logic over from api package (#4931)
* Add app package and move logic over from api package
* Change app package functions to return errors
* Move non-api tests into app package
* Fix merge
Diffstat (limited to 'api/license.go')
-rw-r--r-- | api/license.go | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/api/license.go b/api/license.go index 65ca90943..8a6ee7385 100644 --- a/api/license.go +++ b/api/license.go @@ -10,6 +10,7 @@ import ( "strings" l4g "github.com/alecthomas/log4go" + "github.com/mattermost/platform/app" "github.com/mattermost/platform/model" "github.com/mattermost/platform/utils" ) @@ -29,7 +30,7 @@ func InitLicense() { func LoadLicense() { licenseId := "" - if result := <-Srv.Store.System().Get(); result.Err == nil { + if result := <-app.Srv.Store.System().Get(); result.Err == nil { props := result.Data.(model.StringMap) licenseId = props[model.SYSTEM_ACTIVE_LICENSE_ID] } @@ -39,7 +40,7 @@ func LoadLicense() { return } - if result := <-Srv.Store.License().Get(licenseId); result.Err == nil { + if result := <-app.Srv.Store.License().Get(licenseId); result.Err == nil { record := result.Data.(*model.LicenseRecord) utils.LoadLicense([]byte(record.Bytes)) } else { @@ -104,7 +105,7 @@ func SaveLicense(licenseBytes []byte) (*model.License, *model.AppError) { if success, licenseStr := utils.ValidateLicense(licenseBytes); success { license = model.LicenseFromJson(strings.NewReader(licenseStr)) - if result := <-Srv.Store.User().AnalyticsUniqueUserCount(""); result.Err != nil { + if result := <-app.Srv.Store.User().AnalyticsUniqueUserCount(""); result.Err != nil { return nil, model.NewLocAppError("addLicense", "api.license.add_license.invalid_count.app_error", nil, result.Err.Error()) } else { uniqueUserCount := result.Data.(int64) @@ -121,12 +122,12 @@ 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 := app.Srv.Store.License().Save(record) sysVar := &model.System{} sysVar.Name = model.SYSTEM_ACTIVE_LICENSE_ID sysVar.Value = license.Id - schan := Srv.Store.System().SaveOrUpdate(sysVar) + schan := app.Srv.Store.System().SaveOrUpdate(sysVar) if result := <-rchan; result.Err != nil { RemoveLicense() @@ -164,7 +165,7 @@ func RemoveLicense() *model.AppError { sysVar.Name = model.SYSTEM_ACTIVE_LICENSE_ID sysVar.Value = "" - if result := <-Srv.Store.System().SaveOrUpdate(sysVar); result.Err != nil { + if result := <-app.Srv.Store.System().SaveOrUpdate(sysVar); result.Err != nil { utils.RemoveLicense() return result.Err } |