diff options
author | Folker Bernitt <fbernitt@thoughtworks.com> | 2015-10-14 14:35:16 +0200 |
---|---|---|
committer | Folker Bernitt <fbernitt@thoughtworks.com> | 2015-10-14 14:35:16 +0200 |
commit | 3863e28bf593591b1b323f8b848233b9e6a1947b (patch) | |
tree | 57e3d82b3ae72216120974869cda974ab8976667 /service/pixelated/adapter/mailstore | |
parent | 79053219e55be1ddce6297d0c5eb296776b161b6 (diff) |
Support reply to mail sent by me
- Issue #491
Diffstat (limited to 'service/pixelated/adapter/mailstore')
-rw-r--r-- | service/pixelated/adapter/mailstore/leap_mailstore.py | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/service/pixelated/adapter/mailstore/leap_mailstore.py b/service/pixelated/adapter/mailstore/leap_mailstore.py index f3351dbd..ec8407a7 100644 --- a/service/pixelated/adapter/mailstore/leap_mailstore.py +++ b/service/pixelated/adapter/mailstore/leap_mailstore.py @@ -147,15 +147,26 @@ class LeapMail(Mail): sender_mail = InputMail.FROM_EMAIL_ADDRESS recipients = self._decoded_header_utf_8(self._reply_recipient('To')) - recipients.append(sender_mail) + if not self._parsed_mail_matches(sender_mail, InputMail.FROM_EMAIL_ADDRESS) or len(recipients) == 0: + recipients.append(sender_mail) recipients = self.remove_duplicates(recipients) ccs = self._decoded_header_utf_8(self._reply_recipient('Cc')) - result['single'] = sender_mail + result['single'] = self._single_reply_recipient(recipients, sender_mail) result['all']['to-field'] = recipients result['all']['cc-field'] = ccs return result + def _single_reply_recipient(self, recipients, sender_mail): + """ + Currently the domain model expects only one single recipient for reply action. But it should support an array, + or even better: there should not be any conceptual difference between reply and reply all for this logic + """ + if self._parsed_mail_matches(sender_mail, InputMail.FROM_EMAIL_ADDRESS): + return recipients[0] + else: + return sender_mail + def remove_duplicates(self, recipients): return list(set(recipients)) |