From 231e1dbad848d60a2c60c3900501be08f0fc88ed Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?S=C3=A9bastien=20Blin?=
 <sebastien.blin@savoirfairelinux.com>
Date: Mon, 9 Mar 2020 13:47:53 -0400
Subject: [PATCH] jamiaccount: request SIP connections when sending messages or
 calling

Not when detecting a new online peer.

Change-Id: I50ec7701dfbf4d5b3739ce74d2f8c09195b41d52
Gitlab: #209
---
 src/jamidht/jamiaccount.cpp | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/src/jamidht/jamiaccount.cpp b/src/jamidht/jamiaccount.cpp
index a33cf303c1..1e0c739825 100644
--- a/src/jamidht/jamiaccount.cpp
+++ b/src/jamidht/jamiaccount.cpp
@@ -510,6 +510,10 @@ JamiAccount::startOutgoingCall(const std::shared_ptr<SIPCall>& call, const std::
     {
         // Test if already sent via a SIP transport
         if (devices.find(dev.toString()) != devices.end()) return;
+
+        // Else, ask for a channel (for future calls/text messages) and send a DHT message
+        requestSIPConnection(toUri, dev.toString());
+
         auto call = wCall.lock();
         if (not call) return;
         JAMI_DBG("[call %s] calling device %s", call->getCallId().c_str(), dev.toString().c_str());
@@ -1744,7 +1748,6 @@ JamiAccount::trackPresence(const dht::InfoHash& h, BuddyInfo& buddy)
         if (not expired) {
             // Retry messages every time a new device announce its presence
             messageEngine_.onPeerOnline(h.toString());
-            requestSIPConnection(h.toString(), dev.dev.toString());
         }
         if (isConnected and not wasConnected) {
             onTrackedBuddyOnline(h);
-- 
GitLab