summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--mail/changes/next-changelog.rst1
-rw-r--r--mail/src/leap/mail/imap/mailbox.py22
2 files changed, 13 insertions, 10 deletions
diff --git a/mail/changes/next-changelog.rst b/mail/changes/next-changelog.rst
index 67bf9402..40efb190 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 bfc0bfc6..d545c009 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):
"""