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 cf04c44 Avoid crash with metadata_only=True
cf04c44 is described below
commit cf04c441deeae063241eec9dc2e70615ca33a542
Author: Sebb <[email protected]>
AuthorDate: Sun Nov 14 12:08:01 2021 +0000
Avoid crash with metadata_only=True
In that case, body and body_short don't exist
---
server/plugins/messages.py | 11 ++++++-----
1 file changed, 6 insertions(+), 5 deletions(-)
diff --git a/server/plugins/messages.py b/server/plugins/messages.py
index b99feb8..29cc2a4 100644
--- a/server/plugins/messages.py
+++ b/server/plugins/messages.py
@@ -386,11 +386,12 @@ async def query(
doc["gravatar"] = gravatar(doc)
if not session.credentials:
doc = anonymize(doc)
- 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"]
+ if not metadata_only:
+ 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"]
trim_email(doc)
docs.append(doc)
hits += 1