diff --git a/froide/helper/email_log_parsing.py b/froide/helper/email_log_parsing.py index 8b0ae3151..83e2a9961 100644 --- a/froide/helper/email_log_parsing.py +++ b/froide/helper/email_log_parsing.py @@ -22,7 +22,7 @@ class PostfixLogfileParser(collections.abc.Iterator): DEFAULT_RELEVANT_FIELDS = {"message-id", "from", "to", "status", "removed"} QUEUE_ID_REGEX = r"(?P[0-9A-F]{6,}|[0-9a-zA-Z]{12,})" - TIMESTAMP_RE = r"(?P\w{3}\s+\d+\s+\d+:\d+:\d+)" + TIMESTAMP_RE = r"(?P(\w{3}\s+\d+\s+\d+:\d+:\d+)|(\d{4}-[01]\d-[0-3]\dT[0-2]\d:[0-5]\d:[0-5]\d\.\d+([+-][0-2]\d:[0-5]\d|Z)))" USER_RE = r"(?P[^ ]+)" PROCESS_RE = r"(?P[^:]+)" FIELDS_RE = r"(?P.*)" diff --git a/froide/helper/tests/test_email_log_parsing.py b/froide/helper/tests/test_email_log_parsing.py index 97821a4f5..a7f687b86 100644 --- a/froide/helper/tests/test_email_log_parsing.py +++ b/froide/helper/tests/test_email_log_parsing.py @@ -274,3 +274,18 @@ def test_bouncing_email(req_with_msgs: FoiRequest): assert ( ProblemReport.objects.filter(message=msg).count() == problem_reports_before + 1 ) + + +def test_isodate(): + invocations = [] + + def callback(**kwargs): + invocations.append(kwargs) + + email_left_queue.connect(callback) + assert len(invocations) == 0 + with tempfile.TemporaryDirectory() as dir: + check_delivery_from_log([p("maillog_007.txt")], Path(dir + "/mail_log.offset")) + assert len(invocations) == 1 + + assert invocations[0]["message_id"] == MAIL_1_ID diff --git a/froide/helper/tests/testdata/maillog_007.txt b/froide/helper/tests/testdata/maillog_007.txt new file mode 100644 index 000000000..345b26de5 --- /dev/null +++ b/froide/helper/tests/testdata/maillog_007.txt @@ -0,0 +1,10 @@ +2025-01-01T00:01:02.456789+01:00 mail postfix/smtpd[1234567]: 163CB3EE5E7F: client=localhost.localdomain[127.0.0.1], sasl_method=PLAIN, sasl_username=examplemail@example.com +2025-01-08T10:29:21.062584+01:00 mail postfix/cleanup[2345678]: 163CB3EE5E7F: message-id= +2025-01-01T00:01:02.456789+01:00 mail opendkim[2345678]: 163CB3EE5E7F: DKIM-Signature field added (s=mail, d=example.com) +2025-01-01T00:01:02.456789+01:00 mail postfix/qmgr[2345678]: 163CB3EE5E7F: from=, size=12321, nrcpt=1 (queue active) +2025-01-01T00:01:02.456789+01:00 mail postfix/smtp[2345678]: 163CB3EE5E7F: to=, relay=example.com[123.456.789.123]:25, delay=0.67, delays=0.1/0.37/0.13/0.07, dsn=2.0.0, status=sent (250 Requested mail action okay, completed: id=aaaaa-bbbbb-ccccc-ddddd +) +2025-01-01T00:01:02.456789+01:00 mail postfix/qmgr[2345678]: 163CB3EE5E7F: removed +2025-01-01T00:01:02.456789+01:00 mail postfix/smtpd[2345678]: 065AB16D682C: client=localhost.localdomain[127.0.0.1], sasl_method=PLAIN, sasl_username=examplemail@example.com +2025-01-01T00:01:02.456789+01:00 mail postfix/cleanup[2345678]: 065AB16D682C: message-id= +2025-01-01T00:01:02.456789+01:00 mail opendkim[2345678]: 065AB16D682C: DKIM-Signature field added (s=mail, d=example.com)