diff options
author | Alexandre Pretto Nunes <anunes@thoughtworks.com> | 2015-01-28 14:42:47 -0200 |
---|---|---|
committer | Pixpoa pairing <pixpoapairing@pixelated-project.org> | 2015-01-29 14:55:22 -0200 |
commit | 4ac714acfd3192a397028f1260c5929e80ef15b5 (patch) | |
tree | 119377886ac719318bdbe4a6b4e7533dd3fbd936 /service/pixelated/adapter | |
parent | 1af7c273015246c0cf4130278b2c17fca9de563a (diff) |
#249 make the sending process a deferred
Diffstat (limited to 'service/pixelated/adapter')
-rw-r--r-- | service/pixelated/adapter/services/mail_sender.py | 4 | ||||
-rw-r--r-- | service/pixelated/adapter/services/mail_service.py | 12 |
2 files changed, 11 insertions, 5 deletions
diff --git a/service/pixelated/adapter/services/mail_sender.py b/service/pixelated/adapter/services/mail_sender.py index 50c17ba5..1c2d7ce1 100644 --- a/service/pixelated/adapter/services/mail_sender.py +++ b/service/pixelated/adapter/services/mail_sender.py @@ -35,4 +35,6 @@ class MailSender(): file=StringIO(mail.to_smtp_format()), deferred=resultDeferred) - return reactor.connectTCP('localhost', 4650, senderFactory) + reactor.connectTCP('localhost', 4650, senderFactory) + + return resultDeferred 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() |