Class: Imap::Backup::CLI::Utils

Inherits:
Thor
  • Object
show all
Includes:
Helpers, Thor::Actions
Defined in:
lib/imap/backup/cli/utils.rb

Constant Summary collapse

FAKE_EMAIL =
"[email protected]".freeze

Instance Method Summary collapse

Methods included from Helpers

#account, included, #load_config, #options, #requested_accounts

Instance Method Details

#export_to_thunderbird(email) ⇒ Object



56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
# File 'lib/imap/backup/cli/utils.rb', line 56

def export_to_thunderbird(email)
  Imap::Backup::Logger.setup_logging options
  force = options.key?(:force) ? options[:force] : false
  profile_name = options[:profile]

  config = load_config(**options)
   = (config, email)
  profile = thunderbird_profile(profile_name)

  if !profile
    raise "Thunderbird profile '#{profile_name}' not found" if profile_name

    raise "Default Thunderbird profile not found"
  end

  serialized_folders = ::SerializedFolders.new(account: )

  raise "No serialized folders were found for account '#{email}'" if serialized_folders.none?

  serialized_folders.each do |serializer, _folder|
    Thunderbird::MailboxExporter.new(
      email, serializer, profile, force: force
    ).run
  end
end

#ignore_history(email) ⇒ Object



18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/imap/backup/cli/utils.rb', line 18

def ignore_history(email)
  Logger.setup_logging options
  config = load_config(**options)
   = (config, email)

  backup_folders = ::BackupFolders.new(
    client: .client, account: 
  )
  backup_folders.each do |folder|
    next if !folder.exist?

    serializer = Serializer.new(.local_path, folder.name)
    do_ignore_folder_history(folder, serializer)
  end
end