aboutsummaryrefslogtreecommitdiffstats
path: root/src/main
diff options
context:
space:
mode:
authorChristian Schneppe <christian@pix-art.de>2018-01-21 14:59:39 +0100
committerChristian Schneppe <christian@pix-art.de>2018-01-21 14:59:39 +0100
commit319bf1eefb6f9128823e27827c66907758a7d914 (patch)
tree39534a59b9e740eb9d29ca301bb7b564884e5c9a /src/main
parentaf5445ad103e1eda066924c816eef4067a4d7228 (diff)
treat key transport messages differently to not open empty conversations
Diffstat (limited to 'src/main')
-rw-r--r--src/main/java/de/pixart/messenger/parser/MessageParser.java27
1 files changed, 25 insertions, 2 deletions
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) {