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 50b4ea1  Revert; does not help clarity
50b4ea1 is described below

commit 50b4ea1dc414e81bd4bb4b1e6fa264c7bdb8bd04
Author: Sebb <[email protected]>
AuthorDate: Mon Nov 15 11:16:55 2021 +0000

    Revert; does not help clarity
---
 server/endpoints/stats.py       | 3 +--
 server/plugins/configuration.py | 1 -
 server/plugins/messages.py      | 8 +++++---
 3 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/server/endpoints/stats.py b/server/endpoints/stats.py
index 71fbe5c..c243aaf 100644
--- a/server/endpoints/stats.py
+++ b/server/endpoints/stats.py
@@ -47,8 +47,7 @@ async def process(
     except AssertionError as e:  # If defuzzer encounters syntax errors, it 
will throw an AssertionError
         return aiohttp.web.Response(headers={"content-type": "text/plain",}, 
status=500, text=str(e))
     results = await plugins.messages.query(
-        session, query_defuzzed, query_limit=server.config.database.max_hits,
-        body_max_len=server.config.ui.BODY_MAXLEN,
+        session, query_defuzzed, query_limit=server.config.database.max_hits, 
shorten=True,
     )
 
     # statsOnly: Whether to only send statistical info (for n-grams etc), and 
not the
diff --git a/server/plugins/configuration.py b/server/plugins/configuration.py
index 8e0c444..7fd47a5 100644
--- a/server/plugins/configuration.py
+++ b/server/plugins/configuration.py
@@ -41,7 +41,6 @@ class UIConfig:
     mgmt_enabled: bool
     focus_domain: str
     fully_delete: bool
-    BODY_MAXLEN = 200  # largest body to show in thread display
 
     def __init__(self, subyaml: dict):
         self.wordcloud = bool(subyaml.get("wordcloud", False))
diff --git a/server/plugins/messages.py b/server/plugins/messages.py
index 1884baf..404fa33 100644
--- a/server/plugins/messages.py
+++ b/server/plugins/messages.py
@@ -45,6 +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
+
 # Only these fields are returned by the API:
 # (keep this list sorted)
 USED_UI_FIELDS = [
@@ -349,7 +351,7 @@ async def query(
     session: plugins.session.SessionObject,
     query_defuzzed,
     query_limit=10000,
-    body_max_len=None,
+    shorten=False,
     hide_deleted=True,
     metadata_only=False,
     epoch_order="desc"
@@ -386,8 +388,8 @@ async def query(
             if not session.credentials:
                 doc = anonymize(doc)
             if not metadata_only:
-                if body_max_len and len(doc["body_short"] or "") > 
body_max_len:
-                    doc["body"] = doc["body_short"][:body_max_len] + '...'
+                if shorten and len(doc["body_short"] or "") > BODY_MAXLEN:
+                    doc["body"] = doc["body_short"][:BODY_MAXLEN] + '...'
                 else:
                     doc["body"] = doc["body_short"]
                 del doc["body_short"]

Reply via email to