diff options
author | Folker Bernitt <fbernitt@thoughtworks.com> | 2015-07-21 15:12:41 +0000 |
---|---|---|
committer | Folker Bernitt <fbernitt@thoughtworks.com> | 2015-08-11 17:00:27 +0200 |
commit | 8d62e433994e65484f97dd4f89b2e4279ce4b3dd (patch) | |
tree | 9972fb585d16c91f807dd8cc509a283e57ed69b9 /service/pixelated | |
parent | ba1d6edfc144c0549e88392a8414a147a9f30931 (diff) |
Fixed test_mark_as_read_unread.py.
Diffstat (limited to 'service/pixelated')
-rw-r--r-- | service/pixelated/adapter/services/mail_service.py | 2 | ||||
-rw-r--r-- | service/pixelated/resources/mails_resource.py | 10 |
2 files changed, 9 insertions, 3 deletions
diff --git a/service/pixelated/adapter/services/mail_service.py b/service/pixelated/adapter/services/mail_service.py index 91eeb28f..b66d7345 100644 --- a/service/pixelated/adapter/services/mail_service.py +++ b/service/pixelated/adapter/services/mail_service.py @@ -97,7 +97,7 @@ class MailService(object): @defer.inlineCallbacks def mark_as_unread(self, mail_id): mail = yield self.mail(mail_id) - mail.mark_as_unread() + yield mail.mark_as_unread() self.search_engine.index_mail(mail) def delete_mail(self, mail_id): diff --git a/service/pixelated/resources/mails_resource.py b/service/pixelated/resources/mails_resource.py index 0651a909..27232ffc 100644 --- a/service/pixelated/resources/mails_resource.py +++ b/service/pixelated/resources/mails_resource.py @@ -21,9 +21,15 @@ class MailsUnreadResource(Resource): def render_POST(self, request): idents = json.load(request.content).get('idents') + deferreds = [] for ident in idents: - self._mail_service.mark_as_unread(ident) - return respond_json(None, request) + deferreds.append(self._mail_service.mark_as_unread(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 MailsReadResource(Resource): |