On Thu, 16 Sept 2021 at 01:54, <[email protected]> wrote: > > This is an automated email from the ASF dual-hosted git repository. > > humbedooh pushed a commit to branch master > in repository https://gitbox.apache.org/repos/asf/incubator-ponymail-foal.git > > > The following commit(s) were added to refs/heads/master by this push: > new ae41562 fake a From line if none found. > ae41562 is described below > > commit ae41562bc53e84a8645d60a63aac58bd444acad9 > Author: Daniel Gruno <[email protected]> > AuthorDate: Wed Sep 15 19:54:30 2021 -0500 > > fake a From line if none found. > --- > server/endpoints/mbox.py | 5 +++++ > 1 file changed, 5 insertions(+) > > diff --git a/server/endpoints/mbox.py b/server/endpoints/mbox.py > index 001f8ce..59cfc01 100644 > --- a/server/endpoints/mbox.py > +++ b/server/endpoints/mbox.py > @@ -25,12 +25,17 @@ import re > import typing > import aiohttp.web > import asyncio.exceptions > +import time > > > async def convert_source(session: plugins.session.SessionObject, email: > dict): > source = await plugins.messages.get_source(session, > permalink=email.get("dbid", email["mid"])) > if source: > source_as_text = source["_source"]["source"] > + # Ensure it starts with "From "...or fake it > + if not source_as_text.startswith("From "): > + from_line = "From MAILER-DAEMON %s\n" % time.strftime("%a %b %d > %H:%M:%S %Y") > + source_as_text = from_line + source_as_text
-1 Unconditionally using the current time is not ideal. The LUA version extracts the time from the message if it can: https://github.com/apache/incubator-ponymail/blob/6032eff400c2549f77ff1b6682a6e4d2ab214263/site/api/mbox.lua#L44 > # Convert to mboxrd format > mboxrd_source = "" > line_no = 0
