diff options
author | Daniel Gultsch <daniel@gultsch.de> | 2015-04-21 18:36:11 +0200 |
---|---|---|
committer | Daniel Gultsch <daniel@gultsch.de> | 2015-04-21 18:36:11 +0200 |
commit | 3a627f72fbc5f51efaf3d8723fc7ce883f2f6e83 (patch) | |
tree | 650c3e68a5189a00028ba8cf3efdc621e7d57967 /src/main/java/eu | |
parent | e9783b80d18c5d1b64090d7e6fa4cf1e6b95f177 (diff) |
fixed direct invites
Diffstat (limited to 'src/main/java/eu')
-rw-r--r-- | src/main/java/eu/siacs/conversations/parser/MessageParser.java | 40 |
1 files changed, 28 insertions, 12 deletions
diff --git a/src/main/java/eu/siacs/conversations/parser/MessageParser.java b/src/main/java/eu/siacs/conversations/parser/MessageParser.java index 8ae9b642a..76d014688 100644 --- a/src/main/java/eu/siacs/conversations/parser/MessageParser.java +++ b/src/main/java/eu/siacs/conversations/parser/MessageParser.java @@ -391,15 +391,17 @@ public class MessageParser extends AbstractParser implements private void parseNonMessage(Element packet, Account account) { final Jid from = packet.getAttributeAsJid("from"); + if (account.getJid().equals(from)) { + return; + } if (extractChatState(from == null ? null : mXmppConnectionService.find(account,from), packet)) { mXmppConnectionService.updateConversationUi(); } - Element invite = extractInvite(packet); - if (invite != null) { - Conversation conversation = mXmppConnectionService.findOrCreateConversation(account, from, true); + Invite invite = extractInvite(packet); + if (invite != null && invite.jid != null) { + Conversation conversation = mXmppConnectionService.findOrCreateConversation(account, invite.jid, true); if (!conversation.getMucOptions().online()) { - Element password = invite.findChild("password"); - conversation.getMucOptions().setPassword(password == null ? null : password.getContent()); + conversation.getMucOptions().setPassword(invite.password); mXmppConnectionService.databaseBackend.updateConversation(conversation); mXmppConnectionService.joinMuc(conversation); mXmppConnectionService.updateConversationUi(); @@ -439,16 +441,30 @@ public class MessageParser extends AbstractParser implements } } - private Element extractInvite(Element message) { - Element x = message.findChild("x","http://jabber.org/protocol/muc#user"); - if (x == null) { - x = message.findChild("x","jabber:x:conference"); + private class Invite { + Jid jid; + String password; + Invite(Jid jid, String password) { + this.jid = jid; + this.password = password; } - if (x != null && x.hasChild("invite")) { - return x; + } + + private Invite extractInvite(Element message) { + Element x = message.findChild("x","http://jabber.org/protocol/muc#user"); + if (x != null) { + Element invite = x.findChild("invite"); + if (invite != null) { + Element pw = x.findChild("password"); + return new Invite(message.getAttributeAsJid("from"), pw != null ? pw.getContent(): null); + } } else { - return null; + x = message.findChild("x","jabber:x:conference"); + if (x != null) { + return new Invite(x.getAttributeAsJid("jid"),x.getAttribute("password")); + } } + return null; } private void parseEvent(final Element event, final Jid from, final Account account) { |