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

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


The following commit(s) were added to refs/heads/camel-3.4.x by this push:
     new 3dc4d4b  Camel 15349 (#4058) (#4060)
3dc4d4b is described below

commit 3dc4d4bc684ef76021bc1f4a64911e009a63b49a
Author: Andrea Cosentino <anco...@gmail.com>
AuthorDate: Fri Jul 31 07:31:55 2020 +0200

    Camel 15349 (#4058) (#4060)
    
    * 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
    
    Co-authored-by: vindiagram-ng 
<68953833+vindiagram...@users.noreply.github.com>
---
 .../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

Reply via email to