summaryrefslogtreecommitdiff
path: root/service/pixelated/adapter
diff options
context:
space:
mode:
authorFolker Bernitt <fbernitt@thoughtworks.com>2015-09-02 12:35:33 +0200
committerFolker Bernitt <fbernitt@thoughtworks.com>2015-09-02 12:35:33 +0200
commite5d718f982e0cd3fc85da00d3abdccce1907e488 (patch)
treeebf566a96a2b70c7f234c81065ee48054bf555a3 /service/pixelated/adapter
parent503c917ede122fc97046e35af8ec30a25adbad32 (diff)
Download attachments from mail store instead of querier
- Issue #435 - Improved error handling of attachment resource
Diffstat (limited to 'service/pixelated/adapter')
-rw-r--r--service/pixelated/adapter/mailstore/leap_mailstore.py4
-rw-r--r--service/pixelated/adapter/services/mail_service.py4
2 files changed, 4 insertions, 4 deletions
diff --git a/service/pixelated/adapter/mailstore/leap_mailstore.py b/service/pixelated/adapter/mailstore/leap_mailstore.py
index a3a5e984..993f413c 100644
--- a/service/pixelated/adapter/mailstore/leap_mailstore.py
+++ b/service/pixelated/adapter/mailstore/leap_mailstore.py
@@ -18,7 +18,7 @@ from email.header import decode_header
import quopri
import re
from uuid import uuid4
-from leap.mail.adaptors.soledad import SoledadMailAdaptor
+from leap.mail.adaptors.soledad import SoledadMailAdaptor, ContentDocWrapper
from twisted.internet import defer
from pixelated.adapter.mailstore.body_parser import BodyParser
from pixelated.adapter.mailstore.mailstore import MailStore, underscore_uuid
@@ -182,7 +182,7 @@ class LeapMailStore(MailStore):
def get_mail_attachment(self, attachment_id):
results = yield self.soledad.get_from_index('by-type-and-payloadhash', 'cnt', attachment_id) if attachment_id else []
if len(results):
- content = results[0]
+ content = ContentDocWrapper(**results[0].content)
defer.returnValue({'content-type': content.content_type, 'content': self._try_decode(
content.raw, content.content_transfer_encoding)})
else:
diff --git a/service/pixelated/adapter/services/mail_service.py b/service/pixelated/adapter/services/mail_service.py
index 4ff42046..2c576e98 100644
--- a/service/pixelated/adapter/services/mail_service.py
+++ b/service/pixelated/adapter/services/mail_service.py
@@ -65,8 +65,8 @@ class MailService(object):
def mail(self, mail_id):
return self.mail_store.get_mail(mail_id, include_body=True)
- def attachment(self, attachment_id, encoding):
- return self.querier.attachment(attachment_id, encoding)
+ def attachment(self, attachment_id):
+ return self.mail_store.get_mail_attachment(attachment_id)
@defer.inlineCallbacks
def mail_exists(self, mail_id):