fixed invites
This commit is contained in:
parent
af1410b02a
commit
0ad8796b44
|
@ -348,6 +348,17 @@ public class MessageParser extends AbstractParser implements
|
||||||
|
|
||||||
private void parseNonMessage(Element packet, Account account) {
|
private void parseNonMessage(Element packet, Account account) {
|
||||||
final Jid from = packet.getAttributeAsJid("from");
|
final Jid from = packet.getAttributeAsJid("from");
|
||||||
|
Element invite = extractInvite(packet);
|
||||||
|
if (invite != null) {
|
||||||
|
Conversation conversation = mXmppConnectionService.findOrCreateConversation(account,from, true);
|
||||||
|
if (!conversation.getMucOptions().online()) {
|
||||||
|
Element password = invite.findChild("password");
|
||||||
|
conversation.getMucOptions().setPassword(password == null ? null : password.getContent());
|
||||||
|
mXmppConnectionService.databaseBackend.updateConversation(conversation);
|
||||||
|
mXmppConnectionService.joinMuc(conversation);
|
||||||
|
mXmppConnectionService.updateConversationUi();
|
||||||
|
}
|
||||||
|
}
|
||||||
if (packet.hasChild("event", "http://jabber.org/protocol/pubsub#event")) {
|
if (packet.hasChild("event", "http://jabber.org/protocol/pubsub#event")) {
|
||||||
Element event = packet.findChild("event",
|
Element event = packet.findChild("event",
|
||||||
"http://jabber.org/protocol/pubsub#event");
|
"http://jabber.org/protocol/pubsub#event");
|
||||||
|
@ -374,42 +385,18 @@ public class MessageParser extends AbstractParser implements
|
||||||
updateLastseen(packet, account, false);
|
updateLastseen(packet, account, false);
|
||||||
mXmppConnectionService.markMessage(account, from.toBareJid(),
|
mXmppConnectionService.markMessage(account, from.toBareJid(),
|
||||||
id, Message.STATUS_SEND_RECEIVED);
|
id, Message.STATUS_SEND_RECEIVED);
|
||||||
} else if (packet.hasChild("x", "http://jabber.org/protocol/muc#user")) {
|
|
||||||
Element x = packet.findChild("x",
|
|
||||||
"http://jabber.org/protocol/muc#user");
|
|
||||||
if (x.hasChild("invite")) {
|
|
||||||
Conversation conversation = mXmppConnectionService
|
|
||||||
.findOrCreateConversation(account,
|
|
||||||
packet.getAttributeAsJid("from"), true);
|
|
||||||
if (!conversation.getMucOptions().online()) {
|
|
||||||
if (x.hasChild("password")) {
|
|
||||||
Element password = x.findChild("password");
|
|
||||||
conversation.getMucOptions().setPassword(
|
|
||||||
password.getContent());
|
|
||||||
mXmppConnectionService.databaseBackend
|
|
||||||
.updateConversation(conversation);
|
|
||||||
}
|
|
||||||
mXmppConnectionService.joinMuc(conversation);
|
|
||||||
mXmppConnectionService.updateConversationUi();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (packet.hasChild("x", "jabber:x:conference")) {
|
|
||||||
Element x = packet.findChild("x", "jabber:x:conference");
|
private Element extractInvite(Element message) {
|
||||||
Jid jid = x.getAttributeAsJid("jid");
|
Element x = message.findChild("x","http://jabber.org/protocol/muc#user");
|
||||||
String password = x.getAttribute("password");
|
if (x == null) {
|
||||||
if (jid != null) {
|
x = message.findChild("x","jabber:x:conference");
|
||||||
Conversation conversation = mXmppConnectionService
|
|
||||||
.findOrCreateConversation(account, jid, true);
|
|
||||||
if (!conversation.getMucOptions().online()) {
|
|
||||||
if (password != null) {
|
|
||||||
conversation.getMucOptions().setPassword(password);
|
|
||||||
mXmppConnectionService.databaseBackend
|
|
||||||
.updateConversation(conversation);
|
|
||||||
}
|
|
||||||
mXmppConnectionService.joinMuc(conversation);
|
|
||||||
mXmppConnectionService.updateConversationUi();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
if (x != null && x.hasChild("invite")) {
|
||||||
|
return x;
|
||||||
|
} else {
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -493,7 +480,7 @@ public class MessageParser extends AbstractParser implements
|
||||||
if (message != null) {
|
if (message != null) {
|
||||||
message.markUnread();
|
message.markUnread();
|
||||||
}
|
}
|
||||||
} else if (packet.hasChild("body")) {
|
} else if (packet.hasChild("body") && extractInvite(packet) == null) {
|
||||||
message = this.parseChat(packet, account);
|
message = this.parseChat(packet, account);
|
||||||
if (message != null) {
|
if (message != null) {
|
||||||
message.markUnread();
|
message.markUnread();
|
||||||
|
|
Loading…
Reference in a new issue