@@ -160,12 +160,6 @@ type Event struct {
160160 // Time when this event occurred, being encoded according to RFC 3339 when passed as JSON.
161161 Time time.Time `json:"time"`
162162
163- // Type of this event, e.g., a "state" change, "mute" or "unmute". See further ./internal/event/event.go
164- Type event.Type `json:"type"`
165-
166- // Username may contain a user triggering this event, depending on the event's source.
167- Username string `json:"username"`
168-
169163 // Message of this event, might be a check output when the related Object is an Icinga 2 object.
170164 Message string `json:"message"`
171165}
@@ -291,19 +285,10 @@ func RunPlugin(plugin Plugin) {
291285// The created message is a multi-line message as one might expect it in an email.
292286func FormatMessage (writer io.Writer , req * NotificationRequest ) {
293287 if req .Event .Message != "" {
294- msgTitle := "Comment"
295- if req .Event .Type == event .TypeState {
296- msgTitle = "Output"
297- }
298-
299- _ , _ = fmt .Fprintf (writer , "%s: %s\n \n " , msgTitle , req .Event .Message )
288+ _ , _ = fmt .Fprintf (writer , "Message: %s\n \n " , req .Event .Message )
300289 }
301290
302291 _ , _ = fmt .Fprintf (writer , "When: %s\n \n " , req .Event .Time .Format ("2006-01-02 15:04:05 MST" ))
303-
304- if req .Event .Username != "" {
305- _ , _ = fmt .Fprintf (writer , "Author: %s\n \n " , req .Event .Username )
306- }
307292 _ , _ = fmt .Fprintf (writer , "Object: %s\n \n " , req .Object .Url )
308293 _ , _ = writer .Write ([]byte ("Tags:\n " ))
309294 for k , v := range utils .IterateOrderedMap (req .Object .Tags ) {
@@ -319,18 +304,8 @@ func FormatMessage(writer io.Writer, req *NotificationRequest) {
319304
320305// FormatSubject returns the formatted subject string based on the event type.
321306func FormatSubject (req * NotificationRequest ) string {
322- switch req .Event .Type {
323- case event .TypeState :
324- return fmt .Sprintf ("[#%d] %s %s is %s" , req .Incident .Id , req .Event .Type , req .Object .Name , req .Incident .Severity )
325- case event .TypeAcknowledgementCleared , event .TypeDowntimeRemoved :
326- if req .Incident != nil {
327- return fmt .Sprintf ("[#%d] %s from %s" , req .Incident .Id , req .Event .Type , req .Object .Name )
328- }
329- return fmt .Sprintf ("%s from %s" , req .Event .Type , req .Object .Name )
330- default :
331- if req .Incident != nil {
332- return fmt .Sprintf ("[#%d] %s on %s" , req .Incident .Id , req .Event .Type , req .Object .Name )
333- }
334- return fmt .Sprintf ("%s on %s" , req .Event .Type , req .Object .Name )
307+ if req .Incident != nil {
308+ return fmt .Sprintf ("[#%d] %s is %s" , req .Incident .Id , req .Object .Name , req .Incident .Severity )
335309 }
310+ return req .Object .Name
336311}
0 commit comments