You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ponymail.apache.org by se...@apache.org on 2021/12/13 23:41:46 UTC
[incubator-ponymail-foal] branch master updated (40c3a05 -> 6e0c067)
This is an automated email from the ASF dual-hosted git repository.
sebb pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-ponymail-foal.git.
from 40c3a05 update version
new 53e76e5 Split get_email method into two
new 6e0c067 Update version
The 2 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/plugins/messages.py | 65 ++++++++++++++++++++++++++++------------------
server/server_version.py | 2 +-
2 files changed, 41 insertions(+), 26 deletions(-)
[incubator-ponymail-foal] 02/02: Update version
Posted by se...@apache.org.
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 6e0c0676ea4e034c46c0cfc74218c3563dfee8a1
Author: Sebb <se...@apache.org>
AuthorDate: Mon Dec 13 23:41:36 2021 +0000
Update version
---
server/server_version.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/server/server_version.py b/server/server_version.py
index 591c35b..463b380 100644
--- a/server/server_version.py
+++ b/server/server_version.py
@@ -1,2 +1,2 @@
# This file is generated by server/update_version.sh
-PONYMAIL_SERVER_VERSION = '6838fc0'
+PONYMAIL_SERVER_VERSION = '53e76e5'
[incubator-ponymail-foal] 01/02: Split get_email method into two
Posted by se...@apache.org.
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 53e76e5f6b7631927aed6b4656f78e73acf557e5
Author: Sebb <se...@apache.org>
AuthorDate: Mon Dec 13 23:41:11 2021 +0000
Split get_email method into two
This fixes #178
---
server/plugins/messages.py | 65 ++++++++++++++++++++++++++++------------------
1 file changed, 40 insertions(+), 25 deletions(-)
diff --git a/server/plugins/messages.py b/server/plugins/messages.py
index 42cb948..fc6e173 100644
--- a/server/plugins/messages.py
+++ b/server/plugins/messages.py
@@ -170,11 +170,11 @@ async def fetch_children(session, pdoc, counter=0, pdocs=None, short=False):
counter = counter + 1
if counter > 250:
return []
- docs = await get_email(session, irt=pdoc["message-id"])
+ docs = await get_email_irt(session, pdoc["message-id"])
thread = []
emails = []
- for doc in docs or []:
+ for doc in docs:
# Make sure email is accessible
if doc.get("deleted"):
continue
@@ -212,9 +212,12 @@ async def get_email(
session: plugins.session.SessionObject,
permalink: str = None,
messageid=None,
- irt=None,
source=False,
-):
+) -> typing.Optional[dict]:
+ """
+ Returns a matching mbox or source document or None
+ The calling code is responsible for checking if the entry is accessible
+ """
assert session.database, DATABASE_NOT_CONNECTED
doctype = session.database.dbs.db_mbox
if source:
@@ -223,7 +226,6 @@ async def get_email(
# emails in DBs that may have been incorrectly analyzed.
aggtype = "match"
doc = None
- docs = None
if permalink:
try:
doc = await session.database.get(index=doctype, id=permalink)
@@ -250,14 +252,6 @@ async def get_email(
)
if len(res["hits"]["hits"]) == 1:
doc = res["hits"]["hits"][0]
- elif irt:
- xirt = '"%s"' % irt.replace('"', '\\"')
- res = await session.database.search(
- index=doctype,
- size=250,
- body={"query": {"bool": {"must": [ {"simple_query_string": { "query": xirt, "fields":["in-reply-to", "references"]}}]}}},
- )
- docs = res["hits"]["hits"]
# Did we find a single doc?
if doc and isinstance(doc, dict):
@@ -269,21 +263,42 @@ async def get_email(
doc = anonymize(doc)
return doc
- # multi-doc return?
- elif docs is not None and isinstance(docs, list):
- docs_returned = []
- for doc in docs:
- doc = doc["_source"]
- doc["id"] = doc["mid"]
- if doc and plugins.aaa.can_access_email(session, doc):
- trim_email(doc)
- if not session.credentials:
- doc = anonymize(doc)
- docs_returned.append(doc)
- return docs_returned
# no doc?
return None
+async def get_email_irt(
+ session: plugins.session.SessionObject,
+ irt,
+ source=False,
+) -> typing.List[dict]:
+ """
+ Returns a list of mbox or source document(s) that are related. May be empty.
+ The calling code is responsible for checking if entries are accessible
+ """
+ assert session.database, DATABASE_NOT_CONNECTED
+ doctype = session.database.dbs.db_mbox
+ if source:
+ doctype = session.database.dbs.db_source
+
+ xirt = '"%s"' % irt.replace('"', '\\"')
+ res = await session.database.search(
+ index=doctype,
+ size=250,
+ body={"query": {"bool": {"must": [ {"simple_query_string": { "query": xirt, "fields":["in-reply-to", "references"]}}]}}},
+ )
+ docs = res["hits"]["hits"]
+
+ docs_returned = []
+ for doc in docs:
+ doc = doc["_source"]
+ doc["id"] = doc["mid"]
+ if doc and plugins.aaa.can_access_email(session, doc):
+ trim_email(doc)
+ if not session.credentials:
+ doc = anonymize(doc)
+ docs_returned.append(doc)
+ return docs_returned
+
async def get_source(session: plugins.session.SessionObject, permalink: str = None, raw=False):
assert session.database, DATABASE_NOT_CONNECTED