This is an automated email from the ASF dual-hosted git repository. sebb pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/incubator-ponymail-foal.git
commit 7eb007a17b3fe368ec4d12ae94192da35eda30f5 Author: Sebb <[email protected]> AuthorDate: Tue Jan 4 01:45:36 2022 +0000 Simplify and eliminate unnecessary fetch message-id must be accompanied by list id and vice-versa --- server/endpoints/email.py | 12 +++++++----- server/endpoints/source.py | 10 ++++++---- server/endpoints/thread.py | 8 ++++++-- 3 files changed, 19 insertions(+), 11 deletions(-) diff --git a/server/endpoints/email.py b/server/endpoints/email.py index f23508e..affe4ca 100644 --- a/server/endpoints/email.py +++ b/server/endpoints/email.py @@ -32,12 +32,14 @@ async def process( server: plugins.server.BaseServer, session: plugins.session.SessionObject, indata: dict, ) -> typing.Union[dict, aiohttp.web.Response]: - # First, assume permalink and look up the email based on that - email = await plugins.messages.get_email(session, permalink=indata.get("id")) + # Has a list id been provided? + listid = indata.get("list", "") - # If not found via permalink, it might be message-id instead, so try that - if email is None: - email = await plugins.messages.get_email(session, messageid=indata.get("id"), listid=indata.get("list", "")) + # lookup by message id must always include a list id for disambiguation + if listid: + email = await plugins.messages.get_email(session, messageid=indata.get("id"), listid=listid) + else: # Else assume permalink and look up the email based on that + email = await plugins.messages.get_email(session, permalink=indata.get("id")) if email is None: return aiohttp.web.Response(headers={}, status=404, text="Email not found") diff --git a/server/endpoints/source.py b/server/endpoints/source.py index 0a071b4..0b7e24e 100644 --- a/server/endpoints/source.py +++ b/server/endpoints/source.py @@ -27,13 +27,15 @@ import plugins.aaa async def process( server: plugins.server.BaseServer, session: plugins.session.SessionObject, indata: dict, ) -> aiohttp.web.Response: + + # Has a list id been provided? listid = indata.get("list", "") - # First, assume permalink and look up the email based on that - email = await plugins.messages.get_email(session, permalink=indata.get("id")) - # If not found via permalink, it might be message-id instead, so try that - if email is None: + # lookup by message id must always include a list id for disambiguation + if listid: email = await plugins.messages.get_email(session, messageid=indata.get("id"), listid=listid) + else: # Else assume permalink and look up the email based on that + email = await plugins.messages.get_email(session, permalink=indata.get("id")) if email and isinstance(email, dict) and not email.get("deleted"): if plugins.aaa.can_access_email(session, email): diff --git a/server/endpoints/thread.py b/server/endpoints/thread.py index b8dbe94..6ee9fab 100644 --- a/server/endpoints/thread.py +++ b/server/endpoints/thread.py @@ -28,9 +28,13 @@ async def process( ) -> typing.Optional[dict]: mailid = indata.get("id", "") listid = indata.get("list", "") - email = await plugins.messages.get_email(session, permalink=mailid) - if not email: + + # lookup by message id must always include a list id for disambiguation + if listid: email = await plugins.messages.get_email(session, messageid=mailid, listid=listid) + else: # Else assume permalink and look up the email based on that + email = await plugins.messages.get_email(session, permalink=mailid) + # The id is passed via the path thread/id # This means that + is converted into space # So we need to try both space and '+', and hope no msg ids contain both
