You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by ac...@apache.org on 2020/07/31 05:23:10 UTC

[camel] branch master updated: Camel 15349 (#4058)

This is an automated email from the ASF dual-hosted git repository.

acosentino pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/camel.git


The following commit(s) were added to refs/heads/master by this push:
     new 2d0a4ed  Camel 15349 (#4058)
2d0a4ed is described below

commit 2d0a4edc143031e516c276625435310368fac5fa
Author: vindiagram-ng <68...@users.noreply.github.com>
AuthorDate: Fri Jul 31 01:22:55 2020 -0400

    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
---
 .../java/org/apache/camel/component/xmpp/XmppConsumer.java |  2 +-
 .../java/org/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 37b643c..99be956 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 @@ public class XmppConsumer extends DefaultConsumer implements IncomingChatMessage
         }
 
         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 baaed9c..8a5cdd6 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 @@ public class XmppEndpoint extends DefaultEndpoint implements HeaderFilterStrateg
         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