summaryrefslogtreecommitdiff
path: root/service/pixelated
diff options
context:
space:
mode:
Diffstat (limited to 'service/pixelated')
-rw-r--r--service/pixelated/adapter/services/mail_service.py2
-rw-r--r--service/pixelated/resources/mails_resource.py10
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):