diff options
author | Jesús Espino <jespinog@gmail.com> | 2018-08-08 12:04:36 +0200 |
---|---|---|
committer | Carlos Tadeu Panato Junior <ctadeu@gmail.com> | 2018-08-08 12:04:36 +0200 |
commit | 6bf09e2c34c568e3cb0d296142d5abed77332635 (patch) | |
tree | a8a05b94c842d53dede08fe8d52ad28cf2c89a73 /app/config.go | |
parent | 3b640cd51b5b622002d6c9a0d6b1e7a6e9dafb69 (diff) | |
download | chat-6bf09e2c34c568e3cb0d296142d5abed77332635.tar.gz chat-6bf09e2c34c568e3cb0d296142d5abed77332635.tar.bz2 chat-6bf09e2c34c568e3cb0d296142d5abed77332635.zip |
MM-11384: Add system install date information to the client config (#9218)
* MM-11384: Add system install date information to the client config
* Fixing translation text
* Fixes from Peer Review
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 } |