Skip to content
Open
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
5 changes: 0 additions & 5 deletions notifications/event/type.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,6 @@ const (
TypeAcknowledgementCleared // acknowledgement-cleared
TypeAcknowledgementSet // acknowledgement-set
TypeCustom // custom
TypeDowntimeEnd // downtime-end
TypeDowntimeRemoved // downtime-removed
TypeDowntimeStart // downtime-start
TypeFlappingEnd // flapping-end
TypeFlappingStart // flapping-start
TypeIncidentAge // incident-age
TypeMute // mute
TypeState // state
Expand Down
24 changes: 10 additions & 14 deletions notifications/event/type_string.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 0 additions & 4 deletions notifications/event/type_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ func TestType(t *testing.T) {
{Name: "State", Expected: `"state"`, Data: TypeState, Error: nil},
{Name: "Mute", Expected: `"mute"`, Data: TypeMute, Error: nil},
{Name: "Unmute", Expected: `"unmute"`, Data: TypeUnmute, Error: nil},
{Name: "DowntimeStart", Expected: `"downtime-start"`, Data: TypeDowntimeStart, Error: nil},
}

for _, tt := range testdata {
Expand All @@ -37,7 +36,6 @@ func TestType(t *testing.T) {
{Name: "State", Expected: TypeState, Data: `"state"`, Error: nil},
{Name: "Mute", Expected: TypeMute, Data: `"mute"`, Error: nil},
{Name: "Unmute", Expected: TypeUnmute, Data: `"unmute"`, Error: nil},
{Name: "DowntimeStart", Expected: TypeDowntimeStart, Data: `"downtime-start"`, Error: nil},
{Name: "Invalid", Expected: TypeUnknown, Data: `"invalid"`, Error: testutils.ErrorContains(`unknown type "invalid"`)},
{Name: "Invalid Unknown", Expected: TypeUnknown, Data: `"unknown"`, Error: testutils.ErrorContains(`unknown type "unknown"`)},
}
Expand All @@ -58,7 +56,6 @@ func TestType(t *testing.T) {
{Name: "State", Expected: TypeState, Data: `state`, Error: nil},
{Name: "Mute", Expected: TypeMute, Data: `mute`, Error: nil},
{Name: "Unmute", Expected: TypeUnmute, Data: `unmute`, Error: nil},
{Name: "DowntimeStart", Expected: TypeDowntimeStart, Data: `downtime-start`, Error: nil},
{Name: "Invalid", Expected: TypeUnknown, Data: `invalid`, Error: testutils.ErrorContains(`unknown type "invalid"`)},
}

Expand All @@ -78,7 +75,6 @@ func TestType(t *testing.T) {
{Name: "State", Expected: `state`, Data: TypeState, Error: nil},
{Name: "Mute", Expected: `mute`, Data: TypeMute, Error: nil},
{Name: "Unmute", Expected: `unmute`, Data: TypeUnmute, Error: nil},
{Name: "DowntimeStart", Expected: `downtime-start`, Data: TypeDowntimeStart, Error: nil},
}

for _, tt := range testdata {
Expand Down
12 changes: 11 additions & 1 deletion notifications/plugin/plugin.go
Original file line number Diff line number Diff line change
Expand Up @@ -324,11 +324,21 @@ func FormatSubject(req *NotificationRequest) string {
switch req.Event.Type {
case event.TypeState:
return fmt.Sprintf("[#%d] %s %s is %s", req.Incident.Id, req.Event.Type, req.Object.Name, req.Incident.Severity)
case event.TypeAcknowledgementCleared, event.TypeDowntimeRemoved:
case event.TypeAcknowledgementCleared:
if req.Incident != nil {
return fmt.Sprintf("[#%d] %s from %s", req.Incident.Id, req.Event.Type, req.Object.Name)
}
return fmt.Sprintf("%s from %s", req.Event.Type, req.Object.Name)
case event.TypeMute:
if req.Incident != nil {
return fmt.Sprintf("[#%d] %s is muted", req.Incident.Id, req.Object.Name)
}
return fmt.Sprintf("%s is muted", req.Object.Name)
case event.TypeUnmute:
if req.Incident != nil {
return fmt.Sprintf("[#%d] %s is unmuted", req.Incident.Id, req.Object.Name)
}
return fmt.Sprintf("%s is unmuted", req.Object.Name)
default:
if req.Incident != nil {
return fmt.Sprintf("[#%d] %s on %s", req.Incident.Id, req.Event.Type, req.Object.Name)
Expand Down
Loading