From: Gael Le Mignot Date: Tue, 24 Jun 2025 07:46:58 +0000 (+0200) Subject: More robust handling of errors and too long subjects X-Git-Url: https://git.parisson.com/?a=commitdiff_plain;h=d2c5c97a6f1b8ae9dfb7ec38dd615b051df18b84;p=teleforma.git More robust handling of errors and too long subjects --- diff --git a/teleforma/management/commands/teleforma-get-postman-replies.py b/teleforma/management/commands/teleforma-get-postman-replies.py index af8e8a18..66568bb4 100644 --- a/teleforma/management/commands/teleforma-get-postman-replies.py +++ b/teleforma/management/commands/teleforma-get-postman-replies.py @@ -23,7 +23,7 @@ def decode_header(header, charset): res = [] for value, encoding in header: if isinstance(value, bytes): - value = value.decode(encoding) + value = value.decode(encoding or charset) res.append(value) return " ".join(res) @@ -118,6 +118,9 @@ class Command(BaseCommand): if not msg.thread: msg.thread = msg msg.save() + + if len(subject) > 200: + subject = subject[:200] + "..." mess = Message(sender = msg.recipient, recipient = msg.sender, subject = subject, body = body, thread = msg.thread, @@ -148,8 +151,8 @@ class Command(BaseCommand): self.process(msg) pop.dele(msgid) except Exception as e: - self.logger.warning("Error in message %s: %s" % (msgid, str(e))) - raise + self.logger.warning("Error in message %s: %s" % (msgid, str(e)), + exc_info = e) finally: pop.quit()