diff --git a/deploy/patches/37/0009-fix-dont-crash-if-no-email-events-for-the-record.patch b/deploy/patches/37/0009-fix-dont-crash-if-no-email-events-for-the-record.patch new file mode 100644 index 0000000..7ff0370 --- /dev/null +++ b/deploy/patches/37/0009-fix-dont-crash-if-no-email-events-for-the-record.patch @@ -0,0 +1,22 @@ +From 26b366735f4e5cb1daa180973abd54a4102d5405 Mon Sep 17 00:00:00 2001 +From: Marc Calvo +Date: Tue, 27 Aug 2024 10:13:27 +0200 +Subject: [PATCH] fix dont crash if no email_events for the record + +--- + poweremail_signaturit/poweremail_mailbox.py | 2 ++ + 1 file changed, 2 insertions(+) + +diff --git a/poweremail_signaturit/poweremail_mailbox.py b/poweremail_signaturit/poweremail_mailbox.py +index ef92b27..b9ae780 100644 +--- a/poweremail_signaturit/poweremail_mailbox.py ++++ b/poweremail_signaturit/poweremail_mailbox.py +@@ -60,6 +60,8 @@ def update_poweremail_certificate( + for certificate in res.get("certificates", []): # Hauria de ser nomes 1 pero bueno + for event in certificate.get("events", []): # Ens guardem tots els events que ha tingut el email + email_events.append((event['created_at'], event["type"])) ++ if not email_events: ++ return False + # Si un dels events es que s'ha arrivat al estat get_email_opened_state, ja en tenim prou amb aixo + if final_certificat_state in [x[1] for x in email_events]: + certificat_state_to_write = final_certificat_state diff --git a/poweremail_references/poweremail_mailbox.py b/poweremail_references/poweremail_mailbox.py index 1530b8e..3e870a4 100644 --- a/poweremail_references/poweremail_mailbox.py +++ b/poweremail_references/poweremail_mailbox.py @@ -76,16 +76,6 @@ def restrict_write_callback_from_previous_emails(self, cursor, uid, ref, func, v restrict = False return restrict - def get_certificate_email_ids_with_same_ref(self, cursor, uid, ref, context=None): - if context is None: - context = {} - email_ids = self.search(cursor, uid, [ - ('certificat', '=', True), - ('reference', '=', ref) - ], context=context) - email_ids.sort(reverse=True) - return email_ids - def create(self, cursor, uid, vals, context=None): if context is None: context = {}