lib/flapjack/data/notification.rb in flapjack-0.7.14 vs lib/flapjack/data/notification.rb in flapjack-0.7.15
- old
+ new
@@ -7,18 +7,19 @@
module Flapjack
module Data
class Notification
attr_reader :event, :type, :max_notified_severity, :contacts,
- :default_timezone
+ :default_timezone, :last_state
def self.for_event(event, opts = {})
self.new(:event => event,
:type => opts[:type],
:max_notified_severity => opts[:max_notified_severity],
:contacts => opts[:contacts],
:default_timezone => opts[:default_timezone],
+ :last_state => opts[:last_state],
:logger => opts[:logger])
end
def messages
return [] if contacts.nil? || contacts.empty?
@@ -35,10 +36,12 @@
end
contents = {'event_id' => event_id,
'state' => event_state,
'summary' => event.summary,
+ 'last_state' => @last_state ? @last_state[:state] : nil,
+ 'last_summary' => @last_state ? @last_state[:summary] : nil,
'details' => event.details,
'time' => event.time,
'duration' => event.duration || nil,
'notification_type' => type,
'max_notified_severity' => max_notified_severity }
@@ -120,9 +123,10 @@
@event = event
@type = opts[:type]
@max_notified_severity = opts[:max_notified_severity]
@contacts = opts[:contacts]
@default_timezone = opts[:default_timezone]
+ @last_state = opts[:last_state]
@logger = opts[:logger]
end
# # time restrictions match?
# nil rule.time_restrictions matches