You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@ponymail.apache.org by GitBox <gi...@apache.org> on 2021/09/18 16:06:28 UTC

[GitHub] [incubator-ponymail-foal] Humbedooh commented on a change in pull request #58: Look for dates on envelope and in headers if Date is missing or invalid

Humbedooh commented on a change in pull request #58:
URL: https://github.com/apache/incubator-ponymail-foal/pull/58#discussion_r711608540



##########
File path: tools/archiver.py
##########
@@ -482,15 +482,31 @@ def default_empty_string(value):
             message_date = email.utils.parsedate_tz(
                 str(msg_metadata.get("archived-at"))
             )
-
         if not message_date:
-            epoch = time.time()
+            print("No message date could be derived from the Date: header, looking elsewhere.")
+            # See if we have a "From" header line in the raw email, we can use
+            first_line = raw_msg.split(b"\n", 1)[0].decode("us-ascii")
+            if first_line.startswith("From "):
+                # If we have one, the date must be the third element when splitting by single space.
+                env_from_date = first_line.split(" ", 2)[-1]  # Split twice, grab last element.
+                message_date = email.utils.parsedate_tz(env_from_date)
+                if message_date:

Review comment:
       if the date cannot be parsed, the function returns None. it does not raise an exception.
   If that's not what you asked about, I'd appreciate some context




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@ponymail.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org