Get prune working, at least in a simple case.
[mailshears.git] / lib / prune / prune_dummy_runner.rb
index 8e9fcd9f14280e43af55c7fe10a43940e61efeb1..4274bef8f08db79990e9e98cc42e15d2c129619e 100644 (file)
@@ -1,10 +1,32 @@
 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
+
+    pfa = PostfixadminPrune.new()
+
+    db_users = pfa.list_users()
+    db_domains = pfa.list_domains()
+
+    leftover_users = plugin.get_leftover_accounts(db_users)
+    leftover_domains = plugin.get_leftover_domains(db_domains)
+
+    leftover_users.each do |user|
+      user_description = plugin.describe_account(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