MM-10658 Change config fields to pointers (#9033)
* MM 10658 Change config fields to pointers (#8898) * Change fields of config structs to pointers and set defaults MM-10658 https://github.com/mattermost/mattermost-server/issues/8841 * Fix tests that go broken during switching config structs to pointers MM-10658 https://github.com/mattermost/mattermost-server/issues/8841 * Apply changes of current master while switching config structs to pointers MM-10658 https://github.com/mattermost/mattermost-server/issues/8841 * Fix new config pointer uses * Fix app tests * Fix mail test * remove debugging statement * fix TestUpdateConfig * assign config consistently * initialize AmazonS3Region in TestS3TestConnection * initialize fields for TestEmailTest * fix TestCheckMandatoryS3Fields
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
0c981aa010
Коммит
2ca222033c
16
app/admin.go
16
app/admin.go
@@ -51,8 +51,8 @@ func (a *App) GetLogs(page, perPage int) ([]string, *model.AppError) {
|
||||
func (a *App) GetLogsSkipSend(page, perPage int) ([]string, *model.AppError) {
|
||||
var lines []string
|
||||
|
||||
if a.Config().LogSettings.EnableFile {
|
||||
file, err := os.Open(utils.GetLogFileLocation(a.Config().LogSettings.FileLocation))
|
||||
if *a.Config().LogSettings.EnableFile {
|
||||
file, err := os.Open(utils.GetLogFileLocation(*a.Config().LogSettings.FileLocation))
|
||||
if err != nil {
|
||||
return nil, model.NewAppError("getLogs", "api.admin.file_read_error", nil, err.Error(), http.StatusInternalServerError)
|
||||
}
|
||||
@@ -221,17 +221,17 @@ func (a *App) RecycleDatabaseConnection() {
|
||||
}
|
||||
|
||||
func (a *App) TestEmail(userId string, cfg *model.Config) *model.AppError {
|
||||
if len(cfg.EmailSettings.SMTPServer) == 0 {
|
||||
if len(*cfg.EmailSettings.SMTPServer) == 0 {
|
||||
return model.NewAppError("testEmail", "api.admin.test_email.missing_server", nil, utils.T("api.context.invalid_param.app_error", map[string]interface{}{"Name": "SMTPServer"}), http.StatusBadRequest)
|
||||
}
|
||||
|
||||
// if the user hasn't changed their email settings, fill in the actual SMTP password so that
|
||||
// the user can verify an existing SMTP connection
|
||||
if cfg.EmailSettings.SMTPPassword == model.FAKE_SETTING {
|
||||
if cfg.EmailSettings.SMTPServer == a.Config().EmailSettings.SMTPServer &&
|
||||
cfg.EmailSettings.SMTPPort == a.Config().EmailSettings.SMTPPort &&
|
||||
cfg.EmailSettings.SMTPUsername == a.Config().EmailSettings.SMTPUsername {
|
||||
cfg.EmailSettings.SMTPPassword = a.Config().EmailSettings.SMTPPassword
|
||||
if *cfg.EmailSettings.SMTPPassword == model.FAKE_SETTING {
|
||||
if *cfg.EmailSettings.SMTPServer == *a.Config().EmailSettings.SMTPServer &&
|
||||
*cfg.EmailSettings.SMTPPort == *a.Config().EmailSettings.SMTPPort &&
|
||||
*cfg.EmailSettings.SMTPUsername == *a.Config().EmailSettings.SMTPUsername {
|
||||
*cfg.EmailSettings.SMTPPassword = *a.Config().EmailSettings.SMTPPassword
|
||||
} else {
|
||||
return model.NewAppError("testEmail", "api.admin.test_email.reenter_password", nil, "", http.StatusBadRequest)
|
||||
}
|
||||
|
||||
Ссылка в новой задаче
Block a user