MM-40813: Use config service more extensively (#19679)
https://mattermost.atlassian.net/browse/MM-40816 ```release-note NONE ``` Co-authored-by: Mattermod <mattermod@users.noreply.github.com>
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
cf6aa85d28
Коммит
a2fc602bc2
@@ -3542,7 +3542,7 @@ func TestLoginWithLag(t *testing.T) {
|
||||
t.Skipf("requires test flag: -mysql-replica")
|
||||
}
|
||||
|
||||
if *th.App.Srv().Config().SqlSettings.DriverName != model.DatabaseDriverMysql {
|
||||
if *th.App.Config().SqlSettings.DriverName != model.DatabaseDriverMysql {
|
||||
t.Skipf("requires %q database driver", model.DatabaseDriverMysql)
|
||||
}
|
||||
|
||||
|
||||
@@ -247,9 +247,9 @@ func (ch *Channels) Stop() error {
|
||||
}
|
||||
|
||||
func (ch *Channels) AddConfigListener(listener func(*model.Config, *model.Config)) string {
|
||||
return ch.srv.AddConfigListener(listener)
|
||||
return ch.cfgSvc.AddConfigListener(listener)
|
||||
}
|
||||
|
||||
func (ch *Channels) RemoveConfigListener(id string) {
|
||||
ch.srv.RemoveConfigListener(id)
|
||||
ch.cfgSvc.RemoveConfigListener(id)
|
||||
}
|
||||
|
||||
@@ -2379,7 +2379,7 @@ func TestReplyToPostWithLag(t *testing.T) {
|
||||
th := Setup(t).InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
if *th.App.Srv().Config().SqlSettings.DriverName != model.DatabaseDriverMysql {
|
||||
if *th.App.Config().SqlSettings.DriverName != model.DatabaseDriverMysql {
|
||||
t.Skipf("requires %q database driver", model.DatabaseDriverMysql)
|
||||
}
|
||||
|
||||
|
||||
@@ -235,12 +235,12 @@ func (a *App) GetProductNotices(c *request.Context, userID, teamID string, clien
|
||||
isTeamAdmin := a.SessionHasPermissionToTeam(*c.Session(), teamID, model.PermissionManageTeam)
|
||||
|
||||
// check if notices for regular users are disabled
|
||||
if !*a.Srv().Config().AnnouncementSettings.UserNoticesEnabled && !isSystemAdmin {
|
||||
if !*a.Config().AnnouncementSettings.UserNoticesEnabled && !isSystemAdmin {
|
||||
return []model.NoticeMessage{}, nil
|
||||
}
|
||||
|
||||
// check if notices for admins are disabled
|
||||
if !*a.Srv().Config().AnnouncementSettings.AdminNoticesEnabled && (isTeamAdmin || isSystemAdmin) {
|
||||
if !*a.Config().AnnouncementSettings.AdminNoticesEnabled && (isTeamAdmin || isSystemAdmin) {
|
||||
return []model.NoticeMessage{}, nil
|
||||
}
|
||||
|
||||
@@ -251,7 +251,7 @@ func (a *App) GetProductNotices(c *request.Context, userID, teamID string, clien
|
||||
|
||||
sku := a.Srv().ClientLicense()["SkuShortName"]
|
||||
isCloud := a.Srv().License() != nil && *a.Srv().License().Features.Cloud
|
||||
dbName := *a.Srv().Config().SqlSettings.DriverName
|
||||
dbName := *a.Config().SqlSettings.DriverName
|
||||
|
||||
var searchEngineName, searchEngineVersion string
|
||||
if engine := a.Srv().SearchEngine; engine != nil && engine.ElasticsearchEngine != nil {
|
||||
@@ -339,8 +339,8 @@ func (a *App) UpdateViewedProductNoticesForNewUser(userID string) {
|
||||
|
||||
// UpdateProductNotices is called periodically from a scheduled worker to fetch new notices and update the cache
|
||||
func (a *App) UpdateProductNotices() *model.AppError {
|
||||
url := *a.Srv().Config().AnnouncementSettings.NoticesURL
|
||||
skip := *a.Srv().Config().AnnouncementSettings.NoticesSkipCache
|
||||
url := *a.Config().AnnouncementSettings.NoticesURL
|
||||
skip := *a.Config().AnnouncementSettings.NoticesSkipCache
|
||||
mlog.Debug("Will fetch notices from", mlog.String("url", url), mlog.Bool("skip_cache", skip))
|
||||
var err error
|
||||
a.ch.cachedPostCount, err = a.Srv().Store.Post().AnalyticsPostCount("", false, false)
|
||||
|
||||
@@ -2086,9 +2086,9 @@ func (a *App) getNotificationsLog() (*model.FileData, string) {
|
||||
var warning string
|
||||
|
||||
// Getting notifications.log
|
||||
if *a.Srv().Config().NotificationLogSettings.EnableFile {
|
||||
if *a.Config().NotificationLogSettings.EnableFile {
|
||||
// notifications.log
|
||||
notificationsLog := config.GetNotificationsLogFileLocation(*a.Srv().Config().LogSettings.FileLocation)
|
||||
notificationsLog := config.GetNotificationsLogFileLocation(*a.Config().LogSettings.FileLocation)
|
||||
|
||||
notificationsLogFileData, notificationsLogFileDataErr := ioutil.ReadFile(notificationsLog)
|
||||
|
||||
@@ -2113,9 +2113,9 @@ func (a *App) getMattermostLog() (*model.FileData, string) {
|
||||
var warning string
|
||||
|
||||
// Getting mattermost.log
|
||||
if *a.Srv().Config().LogSettings.EnableFile {
|
||||
if *a.Config().LogSettings.EnableFile {
|
||||
// mattermost.log
|
||||
mattermostLog := config.GetLogFileLocation(*a.Srv().Config().LogSettings.FileLocation)
|
||||
mattermostLog := config.GetLogFileLocation(*a.Config().LogSettings.FileLocation)
|
||||
|
||||
mattermostLogFileData, mattermostLogFileDataErr := ioutil.ReadFile(mattermostLog)
|
||||
|
||||
|
||||
@@ -255,7 +255,7 @@ func (a *App) UpdateLastActivityAtIfNeeded(session model.Session) {
|
||||
// A new ExpiresAt is only written if enough time has elapsed since last update.
|
||||
// Returns true only if the session was extended.
|
||||
func (a *App) ExtendSessionExpiryIfNeeded(session *model.Session) bool {
|
||||
if !*a.Srv().Config().ServiceSettings.ExtendSessionLengthWithActivity {
|
||||
if !*a.Config().ServiceSettings.ExtendSessionLengthWithActivity {
|
||||
return false
|
||||
}
|
||||
|
||||
|
||||
Ссылка в новой задаче
Block a user