From 1c3de25ca64a0eb81b3f9024c7718d45db1d6d66 Mon Sep 17 00:00:00 2001 From: Christian Schneppe Date: Wed, 8 Feb 2017 21:40:40 +0100 Subject: only store messages up to a length of 1M chars --- src/main/java/de/pixart/messenger/Config.java | 1 + src/main/java/de/pixart/messenger/entities/Message.java | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) (limited to 'src/main/java') diff --git a/src/main/java/de/pixart/messenger/Config.java b/src/main/java/de/pixart/messenger/Config.java index eef639e40..8b095a149 100644 --- a/src/main/java/de/pixart/messenger/Config.java +++ b/src/main/java/de/pixart/messenger/Config.java @@ -94,6 +94,7 @@ public final class Config { public static boolean PUT_AUTH_TAG_INTO_KEY = false; public static final int MAX_DISPLAY_MESSAGE_CHARS = 4096; + public static final int MAX_STORAGE_MESSAGE_CHARS = 1024 * 1024 * 1024; public static final boolean ExportLogs = true; // automatically export logs public static final int ExportLogs_Hour = 4; //valid values from 0 to 23 diff --git a/src/main/java/de/pixart/messenger/entities/Message.java b/src/main/java/de/pixart/messenger/entities/Message.java index 5a3549a95..bf53b3cd7 100644 --- a/src/main/java/de/pixart/messenger/entities/Message.java +++ b/src/main/java/de/pixart/messenger/entities/Message.java @@ -219,7 +219,7 @@ public class Message extends AbstractEntity { } else { values.put(TRUE_COUNTERPART, trueCounterpart.toPreppedString()); } - values.put(BODY, body); + values.put(BODY, body.length() > Config.MAX_STORAGE_MESSAGE_CHARS ? body.substring(0,Config.MAX_STORAGE_MESSAGE_CHARS) : body); values.put(TIME_SENT, timeSent); values.put(ENCRYPTION, encryption); values.put(STATUS, status); -- cgit v1.2.3