From 319bf1eefb6f9128823e27827c66907758a7d914 Mon Sep 17 00:00:00 2001 From: Christian Schneppe Date: Sun, 21 Jan 2018 14:59:39 +0100 Subject: treat key transport messages differently to not open empty conversations --- .../de/pixart/messenger/parser/MessageParser.java | 27 ++++++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) (limited to 'src/main/java/de/pixart') diff --git a/src/main/java/de/pixart/messenger/parser/MessageParser.java b/src/main/java/de/pixart/messenger/parser/MessageParser.java index 7ec1f68d3..6e89482ac 100644 --- a/src/main/java/de/pixart/messenger/parser/MessageParser.java +++ b/src/main/java/de/pixart/messenger/parser/MessageParser.java @@ -422,7 +422,7 @@ public class MessageParser extends AbstractParser implements OnMessagePacketRece return; } - if ((body != null || pgpEncrypted != null || axolotlEncrypted != null || oobUrl != null) && !isMucStatusMessage) { + if ((body != null || pgpEncrypted != null || (axolotlEncrypted != null && axolotlEncrypted.hasChild("payload")) || oobUrl != null) && !isMucStatusMessage) { final Conversation conversation = mXmppConnectionService.findOrCreateConversation(account, counterpart.toBareJid(), isTypeGroupChat, false, query, false); final boolean conversationMultiMode = conversation.getMode() == Conversation.MODE_MULTI; if (serverMsgId == null) { @@ -667,10 +667,33 @@ public class MessageParser extends AbstractParser implements OnMessagePacketRece } } } else if (!packet.hasChild("body")) { //no body + final Conversation conversation = mXmppConnectionService.find(account, from.toBareJid()); + if (axolotlEncrypted != null) { + Jid origin; + if (conversation != null && conversation.getMode() == Conversation.MODE_MULTI) { + final Jid fallback = conversation.getMucOptions().getTrueCounterpart(counterpart); + origin = getTrueCounterpart(query != null ? mucUserElement : null, fallback); + if (origin == null) { + Log.d(Config.LOGTAG, "omemo key transport message in non anonymous conference received"); + return; + } + } else if (isTypeGroupChat) { + return; + } else { + origin = from; + } + try { + final XmppAxolotlMessage xmppAxolotlMessage = XmppAxolotlMessage.fromElement(axolotlEncrypted, origin.toBareJid()); + account.getAxolotlService().processReceivingKeyTransportMessage(xmppAxolotlMessage, query != null); + Log.d(Config.LOGTAG, account.getJid().toBareJid() + ": omemo key transport message received from " + origin); + } catch (Exception e) { + Log.d(Config.LOGTAG, account.getJid().toBareJid() + ": invalid omemo key transport message received " + e.getMessage()); + return; + } + } if (query == null && extractChatState(mXmppConnectionService.find(account, counterpart.toBareJid()), isTypeGroupChat, packet)) { mXmppConnectionService.updateConversationUi(); } - final Conversation conversation = mXmppConnectionService.find(account, from.toBareJid()); if (isTypeGroupChat) { if (packet.hasChild("subject")) { if (conversation != null && conversation.getMode() == Conversation.MODE_MULTI) { -- cgit v1.2.3