diff options
author | Jefferson Stachelski <jstachel@thoughtworks.com> | 2016-02-03 14:31:53 -0200 |
---|---|---|
committer | Jefferson Stachelski <jstachel@thoughtworks.com> | 2016-02-04 23:54:15 -0200 |
commit | 9442be5c230e286073244451189ffc05ae6c8083 (patch) | |
tree | e1113019780b6a7fcde3f0c7dec2991fc02b7c73 /service/pixelated | |
parent | 746069cb8fe957aa6206f4c57ec63704838546c1 (diff) |
Issue #549 - Implemented remove attachment
Diffstat (limited to 'service/pixelated')
-rw-r--r-- | service/pixelated/adapter/mailstore/leap_attachment_store.py | 6 | ||||
-rw-r--r-- | service/pixelated/adapter/services/mail_service.py | 10 | ||||
-rw-r--r-- | service/pixelated/resources/attachments_resource.py | 3 |
3 files changed, 16 insertions, 3 deletions
diff --git a/service/pixelated/adapter/mailstore/leap_attachment_store.py b/service/pixelated/adapter/mailstore/leap_attachment_store.py index 982d9222..2c004abf 100644 --- a/service/pixelated/adapter/mailstore/leap_attachment_store.py +++ b/service/pixelated/adapter/mailstore/leap_attachment_store.py @@ -63,3 +63,9 @@ class LeapAttachmentStore(object): def _calc_attachment_id_(self, content, content_type, encoder=encoders.encode_base64): cdoc = self._attachment_to_cdoc(content, content_type, encoder) return cdoc.phash + + @defer.inlineCallbacks + def delete_attachment(self, attachment_id): + doc = yield self.soledad.get_from_index('by-type-and-payloadhash', 'cnt', attachment_id) + doc = doc[0] + yield self.soledad.delete_doc(doc) diff --git a/service/pixelated/adapter/services/mail_service.py b/service/pixelated/adapter/services/mail_service.py index 2da2cca6..5ec3a298 100644 --- a/service/pixelated/adapter/services/mail_service.py +++ b/service/pixelated/adapter/services/mail_service.py @@ -35,7 +35,7 @@ class MailService(object): self.search_engine = search_engine self.mail_sender = mail_sender self.account_email = account_email - self.attchment_store = attachment_store + self.attachment_store = attachment_store @defer.inlineCallbacks def all_mails(self): @@ -43,7 +43,7 @@ class MailService(object): defer.returnValue(mails) def save_attachment(self, content, content_type): - return self.attchment_store.add_attachment(content, content_type) + return self.attachment_store.add_attachment(content, content_type) @log_time_deferred @defer.inlineCallbacks @@ -87,7 +87,7 @@ class MailService(object): return self.mail_store.get_mail(mail_id, include_body=True) def attachment(self, attachment_id): - return self.attchment_store.get_mail_attachment(attachment_id) + return self.attachment_store.get_mail_attachment(attachment_id) @defer.inlineCallbacks def mail_exists(self, mail_id): @@ -151,3 +151,7 @@ class MailService(object): @defer.inlineCallbacks 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) diff --git a/service/pixelated/resources/attachments_resource.py b/service/pixelated/resources/attachments_resource.py index 249d268a..401fb321 100644 --- a/service/pixelated/resources/attachments_resource.py +++ b/service/pixelated/resources/attachments_resource.py @@ -71,6 +71,9 @@ class AttachmentResource(Resource): match = re.compile('([A-Za-z-]+\/[A-Za-z-]+)').search(content_type) return match.group(1) + def render_DELETE(self, request): + self.mail_service.delete_attachment(self.attachment_id) + class AttachmentsResource(BaseResource): BASE_URL = 'attachment' |