summaryrefslogtreecommitdiff
path: root/src/leap/mail/imap/mailbox.py
diff options
context:
space:
mode:
authorRuben Pollan <meskio@sindominio.net>2015-02-18 11:33:42 -0600
committerRuben Pollan <meskio@sindominio.net>2015-02-18 17:30:29 -0600
commit2af7083d4543be9a1b1476de75fafb17bfe78b95 (patch)
treefc7a16d14e0be335240aacea41edc37cc76971aa /src/leap/mail/imap/mailbox.py
parent87c15e3ec5c1ca607890bf72b0d90bb0f114cbb1 (diff)
Use MessageCollection instead of IMAPMailbox in IncomingMail
Diffstat (limited to 'src/leap/mail/imap/mailbox.py')
-rw-r--r--src/leap/mail/imap/mailbox.py42
1 files changed, 2 insertions, 40 deletions
diff --git a/src/leap/mail/imap/mailbox.py b/src/leap/mail/imap/mailbox.py
index 9ec6ea8..2f33aa0 100644
--- a/src/leap/mail/imap/mailbox.py
+++ b/src/leap/mail/imap/mailbox.py
@@ -19,13 +19,9 @@ IMAP Mailbox.
"""
import re
import logging
-import StringIO
-import cStringIO
-import time
import os
from collections import defaultdict
-from email.utils import formatdate
from twisted.internet import defer
from twisted.internet import reactor
@@ -36,7 +32,7 @@ from zope.interface import implements
from leap.common import events as leap_events
from leap.common.events.events_pb2 import IMAP_UNREAD_MAIL
-from leap.common.check import leap_assert, leap_assert_type
+from leap.common.check import leap_assert
from leap.mail.constants import INBOX_NAME, MessageFlags
from leap.mail.imap.messages import IMAPMessage
@@ -326,41 +322,7 @@ class IMAPMailbox(object):
:return: a deferred that will be triggered with the UID of the added
message.
"""
- # TODO should raise ReadOnlyMailbox if not rw.
- # TODO have a look at the cases for internal date in the rfc
- if isinstance(message, (cStringIO.OutputType, StringIO.StringIO)):
- message = message.getvalue()
-
- # XXX we could treat the message as an IMessage from here
- leap_assert_type(message, basestring)
-
- if flags is None:
- flags = tuple()
- else:
- flags = tuple(str(flag) for flag in flags)
-
- if date is None:
- date = formatdate(time.time())
-
- # A better place for this would be the COPY/APPEND dispatcher
- # if PROFILE_CMD:
- # do_profile_cmd(d, "APPEND")
-
- # just_mdoc=True: feels HACKY, but improves a *lot* the responsiveness
- # of the APPENDS: we just need to be notified when the mdoc
- # is saved, and let's hope that the other parts are doing just fine.
- # This will not catch any errors when the inserts of the other parts
- # fail, but on the other hand allows us to return very quickly, which
- # seems a good compromise given that we have to serialize the appends.
- # A better solution will probably involve implementing MULTIAPPEND
- # or patching imap server to support pipelining.
-
- d = self.collection.add_msg(message, flags=flags, date=date,
- notify_just_mdoc=True)
-
- # XXX signal to UI? --- should do it only if INBOX...
- d.addErrback(lambda f: log.msg(f.getTraceback()))
- return d
+ return self.collection.add_raw_msg(message, flags, date)
def notify_new(self, *args):
"""