Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cmd/bosun: fixing empty email body, and handling absence better #1588

Merged
merged 1 commit into from
Feb 11, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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