parse message that only contain oob tag. fixes #2359

This commit is contained in:
Daniel Gultsch 2017-04-04 22:15:38 +02:00
parent 75749d7c7b
commit b34a1f7f5e
4 changed files with 11 additions and 6 deletions

View File

@ -29,6 +29,7 @@ public abstract class AbstractGenerator {
"urn:xmpp:jingle:transports:ibb:1",
"http://jabber.org/protocol/muc",
"jabber:x:conference",
Namespace.OOB,
"http://jabber.org/protocol/caps",
"http://jabber.org/protocol/disco#info",
"urn:xmpp:avatar:metadata+notify",

View File

@ -129,7 +129,7 @@ public class MessageGenerator extends AbstractGenerator {
if (message.hasFileOnRemoteHost()) {
Message.FileParams fileParams = message.getFileParams();
content = fileParams.url.toString();
packet.addChild("x","jabber:x:oob").addChild("url").setContent(content);
packet.addChild("x",Namespace.OOB).addChild("url").setContent(content);
} else {
content = message.getBody();
}

View File

@ -372,8 +372,8 @@ public class MessageParser extends AbstractParser implements OnMessagePacketRece
final Element mucUserElement = packet.findChild("x", "http://jabber.org/protocol/muc#user");
final String pgpEncrypted = packet.findChildContent("x", "jabber:x:encrypted");
final Element replaceElement = packet.findChild("replace", "urn:xmpp:message-correct:0");
final Element oob = packet.findChild("x", "jabber:x:oob");
final boolean isOob = oob!= null && body != null && body.equals(oob.findChildContent("url"));
final Element oob = packet.findChild("x", Namespace.OOB);
final String oobUrl = oob != null ? oob.findChildContent("url") : null;
final String replacementId = replaceElement == null ? null : replaceElement.getAttribute("id");
final Element axolotlEncrypted = packet.findChild(XmppAxolotlMessage.CONTAINERTAG, AxolotlService.PEP_PREFIX);
int status;
@ -414,7 +414,7 @@ public class MessageParser extends AbstractParser implements OnMessagePacketRece
mXmppConnectionService.updateConversationUi();
}
if ((body != null || pgpEncrypted != null || axolotlEncrypted != null) && !isMucStatusMessage) {
if ((body != null || pgpEncrypted != null || axolotlEncrypted != null || oobUrl != null) && !isMucStatusMessage) {
Conversation conversation = mXmppConnectionService.findOrCreateConversation(account, counterpart.toBareJid(), isTypeGroupChat, false, query);
final boolean conversationMultiMode = conversation.getMode() == Conversation.MODE_MULTI;
@ -471,6 +471,9 @@ public class MessageParser extends AbstractParser implements OnMessagePacketRece
if (conversationMultiMode) {
message.setTrueCounterpart(origin);
}
} else if (body == null && oobUrl != null) {
message = new Message(conversation, oobUrl, Message.ENCRYPTION_NONE, status);
message.setOob(true);
} else {
message = new Message(conversation, body, Message.ENCRYPTION_NONE, status);
}
@ -480,7 +483,7 @@ public class MessageParser extends AbstractParser implements OnMessagePacketRece
message.setServerMsgId(serverMsgId);
message.setCarbon(isCarbon);
message.setTime(timestamp);
message.setOob(isOob);
message.setOob(body != null && body.equals(oobUrl));
message.markable = packet.hasChild("markable", "urn:xmpp:chat-markers:0");
if (conversationMultiMode) {
final Jid fallback = conversation.getMucOptions().getTrueCounterpart(counterpart);

View File

@ -10,4 +10,5 @@ public final class Namespace {
public static final String MAM = "urn:xmpp:mam:2";
public static final String MAM_LEGACY = "urn:xmpp:mam:0";
public static final String IDLE = "urn:xmpp:idle:1";
public static final String OOB = "jabber:x:oob";
}