summaryrefslogtreecommitdiff
path: root/service/pixelated/adapter/services/mail_service.py
diff options
context:
space:
mode:
authorAlexandre Pretto Nunes <anunes@thoughtworks.com>2015-01-28 14:42:47 -0200
committerPixpoa pairing <pixpoapairing@pixelated-project.org>2015-01-29 14:55:22 -0200
commit4ac714acfd3192a397028f1260c5929e80ef15b5 (patch)
tree119377886ac719318bdbe4a6b4e7533dd3fbd936 /service/pixelated/adapter/services/mail_service.py
parent1af7c273015246c0cf4130278b2c17fca9de563a (diff)
#249 make the sending process a deferred
Diffstat (limited to 'service/pixelated/adapter/services/mail_service.py')
-rw-r--r--service/pixelated/adapter/services/mail_service.py12
1 files changed, 8 insertions, 4 deletions
diff --git a/service/pixelated/adapter/services/mail_service.py b/service/pixelated/adapter/services/mail_service.py
index 3b70890b..26b4e162 100644
--- a/service/pixelated/adapter/services/mail_service.py
+++ b/service/pixelated/adapter/services/mail_service.py
@@ -45,10 +45,14 @@ class MailService:
return not(not(self.querier.get_header_by_chash(mail_id)))
def send(self, last_draft_ident, mail):
- self.mail_sender.sendmail(mail)
- if last_draft_ident:
- self.mailboxes.drafts().remove(last_draft_ident)
- return self.mailboxes.sent().add(mail)
+ result = self.mail_sender.sendmail(mail)
+
+ def success(_):
+ if last_draft_ident:
+ self.mailboxes.drafts().remove(last_draft_ident)
+ return self.mailboxes.sent().add(mail)
+ result.addCallback(success)
+ return result
def mark_as_read(self, mail_id):
return self.mail(mail_id).mark_as_read()