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
The following commit(s) were added to refs/heads/master by this push:
new 53452a7 Use same name for same usage
53452a7 is described below
commit 53452a767062df8cb2cb5cd4430e53911aa081db
Author: Sebb <[email protected]>
AuthorDate: Mon Nov 15 11:22:50 2021 +0000
Use same name for same usage
---
server/plugins/messages.py | 7 ++++---
tools/archiver.py | 2 +-
2 files changed, 5 insertions(+), 4 deletions(-)
diff --git a/server/plugins/messages.py b/server/plugins/messages.py
index 404fa33..0a95b67 100644
--- a/server/plugins/messages.py
+++ b/server/plugins/messages.py
@@ -45,7 +45,8 @@ ESCAPES_RE = re.compile(r'[\\"]') # Characters to escape
with backslash in make
mbox_cache_privacy: typing.Dict[str, bool] = {}
-BODY_MAXLEN = 200 # TODO: make this a config item
+# This is used to detect if the '...' truncation marker is to be added
+SHORT_BODY_MAX_LEN = 200 # This must be the same as Archiver.SHORT_BODY_MAXLEN
# Only these fields are returned by the API:
# (keep this list sorted)
@@ -388,8 +389,8 @@ async def query(
if not session.credentials:
doc = anonymize(doc)
if not metadata_only:
- if shorten and len(doc["body_short"] or "") > BODY_MAXLEN:
- doc["body"] = doc["body_short"][:BODY_MAXLEN] + '...'
+ if shorten and len(doc["body_short"] or "") >
SHORT_BODY_MAX_LEN:
+ doc["body"] = doc["body_short"][:SHORT_BODY_MAX_LEN] +
'...'
else:
doc["body"] = doc["body_short"]
del doc["body_short"]
diff --git a/tools/archiver.py b/tools/archiver.py
index f3f5cc2..79e11d1 100755
--- a/tools/archiver.py
+++ b/tools/archiver.py
@@ -72,7 +72,7 @@ else:
DEFAULT_CHARACTER_SET = 'utf-8'
# Standard "short body" max length for email aggregations
-SHORT_BODY_MAX_LEN = 200
+SHORT_BODY_MAX_LEN = 200 # This must be the same as
server.plugins.messages.SHORT_BODY_MAX_LEN
# Fetch config from same dir as archiver.py
config = ponymailconfig.PonymailConfig()