From 409e88059e43d1a9c0df43a1df466c56e1dd9cbb Mon Sep 17 00:00:00 2001 From: Patrick J Cherry Date: Tue, 8 May 2012 11:55:19 +0100 Subject: Fixed up PeopleList#resolve_notifications to check for recursion, and only return notify clauses that refer to people. --- lib/mauve/people_list.rb | 28 ++++++++++++++++++++-------- 1 file changed, 20 insertions(+), 8 deletions(-) (limited to 'lib/mauve') diff --git a/lib/mauve/people_list.rb b/lib/mauve/people_list.rb index e6c6c36..8178635 100644 --- a/lib/mauve/people_list.rb +++ b/lib/mauve/people_list.rb @@ -78,16 +78,28 @@ module Mauve l end - def resolve_notifications(default_every=nil, default_during=nil, at = nil) - self.people(at).collect do |person| - if self.notifications.empty? - person.resolve_notifications(default_every, default_during, at) + def resolve_notifications(default_every=nil, default_during=nil, at = nil, lists_seen=[]) + # + # Add our username to the list of lists seen. + # + lists_seen << self.username + + self.people(at).collect do |person_or_people_list| + # + # Make sure we don't parse the same people list twice + # + next if lists_seen.include?(person_or_people_list.username) + + if self.notifications.empty? + person_or_people_list.resolve_notifications(default_every, default_during, at, lists_seen) else self.notifications.collect do |notification| - this_notification = Notification.new(person) - this_notification.every = default_every || notification.every - this_notification.during = default_during || notification.during - this_notification + person_or_people_list.resolve_notifications( + default_every || notification.every, + default_during || notification.during, + at, + lists_seen + ) end end end.flatten.compact -- cgit v1.2.1