You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@ponymail.apache.org by sebb <se...@gmail.com> on 2021/09/16 15:04:43 UTC
Re: [incubator-ponymail-foal] branch master updated: fake a From line
if none found.
On Thu, 16 Sept 2021 at 01:54, <hu...@apache.org> 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 <hu...@apache.org>
> 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
Re: [incubator-ponymail-foal] branch master updated: fake a From line
if none found.
Posted by Daniel Gruno <hu...@apache.org>.
I've updated the function and incorporated your suggestions.
Let me know if this addresses your concerns.
On 17/09/2021 18.21, sebb wrote:
> On Thu, 16 Sept 2021 at 16:04, sebb <se...@gmail.com> wrote:
>>
>> On Thu, 16 Sept 2021 at 01:54, <hu...@apache.org> 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 <hu...@apache.org>
>>> 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
>
> Furthermore, rather than using what appears to be a valid time (i.e.
> now) if the date cannot be parsed, it would be better to use a date
> such as 1/1/1970 to better indicate that the timestamp is not known.
>
>>> # Convert to mboxrd format
>>> mboxrd_source = ""
>>> line_no = 0
Re: [incubator-ponymail-foal] branch master updated: fake a From line
if none found.
Posted by sebb <se...@gmail.com>.
On Thu, 16 Sept 2021 at 16:04, sebb <se...@gmail.com> wrote:
>
> On Thu, 16 Sept 2021 at 01:54, <hu...@apache.org> 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 <hu...@apache.org>
> > 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
Furthermore, rather than using what appears to be a valid time (i.e.
now) if the date cannot be parsed, it would be better to use a date
such as 1/1/1970 to better indicate that the timestamp is not known.
> > # Convert to mboxrd format
> > mboxrd_source = ""
> > line_no = 0