create the Drafts folder for users so K-9 mail doesn't poll unnecessarily, see #129

This commit is contained in:
Joshua Tauberer 2014-08-09 16:49:57 +00:00
parent b56f82cb92
commit e294f7c181
1 changed files with 6 additions and 3 deletions

View File

@ -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")