diff options
author | cpanato <ctadeu@gmail.com> | 2018-08-08 13:53:10 +0200 |
---|---|---|
committer | cpanato <ctadeu@gmail.com> | 2018-08-08 13:53:10 +0200 |
commit | ae891321ad2e4b07e4f77b252379cb998607c687 (patch) | |
tree | de7cfa9b9fb1c0d7da2164e42e8516f62c7aaff1 /app/config.go | |
parent | 99cf15b56eb561dc30def86ad7e3cd97af4c338c (diff) | |
parent | 5fbec91c35d7ea5d9b920b26a01fc21da55bb08e (diff) | |
download | chat-ae891321ad2e4b07e4f77b252379cb998607c687.tar.gz chat-ae891321ad2e4b07e4f77b252379cb998607c687.tar.bz2 chat-ae891321ad2e4b07e4f77b252379cb998607c687.zip |
Merge remote-tracking branch 'upstream/release-5.2' into release-5.2-daily-merge-20180808
Diffstat (limited to 'app/config.go')
-rw-r--r-- | app/config.go | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/app/config.go b/app/config.go index 21571f291..1e96fd4fa 100644 --- a/app/config.go +++ b/app/config.go @@ -16,6 +16,7 @@ import ( "runtime/debug" "strconv" "strings" + "time" "github.com/mattermost/mattermost-server/mlog" "github.com/mattermost/mattermost-server/model" @@ -208,6 +209,30 @@ func (a *App) ensureAsymmetricSigningKey() error { return nil } +func (a *App) ensureInstallationDate() error { + _, err := a.getSystemInstallDate() + if err == nil { + return nil + } + + result := <-a.Srv.Store.User().InferSystemInstallDate() + var installationDate int64 + if result.Err == nil && result.Data.(int64) > 0 { + installationDate = result.Data.(int64) + } else { + installationDate = utils.MillisFromTime(time.Now()) + } + + result = <-a.Srv.Store.System().SaveOrUpdate(&model.System{ + Name: model.SYSTEM_INSTALLATION_DATE_KEY, + Value: strconv.FormatInt(installationDate, 10), + }) + if result.Err != nil { + return result.Err + } + return nil +} + // AsymmetricSigningKey will return a private key that can be used for asymmetric signing. func (a *App) AsymmetricSigningKey() *ecdsa.PrivateKey { return a.asymmetricSigningKey @@ -296,6 +321,10 @@ func (a *App) ClientConfigWithComputed() map[string]string { // by the client. respCfg["NoAccounts"] = strconv.FormatBool(a.IsFirstUserAccount()) respCfg["MaxPostSize"] = strconv.Itoa(a.MaxPostSize()) + respCfg["InstallationDate"] = "" + if installationDate, err := a.getSystemInstallDate(); err == nil { + respCfg["InstallationDate"] = strconv.FormatInt(installationDate, 10) + } return respCfg } |