diff options
Diffstat (limited to 'service/pixelated/resources')
-rw-r--r-- | service/pixelated/resources/mails_resource.py | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/service/pixelated/resources/mails_resource.py b/service/pixelated/resources/mails_resource.py index e18fe2c3..ce05ff3a 100644 --- a/service/pixelated/resources/mails_resource.py +++ b/service/pixelated/resources/mails_resource.py @@ -2,7 +2,7 @@ import json from pixelated.adapter.services.mail_sender import SMTPDownException from pixelated.adapter.model.mail import InputMail from twisted.web.server import NOT_DONE_YET -from pixelated.resources import respond_json, respond_json_deferred +from pixelated.resources import respond_json_deferred from twisted.web.resource import Resource from twisted.web import server from twisted.internet import defer @@ -85,9 +85,13 @@ class MailsRecoverResource(Resource): def render_POST(self, request): idents = json.loads(request.content.read())['idents'] + deferreds = [] for ident in idents: - self._mail_service.recover_mail(ident) - return respond_json(None, request) + deferreds.append(self._mail_service.recover_mail(ident)) + d = defer.gatherResults(deferreds, consumeErrors=True) + d.addCallback(lambda _: respond_json_deferred(None, request)) + d.addErrback(lambda _: respond_json_deferred(None, request, status_code=500)) + return NOT_DONE_YET class MailsResource(Resource): |