diff options
author | Daniel Gultsch <daniel@gultsch.de> | 2015-06-28 22:14:40 +0200 |
---|---|---|
committer | Daniel Gultsch <daniel@gultsch.de> | 2015-06-28 22:14:40 +0200 |
commit | 0d01e51da5333cfbc3ac2cb0e381180823203e1b (patch) | |
tree | ab8ce6913df5f1ef4759dae639ed058a45ee8574 /src | |
parent | 46595b6d43679f17cb8e374b2120ab7889423555 (diff) |
don't parse body from muc status messages
Diffstat (limited to 'src')
-rw-r--r-- | src/main/java/eu/siacs/conversations/parser/MessageParser.java | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/src/main/java/eu/siacs/conversations/parser/MessageParser.java b/src/main/java/eu/siacs/conversations/parser/MessageParser.java index 946e4b6f..5a40b170 100644 --- a/src/main/java/eu/siacs/conversations/parser/MessageParser.java +++ b/src/main/java/eu/siacs/conversations/parser/MessageParser.java @@ -233,13 +233,15 @@ public class MessageParser extends AbstractParser implements } final String body = packet.getBody(); final String encrypted = packet.findChildContent("x", "jabber:x:encrypted"); + final Element mucUserElement = packet.findChild("x","http://jabber.org/protocol/muc#user"); int status; final Jid counterpart; final Jid to = packet.getTo(); final Jid from = packet.getFrom(); final String remoteMsgId = packet.getId(); boolean isTypeGroupChat = packet.getType() == MessagePacket.TYPE_GROUPCHAT; - boolean properlyAddressed = !to.isBareJid() || account.countPresences() == 1; + boolean isProperlyAddressed = !to.isBareJid() || account.countPresences() == 1; + boolean isMucStatusMessage = from.isBareJid() && mucUserElement != null && mucUserElement.hasChild("status"); if (packet.fromAccount(account)) { status = Message.STATUS_SEND; counterpart = to; @@ -262,7 +264,7 @@ public class MessageParser extends AbstractParser implements mXmppConnectionService.updateConversationUi(); } - if (body != null || encrypted != null) { + if ((body != null || encrypted != null) && !isMucStatusMessage) { Conversation conversation = mXmppConnectionService.findOrCreateConversation(account, counterpart.toBareJid(), isTypeGroupChat); if (isTypeGroupChat) { if (counterpart.getResourcepart().equals(conversation.getMucOptions().getActualNick())) { @@ -283,7 +285,7 @@ public class MessageParser extends AbstractParser implements } Message message; if (body != null && body.startsWith("?OTR")) { - if (!isForwarded && !isTypeGroupChat && properlyAddressed) { + if (!isForwarded && !isTypeGroupChat && isProperlyAddressed) { message = parseOtrChat(body, from, remoteMsgId, conversation); if (message == null) { return; @@ -375,9 +377,8 @@ public class MessageParser extends AbstractParser implements } } - final Element x = packet.findChild("x", "http://jabber.org/protocol/muc#user"); - if (conversation != null && x != null && from.isBareJid()) { - for (Element child : x.getChildren()) { + if (conversation != null && isMucStatusMessage) { + for (Element child : mucUserElement.getChildren()) { if (child.getName().equals("status") && MucOptions.STATUS_CODE_ROOM_CONFIG_CHANGED.equals(child.getAttribute("code"))) { mXmppConnectionService.fetchConferenceConfiguration(conversation); |