summaryrefslogtreecommitdiff
path: root/service/pixelated/adapter
diff options
context:
space:
mode:
authorVictor Shyba <victor.shyba@gmail.com>2015-11-23 19:51:12 -0300
committerVictor Shyba <victor.shyba@gmail.com>2015-11-23 19:51:12 -0300
commit27e3ca71f920083e8bf1599facc2cc4638f8efcf (patch)
tree2b1da538e01c110df510ab58b766106124abfc48 /service/pixelated/adapter
parent82c16b35798537302fecbf40ed76b0051e23ddb3 (diff)
Return 422 if deletion failed
This is needed for protecting against concurrent saves on drafts. --Issue #512
Diffstat (limited to 'service/pixelated/adapter')
-rw-r--r--service/pixelated/adapter/mailstore/leap_mailstore.py2
-rw-r--r--service/pixelated/adapter/mailstore/searchable_mailstore.py3
-rw-r--r--service/pixelated/adapter/services/draft_service.py7
3 files changed, 8 insertions, 4 deletions
diff --git a/service/pixelated/adapter/mailstore/leap_mailstore.py b/service/pixelated/adapter/mailstore/leap_mailstore.py
index f59034b8..3bf27bbf 100644
--- a/service/pixelated/adapter/mailstore/leap_mailstore.py
+++ b/service/pixelated/adapter/mailstore/leap_mailstore.py
@@ -291,6 +291,8 @@ class LeapMailStore(MailStore):
message = yield self._fetch_msg_from_soledad(mail_id)
if message and message.get_wrapper().mdoc.doc_id:
yield message.get_wrapper().delete(self.soledad)
+ defer.returnValue(True)
+ defer.returnValue(False)
@defer.inlineCallbacks
def get_mailbox_mail_ids(self, mailbox_name):
diff --git a/service/pixelated/adapter/mailstore/searchable_mailstore.py b/service/pixelated/adapter/mailstore/searchable_mailstore.py
index 0c5310eb..07e99ba7 100644
--- a/service/pixelated/adapter/mailstore/searchable_mailstore.py
+++ b/service/pixelated/adapter/mailstore/searchable_mailstore.py
@@ -39,8 +39,9 @@ class SearchableMailStore(object): # implementes MailStore
@defer.inlineCallbacks
def delete_mail(self, mail_id):
- yield self._delegate.delete_mail(mail_id)
+ removed = yield self._delegate.delete_mail(mail_id)
self._search_engine.remove_from_index(mail_id)
+ defer.returnValue(removed)
@defer.inlineCallbacks
def update_mail(self, mail):
diff --git a/service/pixelated/adapter/services/draft_service.py b/service/pixelated/adapter/services/draft_service.py
index 70cc9136..98444442 100644
--- a/service/pixelated/adapter/services/draft_service.py
+++ b/service/pixelated/adapter/services/draft_service.py
@@ -29,6 +29,7 @@ class DraftService(object):
@defer.inlineCallbacks
def update_draft(self, ident, input_mail):
- yield self._mail_store.delete_mail(ident)
- new_draft = yield self.create_draft(input_mail)
- defer.returnValue(new_draft)
+ removed = yield self._mail_store.delete_mail(ident)
+ if removed:
+ new_draft = yield self.create_draft(input_mail)
+ defer.returnValue(new_draft)