From 9e7643588e124290879a9ae82f20fa628a9c090a Mon Sep 17 00:00:00 2001 From: Duda Dornelles Date: Tue, 3 Feb 2015 18:58:13 -0200 Subject: Movinge MailsResource#render_POST logic to MailService and some search_engine calls to Mailbox --- service/pixelated/adapter/services/mail_service.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'service/pixelated/adapter/services/mail_service.py') diff --git a/service/pixelated/adapter/services/mail_service.py b/service/pixelated/adapter/services/mail_service.py index ab0b16bd..da74c0ef 100644 --- a/service/pixelated/adapter/services/mail_service.py +++ b/service/pixelated/adapter/services/mail_service.py @@ -13,6 +13,7 @@ # # You should have received a copy of the GNU Affero General Public License # along with Pixelated. If not, see . +from pixelated.adapter.model.mail import InputMail class MailService: @@ -47,10 +48,16 @@ class MailService: def mail_exists(self, mail_id): return not(not(self.querier.get_header_by_chash(mail_id))) - def send(self, mail): + def send_mail(self, content_dict): + mail = InputMail.from_dict(content_dict) + draft_id = content_dict.get('ident') + self.mail_sender.sendmail(mail) + sent_mail = self.move_to_sent(draft_id, mail) + + return sent_mail - def move_to_send(self, last_draft_ident, mail): + def move_to_sent(self, last_draft_ident, mail): if last_draft_ident: self.mailboxes.drafts().remove(last_draft_ident) return self.mailboxes.sent().add(mail) -- cgit v1.2.3