From 1fafe4287da5cea6c306565d1586907c44257883 Mon Sep 17 00:00:00 2001 From: Daniel Gultsch Date: Sat, 14 Nov 2020 11:59:35 +0100 Subject: [PATCH] =?UTF-8?q?don=E2=80=99t=20send=20origin-ids=20to=20rooms?= =?UTF-8?q?=20that=20support=20stable-ids.=20fixes=20#3905?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/eu/siacs/conversations/entities/MucOptions.java | 4 ++++ .../eu/siacs/conversations/generator/MessageGenerator.java | 6 ++++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/main/java/eu/siacs/conversations/entities/MucOptions.java b/src/main/java/eu/siacs/conversations/entities/MucOptions.java index 10caa4620..1072eeeb9 100644 --- a/src/main/java/eu/siacs/conversations/entities/MucOptions.java +++ b/src/main/java/eu/siacs/conversations/entities/MucOptions.java @@ -211,6 +211,10 @@ public class MucOptions { return conversation.getBooleanAttribute(Conversation.ATTRIBUTE_MODERATED, false); } + public boolean stableId() { + return getFeatures().contains("http://jabber.org/protocol/muc#stable_id"); + } + public User deleteUser(Jid jid) { User user = findUserByFullJid(jid); if (user != null) { diff --git a/src/main/java/eu/siacs/conversations/generator/MessageGenerator.java b/src/main/java/eu/siacs/conversations/generator/MessageGenerator.java index 5f5c8b967..3f1c5aa49 100644 --- a/src/main/java/eu/siacs/conversations/generator/MessageGenerator.java +++ b/src/main/java/eu/siacs/conversations/generator/MessageGenerator.java @@ -18,12 +18,12 @@ import eu.siacs.conversations.http.P1S3UrlStreamHandler; import eu.siacs.conversations.services.XmppConnectionService; import eu.siacs.conversations.xml.Element; import eu.siacs.conversations.xml.Namespace; +import eu.siacs.conversations.xmpp.Jid; import eu.siacs.conversations.xmpp.chatstate.ChatState; import eu.siacs.conversations.xmpp.jingle.JingleConnectionManager; import eu.siacs.conversations.xmpp.jingle.JingleRtpConnection; import eu.siacs.conversations.xmpp.jingle.Media; import eu.siacs.conversations.xmpp.stanzas.MessagePacket; -import eu.siacs.conversations.xmpp.Jid; public class MessageGenerator extends AbstractGenerator { private static final String OMEMO_FALLBACK_MESSAGE = "I sent you an OMEMO encrypted message but your client doesn’t seem to support that. Find more information on https://conversations.im/omemo"; @@ -58,7 +58,9 @@ 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 (conversation.getMode() == Conversational.MODE_SINGLE || message.isPrivateMessage() || !conversation.getMucOptions().stableId()) { + 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.getEditedIdWireFormat()); }