]> gitweb.michael.orlitzky.com - mailshears.git/commitdiff
Simplify prune plugins and fix array difference error.
authorMichael Orlitzky <michael@orlitzky.com>
Tue, 3 Nov 2015 17:41:32 +0000 (12:41 -0500)
committerMichael Orlitzky <michael@orlitzky.com>
Tue, 3 Nov 2015 17:41:32 +0000 (12:41 -0500)
lib/prune/plugins/agendav.rb
lib/prune/plugins/davical.rb
lib/prune/plugins/dovecot.rb
lib/prune/plugins/roundcube.rb
lib/prune/prune_plugin.rb

index 43b5c99e883cf4287438297308b43769345806aa..86a437bd699727a64f05ea38982ffe59fc53007f 100644 (file)
@@ -4,21 +4,5 @@ require 'prune/prune_plugin'
 require 'rm/plugins/agendav'
 
 class AgendavPrune < AgendavRm
 require 'rm/plugins/agendav'
 
 class AgendavPrune < AgendavRm
-
   include PrunePlugin
   include PrunePlugin
-
-  def get_leftover_domains(db_domains)
-    # AgenDAV doesn't have a concept of domains. We could parse the
-    # usernames to see what domains are present, but the point is
-    # moot: all leftover users will be pruned anyway.
-    return []
-  end
-
-
-  def get_leftover_users(db_users)
-    # Get a list of all users who have logged in to AgenDAV.
-    ad_users = self.list_users()
-    return ad_users - db_users
-  end
-
 end
 end
index 3c5ff0e3401a7087c6a56810f3958866323d92af..f7f4b39cf64d5c0ca86d32fcf542738f1ecbc2a8 100644 (file)
@@ -4,26 +4,5 @@ require 'prune/prune_plugin'
 require 'rm/plugins/davical'
 
 class DavicalPrune < DavicalRm
 require 'rm/plugins/davical'
 
 class DavicalPrune < DavicalRm
-  #
-  # DAViCal only supports Postgres, so even if we ever are
-  # database-agnostic, this plugin can't be.
-  #
   include PrunePlugin
   include PrunePlugin
-
-
-  def get_leftover_domains(db_domains)
-    # DAViCal doesn't have a concept of domains. We could parse the
-    # usernames to see what domains are present, but the point is
-    # moot: all leftover users will be pruned anyway.
-    return []
-  end
-
-
-  def get_leftover_users(db_users)
-    # Get a list of all users who have logged in to DAViCal.
-    davical_users = self.list_users()
-    return davical_users - db_users
-  end
-
-
 end
 end
index bf96420d209753da032d77bd4cbcb7e71d3d5f3e..7d346ac23b22adce05fe92b46716f7614abb9c47 100644 (file)
@@ -2,25 +2,5 @@ require 'prune/prune_plugin'
 require 'rm/plugins/dovecot'
 
 class DovecotPrune < DovecotRm
 require 'rm/plugins/dovecot'
 
 class DovecotPrune < DovecotRm
-
   include PrunePlugin
   include PrunePlugin
-
-
-  def get_leftover_domains(db_domains)
-    # Get the list of domains according to the filesystem.
-    fs_domains = self.list_domains()
-
-    # Return the list of domains on the filesystem that aren't in the DB.
-    return (fs_domains - db_domains)
-  end
-
-  def get_leftover_users(db_users)
-    # Get the list of users according to the filesystem.
-    fs_domains = self.list_domains()
-    fs_users = self.list_domains_users(fs_domains)
-
-    # And return the users on the filesystem that aren't in the DB.
-    return (fs_users - db_users)
-  end
-
 end
 end
index 1bb782700748644905b0fb1141ddd9eb5fb63127..5869b02cabe20aeb2e78ebc5012173d624427a0b 100644 (file)
@@ -4,22 +4,5 @@ require 'prune/prune_plugin'
 require 'rm/plugins/roundcube'
 
 class RoundcubePrune < RoundcubeRm
 require 'rm/plugins/roundcube'
 
 class RoundcubePrune < RoundcubeRm
-
   include PrunePlugin
   include PrunePlugin
-
-
-  def get_leftover_domains(db_domains)
-    # Roundcube doesn't have a concept of domains. We could parse the
-    # usernames to see what domains are present, but the point is
-    # moot: all leftover users will be pruned anyway.
-    return []
-  end
-
-
-  def get_leftover_users(db_users)
-    # Get a list of all users who have logged in to Roundcube.
-    rc_users = self.list_users()
-    return rc_users - db_users
-  end
-
 end
 end
index 44fd636f20888e56c255a765aa1a354d464c7f2c..1046f2d0b29c575a8a4ecfc8c51a54f1e609e6ad 100644 (file)
@@ -20,12 +20,16 @@ module PrunePlugin
   def get_leftover_domains(db_domains)
     # Given a list of domains, determine which domains belonging to
     # this plugin are not contained in the given list.
   def get_leftover_domains(db_domains)
     # Given a list of domains, determine which domains belonging to
     # this plugin are not contained in the given list.
-    raise NotImplementedError
+
+    # WARNING! Array difference doesn't work for some reason.
+    return list_domains().select{ |d| !db_domains.include?(d) }
   end
 
   def get_leftover_users(db_users)
     # Given a list of users, determine which users belonging to
     # this plugin are not contained in the given list.
   end
 
   def get_leftover_users(db_users)
     # Given a list of users, determine which users belonging to
     # this plugin are not contained in the given list.
-    raise NotImplementedError
+
+    # WARNING! Array difference doesn't work for some reason.
+    return list_users().select{ |u| !db_users.include?(u) }
   end
 end
   end
 end