From 5d910a7c7375d2ab98e1488529fc111b055899cb Mon Sep 17 00:00:00 2001 From: Christian Schneppe Date: Thu, 9 Mar 2017 20:48:03 +0100 Subject: add origin-id to outgoing messages --- src/main/java/de/pixart/messenger/generator/MessageGenerator.java | 2 ++ src/main/java/de/pixart/messenger/parser/MessageParser.java | 8 +++++++- 2 files changed, 9 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/main/java/de/pixart/messenger/generator/MessageGenerator.java b/src/main/java/de/pixart/messenger/generator/MessageGenerator.java index b66fb4dc5..c336f41d5 100644 --- a/src/main/java/de/pixart/messenger/generator/MessageGenerator.java +++ b/src/main/java/de/pixart/messenger/generator/MessageGenerator.java @@ -17,6 +17,7 @@ import de.pixart.messenger.entities.Contact; import de.pixart.messenger.entities.Conversation; import de.pixart.messenger.entities.Message; import de.pixart.messenger.services.XmppConnectionService; +import de.pixart.messenger.utils.Namespace; import de.pixart.messenger.xml.Element; import de.pixart.messenger.xmpp.chatstate.ChatState; import de.pixart.messenger.xmpp.jid.Jid; @@ -54,6 +55,7 @@ public class MessageGenerator extends AbstractGenerator { } packet.setFrom(account.getJid()); packet.setId(message.getUuid()); + packet.addChild("origin-id", Namespace.STANZA_IDS).setAttribute("id", message.getUuid()); if (message.edited()) { packet.addChild("replace", "urn:xmpp:message-correct:0").setAttribute("id", message.getEditedId()); } diff --git a/src/main/java/de/pixart/messenger/parser/MessageParser.java b/src/main/java/de/pixart/messenger/parser/MessageParser.java index b34c382e4..2fa7160b6 100644 --- a/src/main/java/de/pixart/messenger/parser/MessageParser.java +++ b/src/main/java/de/pixart/messenger/parser/MessageParser.java @@ -365,7 +365,13 @@ public class MessageParser extends AbstractParser implements OnMessagePacketRece final Jid counterpart; final Jid to = packet.getTo(); final Jid from = packet.getFrom(); - final String remoteMsgId = packet.getId(); + final Element originId = packet.findChild("origin-id", Namespace.STANZA_IDS); + final String remoteMsgId; + if (originId != null && originId.getAttribute("id") != null) { + remoteMsgId = originId.getAttribute("id"); + } else { + remoteMsgId = packet.getId(); + } boolean notify = false; if (from == null) { -- cgit v1.2.3