You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ponymail.apache.org by hu...@apache.org on 2020/09/07 09:44:27 UTC

[incubator-ponymail-foal] branch master updated (c46652b -> 842c59a)

This is an automated email from the ASF dual-hosted git repository.

humbedooh pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-ponymail-foal.git.


    from c46652b  Add OAuth endpoint
     new cf1d36b  use the right path for the exception class
     new 28cddb7  this is an array now, as per archiver.py
     new 6e1ecac  look up via message-id if we must, comment
     new 8293c90  fix typing hints
     new 842c59a  this should support lookups via message-id as well, for old times sake

The 5 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 server/endpoints/email.py  | 11 +++++++++--
 server/endpoints/source.py |  7 ++++++-
 server/plugins/mbox.py     |  5 +++--
 tools/import-mbox.py       |  2 +-
 4 files changed, 19 insertions(+), 6 deletions(-)


[incubator-ponymail-foal] 01/05: use the right path for the exception class

Posted by hu...@apache.org.
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

commit cf1d36be6cdef5a8efe3e67886e51d39dbaae400
Author: Daniel Gruno <hu...@apache.org>
AuthorDate: Mon Sep 7 11:35:44 2020 +0200

    use the right path for the exception class
---
 server/plugins/mbox.py | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/server/plugins/mbox.py b/server/plugins/mbox.py
index 2f46399..a3ac061 100644
--- a/server/plugins/mbox.py
+++ b/server/plugins/mbox.py
@@ -35,6 +35,7 @@ from elasticsearch.helpers import async_scan
 
 import plugins.aaa
 import plugins.session
+import plugins.database
 
 PYPONY_RE_PREFIX = re.compile(r"^([a-zA-Z]+:\s*)+")
 
@@ -165,7 +166,7 @@ async def get_email(
                     doc = anonymize(doc)
                 doc["_source"]["id"] = doc["_source"]["mid"]
                 return doc["_source"]
-        except session.database.DBError:
+        except plugins.database.DBError:
             pass
     elif messageid:
         res = await session.database.search(
@@ -202,7 +203,7 @@ async def get_source(session: plugins.session.SessionObject, permalink: str = No
     try:
         doc = await session.database.get(index=doctype, id=permalink)
         return doc
-    except session.database.DBError:
+    except plugins.database.DBError:
         pass
     res = await session.database.search(
         index=doctype,


[incubator-ponymail-foal] 05/05: this should support lookups via message-id as well, for old times sake

Posted by hu...@apache.org.
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

commit 842c59a19d62e800c2c290499f28cff40f4c6d77
Author: Daniel Gruno <hu...@apache.org>
AuthorDate: Mon Sep 7 11:44:15 2020 +0200

    this should support lookups via message-id as well, for old times sake
---
 server/endpoints/source.py | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/server/endpoints/source.py b/server/endpoints/source.py
index 6164694..c298667 100644
--- a/server/endpoints/source.py
+++ b/server/endpoints/source.py
@@ -29,8 +29,13 @@ async def process(
     session: plugins.session.SessionObject,
     indata: dict,
 ) -> aiohttp.web.Response:
-
+    # First, assume permalink and look up the email based on that
     email = await plugins.mbox.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:
+        email = await plugins.mbox.get_email(session, messageid=indata.get("id"))
+    
     if email and isinstance(email, dict):
         if plugins.aaa.can_access_email(session, email):
             source = await plugins.mbox.get_source(session, permalink=email["mid"])


[incubator-ponymail-foal] 03/05: look up via message-id if we must, comment

Posted by hu...@apache.org.
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

commit 6e1ecac076e830defdc027ceda1fc2fbc00c1a55
Author: Daniel Gruno <hu...@apache.org>
AuthorDate: Mon Sep 7 11:42:20 2020 +0200

    look up via message-id if we must, comment
---
 server/endpoints/email.py | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/server/endpoints/email.py b/server/endpoints/email.py
index f12a4f2..b2de0b3 100644
--- a/server/endpoints/email.py
+++ b/server/endpoints/email.py
@@ -32,7 +32,14 @@ async def process(
     indata: dict,
 ) -> dict:
 
+    # First, assume permalink and look up the email based on that
     email = await plugins.mbox.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:
+        email = await plugins.mbox.get_email(session, messageid=indata.get("id"))
+
+    # If email was found, process the request if we are allowed to display it
     if email and isinstance(email, dict):
         if plugins.aaa.can_access_email(session, email):
             # Are we fetching an attachment?


[incubator-ponymail-foal] 02/05: this is an array now, as per archiver.py

Posted by hu...@apache.org.
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

commit 28cddb7e0858bf91315d134c8e2775b5d4c464d3
Author: Daniel Gruno <hu...@apache.org>
AuthorDate: Mon Sep 7 11:36:19 2020 +0200

    this is an array now, as per archiver.py
---
 tools/import-mbox.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/import-mbox.py b/tools/import-mbox.py
index 821749a..6b0360a 100755
--- a/tools/import-mbox.py
+++ b/tools/import-mbox.py
@@ -313,7 +313,7 @@ class SlurpThread(Thread):
                     try:  # temporary hack to try and find an encoding issue
                         # needs to be replaced by proper exception handling
                         json_source = {
-                            "permalink": json["mid"],
+                            "permalinks": json["permalinks"],
                             "mid": json["dbid"],
                             "message-id": json["message-id"],
                             "source": archiver.mbox_source(message_raw),


[incubator-ponymail-foal] 04/05: fix typing hints

Posted by hu...@apache.org.
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

commit 8293c908f721917f950939b01a9020d9502d675a
Author: Daniel Gruno <hu...@apache.org>
AuthorDate: Mon Sep 7 11:42:55 2020 +0200

    fix typing hints
    
    This can be both JSON and a custom response
---
 server/endpoints/email.py | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/server/endpoints/email.py b/server/endpoints/email.py
index b2de0b3..aed6703 100644
--- a/server/endpoints/email.py
+++ b/server/endpoints/email.py
@@ -24,13 +24,13 @@ import plugins.mbox
 import aiohttp.web
 import plugins.aaa
 import base64
-
+import typing
 
 async def process(
     server: plugins.server.BaseServer,
     session: plugins.session.SessionObject,
     indata: dict,
-) -> dict:
+) -> typing.Union[dict, aiohttp.web.Response]:
 
     # First, assume permalink and look up the email based on that
     email = await plugins.mbox.get_email(session, permalink=indata.get("id"))