summaryrefslogtreecommitdiffstats
path: root/utils
diff options
context:
space:
mode:
Diffstat (limited to 'utils')
-rw-r--r--utils/config.go33
-rw-r--r--utils/config_test.go15
-rw-r--r--utils/mail.go13
3 files changed, 13 insertions, 48 deletions
diff --git a/utils/config.go b/utils/config.go
index eb2ae3050..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
@@ -42,11 +40,6 @@ type SqlSettings struct {
AtRestEncryptKey string
}
-type RedisSettings struct {
- DataSource string
- MaxOpenConns int
-}
-
type LogSettings struct {
ConsoleEnable bool
ConsoleLevel string
@@ -57,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 {
@@ -77,6 +66,7 @@ type ImageSettings struct {
}
type EmailSettings struct {
+ ByPassEmail bool
SMTPUsername string
SMTPPassword string
SMTPServer string
@@ -112,7 +102,6 @@ type Config struct {
LogSettings LogSettings
ServiceSettings ServiceSettings
SqlSettings SqlSettings
- RedisSettings RedisSettings
AWSSettings AWSSettings
ImageSettings ImageSettings
EmailSettings EmailSettings
@@ -218,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()
- }
-}
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<html><body>" + body + "</body></html>"
- 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