From e294f7c1818f80a757522ea270a6a53da7e215f2 Mon Sep 17 00:00:00 2001 From: Joshua Tauberer Date: Sat, 9 Aug 2014 16:49:57 +0000 Subject: [PATCH] create the Drafts folder for users so K-9 mail doesn't poll unnecessarily, see #129 --- management/mailconfig.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/management/mailconfig.py b/management/mailconfig.py index b5b20a20..1ad7c57c 100755 --- a/management/mailconfig.py +++ b/management/mailconfig.py @@ -89,7 +89,9 @@ def add_mail_user(email, pw, env): # write databasebefore next step conn.commit() - # Create the user's INBOX and Spam folders and subscribe them. + # Create the user's INBOX, Spam, and Drafts folders, and subscribe them. + # K-9 mail will poll every 90 seconds if a Drafts folder does not exist, so create it + # to avoid unnecessary polling. # Check if the mailboxes exist before creating them. When creating a user that had previously # been deleted, the mailboxes will still exist because they are still on disk. @@ -100,8 +102,9 @@ def add_mail_user(email, pw, env): conn.commit() return ("Failed to initialize the user: " + e.output.decode("utf8"), 400) - if "INBOX" not in existing_mboxes: utils.shell('check_call', ["doveadm", "mailbox", "create", "-u", email, "-s", "INBOX"]) - if "Spam" not in existing_mboxes: utils.shell('check_call', ["doveadm", "mailbox", "create", "-u", email, "-s", "Spam"]) + for folder in ("INBOX", "Spam", "Drafts"): + if folder not in existing_mboxes: + utils.shell('check_call', ["doveadm", "mailbox", "create", "-u", email, "-s", folder]) # Update things in case any new domains are added. return kick(env, "mail user added")