From bc91495d7b70e74bd432c7a0bd745278a6f11e4b Mon Sep 17 00:00:00 2001 From: Christian Larsen Date: Tue, 18 May 2021 14:00:05 +0100 Subject: [PATCH] Deal with combinations of lack of recipients I have edge cases for mails that have combinations of no to recipients, no cc recipients, or neither. Add in a bit of logic to deal with those cases. This isn't elegant, but it _seems_ to work. --- calrules/item.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/calrules/item.py b/calrules/item.py index 73fddca..329d35c 100644 --- a/calrules/item.py +++ b/calrules/item.py @@ -47,7 +47,14 @@ def hydrate(self, item: BaseMeetingItem): self.subject = item.subject self.sender = item.sender.email_address - to_recipients = item.to_recipients if item.cc_recipients is None else item.to_recipients + item.cc_recipients + if item.to_recipients is None and item.cc_recipients is None: + to_recipients = [] + elif item.cc_recipients is None: + to_recipients = item.to_recipients + elif item.to_recipients is None: + to_recipients = item.cc_recipients + else: + to_recipients = item.to_recipients + item.cc_recipients self.recipients = [to.email_address for to in to_recipients] if isinstance(item, MeetingRequest) and item.conflicting_meeting_count > 0: