diff options
Diffstat (limited to 'app')
-rw-r--r-- | app/app.go | 5 | ||||
-rw-r--r-- | app/timezone.go | 28 |
2 files changed, 33 insertions, 0 deletions
diff --git a/app/app.go b/app/app.go index 48e95fb99..6329a80d3 100644 --- a/app/app.go +++ b/app/app.go @@ -63,6 +63,8 @@ type App struct { clientLicenseValue atomic.Value licenseListeners map[string]func() + timezones atomic.Value + siteURL string newStore func() store.Store @@ -125,6 +127,9 @@ func New(options ...Option) (outApp *App, outErr error) { return nil, err } app.EnableConfigWatch() + + app.LoadTimezones() + if err := utils.InitTranslations(app.Config().LocalizationSettings); err != nil { return nil, errors.Wrapf(err, "unable to load Mattermost translation files") } diff --git a/app/timezone.go b/app/timezone.go new file mode 100644 index 000000000..84d912da6 --- /dev/null +++ b/app/timezone.go @@ -0,0 +1,28 @@ +// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved. +// See License.txt for license information. + +package app + +import ( + "github.com/mattermost/mattermost-server/model" + "github.com/mattermost/mattermost-server/utils" +) + +func (a *App) Timezones() model.SupportedTimezones { + if cfg := a.timezones.Load(); cfg != nil { + return cfg.(model.SupportedTimezones) + } + return model.SupportedTimezones{} +} + +func (a *App) LoadTimezones() { + timezonePath := "timezones.json" + + if a.Config().TimezoneSettings.SupportedTimezonesPath != nil && len(*a.Config().TimezoneSettings.SupportedTimezonesPath) > 0 { + timezonePath = *a.Config().TimezoneSettings.SupportedTimezonesPath + } + + timezoneCfg := utils.LoadTimezones(timezonePath) + + a.timezones.Store(timezoneCfg) +} |