X-Git-Url: http://gitweb.michael.orlitzky.com/?p=mailshears.git;a=blobdiff_plain;f=lib%2Fcommon%2Fdovecot_plugin.rb;h=02e92957cf6994df0e01ebc1a67fa4d07ffbe591;hp=ab5a40930400af057229ded188d40516cc88b866;hb=72696d3f6e95ef773af9727e9c3459b9038b0fc2;hpb=8064b7be68006d07889e2d24eb0bddc6063d3275;ds=sidebyside diff --git a/lib/common/dovecot_plugin.rb b/lib/common/dovecot_plugin.rb index ab5a409..02e9295 100644 --- a/lib/common/dovecot_plugin.rb +++ b/lib/common/dovecot_plugin.rb @@ -19,11 +19,11 @@ module DovecotPlugin end end - def describe_account(account) + def describe_user(user) begin - account_path = get_account_path(account) - return account_path - rescue NonexistentAccountError => e + user_path = get_user_path(user) + return user_path + rescue NonexistentUserError => e return "Doesn't exist: #{e.to_s}" end end @@ -45,30 +45,30 @@ module DovecotPlugin end - def get_account_path(account) - # Return the filesystem path of this account's mailbox. - # Only works if the account exists! - if not account.include?('@') - msg = "#{account}: Accounts must contain an '@' symbol." - raise InvalidAccountError.new(msg) + def get_user_path(user) + # Return the filesystem path of this user's mailbox. + # Only works if the user exists! + if not user.include?('@') + msg = "#{user}: Users must contain an '@' symbol." + raise InvalidUserError.new(msg) end - account_parts = account.split('@') - user_part = account_parts[0] - domain_part = account_parts[1] + user_parts = user.split('@') + local_part = user_parts[0] + domain_part = user_parts[1] begin domain_path = get_domain_path(domain_part) rescue NonexistentDomainError - raise NonexistentAccountError.new(account) + raise NonexistentUserError.new(user) end - account_path = File.join(domain_path, user_part) + user_path = File.join(domain_path, local_part) - if File.directory?(account_path) - return account_path + if File.directory?(user_path) + return user_path else - raise NonexistentAccountError.new(account) + raise NonexistentUserError.new(user) end end @@ -78,25 +78,25 @@ module DovecotPlugin end def list_domains_users(domains) - accounts = [] + users = [] 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. + # to report zero users. domain_path = get_domain_path(domain) usernames = Filesystem.get_subdirs(domain_path) usernames.each do |username| - accounts << "#{username}@#{domain}" + users << "#{username}@#{domain}" end rescue NonexistentDomainError # Party hard. end end - return accounts + return users end