Simplify prune plugins and fix array difference error.
[mailshears.git] / lib / prune / prune_plugin.rb
1 require 'rm/rm_plugin'
2
3 module PrunePlugin
4 #
5 # Plugins for the removal of leftover non-PostfixAdmin users,
6 # i.e. after an user has been removed from the PostfixAdmin
7 # database.
8 #
9 include RmPlugin
10 extend Plugin::Run
11
12 def self.runner()
13 return PruneRunner
14 end
15
16 def self.dummy_runner
17 return PruneDummyRunner
18 end
19
20 def get_leftover_domains(db_domains)
21 # Given a list of domains, determine which domains belonging to
22 # this plugin are not contained in the given list.
23
24 # WARNING! Array difference doesn't work for some reason.
25 return list_domains().select{ |d| !db_domains.include?(d) }
26 end
27
28 def get_leftover_users(db_users)
29 # Given a list of users, determine which users belonging to
30 # this plugin are not contained in the given list.
31
32 # WARNING! Array difference doesn't work for some reason.
33 return list_users().select{ |u| !db_users.include?(u) }
34 end
35 end