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
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, existence_check = true)
+ # Return the filesystem path of this user's mailbox. With
+ # existence_check = true, it only works if the user exists!
+ # We always require that the domain 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
+ return user_path if not existence_check
+
+ if File.directory?(user_path)
+ return user_path
else
- raise NonexistentAccountError.new(account)
+ raise NonexistentUserError.new(user)
end
end
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