fd0c541a44cb25ed7ffbe7e96db3c19b59426265
[mailshears.git] / lib / rm / rm_plugin.rb
1 require 'common/plugin.rb'
2
3 module RmPlugin
4 #
5 # Plugins for the removal of users.
6 #
7
8 extend Plugin::Run
9
10 def self.runner()
11 return RmRunner
12 end
13
14 def self.dummy_runner()
15 return RmDummyRunner
16 end
17
18 def delete(target)
19 # A generic version of delete_user/delete_domain that
20 # dispatches base on the class of the target.
21 if target.is_a?(User)
22 return delete_user(target)
23 elsif target.is_a?(Domain)
24 return delete_domain(target)
25 else
26 raise NotImplementedError
27 end
28 end
29
30 def delete_domain(domain)
31 # Delete the given domain. Some plugins don't have a concept of
32 # domains, so just delete all users with a username that looks
33 # like it's in the given domain.
34 users = list_domains_users([domain])
35
36 raise NonexistentDomainError.new(domain.to_s()) if users.empty?
37
38 users.each do |u|
39 delete_user(u)
40 end
41 end
42
43 def delete_user(user)
44 # Delete the given user.
45 raise NotImplementedError
46 end
47
48 end