From: Trenton Holmes <797416+stumpylog@users.noreply.github.com> Date: Sat, 31 Dec 2022 16:35:52 +0000 (-0800) Subject: Check for and handle the mail's date being naive X-Git-Tag: v1.11.3~1^2~1 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=28b26eb4c7468a74eab512e51bb2f93bccc0cf8a;p=thirdparty%2Fpaperless-ngx.git Check for and handle the mail's date being naive --- diff --git a/src/paperless_mail/parsers.py b/src/paperless_mail/parsers.py index d50217f2e8..cc5d4e3c80 100644 --- a/src/paperless_mail/parsers.py +++ b/src/paperless_mail/parsers.py @@ -8,6 +8,8 @@ import requests from bleach import clean from bleach import linkify from django.conf import settings +from django.utils.timezone import is_naive +from django.utils.timezone import make_aware from documents.parsers import DocumentParser from documents.parsers import make_thumbnail_from_pdf from documents.parsers import ParseError @@ -135,7 +137,11 @@ class MailDocumentParser(DocumentParser): self.text += f"\n\n{strip_text(mail.text)}" - self.date = mail.date + if is_naive(mail.date): + self.date = make_aware(mail.date) + else: + self.date = mail.date + self.archive_path = self.generate_pdf(document_path) def tika_parse(self, html: str):