summaryrefslogtreecommitdiff
path: root/service
diff options
context:
space:
mode:
Diffstat (limited to 'service')
-rw-r--r--service/pixelated/adapter/soledad/soledad_reader_mixin.py12
-rw-r--r--service/pixelated/resources/mail_resource.py12
2 files changed, 15 insertions, 9 deletions
diff --git a/service/pixelated/adapter/soledad/soledad_reader_mixin.py b/service/pixelated/adapter/soledad/soledad_reader_mixin.py
index dab38376..631a8414 100644
--- a/service/pixelated/adapter/soledad/soledad_reader_mixin.py
+++ b/service/pixelated/adapter/soledad/soledad_reader_mixin.py
@@ -61,13 +61,15 @@ class SoledadReaderMixin(SoledadDbFacadeMixin, object):
def mail_exists(self, ident):
return self.get_flags_by_chash(ident)
+ @defer.inlineCallbacks
def mail(self, ident):
- fdoc = self.get_flags_by_chash(ident)
- hdoc = self.get_header_by_chash(ident)
- bdoc = self.get_content_by_phash(hdoc.content['body'])
- parts = self._extract_parts(hdoc.content)
+ fdoc = yield self.get_flags_by_chash(ident)
+ hdoc = yield self.get_header_by_chash(ident)
+ bdoc = yield self.get_content_by_phash(hdoc.content['body'])
+ parts = yield self._extract_parts(hdoc.content)
- return PixelatedMail.from_soledad(fdoc, hdoc, bdoc, parts=parts, soledad_querier=self)
+ mail = PixelatedMail.from_soledad(fdoc, hdoc, bdoc, parts=parts, soledad_querier=self)
+ defer.returnValue(mail)
@defer.inlineCallbacks
def mails(self, idents):
diff --git a/service/pixelated/resources/mail_resource.py b/service/pixelated/resources/mail_resource.py
index dff594b0..40d6aa89 100644
--- a/service/pixelated/resources/mail_resource.py
+++ b/service/pixelated/resources/mail_resource.py
@@ -1,7 +1,7 @@
import json
-from pixelated.resources import respond_json
+from pixelated.resources import respond_json, respond_json_deferred
from twisted.web.resource import Resource
-
+from twisted.web.server import NOT_DONE_YET
class MailTags(Resource):
@@ -31,8 +31,12 @@ class Mail(Resource):
self._mail_service = mail_service
def render_GET(self, request):
- mail = self._mail_service.mail(self._mail_id)
- return respond_json(mail.as_dict(), request)
+ d = self._mail_service.mail(self._mail_id)
+
+ response = lambda mail: respond_json_deferred(mail.as_dict(), request)
+ d.addCallback(response)
+
+ return NOT_DONE_YET
def render_DELETE(self, request):
self._mail_service.delete_mail(self._mail_id)