summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBruno Wagner <bwagner@riseup.net>2015-09-10 16:16:20 -0300
committerBruno Wagner <bwagner@riseup.net>2015-09-10 16:16:20 -0300
commit63b8dee422c196f9993435f53417df23828e054f (patch)
tree8a1e569c934137dee9e69e1120e01f1ba2650514
parent8d2dac75d667818ea28abc0c25f45e4ce4b3f6c8 (diff)
Removed bounced email contact removal (#441)
This feature was never working anyway. Anybody could remove addresses from anyones adressbook by sending a bounce and then the receiver was not able to send an email to that address anymore. Nice dos :)
-rw-r--r--service/pixelated/adapter/mailstore/leap_mailstore.py5
-rw-r--r--service/pixelated/adapter/mailstore/searchable_mailstore.py2
-rw-r--r--service/pixelated/adapter/model/mail.py4
-rw-r--r--service/pixelated/adapter/search/__init__.py3
-rw-r--r--service/pixelated/adapter/search/contacts.py11
-rw-r--r--service/test/integration/test_contacts.py30
6 files changed, 1 insertions, 54 deletions
diff --git a/service/pixelated/adapter/mailstore/leap_mailstore.py b/service/pixelated/adapter/mailstore/leap_mailstore.py
index b7c6d0ff..5357167b 100644
--- a/service/pixelated/adapter/mailstore/leap_mailstore.py
+++ b/service/pixelated/adapter/mailstore/leap_mailstore.py
@@ -165,11 +165,6 @@ 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
diff --git a/service/pixelated/adapter/mailstore/searchable_mailstore.py b/service/pixelated/adapter/mailstore/searchable_mailstore.py
index 8ffc41b8..0c5310eb 100644
--- a/service/pixelated/adapter/mailstore/searchable_mailstore.py
+++ b/service/pixelated/adapter/mailstore/searchable_mailstore.py
@@ -34,8 +34,6 @@ 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/pixelated/adapter/model/mail.py b/service/pixelated/adapter/model/mail.py
index 31eb0654..9f2db32e 100644
--- a/service/pixelated/adapter/model/mail.py
+++ b/service/pixelated/adapter/model/mail.py
@@ -85,10 +85,6 @@ class Mail(object):
# FIXME mbox is no longer available, instead we now have mbox_uuid
return self.fdoc.content.get('mbox', 'INBOX')
- @property
- def bounced(self):
- return False
-
def _encode_header_value_list(self, header_value_list):
return [self._encode_header_value(v) for v in header_value_list]
diff --git a/service/pixelated/adapter/search/__init__.py b/service/pixelated/adapter/search/__init__.py
index 84e69a9a..0c86582d 100644
--- a/service/pixelated/adapter/search/__init__.py
+++ b/service/pixelated/adapter/search/__init__.py
@@ -102,7 +102,6 @@ class SearchEngine(object):
to=KEYWORD(stored=False, commas=True),
cc=KEYWORD(stored=False, commas=True),
bcc=KEYWORD(stored=False, commas=True),
- bounced=KEYWORD(stored=False, commas=True),
subject=TEXT(stored=False),
date=NUMERIC(stored=False, sortable=True, bits=64, signed=False),
body=TEXT(stored=False),
@@ -123,7 +122,6 @@ class SearchEngine(object):
header = mdict['header']
tags = set(mdict.get('tags', {}))
tags.add(mail.mailbox_name.lower())
- bounced = mail.bounced if mail.bounced else ['']
index_data = {
'sender': self._empty_string_to_none(header.get('from', '')),
@@ -133,7 +131,6 @@ class SearchEngine(object):
'cc': self._format_recipient(header, 'cc'),
'bcc': self._format_recipient(header, 'bcc'),
'tag': u','.join(unique(tags)),
- 'bounced': u','.join(bounced),
'body': unicode(mdict['textPlainBody'] if 'textPlainBody' in mdict else mdict['body']),
'ident': unicode(mdict['ident']),
'flags': unicode(','.join(unique(mail.flags))),
diff --git a/service/pixelated/adapter/search/contacts.py b/service/pixelated/adapter/search/contacts.py
index 0dfeb15b..0729e146 100644
--- a/service/pixelated/adapter/search/contacts.py
+++ b/service/pixelated/adapter/search/contacts.py
@@ -31,21 +31,12 @@ def address_duplication_filter(contacts):
return contacts_by_mail.values()
-def bounced_addresses_filter(searcher, contacts):
- query = QueryParser('bounced', searcher.schema).parse('*')
- bounced_addresses = searcher.search(query,
- limit=None,
- groupedby=sorting.FieldFacet('bounced',
- allow_overlap=True)).groups()
- return set(contacts) - set(flatten([bounced_addresses]))
-
-
def extract_mail_address(text):
return parseaddr(text)[1]
def contacts_suggestions(query, searcher):
- return address_duplication_filter(bounced_addresses_filter(searcher, search_addresses(searcher, query))) if query else []
+ return address_duplication_filter(search_addresses(searcher, query)) if query else []
def search_addresses(searcher, query):
diff --git a/service/test/integration/test_contacts.py b/service/test/integration/test_contacts.py
index 148f614c..4a0957a8 100644
--- a/service/test/integration/test_contacts.py
+++ b/service/test/integration/test_contacts.py
@@ -74,33 +74,3 @@ class ContactsTest(SoledadTestBase):
self.assertTrue('Recipient Principal <recipient@to.com>' in contacts)
self.assertTrue('Recipient Copied <recipient@cc.com>' in contacts)
self.assertTrue('Recipient Carbon <recipient@bcc.com>' in contacts)
-
- @defer.inlineCallbacks
- def test_bounced_addresses_are_ignored(self):
- self.skipTest("bounced mails filter still needs to be migrated")
- to_be_bounced = MailBuilder().with_to('this_mail_was_bounced@domain.com').build_input_mail()
- yield self.add_mail_to_inbox(to_be_bounced)
-
- 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)
- self.assertNotIn("MAILER-DAEMON@domain.org (Mail Delivery System)", contacts)
- self.assertIn('this_mail_was_not@bounced.com', contacts)
-
- def _bounced_mail_hdoc_content(self):
- hdoc_file = pkg_resources.resource_filename('test.unit.fixtures', 'bounced_mail_hdoc.json')
- with open(hdoc_file) as f:
- hdoc = json.loads(f.read())
- return hdoc