summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--service/pixelated/adapter/mailstore/leap_mailstore.py18
-rw-r--r--service/pixelated/adapter/mailstore/searchable_mailstore.py2
-rw-r--r--service/test/integration/test_contacts.py4
-rw-r--r--service/test/support/integration/model.py3
4 files changed, 27 insertions, 0 deletions
diff --git a/service/pixelated/adapter/mailstore/leap_mailstore.py b/service/pixelated/adapter/mailstore/leap_mailstore.py
index a27ce5c4..6dad12b0 100644
--- a/service/pixelated/adapter/mailstore/leap_mailstore.py
+++ b/service/pixelated/adapter/mailstore/leap_mailstore.py
@@ -162,6 +162,24 @@ class LeapMail(Mail):
return [recipient for recipient in recipients if recipient != InputMail.FROM_EMAIL_ADDRESS]
+ @property
+ def bounced(self):
+ # TODO: Must be implemented for the search engine identify bounced mails
+ return False
+
+ @staticmethod
+ def from_dict(mail_dict):
+ # TODO: implement this method and also write tests for it
+ headers = {key.capitalize(): value for key, value in mail_dict.get('header', {}).items()}
+ headers['Date'] = date.iso_now()
+ body = mail_dict.get('body', '')
+ tags = set(mail_dict.get('tags', []))
+ status = set(mail_dict.get('status', []))
+ attachments = []
+
+ # mail_id, mailbox_name, headers=None, tags=set(), flags=set(), body=None, attachments=[]
+ return LeapMail(None, None, headers, tags, set(), body, attachments)
+
def _extract_filename(content_disposition):
match = re.compile('.*name=\"(.*)\".*').search(content_disposition)
diff --git a/service/pixelated/adapter/mailstore/searchable_mailstore.py b/service/pixelated/adapter/mailstore/searchable_mailstore.py
index 0c5310eb..8ffc41b8 100644
--- a/service/pixelated/adapter/mailstore/searchable_mailstore.py
+++ b/service/pixelated/adapter/mailstore/searchable_mailstore.py
@@ -34,6 +34,8 @@ class SearchableMailStore(object): # implementes MailStore
@defer.inlineCallbacks
def add_mail(self, mailbox_name, mail):
stored_mail = yield self._delegate.add_mail(mailbox_name, mail)
+ # the stored_mail dont't have a content type needed for identify
+ # that the email is bounced or not, but this header is setted on input_mail
self._search_engine.index_mail(stored_mail)
defer.returnValue(stored_mail)
diff --git a/service/test/integration/test_contacts.py b/service/test/integration/test_contacts.py
index 98c2e6f6..148f614c 100644
--- a/service/test/integration/test_contacts.py
+++ b/service/test/integration/test_contacts.py
@@ -84,11 +84,15 @@ class ContactsTest(SoledadTestBase):
bounced_hdoc = self._bounced_mail_hdoc_content()
bounced_mail_template = MailBuilder().build_input_mail()
bounced_mail_template.headers.update(bounced_hdoc["headers"])
+ # TODO: must add attachments to bounced_mail_template
+ yield self.add_mail_to_inbox(bounced_mail_template)
not_bounced_mail = MailBuilder(
).with_tags(['important']).with_to('this_mail_was_not@bounced.com').build_input_mail()
yield self.add_mail_to_inbox(not_bounced_mail)
+ mails = yield self.mail_service.all_mails()
+ self.search_engine.index_mails(mails)
contacts = yield self.get_contacts(query='this')
self.assertNotIn('this_mail_was_bounced@domain.com', contacts)
diff --git a/service/test/support/integration/model.py b/service/test/support/integration/model.py
index 93b5969b..8b6f9759 100644
--- a/service/test/support/integration/model.py
+++ b/service/test/support/integration/model.py
@@ -80,6 +80,9 @@ class MailBuilder:
def build_input_mail(self):
return InputMail.from_dict(self.mail)
+ def build_leap_mail(self):
+ return LeapMail.from_dict(self.mail)
+
class ResponseMail:
def __init__(self, mail_dict):