diff options
author | Folker Bernitt <fbernitt@thoughtworks.com> | 2015-07-23 18:10:20 +0200 |
---|---|---|
committer | Folker Bernitt <fbernitt@thoughtworks.com> | 2015-08-11 17:00:27 +0200 |
commit | ca2be15686064d3ece97261df72560a4f91ade4d (patch) | |
tree | f3802b42da093eecb0858d1d167e9c837cfdbe8c /service/pixelated | |
parent | 4de9e17f4cd1f597251552408080c1a82c45720f (diff) |
Added include_body to get_mail.
Diffstat (limited to 'service/pixelated')
-rw-r--r-- | service/pixelated/adapter/mailstore/leap_mailstore.py | 19 |
1 files changed, 14 insertions, 5 deletions
diff --git a/service/pixelated/adapter/mailstore/leap_mailstore.py b/service/pixelated/adapter/mailstore/leap_mailstore.py index a39f4eae..893eb52b 100644 --- a/service/pixelated/adapter/mailstore/leap_mailstore.py +++ b/service/pixelated/adapter/mailstore/leap_mailstore.py @@ -38,6 +38,7 @@ class LeapMail(Mail): 'header': {k.lower(): v for k, v in self.headers.items()}, 'ident': self._mail_id, 'tags': self._tags, + 'body': self._body } @@ -49,12 +50,13 @@ class LeapMailStore(MailStore): self.soledad = soledad @defer.inlineCallbacks - def get_mail(self, mail_id): + def get_mail(self, mail_id, include_body=False): try: message = yield SoledadMailAdaptor().get_msg_from_mdoc_id(Message, self.soledad, mail_id) + leap_mail = yield self._leap_message_to_leap_mail(mail_id, message, include_body) - defer.returnValue(self._leap_message_to_leap_mail(mail_id, message)) - except AttributeError: + defer.returnValue(leap_mail) + except AttributeError, e: defer.returnValue(None) def get_mails(self, mail_ids): @@ -64,6 +66,13 @@ class LeapMailStore(MailStore): return defer.gatherResults(deferreds, consumeErrors=True) - def _leap_message_to_leap_mail(self, mail_id, message): - return LeapMail(mail_id, message.get_headers(), message.get_tags()) + @defer.inlineCallbacks + def _leap_message_to_leap_mail(self, mail_id, message, include_body): + if include_body: + body = (yield message._wrapper.get_body(self.soledad)).raw + else: + body = None + mail = LeapMail(mail_id, message.get_headers(), message.get_tags(), body=body) + + defer.returnValue(mail) |