diff options
author | Ruben Pollan <meskio@sindominio.net> | 2016-03-16 18:02:04 +0100 |
---|---|---|
committer | Ruben Pollan <meskio@sindominio.net> | 2016-03-24 14:52:57 +0100 |
commit | 527179a6d6a5dd1672dbf5513deffd99d15c9c91 (patch) | |
tree | b37b7e46149ef117f21c193475283767a01e511b | |
parent | 1d5f5bfec9ee8ab792fd651462bdcae43f55b49f (diff) |
[bug] Fix IMAP fetch headers
- Resolves: #7898
-rw-r--r-- | mail/changes/next-changelog.rst | 1 | ||||
-rw-r--r-- | mail/src/leap/mail/imap/mailbox.py | 22 |
2 files changed, 13 insertions, 10 deletions
diff --git a/mail/changes/next-changelog.rst b/mail/changes/next-changelog.rst index 67bf940..40efb19 100644 --- a/mail/changes/next-changelog.rst +++ b/mail/changes/next-changelog.rst @@ -21,6 +21,7 @@ Features Bugfixes ~~~~~~~~ - `#7861 <https://leap.se/code/issues/7861>`_: Use the right succeed function for passthrough encrypted email. +- `#7898 <https://leap.se/code/issues/7898>`_: Fix IMAP fetch headers - Fix the get_body logic for corner-cases in which body is None (yet-to-be synced docs, mainly). - `#1235 <https://leap.se/code/issues/1235>`_: Description for the fixed stuff corresponding with issue #1235. diff --git a/mail/src/leap/mail/imap/mailbox.py b/mail/src/leap/mail/imap/mailbox.py index bfc0bfc..d545c00 100644 --- a/mail/src/leap/mail/imap/mailbox.py +++ b/mail/src/leap/mail/imap/mailbox.py @@ -508,7 +508,7 @@ class IMAPMailbox(object): def get_range(messages_asked): return self._filter_msg_seq(messages_asked) - d = defer.maybeDeferred(self._bound_seq, messages_asked, uid) + d = self._bound_seq(messages_asked, uid) if uid: d.addCallback(get_range) d.addErrback(lambda f: log.err(f)) @@ -520,7 +520,7 @@ class IMAPMailbox(object): :param messages_asked: IDs of the messages. :type messages_asked: MessageSet - :rtype: MessageSet + :return: a Deferred that will fire with a MessageSet """ def set_last_uid(last_uid): @@ -543,7 +543,7 @@ class IMAPMailbox(object): d = self.collection.all_uid_iter() d.addCallback(set_last_seq) return d - return messages_asked + return defer.succeed(messages_asked) def _filter_msg_seq(self, messages_asked): """ @@ -713,6 +713,7 @@ class IMAPMailbox(object): d_seq.addCallback(get_flags_for_seq) return d_seq + @defer.inlineCallbacks def fetch_headers(self, messages_asked, uid): """ A fast method to fetch all headers, tricking just the @@ -757,14 +758,15 @@ class IMAPMailbox(object): for key, value in self.headers.items()) - messages_asked = self._bound_seq(messages_asked) - seq_messg = self._filter_msg_seq(messages_asked) + messages_asked = yield self._bound_seq(messages_asked, uid) + seq_messg = yield self._filter_msg_seq(messages_asked) - all_headers = self.messages.all_headers() - result = ((msgid, headersPart( - msgid, all_headers.get(msgid, {}))) - for msgid in seq_messg) - return result + result = [] + for msgid in seq_messg: + msg = yield self.collection.get_message_by_uid(msgid) + headers = headersPart(msgid, msg.get_headers()) + result.append((msgid, headers)) + defer.returnValue(iter(result)) def store(self, messages_asked, flags, mode, uid): """ |