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/09 09:18:55 UTC

[incubator-ponymail-foal] 01/02: look for other permalinks if not found initially

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 22cc4cf6130513ddc9e0c16e3b485cf1ac3265e6
Author: Daniel Gruno <hu...@apache.org>
AuthorDate: Wed Sep 9 11:08:56 2020 +0200

    look for other permalinks if not found initially
---
 server/plugins/mbox.py | 14 +++++++++++++-
 1 file changed, 13 insertions(+), 1 deletion(-)

diff --git a/server/plugins/mbox.py b/server/plugins/mbox.py
index 787c99a..1610f1c 100644
--- a/server/plugins/mbox.py
+++ b/server/plugins/mbox.py
@@ -167,8 +167,20 @@ async def get_email(
                     doc = anonymize(doc)
                 doc["_source"]["id"] = doc["_source"]["mid"]
                 return doc["_source"]
+        # Email not found through primary ID, look for other permalinks?
         except plugins.database.DBError:
-            pass
+            res = await session.database.search(
+                index=doctype,
+                size=1,
+                body={"query": {"bool": {"must": [{aggtype: {"permalinks": permalink}}]}}},
+            )
+            if len(res["hits"]["hits"]) == 1:
+                doc = res["hits"]["hits"][0]["_source"]
+                doc["id"] = doc["mid"]
+                if plugins.aaa.can_access_email(session, doc):
+                    if not session.credentials:
+                        doc = anonymize(doc)
+                    return doc
     elif messageid:
         res = await session.database.search(
             index=doctype,