diff options
author | Patrick Maia <patrickjourdanmaia@gmail.com> | 2014-11-12 18:07:10 +0000 |
---|---|---|
committer | Patrick Maia <patrickjourdanmaia@gmail.com> | 2014-11-12 18:07:10 +0000 |
commit | f202ed1c57d5a727dbcc6d10d6a669d363639ab3 (patch) | |
tree | 36689a3d6de027c5eb8edb2e746a3b5d1971f619 /service/pixelated/adapter | |
parent | fa24aaf94af1dd8b4ead48d6518d3770a60d1211 (diff) |
Card #30 - adds attachments information to bulk mail retrieval (GET /mails)
Diffstat (limited to 'service/pixelated/adapter')
-rw-r--r-- | service/pixelated/adapter/mail.py | 2 | ||||
-rw-r--r-- | service/pixelated/adapter/soledad_querier.py | 9 |
2 files changed, 6 insertions, 5 deletions
diff --git a/service/pixelated/adapter/mail.py b/service/pixelated/adapter/mail.py index 52a0a2e8..5977e252 100644 --- a/service/pixelated/adapter/mail.py +++ b/service/pixelated/adapter/mail.py @@ -190,7 +190,7 @@ class InputMail(Mail): class PixelatedMail(Mail): @staticmethod - def from_soledad(fdoc, hdoc, bdoc, soledad_querier=None, parts=None): + def from_soledad(fdoc, hdoc, bdoc, parts=None, soledad_querier=None): mail = PixelatedMail() mail.parts = parts mail.boundary = str(uuid4()).replace('-', '') diff --git a/service/pixelated/adapter/soledad_querier.py b/service/pixelated/adapter/soledad_querier.py index c1e0350e..2e67a5ab 100644 --- a/service/pixelated/adapter/soledad_querier.py +++ b/service/pixelated/adapter/soledad_querier.py @@ -88,14 +88,15 @@ class SoledadQuerier: fdocs_hdocs.append((fdoc, hdoc[0])) fdocs_hdocs_bodyphash = [(f[0], f[1], f[1].content.get('body')) for f in fdocs_hdocs] - fdocs_hdocs_bdocs = [] + fdocs_hdocs_bdocs_parts = [] for fdoc, hdoc, body_phash in fdocs_hdocs_bodyphash: bdoc = self.soledad.get_from_index('by-type-and-payloadhash', 'cnt', body_phash) if len(bdoc) == 0: continue - fdocs_hdocs_bdocs.append((fdoc, hdoc, bdoc[0])) + parts = self._extract_parts(hdoc.content) + fdocs_hdocs_bdocs_parts.append((fdoc, hdoc, bdoc[0], parts)) - return [PixelatedMail.from_soledad(*raw_mail, soledad_querier=self) for raw_mail in fdocs_hdocs_bdocs] + return [PixelatedMail.from_soledad(*raw_mail, soledad_querier=self) for raw_mail in fdocs_hdocs_bdocs_parts] def save_mail(self, mail): # XXX update only what has to be updated @@ -121,7 +122,7 @@ class SoledadQuerier: parts = self._extract_parts(hdoc.content) bdoc = self.soledad.get_from_index('by-type-and-payloadhash', 'cnt', hdoc.content['body'])[0] - return PixelatedMail.from_soledad(fdoc, hdoc, bdoc, soledad_querier=self, parts=parts) + return PixelatedMail.from_soledad(fdoc, hdoc, bdoc, parts=parts, soledad_querier=self) def attachment(self, ident, encoding): bdoc = self.soledad.get_from_index('by-type-and-payloadhash', 'cnt', ident)[0] |