lib/flapjack/data/notification.rb in flapjack-0.7.6 vs lib/flapjack/data/notification.rb in flapjack-0.7.7

- old
+ new

@@ -1,7 +1,9 @@ #!/usr/bin/env ruby +require 'flapjack/data/contact' +require 'flapjack/data/event' require 'flapjack/data/message' module Flapjack module Data class Notification @@ -17,18 +19,17 @@ def messages(opts = {}) contacts = opts[:contacts] return [] if contacts.nil? @messages ||= contacts.collect {|contact| - # TODO don't include messages here if the contact doesn't have - # the medium enabled or has blackholed at this level -- this - # will simplify the executive logic + # TODO move the message filtering logic from executive into this + # class and apply here, don't generate message if it won't be sent - contact.media.keys.inject([]) { |ret, mk| + contact.media.each_pair.inject([]) { |ret, (k, v)| m = Flapjack::Data::Message.for_contact(:contact => contact) m.notification = self - m.medium = mk - m.address = contact.media[mk] + m.medium = k + m.address = v ret << m ret } }.flatten end