summaryrefslogtreecommitdiff
path: root/service/pixelated
diff options
context:
space:
mode:
authorFolker Bernitt <fbernitt@thoughtworks.com>2015-10-14 11:24:12 +0200
committerFolker Bernitt <fbernitt@thoughtworks.com>2015-10-14 11:42:18 +0200
commit79053219e55be1ddce6297d0c5eb296776b161b6 (patch)
tree26924942885ffe7c5785f5ad66da6743f9c4b386 /service/pixelated
parent4549490d806b98f23561db1cfc8f689332feee04 (diff)
Parse address before filtering for reply
- Issue #491 - Now supports whitespaces, names before the address and encoded addresses
Diffstat (limited to 'service/pixelated')
-rw-r--r--service/pixelated/adapter/mailstore/leap_mailstore.py8
1 files changed, 7 insertions, 1 deletions
diff --git a/service/pixelated/adapter/mailstore/leap_mailstore.py b/service/pixelated/adapter/mailstore/leap_mailstore.py
index 0182efd9..f3351dbd 100644
--- a/service/pixelated/adapter/mailstore/leap_mailstore.py
+++ b/service/pixelated/adapter/mailstore/leap_mailstore.py
@@ -15,6 +15,7 @@
# along with Pixelated. If not, see <http://www.gnu.org/licenses/>.
import base64
from email.header import decode_header
+from email.utils import parseaddr
import quopri
from uuid import uuid4
@@ -163,7 +164,12 @@ class LeapMail(Mail):
if not recipients:
recipients = []
- return [recipient for recipient in recipients if recipient != InputMail.FROM_EMAIL_ADDRESS]
+ return [recipient for recipient in recipients if not self._parsed_mail_matches(recipient, InputMail.FROM_EMAIL_ADDRESS)]
+
+ def _parsed_mail_matches(self, to_parse, expected):
+ if InputMail.FROM_EMAIL_ADDRESS is None:
+ return False
+ return parseaddr(self._decoded_header_utf_8(to_parse))[1] == expected
@staticmethod
def from_dict(mail_dict):