Commit d07def51 authored by Harrison Healey's avatar Harrison Healey

Merge branch 'master' into post-metadata

parents fab63f8b e0569e76
......@@ -33,6 +33,14 @@
pruneopts = "UT"
revision = "3a771d992973f24aa725d07868b467d1ddfceafb"
[[projects]]
digest = "1:705c40022f5c03bf96ffeb6477858d88565064485a513abcd0f11a0911546cb6"
name = "github.com/blang/semver"
packages = ["."]
pruneopts = "UT"
revision = "2ee87856327ba09384cabd113bc6b5d174e9ec0f"
version = "v3.5.1"
[[projects]]
branch = "master"
digest = "1:cc439e1d9d8cff3d575642f5401033b00f2b8d0cd9f859db45604701c990879a"
......@@ -633,12 +641,12 @@
revision = "204274ad699c0983a70203a566887f17a717fef4"
[[projects]]
digest = "1:dc2d85c13ac22c22a1f3170a41a8e1b897fa05134aaf533f16df44f66a25b4a1"
digest = "1:69b1cc331fca23d702bd72f860c6a647afd0aa9fcbc1d0659b1365e26546dd70"
name = "github.com/sirupsen/logrus"
packages = ["."]
pruneopts = "UT"
revision = "a67f783a3814b8729bd2dac5780b5f78f8dbd64d"
version = "v1.1.0"
revision = "bcd833dfe83d3cebad139e4a29ed79cb2318bf95"
version = "v1.2.0"
[[projects]]
digest = "1:6a4a11ba764a56d2758899ec6f3848d24698d48442ebce85ee7a3f63284526cd"
......@@ -984,6 +992,7 @@
input-imports = [
"github.com/NYTimes/gziphandler",
"github.com/avct/uasurfer",
"github.com/blang/semver",
"github.com/dgryski/dgoogauth",
"github.com/disintegration/imaging",
"github.com/dyatlov/go-opengraph/opengraph",
......@@ -1022,6 +1031,7 @@
"github.com/rs/cors",
"github.com/rwcarlsen/goexif/exif",
"github.com/segmentio/analytics-go",
"github.com/sirupsen/logrus",
"github.com/spf13/cobra",
"github.com/stretchr/testify/assert",
"github.com/stretchr/testify/mock",
......
......@@ -54,6 +54,14 @@
name = "github.com/hashicorp/go-plugin"
revision = "a4620f9913d19f03a6bf19b2f304daaaf83ea130"
[[constraint]]
name = "github.com/blang/semver"
version = "~3.5.0"
[prune]
go-tests = true
unused-packages = true
[[constraint]]
name = "github.com/sirupsen/logrus"
version = "1.2.0"
......@@ -65,6 +65,6 @@ Receive notifications of critical security updates. The sophistication of online
- **Twitter** - Follow [Mattermost](https://twitter.com/mattermost)
- **Blog** - Get the latest updates from the [Mattermost blog](https://about.mattermost.com/blog/).
- **Email** - Subscribe to our [newsletter](http://mattermost.us11.list-manage.com/subscribe?u=6cdba22349ae374e188e7ab8e&id=2add1c8034) (1 or 2 per month)
- **IRC** - Join us on #matterbridge (thanks to [matterircd](https://github.com/42wim/matterircd))
- **IRC** - Join the #matterbridge channel on [Freenode](https://freenode.net/) (thanks to [matterircd](https://github.com/42wim/matterircd))
Any other questions, mail us at info@mattermost.com. We’d love to meet you!
......@@ -4,17 +4,18 @@
package api4
import (
"net/http"
"github.com/mattermost/mattermost-server/app"
"github.com/mattermost/mattermost-server/model"
"net/http"
)
func (api *API) InitTermsOfService() {
api.BaseRoutes.TermsOfService.Handle("", api.ApiSessionRequired(getTermsOfService)).Methods("GET")
api.BaseRoutes.TermsOfService.Handle("", api.ApiSessionRequired(getLatestTermsOfService)).Methods("GET")
api.BaseRoutes.TermsOfService.Handle("", api.ApiSessionRequired(createTermsOfService)).Methods("POST")
}
func getTermsOfService(c *Context, w http.ResponseWriter, r *http.Request) {
func getLatestTermsOfService(c *Context, w http.ResponseWriter, r *http.Request) {
termsOfService, err := c.App.GetLatestTermsOfService()
if err != nil {
c.Err = err
......
package api4
import (
"testing"
"github.com/mattermost/mattermost-server/model"
"github.com/stretchr/testify/assert"
"testing"
)
func TestGetTermsOfService(t *testing.T) {
......
......@@ -40,7 +40,8 @@ func (api *API) InitUser() {
api.BaseRoutes.Users.Handle("/password/reset/send", api.ApiHandler(sendPasswordReset)).Methods("POST")
api.BaseRoutes.Users.Handle("/email/verify", api.ApiHandler(verifyUserEmail)).Methods("POST")
api.BaseRoutes.Users.Handle("/email/verify/send", api.ApiHandler(sendVerificationEmail)).Methods("POST")
api.BaseRoutes.User.Handle("/terms_of_service", api.ApiSessionRequired(registerTermsOfServiceAction)).Methods("POST")
api.BaseRoutes.User.Handle("/terms_of_service", api.ApiSessionRequired(saveUserTermsOfService)).Methods("POST")
api.BaseRoutes.User.Handle("/terms_of_service", api.ApiSessionRequired(getUserTermsOfService)).Methods("GET")
api.BaseRoutes.User.Handle("/auth", api.ApiSessionRequiredTrustRequester(updateUserAuth)).Methods("PUT")
......@@ -845,7 +846,7 @@ func updateUserActive(c *Context, w http.ResponseWriter, r *http.Request) {
c.LogAuditWithUserId(user.Id, fmt.Sprintf("active=%v", active))
if isSelfDeactive {
c.App.Go(func() {
c.App.Srv.Go(func() {
if err = c.App.SendDeactivateAccountEmail(user.Email, user.Locale, c.App.GetSiteURL()); err != nil {
mlog.Error(err.Error())
}
......@@ -1626,7 +1627,7 @@ func enableUserAccessToken(c *Context, w http.ResponseWriter, r *http.Request) {
ReturnStatusOK(w)
}
func registerTermsOfServiceAction(c *Context, w http.ResponseWriter, r *http.Request) {
func saveUserTermsOfService(c *Context, w http.ResponseWriter, r *http.Request) {
props := model.StringInterfaceFromJson(r.Body)
userId := c.Session.UserId
......@@ -1638,7 +1639,7 @@ func registerTermsOfServiceAction(c *Context, w http.ResponseWriter, r *http.Req
return
}
if err := c.App.RecordUserTermsOfServiceAction(userId, termsOfServiceId, accepted); err != nil {
if err := c.App.SaveUserTermsOfService(userId, termsOfServiceId, accepted); err != nil {
c.Err = err
return
}
......@@ -1646,3 +1647,13 @@ func registerTermsOfServiceAction(c *Context, w http.ResponseWriter, r *http.Req
c.LogAudit("TermsOfServiceId=" + termsOfServiceId + ", accepted=" + strconv.FormatBool(accepted))
ReturnStatusOK(w)
}
func getUserTermsOfService(c *Context, w http.ResponseWriter, r *http.Request) {
userId := c.Session.UserId
if result, err := c.App.GetUserTermsOfService(userId); err != nil {
c.Err = err
return
} else {
w.Write([]byte(result.ToJson()))
}
}
......@@ -3087,10 +3087,34 @@ func TestRegisterTermsOfServiceAction(t *testing.T) {
CheckNoError(t, resp)
assert.True(t, *success)
user, err := th.App.GetUser(th.BasicUser.Id)
_, err = th.App.GetUser(th.BasicUser.Id)
if err != nil {
t.Fatal(err)
}
}
func TestGetUserTermsOfService(t *testing.T) {
th := Setup().InitBasic()
defer th.TearDown()
Client := th.Client
_, resp := Client.GetUserTermsOfService(th.BasicUser.Id, "")
CheckErrorMessage(t, resp, "store.sql_user_terms_of_service.get_by_user.no_rows.app_error")
termsOfService, err := th.App.CreateTermsOfService("terms of service", th.BasicUser.Id)
if err != nil {
t.Fatal(err)
}
success, resp := Client.RegisteTermsOfServiceAction(th.BasicUser.Id, termsOfService.Id, true)
CheckNoError(t, resp)
assert.True(t, *success)
userTermsOfService, resp := Client.GetUserTermsOfService(th.BasicUser.Id, "")
CheckNoError(t, resp)
assert.Equal(t, user.AcceptedTermsOfServiceId, termsOfService.Id)
assert.Equal(t, th.BasicUser.Id, userTermsOfService.UserId)
assert.Equal(t, termsOfService.Id, userTermsOfService.TermsOfServiceId)
assert.NotEmpty(t, userTermsOfService.CreateAt)
}
......@@ -139,7 +139,7 @@ func (a *App) InvalidateAllCaches() *model.AppError {
func (a *App) InvalidateAllCachesSkipSend() {
mlog.Info("Purging all caches")
a.sessionCache.Purge()
a.Srv.sessionCache.Purge()
ClearStatusCache()
a.Srv.Store.Channel().ClearCaches()
a.Srv.Store.User().ClearCaches()
......@@ -212,8 +212,8 @@ func (a *App) RecycleDatabaseConnection() {
oldStore := a.Srv.Store
mlog.Warn("Attempting to recycle the database connection.")
a.Srv.Store = a.newStore()
a.Jobs.Store = a.Srv.Store
a.Srv.Store = a.Srv.newStore()
a.Srv.Jobs.Store = a.Srv.Store
if a.Srv.Store != oldStore {
time.Sleep(20 * time.Second)
......
This diff is collapsed.
......@@ -246,8 +246,12 @@ func TestDoAdvancedPermissionsMigration(t *testing.T) {
restrictPrivateChannel := *th.App.Config().TeamSettings.DEPRECATED_DO_NOT_USE_RestrictPrivateChannelManagement
defer func() {
th.App.UpdateConfig(func(cfg *model.Config) { *cfg.TeamSettings.DEPRECATED_DO_NOT_USE_RestrictPublicChannelManagement = restrictPublicChannel })
th.App.UpdateConfig(func(cfg *model.Config) { *cfg.TeamSettings.DEPRECATED_DO_NOT_USE_RestrictPrivateChannelManagement = restrictPrivateChannel })
th.App.UpdateConfig(func(cfg *model.Config) {
*cfg.TeamSettings.DEPRECATED_DO_NOT_USE_RestrictPublicChannelManagement = restrictPublicChannel
})
th.App.UpdateConfig(func(cfg *model.Config) {
*cfg.TeamSettings.DEPRECATED_DO_NOT_USE_RestrictPrivateChannelManagement = restrictPrivateChannel
})
}()
th.App.UpdateConfig(func(cfg *model.Config) {
......@@ -433,8 +437,8 @@ func TestDoAdvancedPermissionsMigration(t *testing.T) {
postEditTimeLimit := *th.App.Config().ServiceSettings.PostEditTimeLimit
defer func() {
th.App.UpdateConfig(func(cfg *model.Config) { *cfg.ServiceSettings.DEPRECATED_DO_NOT_USE_AllowEditPost = allowEditPost})
th.App.UpdateConfig(func(cfg *model.Config) { *cfg.ServiceSettings.PostEditTimeLimit = postEditTimeLimit})
th.App.UpdateConfig(func(cfg *model.Config) { *cfg.ServiceSettings.DEPRECATED_DO_NOT_USE_AllowEditPost = allowEditPost })
th.App.UpdateConfig(func(cfg *model.Config) { *cfg.ServiceSettings.PostEditTimeLimit = postEditTimeLimit })
}()
th.App.UpdateConfig(func(cfg *model.Config) {
......
......@@ -212,9 +212,9 @@ func (a *App) CreateChannel(channel *model.Channel, addMember bool) (*model.Chan
}
if a.PluginsReady() {
a.Go(func() {
a.Srv.Go(func() {
pluginContext := &plugin.Context{}
a.Plugins.RunMultiPluginHook(func(hooks plugin.Hooks) bool {
a.Srv.Plugins.RunMultiPluginHook(func(hooks plugin.Hooks) bool {
hooks.ChannelHasBeenCreated(pluginContext, sc)
return true
}, plugin.ChannelHasBeenCreatedId)
......@@ -239,9 +239,9 @@ func (a *App) CreateDirectChannel(userId string, otherUserId string) (*model.Cha
a.InvalidateCacheForUser(otherUserId)
if a.PluginsReady() {
a.Go(func() {
a.Srv.Go(func() {
pluginContext := &plugin.Context{}
a.Plugins.RunMultiPluginHook(func(hooks plugin.Hooks) bool {
a.Srv.Plugins.RunMultiPluginHook(func(hooks plugin.Hooks) bool {
hooks.ChannelHasBeenCreated(pluginContext, channel)
return true
}, plugin.ChannelHasBeenCreatedId)
......@@ -663,6 +663,10 @@ func (a *App) UpdateChannelMemberNotifyProps(data map[string]string, channelId s
member.NotifyProps[model.PUSH_NOTIFY_PROP] = push
}
if ignoreChannelMentions, exists := data[model.IGNORE_CHANNEL_MENTIONS_NOTIFY_PROP]; exists {
member.NotifyProps[model.IGNORE_CHANNEL_MENTIONS_NOTIFY_PROP] = ignoreChannelMentions
}
result := <-a.Srv.Store.Channel().UpdateMember(member)
if result.Err != nil {
return nil, result.Err
......@@ -854,9 +858,9 @@ func (a *App) AddChannelMember(userId string, channel *model.Channel, userReques
}
if a.PluginsReady() {
a.Go(func() {
a.Srv.Go(func() {
pluginContext := &plugin.Context{}
a.Plugins.RunMultiPluginHook(func(hooks plugin.Hooks) bool {
a.Srv.Plugins.RunMultiPluginHook(func(hooks plugin.Hooks) bool {
hooks.UserHasJoinedChannel(pluginContext, cm, userRequestor)
return true
}, plugin.UserHasJoinedChannelId)
......@@ -866,7 +870,7 @@ func (a *App) AddChannelMember(userId string, channel *model.Channel, userReques
if userRequestorId == "" || userId == userRequestorId {
a.postJoinChannelMessage(user, channel)
} else {
a.Go(func() {
a.Srv.Go(func() {
a.PostAddToChannelMessage(userRequestor, user, channel, postRootId)
})
}
......@@ -1244,9 +1248,9 @@ func (a *App) JoinChannel(channel *model.Channel, userId string) *model.AppError
}
if a.PluginsReady() {
a.Go(func() {
a.Srv.Go(func() {
pluginContext := &plugin.Context{}
a.Plugins.RunMultiPluginHook(func(hooks plugin.Hooks) bool {
a.Srv.Plugins.RunMultiPluginHook(func(hooks plugin.Hooks) bool {
hooks.UserHasJoinedChannel(pluginContext, cm, nil)
return true
}, plugin.UserHasJoinedChannelId)
......@@ -1336,7 +1340,7 @@ func (a *App) LeaveChannel(channelId string, userId string) *model.AppError {
return nil
}
a.Go(func() {
a.Srv.Go(func() {
a.postLeaveChannelMessage(user, channel)
})
......@@ -1451,9 +1455,9 @@ func (a *App) removeUserFromChannel(userIdToRemove string, removerUserId string,
actorUser, _ = a.GetUser(removerUserId)
}
a.Go(func() {
a.Srv.Go(func() {
pluginContext := &plugin.Context{}
a.Plugins.RunMultiPluginHook(func(hooks plugin.Hooks) bool {
a.Srv.Plugins.RunMultiPluginHook(func(hooks plugin.Hooks) bool {
hooks.UserHasLeftChannel(pluginContext, cm, actorUser)
return true
}, plugin.UserHasLeftChannelId)
......@@ -1489,7 +1493,7 @@ func (a *App) RemoveUserFromChannel(userIdToRemove string, removerUserId string,
if userIdToRemove == removerUserId {
a.postLeaveChannelMessage(user, channel)
} else {
a.Go(func() {
a.Srv.Go(func() {
a.postRemoveFromChannelMessage(removerUserId, user, channel)
})
}
......
......@@ -13,19 +13,19 @@ import (
// be called.
func (a *App) AddClusterLeaderChangedListener(listener func()) string {
id := model.NewId()
a.clusterLeaderListeners.Store(id, listener)
a.Srv.clusterLeaderListeners.Store(id, listener)
return id
}
// Removes a listener function by the unique ID returned when AddConfigListener was called
func (a *App) RemoveClusterLeaderChangedListener(id string) {
a.clusterLeaderListeners.Delete(id)
a.Srv.clusterLeaderListeners.Delete(id)
}
func (a *App) InvokeClusterLeaderChangedListeners() {
mlog.Info("Cluster leader changed. Invoking ClusterLeaderChanged listeners.")
a.Go(func() {
a.clusterLeaderListeners.Range(func(_, listener interface{}) bool {
a.Srv.Go(func() {
a.Srv.clusterLeaderListeners.Range(func(_, listener interface{}) bool {
listener.(func())()
return true
})
......
......@@ -78,7 +78,7 @@ func (me *EchoProvider) DoCommand(a *App, args *model.CommandArgs, message strin
}
echoSem <- true
a.Go(func() {
a.Srv.Go(func() {
defer func() { <-echoSem }()
post := &model.Post{}
post.ChannelId = args.ChannelId
......
......@@ -51,5 +51,5 @@ func (me *LeaveProvider) DoCommand(a *App, args *model.CommandArgs, message stri
return &model.CommandResponse{Text: args.T("api.command_leave.fail.app_error"), ResponseType: model.COMMAND_RESPONSE_TYPE_EPHEMERAL}
}
return &model.CommandResponse{GotoLocation: args.SiteURL + "/" + team.Name + "/channels/" + model.DEFAULT_CHANNEL, Text: args.T("api.command_leave.success"), ResponseType: model.COMMAND_RESPONSE_TYPE_EPHEMERAL}
return &model.CommandResponse{GotoLocation: args.SiteURL + "/" + team.Name + "/channels/" + model.DEFAULT_CHANNEL}
}
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See License.txt for license information.
package app
import (
"testing"
"time"
"github.com/stretchr/testify/assert"
"github.com/mattermost/mattermost-server/model"
)
func TestLeaveProviderDoCommand(t *testing.T) {
th := Setup().InitBasic()
defer th.TearDown()
lp := LeaveProvider{}
publicChannel, _ := th.App.CreateChannel(&model.Channel{
DisplayName: "AA",
Name: "aa" + model.NewId() + "a",
Type: model.CHANNEL_OPEN,
TeamId: th.BasicTeam.Id,
CreatorId: th.BasicUser.Id,
}, false)
privateChannel, _ := th.App.CreateChannel(&model.Channel{
DisplayName: "BB",
Name: "aa" + model.NewId() + "a",
Type: model.CHANNEL_OPEN,
TeamId: th.BasicTeam.Id,
CreatorId: th.BasicUser.Id,
}, false)
th.App.AddUserToTeam(th.BasicTeam.Id, th.BasicUser.Id, th.BasicUser.Id)
th.App.AddUserToChannel(th.BasicUser, publicChannel)
th.App.AddUserToChannel(th.BasicUser, privateChannel)
args := &model.CommandArgs{
T: func(s string, args ...interface{}) string { return s },
}
// Should error when no Channel ID in args
actual := lp.DoCommand(th.App, args, "")
assert.Equal(t, "api.command_leave.fail.app_error", actual.Text)
assert.Equal(t, model.COMMAND_RESPONSE_TYPE_EPHEMERAL, actual.ResponseType)
// Should error when no Team ID in args
args.ChannelId = publicChannel.Id
actual = lp.DoCommand(th.App, args, "")
assert.Equal(t, "api.command_leave.fail.app_error", actual.Text)
assert.Equal(t, model.COMMAND_RESPONSE_TYPE_EPHEMERAL, actual.ResponseType)
// Leave a public channel
siteURL := "http://localhost:8065"
args.TeamId = th.BasicTeam.Id
args.SiteURL = siteURL
actual = lp.DoCommand(th.App, args, "")
assert.Equal(t, "", actual.Text)
assert.Equal(t, siteURL+"/"+th.BasicTeam.Name+"/channels/"+model.DEFAULT_CHANNEL, actual.GotoLocation)
assert.Equal(t, "", actual.ResponseType)
time.Sleep(100 * time.Millisecond)
member, err := th.App.GetChannelMember(publicChannel.Id, th.BasicUser.Id)
if member == nil {
t.Errorf("Expected member object, got nil")
}
if err != nil {
t.Errorf("Expected nil object, got %s", err)
}
// Leave a private channel
args.ChannelId = privateChannel.Id
actual = lp.DoCommand(th.App, args, "")
assert.Equal(t, "", actual.Text)
// Should not leave a default channel
defaultChannel, _ := th.App.GetChannelByName(model.DEFAULT_CHANNEL, th.BasicTeam.Id, false)
args.ChannelId = defaultChannel.Id
actual = lp.DoCommand(th.App, args, "")
assert.Equal(t, "api.channel.leave.default.app_error", actual.Text)
}
......@@ -36,7 +36,7 @@ func (a *App) SaveComplianceReport(job *model.Compliance) (*model.Compliance, *m
}
job = result.Data.(*model.Compliance)
a.Go(func() {
a.Srv.Go(func() {
a.Compliance.RunComplianceJob(job)
})
......
......@@ -28,15 +28,15 @@ const (
)
func (a *App) Config() *model.Config {
if cfg := a.config.Load(); cfg != nil {
if cfg := a.Srv.config.Load(); cfg != nil {
return cfg.(*model.Config)
}
return &model.Config{}
}
func (a *App) EnvironmentConfig() map[string]interface{} {
if a.envConfig != nil {
return a.envConfig
if a.Srv.envConfig != nil {
return a.Srv.envConfig
}
return map[string]interface{}{}
}
......@@ -45,7 +45,7 @@ func (a *App) UpdateConfig(f func(*model.Config)) {
old := a.Config()
updated := old.Clone()
f(updated)
a.config.Store(updated)
a.Srv.config.Store(updated)
a.InvokeConfigListeners(old, updated)
}
......@@ -62,11 +62,10 @@ func (a *App) LoadConfig(configFile string) *model.AppError {
return err
}
*cfg.ServiceSettings.SiteURL = strings.TrimRight(*cfg.ServiceSettings.SiteURL, "/")
a.config.Store(cfg)
a.Srv.config.Store(cfg)
a.configFile = configPath
a.envConfig = envConfig
a.siteURL = *cfg.ServiceSettings.SiteURL
a.Srv.configFile = configPath
a.Srv.envConfig = envConfig
a.InvokeConfigListeners(old, cfg)
return nil
......@@ -74,7 +73,7 @@ func (a *App) LoadConfig(configFile string) *model.AppError {
func (a *App) ReloadConfig() *model.AppError {
debug.FreeOSMemory()
if err := a.LoadConfig(a.configFile); err != nil {
if err := a.LoadConfig(a.Srv.configFile); err != nil {
return err
}
......@@ -84,37 +83,37 @@ func (a *App) ReloadConfig() *model.AppError {
}
func (a *App) ConfigFileName() string {
return a.configFile
return a.Srv.configFile
}
func (a *App) ClientConfig() map[string]string {
return a.clientConfig
return a.Srv.clientConfig
}
func (a *App) ClientConfigHash() string {
return a.clientConfigHash
return a.Srv.clientConfigHash
}
func (a *App) LimitedClientConfig() map[string]string {
return a.limitedClientConfig
return a.Srv.limitedClientConfig
}
func (a *App) EnableConfigWatch() {
if a.configWatcher == nil && !a.disableConfigWatch {
if a.Srv.configWatcher == nil && !a.Srv.disableConfigWatch {
configWatcher, err := utils.NewConfigWatcher(a.ConfigFileName(), func() {
a.ReloadConfig()
})
if err != nil {
mlog.Error(fmt.Sprint(err))
}
a.configWatcher = configWatcher
a.Srv.configWatcher = configWatcher
}
}
func (a *App) DisableConfigWatch() {
if a.configWatcher != nil {
a.configWatcher.Close()
a.configWatcher = nil
if a.Srv.configWatcher != nil {
a.Srv.configWatcher.Close()
a.Srv.configWatcher = nil
}
}
......@@ -123,17 +122,17 @@ func (a *App) DisableConfigWatch() {
// for the listener that can later be used to remove it.
func (a *App) AddConfigListener(listener func(*model.Config, *model.Config)) string {
id := model.NewId()
a.configListeners[id] = listener
a.Srv.configListeners[id] = listener
return id
}
// Removes a listener function by the unique ID returned when AddConfigListener was called
func (a *App) RemoveConfigListener(id string) {
delete(a.configListeners, id)
delete(a.Srv.configListeners, id)
}
func (a *App) InvokeConfigListeners(old, current *model.Config) {
for _, listener := range a.configListeners {
for _, listener := range a.Srv.configListeners {
listener(old, current)
}
}
......@@ -141,7 +140,7 @@ func (a *App) InvokeConfigListeners(old, current *model.Config) {
// EnsureAsymmetricSigningKey ensures that an asymmetric signing key exists and future calls to
// AsymmetricSigningKey will always return a valid signing key.
func (a *App) ensureAsymmetricSigningKey() error {
if a.asymmetricSigningKey != nil {
if a.Srv.asymmetricSigningKey != nil {
return nil
}
......@@ -202,7 +201,7 @@ func (a *App) ensureAsymmetricSigningKey() error {
default:
return fmt.Errorf("unknown curve: " + key.ECDSAKey.Curve)
}
a.asymmetricSigningKey = &ecdsa.PrivateKey{
a.Srv.asymmetricSigningKey = &ecdsa.PrivateKey{
PublicKey: ecdsa.PublicKey{
Curve: curve,
X: key.ECDSAKey.X,
......@@ -240,31 +239,31 @@ func (a *App) ensureInstallationDate() error {
// AsymmetricSigningKey will return a private key that can be used for asymmetric signing.
func (a *App) AsymmetricSigningKey() *ecdsa.PrivateKey {
return a.asymmetricSigningKey
return a.Srv.asymmetricSigningKey
}
func (a *App) regenerateClientConfig() {
a.clientConfig = utils.GenerateClientConfig(a.Config(), a.DiagnosticId(), a.License())
a.Srv.clientConfig = utils.GenerateClientConfig(a.Config(), a.DiagnosticId(), a.License())
if a.clientConfig["EnableCustomTermsOfService"] == "true" {
if a.Srv.clientConfig["EnableCustomTermsOfService"] == "true" {