From 252d0f3924dd19aa4dd1900c6c00c41c84755d1e Mon Sep 17 00:00:00 2001 From: =Corey Hulen Date: Sun, 12 Jul 2015 23:36:52 -0800 Subject: Fixes mm-1415 adding email bypass flag --- utils/config.go | 1 + utils/mail.go | 13 ++++++------- 2 files changed, 7 insertions(+), 7 deletions(-) (limited to 'utils') diff --git a/utils/config.go b/utils/config.go index eb2ae3050..97cb99f3e 100644 --- a/utils/config.go +++ b/utils/config.go @@ -77,6 +77,7 @@ type ImageSettings struct { } type EmailSettings struct { + ByPassEmail bool SMTPUsername string SMTPPassword string SMTPServer string diff --git a/utils/mail.go b/utils/mail.go index 3cd37ffef..0fe7042b7 100644 --- a/utils/mail.go +++ b/utils/mail.go @@ -8,14 +8,14 @@ import ( "crypto/tls" "fmt" "github.com/mattermost/platform/model" + "html" "net" "net/mail" "net/smtp" - "html" ) func CheckMailSettings() *model.AppError { - if len(Cfg.EmailSettings.SMTPServer) == 0 { + if len(Cfg.EmailSettings.SMTPServer) == 0 || Cfg.EmailSettings.ByPassEmail { return model.NewAppError("CheckMailSettings", "No email settings present, mail will not be sent", "") } conn, err := connectToSMTPServer() @@ -79,6 +79,10 @@ func newSMTPClient(conn net.Conn) (*smtp.Client, *model.AppError) { func SendMail(to, subject, body string) *model.AppError { + if len(Cfg.EmailSettings.SMTPServer) == 0 || Cfg.EmailSettings.ByPassEmail { + return nil + } + fromMail := mail.Address{"", Cfg.EmailSettings.FeedbackEmail} toMail := mail.Address{"", to} @@ -95,11 +99,6 @@ func SendMail(to, subject, body string) *model.AppError { } message += "\r\n" + body + "" - if len(Cfg.EmailSettings.SMTPServer) == 0 { - l4g.Warn("Skipping sending of email because EmailSettings are not configured") - return nil - } - conn, err1 := connectToSMTPServer() if err1 != nil { return err1 -- cgit v1.2.3-1-g7c22 From 246d12aaf23fa3a2c23225b33a333effff76253b Mon Sep 17 00:00:00 2001 From: =Corey Hulen Date: Tue, 14 Jul 2015 15:12:04 -0800 Subject: fixes mm-1348 removing dependency on redis --- utils/config.go | 6 ------ 1 file changed, 6 deletions(-) (limited to 'utils') diff --git a/utils/config.go b/utils/config.go index eb2ae3050..a166c3d0e 100644 --- a/utils/config.go +++ b/utils/config.go @@ -42,11 +42,6 @@ type SqlSettings struct { AtRestEncryptKey string } -type RedisSettings struct { - DataSource string - MaxOpenConns int -} - type LogSettings struct { ConsoleEnable bool ConsoleLevel string @@ -112,7 +107,6 @@ type Config struct { LogSettings LogSettings ServiceSettings ServiceSettings SqlSettings SqlSettings - RedisSettings RedisSettings AWSSettings AWSSettings ImageSettings ImageSettings EmailSettings EmailSettings -- cgit v1.2.3-1-g7c22 From c6fb95912bb481791c1ca370a46a4da9c05d05ad Mon Sep 17 00:00:00 2001 From: Christopher Speller Date: Wed, 8 Jul 2015 11:50:10 -0400 Subject: Changing the way we mattermost handles URLs. team.domain.com becomes domain.com/team. Renaming team.Name to team.DisplayName and team.Domain to team.Name. So: team.Name -> url safe name. team.DisplayName -> nice name for users --- utils/config.go | 26 ++++++-------------------- utils/config_test.go | 15 --------------- 2 files changed, 6 insertions(+), 35 deletions(-) (limited to 'utils') diff --git a/utils/config.go b/utils/config.go index 6ad29ab7d..efa4b263a 100644 --- a/utils/config.go +++ b/utils/config.go @@ -19,13 +19,11 @@ const ( type ServiceSettings struct { SiteName string - Domain string Mode string AllowTesting bool UseSSL bool Port string Version string - Shards map[string]string InviteSalt string PublicLinkSalt string ResetSalt string @@ -52,14 +50,10 @@ type LogSettings struct { } type AWSSettings struct { - S3AccessKeyId string - S3SecretAccessKey string - S3Bucket string - S3Region string - Route53AccessKeyId string - Route53SecretAccessKey string - Route53ZoneId string - Route53Region string + S3AccessKeyId string + S3SecretAccessKey string + S3Bucket string + S3Region string } type ImageSettings struct { @@ -213,18 +207,10 @@ func LoadConfig(fileName string) { panic("Error decoding configuration " + err.Error()) } - // Grabs the domain from enviroment variable if not in configuration - if config.ServiceSettings.Domain == "" { - config.ServiceSettings.Domain = os.Getenv("MATTERMOST_DOMAIN") - // If the enviroment variable is not set, use a default - if config.ServiceSettings.Domain == "" { - config.ServiceSettings.Domain = "localhost" - } - } - // Check for a valid email for feedback, if not then do feedback@domain if _, err := mail.ParseAddress(config.EmailSettings.FeedbackEmail); err != nil { - config.EmailSettings.FeedbackEmail = "feedback@" + config.ServiceSettings.Domain + config.EmailSettings.FeedbackEmail = "feedback@localhost" + l4g.Error("Misconfigured feedback email setting: %s", config.EmailSettings.FeedbackEmail) } configureLog(config.LogSettings) diff --git a/utils/config_test.go b/utils/config_test.go index 9067dc647..4d37b4e88 100644 --- a/utils/config_test.go +++ b/utils/config_test.go @@ -4,24 +4,9 @@ package utils import ( - "os" "testing" ) func TestConfig(t *testing.T) { LoadConfig("config.json") } - -func TestEnvOverride(t *testing.T) { - os.Setenv("MATTERMOST_DOMAIN", "testdomain.com") - - LoadConfig("config_docker.json") - if Cfg.ServiceSettings.Domain != "testdomain.com" { - t.Fail() - } - - LoadConfig("config.json") - if Cfg.ServiceSettings.Domain == "testdomain.com" { - t.Fail() - } -} -- cgit v1.2.3-1-g7c22