diff options
author | Victor Shyba <victor.shyba@gmail.com> | 2015-08-25 18:36:51 -0300 |
---|---|---|
committer | Victor Shyba <victor.shyba@gmail.com> | 2015-08-25 18:36:51 -0300 |
commit | 7c385309dfe9fcfbbad012d46f44e0b19aee82b1 (patch) | |
tree | 90c49779e8871a182c79edcf6a4b9361ac13a85a /service/pixelated/resources | |
parent | 552a0471a2223f4d48e1a81ad9a51385deafc0ca (diff) |
[refactor] remove mailbox references
Extracted listener logic and removed remaining mailboxes references
Issues
-- #439
-- #440
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): |