From 6c999d86fa684815e32a72fb5712cfea882e378d Mon Sep 17 00:00:00 2001
From: Amna <amna.snene@savoirfairelinux.com>
Date: Tue, 15 Aug 2023 15:19:41 -0400
Subject: [PATCH] connectionmanager: add deviceId to getConnectionList

Change-Id: I20a08723ae90cb8daf1b35bf7cbbea44ef067dca
---
 include/connectionmanager.h | 3 ++-
 src/connectionmanager.cpp   | 8 +++++---
 2 files changed, 7 insertions(+), 4 deletions(-)

diff --git a/include/connectionmanager.h b/include/connectionmanager.h
index ae08212..b03c345 100644
--- a/include/connectionmanager.h
+++ b/include/connectionmanager.h
@@ -221,7 +221,8 @@ public:
      * Note: The connections are represented as maps with string keys and string values. The map
      *       contains the following key-value pairs:
      *       - "id": The unique identifier of the connection.
-     *       - "userUri": The user URI associated with the connection (if available).
+     *       - "peer": The contact URI associated with the connection (if available).
+     *       - "device": The device URI associated with the connection.
      *       - "status": The status of the connection, represented as an integer:
      *                   - 0: ConnectionStatus::Connected
      *                   - 1: ConnectionStatus::TLS
diff --git a/src/connectionmanager.cpp b/src/connectionmanager.cpp
index 9fda75c..9134bd9 100644
--- a/src/connectionmanager.cpp
+++ b/src/connectionmanager.cpp
@@ -1783,9 +1783,11 @@ ConnectionManager::getConnectionList(const DeviceId& device) const
             continue;
         std::map<std::string, std::string> connectionInfo;
         connectionInfo["id"] = callbackIdToString(key.first, key.second);
-        if (ci->tls_ && ci->tls_->peerCertificate()) {
-            auto cert = ci->tls_->peerCertificate();
-            connectionInfo["userUri"] = cert->issuer->getId().toString();
+        connectionInfo["device"] = key.first;
+        if (ci->tls_) {
+            if (auto cert = ci->tls_->peerCertificate()) {
+                connectionInfo["peer"] = cert->issuer->getId().toString();
+            }
         }
         if (ci->socket_) {
             connectionInfo["status"] = std::to_string(static_cast<int>(ConnectionStatus::Connected));
-- 
GitLab