diff options
author | Christian Schneppe <christian@pix-art.de> | 2016-11-07 21:37:13 +0100 |
---|---|---|
committer | Christian Schneppe <christian@pix-art.de> | 2016-11-07 21:37:13 +0100 |
commit | e935c7e8f5d2e8afa235af102d02211173ba0039 (patch) | |
tree | 507a0a9dff4ec1264538428d5ea7e2f26a989193 /src | |
parent | 2362579eee68c24a9a91ff01b01ce96873a6fb14 (diff) |
extracting stanza-id where by=account
Diffstat (limited to 'src')
3 files changed, 19 insertions, 2 deletions
diff --git a/src/main/java/de/pixart/messenger/parser/MessageParser.java b/src/main/java/de/pixart/messenger/parser/MessageParser.java index d03638f85..adc5fcdff 100644 --- a/src/main/java/de/pixart/messenger/parser/MessageParser.java +++ b/src/main/java/de/pixart/messenger/parser/MessageParser.java @@ -31,6 +31,7 @@ import de.pixart.messenger.http.HttpConnectionManager; import de.pixart.messenger.services.MessageArchiveService; import de.pixart.messenger.services.XmppConnectionService; import de.pixart.messenger.utils.CryptoHelper; +import de.pixart.messenger.utils.Xmlns; import de.pixart.messenger.xml.Element; import de.pixart.messenger.xmpp.OnMessagePacketReceived; import de.pixart.messenger.xmpp.chatstate.ChatState; @@ -208,7 +209,7 @@ public class MessageParser extends AbstractParser implements OnMessagePacketRece private static String extractStanzaId(Element packet, Jid by) { for(Element child : packet.getChildren()) { if (child.getName().equals("stanza-id") - && "urn:xmpp:sid:0".equals(child.getNamespace()) + && Xmlns.STANZA_IDS.equals(child.getNamespace()) && by.equals(child.getAttributeAsJid("by"))) { return child.getAttribute("id"); } @@ -430,7 +431,18 @@ public class MessageParser extends AbstractParser implements OnMessagePacketRece } if (serverMsgId == null) { - serverMsgId = extractStanzaId(packet, isTypeGroupChat ? conversation.getJid().toBareJid() : account.getServer()); + final Jid by; + final boolean safeToExtract; + if (isTypeGroupChat) { + by = conversation.getJid().toBareJid(); + safeToExtract = true; //conversation.getMucOptions().hasFeature(Xmlns.STANZA_IDS); + } else { + by = account.getJid().toBareJid(); + safeToExtract = true; //account.getXmppConnection().getFeatures().stanzaIds(); + } + if (safeToExtract) { + serverMsgId = extractStanzaId(packet, by); + } } message.setCounterpart(counterpart); diff --git a/src/main/java/de/pixart/messenger/utils/Xmlns.java b/src/main/java/de/pixart/messenger/utils/Xmlns.java index cdae3a819..a4022e03e 100644 --- a/src/main/java/de/pixart/messenger/utils/Xmlns.java +++ b/src/main/java/de/pixart/messenger/utils/Xmlns.java @@ -6,4 +6,5 @@ public final class Xmlns { public static final String REGISTER = "jabber:iq:register"; public static final String BYTE_STREAMS = "http://jabber.org/protocol/bytestreams"; public static final String HTTP_UPLOAD = "urn:xmpp:http:upload"; + public static final String STANZA_IDS = "urn:xmpp:sid:0"; } diff --git a/src/main/java/de/pixart/messenger/xmpp/XmppConnection.java b/src/main/java/de/pixart/messenger/xmpp/XmppConnection.java index 4b98a9fd3..2642ee84a 100644 --- a/src/main/java/de/pixart/messenger/xmpp/XmppConnection.java +++ b/src/main/java/de/pixart/messenger/xmpp/XmppConnection.java @@ -1705,6 +1705,10 @@ public class XmppConnection implements Runnable { return -1; } } + + public boolean stanzaIds() { + return hasDiscoFeature(account.getJid().toBareJid(),Xmlns.STANZA_IDS); + } } private IqGenerator getIqGenerator() { |