From 7dc1a52561fc340f7385c48b43d62b96e6887b0f Mon Sep 17 00:00:00 2001 From: vindiagram-ng <68953833+vindiagram-ng@users.noreply.github.com> Date: Fri, 31 Jul 2020 01:22:55 -0400 Subject: [PATCH] Camel 15349 (#4058) * Added function to resolve fully qualified JID for participants Changed the consumer to get the entityBareFrom the resolved participant JID * Fixed formatting issues outlined by sourcecheck --- .../apache/camel/component/xmpp/XmppConsumer.java | 2 +- .../apache/camel/component/xmpp/XmppEndpoint.java | 14 ++++++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/components/camel-xmpp/src/main/java/org/apache/camel/component/xmpp/XmppConsumer.java b/components/camel-xmpp/src/main/java/org/apache/camel/component/xmpp/XmppConsumer.java index 37b643c56b3d7..99be956a135f8 100644 --- a/components/camel-xmpp/src/main/java/org/apache/camel/component/xmpp/XmppConsumer.java +++ b/components/camel-xmpp/src/main/java/org/apache/camel/component/xmpp/XmppConsumer.java @@ -95,7 +95,7 @@ protected void doStart() throws Exception { } if (endpoint.getRoom() == null) { - privateChat = chatManager.chatWith(JidCreate.entityBareFrom(endpoint.getChatId())); + privateChat = chatManager.chatWith(JidCreate.entityBareFrom(endpoint.resolveParticipant(connection))); } else { // add the presence packet listener to the connection so we only get packets that concerns us // we must add the listener before creating the muc diff --git a/components/camel-xmpp/src/main/java/org/apache/camel/component/xmpp/XmppEndpoint.java b/components/camel-xmpp/src/main/java/org/apache/camel/component/xmpp/XmppEndpoint.java index baaed9ca0ca2e..8a5cdd6990327 100644 --- a/components/camel-xmpp/src/main/java/org/apache/camel/component/xmpp/XmppEndpoint.java +++ b/components/camel-xmpp/src/main/java/org/apache/camel/component/xmpp/XmppEndpoint.java @@ -234,6 +234,20 @@ private XMPPTCPConnection createConnectionInternal() throws UnknownHostException return new XMPPTCPConnection(conf); } + /** + * If there is no "@" symbol in the participant, find the service domain + * JID and return the fully qualified JID for the participant as user@server.domain + */ + public String resolveParticipant(XMPPConnection connection) { + String participant = getParticipant(); + + if (participant.indexOf('@', 0) != -1) { + return participant; + } + + return participant + "@" + connection.getXMPPServiceDomain().toString(); + } + /* * If there is no "@" symbol in the room, find the chat service JID and * return fully qualified JID for the room as room@conference.server.domain