From fc8a5641db962ae7df14e7aad4a6319d765c939d Mon Sep 17 00:00:00 2001 From: Daniel Gultsch Date: Sat, 2 Dec 2017 18:11:03 +0100 Subject: [PATCH] MAM: assume true counterpart is safe to extract when using mam:2 --- src/main/java/eu/siacs/conversations/Config.java | 2 -- .../java/eu/siacs/conversations/parser/MessageParser.java | 4 ++-- .../siacs/conversations/services/MessageArchiveService.java | 4 ++++ 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/main/java/eu/siacs/conversations/Config.java b/src/main/java/eu/siacs/conversations/Config.java index 511af46f6..0011f1386 100644 --- a/src/main/java/eu/siacs/conversations/Config.java +++ b/src/main/java/eu/siacs/conversations/Config.java @@ -100,8 +100,6 @@ public final class Config { public static final boolean IGNORE_ID_REWRITE_IN_MUC = true; - public static final boolean PARSE_REAL_JID_FROM_MUC_MAM = false; //dangerous if server doesn’t filter - public static final long MAM_MAX_CATCHUP = MILLISECONDS_IN_DAY * 5; public static final int MAM_MAX_MESSAGES = 750; diff --git a/src/main/java/eu/siacs/conversations/parser/MessageParser.java b/src/main/java/eu/siacs/conversations/parser/MessageParser.java index 2b84e4e31..7fcf6b971 100644 --- a/src/main/java/eu/siacs/conversations/parser/MessageParser.java +++ b/src/main/java/eu/siacs/conversations/parser/MessageParser.java @@ -506,8 +506,8 @@ public class MessageParser extends AbstractParser implements OnMessagePacketRece Jid trueCounterpart; if (message.getEncryption() == Message.ENCRYPTION_AXOLOTL) { trueCounterpart = message.getTrueCounterpart(); - } else if (Config.PARSE_REAL_JID_FROM_MUC_MAM) { - trueCounterpart = getTrueCounterpart(query != null ? mucUserElement : null, fallback); + } else if (query != null && query.safeToExtractTrueCounterpart()) { + trueCounterpart = getTrueCounterpart(mucUserElement, fallback); } else { trueCounterpart = fallback; } diff --git a/src/main/java/eu/siacs/conversations/services/MessageArchiveService.java b/src/main/java/eu/siacs/conversations/services/MessageArchiveService.java index 9f28acdfb..ef5c6755d 100644 --- a/src/main/java/eu/siacs/conversations/services/MessageArchiveService.java +++ b/src/main/java/eu/siacs/conversations/services/MessageArchiveService.java @@ -354,6 +354,10 @@ public class MessageArchiveService implements OnAdvancedStreamFeaturesLoaded { } } + public boolean safeToExtractTrueCounterpart() { + return muc() && !isLegacy(); + } + public Query next(String reference) { Query query = page(reference); query.pagingOrder = PagingOrder.NORMAL;