require 'common/plugin'
+require 'common/filesystem'
module DovecotMailstorePlugin
# Code that all DovecotMailstore plugins (Prune, Rm, Mv...) will
# Return the filesystem path of this account's mailbox.
# Only works if the account exists!
if not account.include?('@')
- raise InvalidAccountError.new("#{account}: Accounts must contain an '@' symbol.")
+ msg = "#{account}: Accounts must contain an '@' symbol."
+ raise InvalidAccountError.new(msg)
end
account_parts = account.split('@')
if File.directory?(account_path)
return account_path
else
- raise NonexistentAccountError(account)
+ raise NonexistentAccountError.new(account)
end
end
+
+ def list_domains()
+ return Filesystem.get_subdirs(@domain_root)
+ end
+
+ def list_domains_users(domains)
+ accounts = []
+
+ domains.each do |domain|
+ begin
+ # Throws a NonexistentDomainError if the domain's path
+ # doesn't exist on the filesystem. In this case, we want
+ # to report zero accounts.
+ domain_path = get_domain_path(domain)
+ usernames = Filesystem.get_subdirs(domain_path)
+
+ usernames.each do |username|
+ accounts << "#{username}@#{domain}"
+ end
+ rescue NonexistentDomainError
+ # Party hard.
+ end
+ end
+
+ return accounts
+ end
+
+
+ def list_users()
+ domains = list_domains()
+ users = list_domains_users(domains)
+ return users
+ end
+
end