From 1793c07b7d65b73f75d11c77afc5f33b7ecc6c3f Mon Sep 17 00:00:00 2001 From: Squeaky Date: Thu, 16 Mar 2023 11:21:15 +0100 Subject: [PATCH] Don't break on missing categories --- inbox/models/thread.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/inbox/models/thread.py b/inbox/models/thread.py index 996eb8c43..11a22a2c3 100644 --- a/inbox/models/thread.py +++ b/inbox/models/thread.py @@ -117,9 +117,11 @@ def most_recent_sent_date(self): sorted_messages = sorted( self.messages, key=lambda m: m.received_date, reverse=True ) - for m in sorted_messages: - if "sent" in [c.name for c in m.categories] or (m.is_draft and m.is_sent): - sent_recent_date = m.received_date + for message in sorted_messages: + if "sent" in [ + category.name for category in message.categories if category + ] or (message.is_draft and message.is_sent): + sent_recent_date = message.received_date return sent_recent_date @property