diff options
author | Folker Bernitt <fbernitt@thoughtworks.com> | 2015-05-11 12:09:04 +0200 |
---|---|---|
committer | Folker Bernitt <fbernitt@thoughtworks.com> | 2015-05-11 12:09:04 +0200 |
commit | 36b3c5beee77b4376cb910b80b0dfb7380f39bfe (patch) | |
tree | b4543e5007152b4263eb3536811ba221d9464f0d /service/pixelated | |
parent | 981e1efffb59762773ac7861729d98c0860ee64b (diff) |
Use maildir for folders like DRAFTS or SENT.
- Issues #337, #338
- Added example how to use maildir sub folders
Diffstat (limited to 'service/pixelated')
-rw-r--r-- | service/pixelated/maintenance.py | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/service/pixelated/maintenance.py b/service/pixelated/maintenance.py index bfa78da8..167a844a 100644 --- a/service/pixelated/maintenance.py +++ b/service/pixelated/maintenance.py @@ -147,19 +147,25 @@ def delete_all_mails(args): return args +def is_keep_file(mail): + return mail['subject'] is None + + def add_mail_folder(account, maildir, folder_name, deferreds): if folder_name not in account.mailboxes: account.addMailbox(folder_name) mbx = account.getMailbox(folder_name) for mail in maildir: + if is_keep_file(mail): + continue + flags = (WithMsgFields.RECENT_FLAG,) if mail.get_subdir() == 'new' else () if 'S' in mail.get_flags(): flags = (WithMsgFields.SEEN_FLAG,) + flags if 'R' in mail.get_flags(): flags = (WithMsgFields.ANSWERED_FLAG,) + flags - mail.set_payload(mail.get_payload() + '\n' + folder_name) deferreds.append(mbx.addMessage(mail.as_string(), flags=flags, notify_on_disk=False)) @@ -173,8 +179,6 @@ def load_mails(args, mail_paths): for path in mail_paths: maildir = Maildir(path, factory=None) add_mail_folder(account, maildir, 'INBOX', deferreds) - add_mail_folder(account, maildir, 'DRAFTS', deferreds) - add_mail_folder(account, maildir, 'SENT', deferreds) for mail_folder_name in maildir.list_folders(): mail_folder = maildir.get_folder(mail_folder_name) add_mail_folder(account, mail_folder, mail_folder_name, deferreds) |