summaryrefslogtreecommitdiff
path: root/mail/src
diff options
context:
space:
mode:
authorKali Kaneko <kali@leap.se>2015-03-23 13:08:24 -0400
committerKali Kaneko <kali@leap.se>2015-03-30 14:48:14 -0400
commita1d9b725e957c1ecadcbe85994c811c032c558e0 (patch)
tree9b7dfc1ac4dadda714a0acea4c5b1729530deda3 /mail/src
parent373bbb7552ca6012edeae8bf3b8ee2d75cd5f58f (diff)
[bug] move creation_ts to mail generic api
This also fixes a bug in which INBOX wasn't being given a creation timestamp, and therefore always being identified with the same UIDVALIDITY = 1, which could be confusing MUAs since this value should be unique, and it's relied on to uniquely identifying a given message. Releases: 0.4.0
Diffstat (limited to 'mail/src')
-rw-r--r--mail/src/leap/mail/imap/account.py15
-rw-r--r--mail/src/leap/mail/mail.py17
2 files changed, 18 insertions, 14 deletions
diff --git a/mail/src/leap/mail/imap/account.py b/mail/src/leap/mail/imap/account.py
index 38df845..ccb4b75 100644
--- a/mail/src/leap/mail/imap/account.py
+++ b/mail/src/leap/mail/imap/account.py
@@ -163,28 +163,17 @@ class IMAPAccount(object):
# FIXME --- return failure instead of AssertionError
# See AccountTestCase...
leap_assert(name, "Need a mailbox name to create a mailbox")
- if creation_ts is None:
- # by default, we pass an int value
- # taken from the current time
- # we make sure to take enough decimals to get a unique
- # mailbox-uidvalidity.
- creation_ts = int(time.time() * 10E2)
def check_it_does_not_exist(mailboxes):
if name in mailboxes:
raise imap4.MailboxCollision, repr(name)
return mailboxes
- def set_mbox_creation_ts(collection):
- d = collection.set_mbox_attr("created", creation_ts)
- d.addCallback(lambda _: collection)
- return d
-
d = self.account.list_all_mailbox_names()
d.addCallback(check_it_does_not_exist)
- d.addCallback(lambda _: self.account.add_mailbox(name))
+ d.addCallback(lambda _: self.account.add_mailbox(
+ name, creation_ts=creation_ts))
d.addCallback(lambda _: self.account.get_collection_by_mailbox(name))
- d.addCallback(set_mbox_creation_ts)
d.addCallback(self._return_mailbox_from_collection)
return d
diff --git a/mail/src/leap/mail/mail.py b/mail/src/leap/mail/mail.py
index 99c3873..89f89b0 100644
--- a/mail/src/leap/mail/mail.py
+++ b/mail/src/leap/mail/mail.py
@@ -21,6 +21,7 @@ import itertools
import uuid
import logging
import StringIO
+import time
import weakref
from twisted.internet import defer
@@ -833,7 +834,20 @@ class Account(object):
d = self.adaptor.get_all_mboxes(self.store)
return d
- def add_mailbox(self, name):
+ def add_mailbox(self, name, creation_ts=None):
+
+ if creation_ts is None:
+ # by default, we pass an int value
+ # taken from the current time
+ # we make sure to take enough decimals to get a unique
+ # mailbox-uidvalidity.
+ creation_ts = int(time.time() * 10E2)
+
+ def set_creation_ts(wrapper):
+ wrapper.created = creation_ts
+ d = wrapper.update(self.store)
+ d.addCallback(lambda _: wrapper)
+ return d
def create_uuid(wrapper):
if not wrapper.uuid:
@@ -849,6 +863,7 @@ class Account(object):
return d
d = self.adaptor.get_or_create_mbox(self.store, name)
+ d.addCallback(set_creation_ts)
d.addCallback(create_uuid)
d.addCallback(create_uid_table_cb)
return d