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 60e5a6a Show when body has been truncated
60e5a6a is described below
commit 60e5a6a3dfc9882b2e7734b574eff9d4c2de52ee
Author: Sebb <[email protected]>
AuthorDate: Thu Oct 7 00:39:41 2021 +0100
Show when body has been truncated
---
server/plugins/messages.py | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/server/plugins/messages.py b/server/plugins/messages.py
index 322d4bc..700e861 100644
--- a/server/plugins/messages.py
+++ b/server/plugins/messages.py
@@ -42,6 +42,8 @@ DATABASE_NOT_CONNECTED = "Database not connected!"
mbox_cache_privacy: typing.Dict[str, bool] = {}
+BODY_MAXLEN = 200 # TODO: make this a config item
+
USED_UI_FIELDS = [
"private",
"list",
@@ -338,8 +340,8 @@ async def query(
doc["gravatar"] = gravatar(doc)
if not session.credentials:
doc = anonymize(doc)
- if shorten:
- doc["body"] = (doc["body"] or "")[:200]
+ if shorten and len(doc["body"] or "") > BODY_MAXLEN:
+ doc["body"] = doc["body"][:BODY_MAXLEN] + '...'
trim_email(doc)
docs.append(doc)
hits += 1