From cd6032756dcadbad8907f52a7214ba7861616569 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?L=C3=A9o?= <leopold.chappuis@savoirfairelinux.com>
Date: Mon, 3 Feb 2025 11:27:35 -0500
Subject: [PATCH] jams-device-revocation: fix daemon not filtering non-revoked
 devices

Change-Id: Idaf8e45775d2b76a9b306563baa074c7484ff68c
---
 src/jamidht/server_account_manager.cpp | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/src/jamidht/server_account_manager.cpp b/src/jamidht/server_account_manager.cpp
index 33d66617e..db3a4d9c0 100644
--- a/src/jamidht/server_account_manager.cpp
+++ b/src/jamidht/server_account_manager.cpp
@@ -534,12 +534,19 @@ ServerAccountManager::syncDevices()
                     } else {
                         for (unsigned i = 0, n = json.size(); i < n; i++) {
                             const auto& e = json[i];
+                            const bool revoked = e["revoked"].asBool();
                             dht::PkId deviceId(e["deviceId"].asString());
-                            if (deviceId) {
+                            if(!deviceId){
+                                continue;
+                            }
+                            if (!revoked) {
                                 this_->info_->contacts->foundAccountDevice(deviceId,
                                                                             e["alias"].asString(),
                                                                             clock::now());
                             }
+                            else {
+                                this_->info_->contacts->removeAccountDevice(deviceId);
+                            }
                         }
                     }
                 } catch (const std::exception& e) {
@@ -609,7 +616,7 @@ ServerAccountManager::revokeDevice(const std::string& device,
                     if (json["errorDetails"].empty()) {
                         if (cb)
                             cb(RevokeDeviceResult::SUCCESS);
-                        this_->syncDevices();
+                        this_->syncDevices(); // this will remove the devices from the known devices
                     }
                 } catch (const std::exception& e) {
                     JAMI_ERROR("Error when loading device list: {}", e.what());
-- 
GitLab