lib/flapjack/data/notification.rb in flapjack-0.8.1 vs lib/flapjack/data/notification.rb in flapjack-0.8.2

- old
+ new

@@ -140,10 +140,16 @@ else # matchers are rules of the contact that have matched the current event # for time, entity and tags matchers = rules.select do |rule| logger.debug("considering rule with entities: #{rule.entities} and tags: #{rule.tags.to_json}") - (rule.match_entity?(@event_id) || rule.match_tags?(@tags) || ! rule.is_specific?) && + rule_has_tags = rule.tags ? (rule.tags.length > 0) : false + rule_has_entities = rule.entities ? (rule.entities.length > 0) : false + + matches_tags = rule_has_tags ? rule.match_tags?(@tags) : true + matches_entity = rule_has_entities ? rule.match_entity?(@event_id) : true + + ((matches_entity && matches_tags) || ! rule.is_specific?) && rule_occurring_now?(rule, :contact => contact, :default_timezone => default_timezone) end logger.debug "#{matchers.length} matchers remain for this contact after time, entity and tags are matched:" matchers.each do |matcher|