Skip to content

Commit

Permalink
cmd/bosun: fixing empty email body, and handling absence better
Browse files Browse the repository at this point in the history
  • Loading branch information
Craig Peterson committed Feb 11, 2016
1 parent 1022108 commit d006417
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 5 deletions.
9 changes: 7 additions & 2 deletions cmd/bosun/sched/check.go
Original file line number Diff line number Diff line change
Expand Up @@ -302,8 +302,13 @@ func (s *Schedule) executeTemplates(state *models.IncidentState, event *models.E
}
state.Subject = string(subject)
state.Body = string(body)
state.EmailBody = emailbody
state.EmailSubject = emailsubject
//don't save email seperately if they are identical
if string(state.EmailBody) != state.Body {
state.EmailBody = emailbody
}
if string(state.EmailSubject) != state.Subject {
state.EmailSubject = emailsubject
}
state.Attachments = attachments
}
}
Expand Down
6 changes: 6 additions & 0 deletions cmd/bosun/sched/notify.go
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,12 @@ var unknownMultiGroup = ttemplate.Must(ttemplate.New("unknownMultiGroup").Parse(
`))

func (s *Schedule) notify(st *models.IncidentState, n *conf.Notification) {
if len(st.EmailSubject) == 0 {
st.EmailSubject = []byte(st.Subject)
}
if len(st.EmailBody) == 0 {
st.EmailBody = []byte(st.Body)
}
n.Notify(st.Subject, st.Body, st.EmailSubject, st.EmailBody, s.Conf, string(st.AlertKey), st.Attachments...)
}

Expand Down
6 changes: 3 additions & 3 deletions models/incidents.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@ type IncidentState struct {

Subject string
Body string
EmailBody []byte `json:"-"`
EmailSubject []byte `json:"-"`
Attachments []*Attachment `json:"-"`
EmailBody []byte
EmailSubject []byte
Attachments []*Attachment

NeedAck bool
Open bool
Expand Down

0 comments on commit d006417

Please sign in to comment.