]> gitweb.michael.orlitzky.com - mailshears.git/blobdiff - lib/prune/prune_dummy_runner.rb
Replace 'account' with 'user' everywhere.
[mailshears.git] / lib / prune / prune_dummy_runner.rb
index f9bde5e17c667b086f037a0232b054644d7ce292..6cb789fcee6c4243f7e4a819eaf55fc8f8102e76 100644 (file)
@@ -1,8 +1,33 @@
+require 'common/runner'
+
+# This is always needed, regardless of which plugin is running.
+require 'prune/plugins/postfixadmin'
+
 class PruneDummyRunner
   include Runner
 
   def run(plugin)
-    puts "Not implemented"
+    # We don't want to check the PostfixAdmin database against itself.
+    return if plugin.class == PostfixadminPrune
+
+    cfg = Configuration.new()
+    pfa = PostfixadminPrune.new(cfg)
+
+    db_users = pfa.list_users()
+    db_domains = pfa.list_domains()
+
+    leftover_users = plugin.get_leftover_users(db_users)
+    leftover_domains = plugin.get_leftover_domains(db_domains)
+
+    leftover_users.each do |user|
+      user_description = plugin.describe_user(user)
+      report(plugin, "Would remove user: #{user} (#{user_description})")
+    end
+
+    leftover_domains.each do |domain|
+      domain_description = plugin.describe_domain(domain)
+      report(plugin, "Would remove domain: #{domain} (#{domain_description})")
+    end
   end
 
 end