From d19032de317b7ad63172ac9d71d0f16f89f802ff Mon Sep 17 00:00:00 2001
From: Adrien Beraud <adrien.beraud@savoirfairelinux.com>
Date: Thu, 15 Jun 2017 19:15:48 +0200
Subject: [PATCH] ringaccount: add created device to known device list

The "Ring device" creation routine generates a new device and sets the
default name for the device, however this device was not added to the
known device list.
This caused the new device to not be in the known device list or to not
have the right name set for device sync or to show to clients.
Now add a new created device to the know device list in the device
creation routine.

Change-Id: Ifce61009c59aececd106d8985c45039748c0bc3e
Reviewed-by: Andreas Traczyk <andreas.traczyk@savoirfairelinux.com>
---
 src/ringdht/ringaccount.cpp | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/src/ringdht/ringaccount.cpp b/src/ringdht/ringaccount.cpp
index 7b4ccdfdb0..a8fd85bb95 100644
--- a/src/ringdht/ringaccount.cpp
+++ b/src/ringdht/ringaccount.cpp
@@ -809,10 +809,12 @@ RingAccount::createRingDevice(const dht::crypto::Identity& id)
     identity_ = dev_id;
     accountTrust_ = dht::crypto::TrustList{};
     accountTrust_.add(*id.second);
-    ringDeviceId_ = dev_id.first->getPublicKey().getId().toString();
+    auto deviceId = dev_id.first->getPublicKey().getId();
+    ringDeviceId_ = deviceId.toString();
     ringDeviceName_ = ip_utils::getDeviceName();
     if (ringDeviceName_.empty())
         ringDeviceName_ = ringDeviceId_.substr(8);
+    knownDevices_.emplace(deviceId, KnownDevice{dev_id.second, ringDeviceName_, clock::now()});
 
     receipt_ = makeReceipt(id);
     RING_WARN("createRingDevice with %s", id.first->getPublicKey().getId().toString().c_str());
-- 
GitLab