diff options
author | mnandri <mnandri@eunglick.corporate.thoughtworks.com> | 2015-12-17 18:41:58 +0100 |
---|---|---|
committer | mnandri <mnandri@eunglick.corporate.thoughtworks.com> | 2015-12-18 11:22:34 +0100 |
commit | 06ac408dbd7629d387dd7b311a26c144ee56631e (patch) | |
tree | c263a0586628b627076b12132166322714394256 /service/pixelated/adapter/mailstore/leap_mailstore.py | |
parent | 39fa6e68fc2afaafc0e8440d212b464d2e20c326 (diff) |
extracted a leap attachment store, handling all attachment responsibilities, including saving attachments.
Issue #548
Diffstat (limited to 'service/pixelated/adapter/mailstore/leap_mailstore.py')
-rw-r--r-- | service/pixelated/adapter/mailstore/leap_mailstore.py | 22 |
1 files changed, 0 insertions, 22 deletions
diff --git a/service/pixelated/adapter/mailstore/leap_mailstore.py b/service/pixelated/adapter/mailstore/leap_mailstore.py index 14b0e417..2660a208 100644 --- a/service/pixelated/adapter/mailstore/leap_mailstore.py +++ b/service/pixelated/adapter/mailstore/leap_mailstore.py @@ -16,7 +16,6 @@ import base64 from email.header import decode_header from email.utils import parseaddr -import quopri from uuid import uuid4 import re @@ -222,27 +221,6 @@ class LeapMailStore(MailStore): return defer.gatherResults(deferreds, consumeErrors=True) @defer.inlineCallbacks - 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 = ContentDocWrapper(**results[0].content) - defer.returnValue({'content-type': content.content_type, 'content': self._try_decode( - content.raw, content.content_transfer_encoding)}) - else: - raise ValueError('No attachment with id %s found!' % attachment_id) - - def _try_decode(self, raw, encoding): - encoding = encoding.lower() - if encoding == 'base64': - data = base64.decodestring(raw) - elif encoding == 'quoted-printable': - data = quopri.decodestring(raw) - else: - data = str(raw) - - return bytearray(data) - - @defer.inlineCallbacks def update_mail(self, mail): message = yield self._fetch_msg_from_soledad(mail.mail_id) message.get_wrapper().set_tags(tuple(mail.tags)) |