From f202ed1c57d5a727dbcc6d10d6a669d363639ab3 Mon Sep 17 00:00:00 2001 From: Patrick Maia Date: Wed, 12 Nov 2014 18:07:10 +0000 Subject: Card #30 - adds attachments information to bulk mail retrieval (GET /mails) --- service/pixelated/adapter/mail.py | 2 +- service/pixelated/adapter/soledad_querier.py | 9 +++++---- 2 files changed, 6 insertions(+), 5 deletions(-) (limited to 'service/pixelated') 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] -- cgit v1.2.3