Sha256: f4d9d4cad54a4efdf5533fd6b15925ef01cbe3d5b5dc6210de9eb3966a836c7f
Contents?: true
Size: 1.22 KB
Versions: 6
Compression:
Stored size: 1.22 KB
Contents
require "socket" require "email/provider" require "imap/backup/client/apple_mail" require "imap/backup/client/default" require "retry_on_error" module Imap; end module Imap::Backup class Account; end class Account::ClientFactory include RetryOnError LOGIN_RETRY_CLASSES = [::EOFError, ::Errno::ECONNRESET, ::SocketError].freeze attr_reader :account def initialize(account:) @account = account @provider = nil @server = nil end def run retry_on_error(errors: LOGIN_RETRY_CLASSES) do options = provider_options Logger.logger.debug( "Creating IMAP instance: #{server}, options: #{options.inspect}" ) client = if provider.is_a?(Email::Provider::AppleMail) Client::AppleMail.new(server, account, options) else Client::Default.new(server, account, options) end client.login client end end private def provider @provider ||= Email::Provider.for_address(account.username) end def provider_options provider.options.merge(account.connection_options || {}) end def server @server ||= account.server || provider.host end end end
Version data entries
6 entries across 6 versions & 1 rubygems