]> gitweb.michael.orlitzky.com - mailshears.git/blob - lib/prune/prune_plugin.rb
Update the version in mailshears.gemspec.
[mailshears.git] / lib / prune / prune_plugin.rb
1 require 'common/plugin.rb'
2
3 # Plugins for pruning users. By "pruning," we mean the removal of
4 # leftover non-PostfixAdmin users after the associated user has been
5 # removed from the Postfixadmin database.
6 #
7 module PrunePlugin
8
9 # Absorb the subclass run() magic from the Plugin::Run module.
10 extend Plugin::Run
11
12 # The runner class associated with pruning plugins.
13 #
14 # @return [Class] the {PruneRunner} class.
15 #
16 def self.runner()
17 return PruneRunner
18 end
19
20
21 # The "dummy" runner class associated with pruning plugins.
22 #
23 # @return [Class] the {PruneDummyRunner} class.
24 #
25 def self.dummy_runner
26 return PruneDummyRunner
27 end
28
29
30 # Determine which domains are "left over" for this plugin. A domain
31 # is considered "left over" if it has been removed from Postfixadmin
32 # but not some other plugin.
33 #
34 # The leftovers are determined with respect to the list *db_domains*
35 # of domains that Postfixadmin knows about.
36 #
37 # @param db_domains [Array<Domain>] a list of domains that are present
38 # in the Postfixadmin database.
39 #
40 # @return [Array<Domain>] a list of domains known to this plugin but
41 # not to Postfixadmin.
42 #
43 def get_leftover_domains(db_domains)
44 # WARNING! Array difference doesn't work for some reason.
45 return list_domains().select{ |d| !db_domains.include?(d) }
46 end
47
48
49 # Determine which users are "left over" for this plugin. A user
50 # is considered "left over" if it has been removed from Postfixadmin
51 # but not some other plugin.
52 #
53 # The leftovers are determined with respect to the list *db_users*
54 # of users that Postfixadmin knows about.
55 #
56 # @param db_users [Array<User>] a list of users that are present
57 # in the Postfixadmin database.
58 #
59 # @return [Array<User>] a list of users known to this plugin but
60 # not to Postfixadmin.
61 #
62 def get_leftover_users(db_users)
63 # WARNING! Array difference doesn't work for some reason.
64 return list_users().select{ |u| !db_users.include?(u) }
65 end
66 end