Limit small message size

pull/185/head
M66B 5 years ago
parent c8864d08d3
commit 0b7918a077

@ -2845,11 +2845,11 @@ class Core {
if (download && message.size != null && !message.ui_hide) { if (download && message.size != null && !message.ui_hide) {
long maxSize; long maxSize;
if (state == null || state.networkState.isUnmetered()) if (state == null || state.networkState.isUnmetered())
maxSize = MessageHelper.DEFAULT_DOWNLOAD_SIZE; maxSize = MessageHelper.SMALL_MESSAGE_SIZE;
else { else {
maxSize = prefs.getInt("download", MessageHelper.DEFAULT_DOWNLOAD_SIZE); maxSize = prefs.getInt("download", MessageHelper.DEFAULT_DOWNLOAD_SIZE);
if (maxSize == 0) if (maxSize == 0 || maxSize > MessageHelper.SMALL_MESSAGE_SIZE)
maxSize = MessageHelper.DEFAULT_DOWNLOAD_SIZE; maxSize = MessageHelper.SMALL_MESSAGE_SIZE;
} }
if (message.size < maxSize) { if (message.size < maxSize) {

@ -113,6 +113,7 @@ public class MessageHelper {
private static File cacheDir = null; private static File cacheDir = null;
static final int SMALL_MESSAGE_SIZE = 192 * 1024; // bytes
static final int DEFAULT_DOWNLOAD_SIZE = 256 * 1024; // bytes static final int DEFAULT_DOWNLOAD_SIZE = 256 * 1024; // bytes
static final String HEADER_CORRELATION_ID = "X-Correlation-ID"; static final String HEADER_CORRELATION_ID = "X-Correlation-ID";

Loading…
Cancel
Save