mirror of
https://github.com/moparisthebest/Conversations
synced 2024-11-24 17:52:17 -05:00
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")) {
|
private Element extractInvite(Element message) {
|
||||||
Conversation conversation = mXmppConnectionService
|
Element x = message.findChild("x","http://jabber.org/protocol/muc#user");
|
||||||
.findOrCreateConversation(account,
|
if (x == null) {
|
||||||
packet.getAttributeAsJid("from"), true);
|
x = message.findChild("x","jabber:x:conference");
|
||||||
if (!conversation.getMucOptions().online()) {
|
}
|
||||||
if (x.hasChild("password")) {
|
if (x != null && x.hasChild("invite")) {
|
||||||
Element password = x.findChild("password");
|
return x;
|
||||||
conversation.getMucOptions().setPassword(
|
} else {
|
||||||
password.getContent());
|
return null;
|
||||||
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");
|
|
||||||
Jid jid = x.getAttributeAsJid("jid");
|
|
||||||
String password = x.getAttribute("password");
|
|
||||||
if (jid != null) {
|
|
||||||
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();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -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 New Issue
Block a user