]> nos-oignons.net Git - gestion-adh.git/commitdiff
Only call Mailman scripts when there is something to do
authorLunar <lunar@anargeek.net>
Mon, 3 Jun 2013 10:48:36 +0000 (12:48 +0200)
committerLunar <lunar@anargeek.net>
Mon, 3 Jun 2013 10:48:36 +0000 (12:48 +0200)
lib/nos_oignons.rb

index 26ffdc63e09b25e9eed5349246a6b4ef23c70c28..ff387d1af21b6ca32b2dc33deb0a09e70eaf7fb6 100644 (file)
@@ -26,8 +26,10 @@ module NosOignons
       current_emails = NosOignons::Mailman.list_members(list)
       uptodate_emails = NosOignons::Member.all.select(&:up_to_date?).collect(&:email)
 
-      NosOignons::Mailman.add_members(list, uptodate_emails - current_emails)
-      NosOignons::Mailman.remove_members(list, current_emails - uptodate_emails)
+      emails_to_add = uptodate_emails - current_emails
+      NosOignons::Mailman.add_members(list, emails_to_add) unless emails_to_add.empty?
+      emails_to_remove = current_emails - uptodate_emails
+      NosOignons::Mailman.remove_members(list, emails_to_remove) unless emails_to_remove.empty?
     end
 
     def send_membership_reminders!