From 6bf09e2c34c568e3cb0d296142d5abed77332635 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jes=C3=BAs=20Espino?= Date: Wed, 8 Aug 2018 12:04:36 +0200 Subject: 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 --- app/app.go | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'app/app.go') diff --git a/app/app.go b/app/app.go index 5cedca2ad..b704bb449 100644 --- a/app/app.go +++ b/app/app.go @@ -11,6 +11,7 @@ import ( "net/http" "path" "reflect" + "strconv" "strings" "sync" "sync/atomic" @@ -212,6 +213,10 @@ func New(options ...Option) (outApp *App, outErr error) { return nil, errors.Wrapf(err, "unable to ensure asymmetric signing key") } + if err := app.ensureInstallationDate(); err != nil { + return nil, errors.Wrapf(err, "unable to ensure installation date") + } + app.EnsureDiagnosticId() app.regenerateClientConfig() @@ -740,3 +745,16 @@ func (a *App) StartElasticsearch() { } }) } + +func (a *App) getSystemInstallDate() (int64, *model.AppError) { + result := <-a.Srv.Store.System().GetByName(model.SYSTEM_INSTALLATION_DATE_KEY) + if result.Err != nil { + return 0, result.Err + } + systemData := result.Data.(*model.System) + value, err := strconv.ParseInt(systemData.Value, 10, 64) + if err != nil { + return 0, model.NewAppError("getSystemInstallDate", "app.system_install_date.parse_int.app_error", nil, err.Error(), http.StatusInternalServerError) + } + return value, nil +} -- cgit v1.2.3-1-g7c22