This is an automated email from the ASF dual-hosted git repository.

quantranhong1999 pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/james-project.git


The following commit(s) were added to refs/heads/master by this push:
     new 452df84d1e JAMES-4227 Allow controlling JMAP message preview length
452df84d1e is described below

commit 452df84d1e0850f3d8f7d48b04540d9f24719f42
Author: Benoit TELLIER <[email protected]>
AuthorDate: Sat Sep 5 21:10:12 2026 +0200

    JAMES-4227 Allow controlling JMAP message preview length
---
 docs/modules/servers/partials/configure/jvm.adoc    | 21 +++++++++++++++++++++
 .../sample-configuration/jvm.properties             |  5 +++++
 .../org/apache/james/jmap/api/model/Preview.java    | 20 +++++++++++++++++++-
 3 files changed, 45 insertions(+), 1 deletion(-)

diff --git a/docs/modules/servers/partials/configure/jvm.adoc 
b/docs/modules/servers/partials/configure/jvm.adoc
index 76cfa72e55..e2418d40af 100644
--- a/docs/modules/servers/partials/configure/jvm.adoc
+++ b/docs/modules/servers/partials/configure/jvm.adoc
@@ -78,6 +78,27 @@ james.blob.id.hash.encoding=base16
 
 Optional. String. Defaults to base64Url.
 
+== Change the length of JMAP previews
+
+A JMAP preview keeps the first 256 characters of the text body of a message, 
so that clients can render a
+message list without fetching bodies. The property `james.jmap.preview.length` 
changes that, in
+characters.
+
+Ex in `jvm.properties`
+----
+james.jmap.preview.length=128
+----
+
+Optional. Strictly positive integer. Defaults to 256.
+
+Previews are the heaviest per message projection James stores in Cassandra, 
ahead of any single mailbox
+metadata column, so halving them is the shortest path to a smaller 
`messageFastViewProjection` table.
+Weigh it against how many characters your JMAP clients actually display: most 
message lists show two
+lines at most.
+
+Lowering it only affects previews computed afterwards. Those already stored 
keep their length until the
+message is reindexed, so the space comes back progressively rather than at 
once.
+
 == Improve listing support for MinIO
 
 Due to blobs being stored in folder, adding `/` in blobs name emulates folder 
and avoids blobs to be all stored in a
diff --git a/server/apps/distributed-app/sample-configuration/jvm.properties 
b/server/apps/distributed-app/sample-configuration/jvm.properties
index 4c1ce91297..ce4087873b 100644
--- a/server/apps/distributed-app/sample-configuration/jvm.properties
+++ b/server/apps/distributed-app/sample-configuration/jvm.properties
@@ -96,6 +96,11 @@ jmx.remote.x.mlet.allow.getMBeansFromURL=false
 # Be careful turning on this as `%` and `*` are ambiguous for the LIST / LSUB 
commands that interpret those as wildcard thus returning all mailboxes matching 
the pattern.
 #james.relaxed.mailbox.name.validation=true
 
+# Characters of the text body kept in a JMAP preview. Strictly positive, 
defaults to 256.
+# Previews are the heaviest per message projection stored in Cassandra: 
halving this halves the
+# messageFastViewProjection table. Only applies to previews computed 
afterwards.
+# james.jmap.preview.length=128
+
 # Count of octet from which hashing shall be done out of the IO threads in 
deduplicating blob store
 # james.deduplicating.blobstore.thread.switch.threshold=32768
 # Count of octet from which streams are buffered to files and not to memory
diff --git 
a/server/data/data-jmap/src/main/java/org/apache/james/jmap/api/model/Preview.java
 
b/server/data/data-jmap/src/main/java/org/apache/james/jmap/api/model/Preview.java
index 53c923498f..6faaad5645 100644
--- 
a/server/data/data-jmap/src/main/java/org/apache/james/jmap/api/model/Preview.java
+++ 
b/server/data/data-jmap/src/main/java/org/apache/james/jmap/api/model/Preview.java
@@ -89,7 +89,25 @@ public class Preview {
 
     public static final Preview EMPTY = Preview.from("");
 
-    private static final int MAX_LENGTH = 256;
+    public static final String MAX_LENGTH_PROPERTY = 
"james.jmap.preview.length";
+    public static final int DEFAULT_MAX_LENGTH = 256;
+
+    /**
+     * How many characters of the text body a preview keeps.
+     *
+     * <p>Previews are the heaviest per message projection James stores, so 
shortening them is a
+     * straightforward way to trade list rendering for storage. Lowering it 
only affects previews computed
+     * afterwards: the ones already stored keep their length until they are 
recomputed.</p>
+     */
+    private static final int MAX_LENGTH = maxLength();
+
+    @VisibleForTesting
+    static int maxLength() {
+        int maxLength = Integer.getInteger(MAX_LENGTH_PROPERTY, 
DEFAULT_MAX_LENGTH);
+        Preconditions.checkArgument(maxLength > 0,
+            "'%s' must be strictly positive, got %s", MAX_LENGTH_PROPERTY, 
maxLength);
+        return maxLength;
+    }
 
     public static Preview from(String value) {
         return new Preview(value);


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to