add origin-id to outgoing messages

This commit is contained in:
Daniel Gultsch 2017-03-08 21:30:12 +01:00
parent 9d043076e8
commit 1f3be1597c
2 changed files with 9 additions and 1 deletions

View file

@ -18,6 +18,7 @@ import eu.siacs.conversations.entities.Conversation;
import eu.siacs.conversations.entities.Message; import eu.siacs.conversations.entities.Message;
import eu.siacs.conversations.services.XmppConnectionService; import eu.siacs.conversations.services.XmppConnectionService;
import eu.siacs.conversations.xml.Element; import eu.siacs.conversations.xml.Element;
import eu.siacs.conversations.xml.Namespace;
import eu.siacs.conversations.xmpp.chatstate.ChatState; import eu.siacs.conversations.xmpp.chatstate.ChatState;
import eu.siacs.conversations.xmpp.jid.Jid; import eu.siacs.conversations.xmpp.jid.Jid;
import eu.siacs.conversations.xmpp.stanzas.MessagePacket; import eu.siacs.conversations.xmpp.stanzas.MessagePacket;
@ -54,6 +55,7 @@ public class MessageGenerator extends AbstractGenerator {
} }
packet.setFrom(account.getJid()); packet.setFrom(account.getJid());
packet.setId(message.getUuid()); packet.setId(message.getUuid());
packet.addChild("origin-id", Namespace.STANZA_IDS).setAttribute("id",message.getUuid());
if (message.edited()) { if (message.edited()) {
packet.addChild("replace","urn:xmpp:message-correct:0").setAttribute("id",message.getEditedId()); packet.addChild("replace","urn:xmpp:message-correct:0").setAttribute("id",message.getEditedId());
} }

View file

@ -366,7 +366,13 @@ public class MessageParser extends AbstractParser implements OnMessagePacketRece
final Jid counterpart; final Jid counterpart;
final Jid to = packet.getTo(); final Jid to = packet.getTo();
final Jid from = packet.getFrom(); 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; boolean notify = false;
if (from == null) { if (from == null) {