fishing invites and delivery reports out of carbon copied messages

This commit is contained in:
iNPUTmice 2014-07-11 14:49:06 +02:00
parent beb82310da
commit 2b14ad51ec
1 changed files with 10 additions and 6 deletions

View File

@ -155,8 +155,12 @@ public class MessageParser extends AbstractParser {
return null; return null;
} }
Element message = forwarded.findChild("message"); Element message = forwarded.findChild("message");
if ((message == null) || (!message.hasChild("body"))) if ((message == null) || (!message.hasChild("body"))) {
return null; // either malformed or boring if (status == Message.STATUS_RECIEVED) {
parseNormal(message, account);
}
return null;
}
if (status == Message.STATUS_RECIEVED) { if (status == Message.STATUS_RECIEVED) {
fullJid = message.getAttribute("from"); fullJid = message.getAttribute("from");
updateLastseen(message, account,true); updateLastseen(message, account,true);
@ -185,21 +189,21 @@ public class MessageParser extends AbstractParser {
packet.getId(), Message.STATUS_SEND_FAILED); packet.getId(), Message.STATUS_SEND_FAILED);
} }
public void parseNormal(MessagePacket packet, Account account) { public void parseNormal(Element packet, Account account) {
if (packet.hasChild("displayed","urn:xmpp:chat-markers:0")) { if (packet.hasChild("displayed","urn:xmpp:chat-markers:0")) {
String id = packet.findChild("displayed","urn:xmpp:chat-markers:0").getAttribute("id"); String id = packet.findChild("displayed","urn:xmpp:chat-markers:0").getAttribute("id");
String[] fromParts = packet.getFrom().split("/"); String[] fromParts = packet.getAttribute("from").split("/");
updateLastseen(packet, account,true); updateLastseen(packet, account,true);
mXmppConnectionService.markMessage(account,fromParts[0], id, Message.STATUS_SEND_DISPLAYED); mXmppConnectionService.markMessage(account,fromParts[0], id, Message.STATUS_SEND_DISPLAYED);
} else if (packet.hasChild("received","urn:xmpp:chat-markers:0")) { } else if (packet.hasChild("received","urn:xmpp:chat-markers:0")) {
String id = packet.findChild("received","urn:xmpp:chat-markers:0").getAttribute("id"); String id = packet.findChild("received","urn:xmpp:chat-markers:0").getAttribute("id");
String[] fromParts = packet.getFrom().split("/"); String[] fromParts = packet.getAttribute("from").split("/");
updateLastseen(packet, account,false); updateLastseen(packet, account,false);
mXmppConnectionService.markMessage(account,fromParts[0], id, Message.STATUS_SEND_RECEIVED); mXmppConnectionService.markMessage(account,fromParts[0], id, Message.STATUS_SEND_RECEIVED);
} else if (packet.hasChild("x")) { } else if (packet.hasChild("x")) {
Element x = packet.findChild("x"); Element x = packet.findChild("x");
if (x.hasChild("invite")) { if (x.hasChild("invite")) {
Conversation conversation = mXmppConnectionService.findOrCreateConversation(account, packet.getFrom(), Conversation conversation = mXmppConnectionService.findOrCreateConversation(account, packet.getAttribute("from"),
true); true);
mXmppConnectionService.updateUi(conversation, false); mXmppConnectionService.updateUi(conversation, false);
} }