diff options
author | Folker Bernitt <fbernitt@thoughtworks.com> | 2015-08-09 22:09:08 +0200 |
---|---|---|
committer | Folker Bernitt <fbernitt@thoughtworks.com> | 2015-08-11 17:00:33 +0200 |
commit | 46ed5e1731fa0295a7f4b612457069db36bb8e64 (patch) | |
tree | f7b1d81e19f1e86d40c605910063e86feef6eb73 /service/pixelated/adapter/services | |
parent | 319e5e2ddd20444bb30f294a2fd08854dfaae494 (diff) |
Worked on integration tests.
Diffstat (limited to 'service/pixelated/adapter/services')
-rw-r--r-- | service/pixelated/adapter/services/draft_service.py | 21 | ||||
-rw-r--r-- | service/pixelated/adapter/services/mail_service.py | 20 |
2 files changed, 26 insertions, 15 deletions
diff --git a/service/pixelated/adapter/services/draft_service.py b/service/pixelated/adapter/services/draft_service.py index 5a0ee5f3..c3a14928 100644 --- a/service/pixelated/adapter/services/draft_service.py +++ b/service/pixelated/adapter/services/draft_service.py @@ -17,18 +17,23 @@ from twisted.internet import defer class DraftService(object): - __slots__ = '_mailboxes' + __slots__ = '_mail_store' - def __init__(self, mailboxes): - self._mailboxes = mailboxes + def __init__(self, mail_store): + self._mail_store = mail_store @defer.inlineCallbacks def create_draft(self, input_mail): - pixelated_mail = yield (yield self._mailboxes.drafts).add(input_mail) - defer.returnValue(pixelated_mail) + mail = yield self._mail_store.add_mail('DRAFTS', input_mail.raw) + defer.returnValue(mail) + # pixelated_mail = yield (yield self._mailboxes.drafts).add(input_mail) + # defer.returnValue(pixelated_mail) @defer.inlineCallbacks def update_draft(self, ident, input_mail): - pixelated_mail = yield self.create_draft(input_mail) - yield (yield self._mailboxes.drafts).remove(ident) - defer.returnValue(pixelated_mail) + new_draft = yield self.create_draft(input_mail) + yield self._mail_store.delete_mail(ident) + defer.returnValue(new_draft) + # pixelated_mail = yield self.create_draft(input_mail) + # yield (yield self._mailboxes.drafts).remove(ident) + # defer.returnValue(pixelated_mail) diff --git a/service/pixelated/adapter/services/mail_service.py b/service/pixelated/adapter/services/mail_service.py index 6b011e11..1d161958 100644 --- a/service/pixelated/adapter/services/mail_service.py +++ b/service/pixelated/adapter/services/mail_service.py @@ -15,6 +15,7 @@ # along with Pixelated. If not, see <http://www.gnu.org/licenses/>. from twisted.internet import defer from pixelated.adapter.model.mail import InputMail +from pixelated.adapter.model.status import Status from pixelated.adapter.services.tag_service import extract_reserved_tags @@ -77,7 +78,11 @@ class MailService(object): @defer.inlineCallbacks def mail_exists(self, mail_id): - defer.returnValue(not(not((yield self.querier.get_header_by_chash(mail_id))))) + try: + mail = yield self.mail_store.get_mail(mail_id) + defer.returnValue(mail is not None) + except Exception, e: + defer.returnValue(False) @defer.inlineCallbacks def send_mail(self, content_dict): @@ -91,20 +96,21 @@ class MailService(object): @defer.inlineCallbacks def move_to_sent(self, last_draft_ident, mail): if last_draft_ident: - yield (yield self.mailboxes.drafts).remove(last_draft_ident) - defer.returnValue((yield (yield self.mailboxes.sent).add(mail))) + yield self.mail_store.delete_mail(last_draft_ident) + sent_mail = yield self.mail_store.add_mail('SENT', mail.raw) + defer.returnValue(sent_mail) @defer.inlineCallbacks def mark_as_read(self, mail_id): mail = yield self.mail(mail_id) - yield mail.mark_as_read() - self.search_engine.index_mail(mail) + mail.flags.add(Status.SEEN) + yield self.mail_store.update_mail(mail) @defer.inlineCallbacks def mark_as_unread(self, mail_id): mail = yield self.mail(mail_id) - yield mail.mark_as_unread() - self.search_engine.index_mail(mail) + mail.flags.remove(Status.SEEN) + yield self.mail_store.update_mail(mail) @defer.inlineCallbacks def delete_mail(self, mail_id): |