diff options
-rw-r--r-- | service/pixelated/adapter/services/mail_service.py | 3 | ||||
-rw-r--r-- | service/pixelated/resources/attachments_resource.py | 13 |
2 files changed, 13 insertions, 3 deletions
diff --git a/service/pixelated/adapter/services/mail_service.py b/service/pixelated/adapter/services/mail_service.py index 5ec3a298..d2506dcf 100644 --- a/service/pixelated/adapter/services/mail_service.py +++ b/service/pixelated/adapter/services/mail_service.py @@ -152,6 +152,5 @@ class MailService(object): def delete_permanent(self, mail_id): yield self.mail_store.delete_mail(mail_id) - @defer.inlineCallbacks def delete_attachment(self, attachment_id): - yield self.attachment_store.delete_attachment(attachment_id) + return self.attachment_store.delete_attachment(attachment_id) diff --git a/service/pixelated/resources/attachments_resource.py b/service/pixelated/resources/attachments_resource.py index db8b4df1..da455f98 100644 --- a/service/pixelated/resources/attachments_resource.py +++ b/service/pixelated/resources/attachments_resource.py @@ -73,7 +73,18 @@ class AttachmentResource(Resource): return match.group(1) def render_DELETE(self, request): - self.mail_service.delete_attachment(self.attachment_id) + def success(_): + response_json = {"ident": self.attachment_id} + respond_json_deferred(response_json, request, status_code=200) + + def failure(err): + request.code = 500 + request.finish() + + d = self.mail_service.delete_attachment(self.attachment_id) + d.addCallback(success) + d.addErrback(failure) + return server.NOT_DONE_YET class AttachmentsResource(BaseResource): |