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/10 15:00:25 UTC
[incubator-ponymail-foal] 03/03: trim away the _* fields from what
we return in the UI
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 32c7cf841a0587e6f9c53e2ead11b4f34e4bb83c
Author: Daniel Gruno <hu...@apache.org>
AuthorDate: Thu Sep 10 17:00:00 2020 +0200
trim away the _* fields from what we return in the UI
We don't need the meta fields for UI operations.
---
server/plugins/mbox.py | 10 ++++++++++
1 file changed, 10 insertions(+)
diff --git a/server/plugins/mbox.py b/server/plugins/mbox.py
index 338d82f..87f6fdb 100644
--- a/server/plugins/mbox.py
+++ b/server/plugins/mbox.py
@@ -42,6 +42,13 @@ PYPONY_RE_PREFIX = re.compile(r"^([a-zA-Z]+:\s*)+")
mbox_cache_privacy: typing.Dict[str, bool] = {}
+def trim_email(doc):
+ """Trims away document fields not used by the UI"""
+ for header in doc.keys():
+ if header.startswith('_'):
+ del doc[header]
+
+
def extract_name(addr):
""" Extract name and email from from: header """
m = re.match(r"^([^<]+)\s*<(.+)>$", addr)
@@ -196,6 +203,7 @@ async def get_email(
if doc and plugins.aaa.can_access_email(session, doc):
if not session.credentials:
doc = anonymize(doc)
+ trim_email(doc)
return doc
# multi-doc return?
@@ -207,6 +215,7 @@ async def get_email(
if doc and plugins.aaa.can_access_email(session, doc):
if not session.credentials:
doc = anonymize(doc)
+ trim_email(doc)
docs_returned.append(doc)
return docs_returned
# no doc?
@@ -289,6 +298,7 @@ async def query(
doc = anonymize(doc)
if shorten:
doc["body"] = (doc["body"] or "")[:200]
+ trim_email(doc)
docs.append(doc)
hits += 1
if hits > query_limit: