removed notifier exports

pull/78/head
Hunter Long 2018-10-05 22:03:10 -07:00
parent 2b2c08ce40
commit 7a859180fe
4 changed files with 20 additions and 20 deletions

View File

@ -157,9 +157,9 @@ func init() {
} }
} }
// Send will send the SMTP email with your authentication It accepts type: *EmailOutgoing // Send will send the SMTP email with your authentication It accepts type: *emailOutgoing
func (u *email) Send(msg interface{}) error { func (u *email) Send(msg interface{}) error {
email := msg.(*EmailOutgoing) email := msg.(*emailOutgoing)
err := u.dialSend(email) err := u.dialSend(email)
if err != nil { if err != nil {
utils.Log(3, fmt.Sprintf("email Notifier could not send email: %v", err)) utils.Log(3, fmt.Sprintf("email Notifier could not send email: %v", err))
@ -168,7 +168,7 @@ func (u *email) Send(msg interface{}) error {
return nil return nil
} }
type EmailOutgoing struct { type emailOutgoing struct {
To string To string
Subject string Subject string
Template string Template string
@ -180,7 +180,7 @@ type EmailOutgoing struct {
// OnFailure will trigger failing service // OnFailure will trigger failing service
func (u *email) OnFailure(s *types.Service, f *types.Failure) { func (u *email) OnFailure(s *types.Service, f *types.Failure) {
email := &EmailOutgoing{ email := &emailOutgoing{
To: emailer.GetValue("var2"), To: emailer.GetValue("var2"),
Subject: fmt.Sprintf("Service %v is Failing", s.Name), Subject: fmt.Sprintf("Service %v is Failing", s.Name),
Template: TEMPLATE, Template: TEMPLATE,
@ -194,7 +194,7 @@ func (u *email) OnFailure(s *types.Service, f *types.Failure) {
// OnSuccess will trigger successful service // OnSuccess will trigger successful service
func (u *email) OnSuccess(s *types.Service) { func (u *email) OnSuccess(s *types.Service) {
if !u.Online { if !u.Online {
email := &EmailOutgoing{ email := &emailOutgoing{
To: emailer.GetValue("var2"), To: emailer.GetValue("var2"),
Subject: fmt.Sprintf("Service %v is Back Online", s.Name), Subject: fmt.Sprintf("Service %v is Back Online", s.Name),
Template: TEMPLATE, Template: TEMPLATE,
@ -229,7 +229,7 @@ func (u *email) OnTest() error {
return dial.Auth(auth) return dial.Auth(auth)
} }
func (u *email) dialSend(email *EmailOutgoing) error { func (u *email) dialSend(email *emailOutgoing) error {
mailer = mail.NewDialer(emailer.Host, emailer.Port, emailer.Username, emailer.Password) mailer = mail.NewDialer(emailer.Host, emailer.Port, emailer.Username, emailer.Password)
mailer.TLSConfig = &tls.Config{InsecureSkipVerify: true} mailer.TLSConfig = &tls.Config{InsecureSkipVerify: true}
emailSource(email) emailSource(email)
@ -245,12 +245,12 @@ func (u *email) dialSend(email *EmailOutgoing) error {
return nil return nil
} }
func emailSource(email *EmailOutgoing) { func emailSource(email *emailOutgoing) {
source := EmailTemplate(email.Template, email.Data) source := emailTemplate(email.Template, email.Data)
email.Source = source email.Source = source
} }
func EmailTemplate(contents string, data interface{}) string { func emailTemplate(contents string, data interface{}) string {
t := template.New("email") t := template.New("email")
t, err := t.Parse(contents) t, err := t.Parse(contents)
if err != nil { if err != nil {

View File

@ -34,7 +34,7 @@ var (
EMAIL_PORT = utils.StringInt(os.Getenv("EMAIL_PORT")) EMAIL_PORT = utils.StringInt(os.Getenv("EMAIL_PORT"))
) )
var testEmail *EmailOutgoing var testEmail *emailOutgoing
func init() { func init() {
EMAIL_HOST = os.Getenv("EMAIL_HOST") EMAIL_HOST = os.Getenv("EMAIL_HOST")
@ -69,7 +69,7 @@ func TestEmailNotifier(t *testing.T) {
emailer.Port = int(EMAIL_PORT) emailer.Port = int(EMAIL_PORT)
emailer.Delay = time.Duration(100 * time.Millisecond) emailer.Delay = time.Duration(100 * time.Millisecond)
testEmail = &EmailOutgoing{ testEmail = &emailOutgoing{
To: emailer.GetValue("var2"), To: emailer.GetValue("var2"),
Subject: fmt.Sprintf("Service %v is Failing", TestService.Name), Subject: fmt.Sprintf("Service %v is Failing", TestService.Name),
Template: TEMPLATE, Template: TEMPLATE,

View File

@ -67,7 +67,7 @@ func parseSlackMessage(temp string, data interface{}) error {
return nil return nil
} }
type SlackMessage struct { type slackMessage struct {
Service *types.Service Service *types.Service
Template string Template string
Time int64 Time int64
@ -114,7 +114,7 @@ func (u *slack) OnTest() error {
// OnFailure will trigger failing service // OnFailure will trigger failing service
func (u *slack) OnFailure(s *types.Service, f *types.Failure) { func (u *slack) OnFailure(s *types.Service, f *types.Failure) {
message := SlackMessage{ message := slackMessage{
Service: s, Service: s,
Template: FAILING_TEMPLATE, Template: FAILING_TEMPLATE,
Time: time.Now().Unix(), Time: time.Now().Unix(),
@ -126,7 +126,7 @@ func (u *slack) OnFailure(s *types.Service, f *types.Failure) {
// OnSuccess will trigger successful service // OnSuccess will trigger successful service
func (u *slack) OnSuccess(s *types.Service) { func (u *slack) OnSuccess(s *types.Service) {
if !u.Online { if !u.Online {
message := SlackMessage{ message := slackMessage{
Service: s, Service: s,
Template: SUCCESS_TEMPLATE, Template: SUCCESS_TEMPLATE,
Time: time.Now().Unix(), Time: time.Now().Unix(),

View File

@ -139,8 +139,8 @@ func (u *twilio) OnTest() error {
return u.Send(msg) return u.Send(msg)
} }
func twilioSuccess(res []byte) (bool, TwilioResponse) { func twilioSuccess(res []byte) (bool, twilioResponse) {
var obj TwilioResponse var obj twilioResponse
json.Unmarshal(res, &obj) json.Unmarshal(res, &obj)
if obj.Status == "queued" { if obj.Status == "queued" {
return true, obj return true, obj
@ -148,20 +148,20 @@ func twilioSuccess(res []byte) (bool, TwilioResponse) {
return false, obj return false, obj
} }
func twilioError(res []byte) TwilioError { func twilioError(res []byte) twilioErrorObj {
var obj TwilioError var obj twilioErrorObj
json.Unmarshal(res, &obj) json.Unmarshal(res, &obj)
return obj return obj
} }
type TwilioError struct { type twilioErrorObj struct {
Code int `json:"code"` Code int `json:"code"`
Message string `json:"message"` Message string `json:"message"`
MoreInfo string `json:"more_info"` MoreInfo string `json:"more_info"`
Status int `json:"status"` Status int `json:"status"`
} }
type TwilioResponse struct { type twilioResponse struct {
Sid string `json:"sid"` Sid string `json:"sid"`
DateCreated string `json:"date_created"` DateCreated string `json:"date_created"`
DateUpdated string `json:"date_updated"` DateUpdated string `json:"date_updated"`