From 9d500e78fd2824785d324edfe6bd170a69ec9c6c Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Fran=C3=A7ois-Simon=20Fauteux-Chapleau?=
 <francois-simon.fauteux-chapleau@savoirfairelinux.com>
Date: Mon, 5 Aug 2024 11:32:00 -0400
Subject: [PATCH] conversation_module: don't update removed conversations

When removing a contact, we need to set the "removed" timestamp for our
active conversations with that contact, but we shouldn't update the
timestamp for conversations that had already been removed in the past.

GitLab: #1048
Change-Id: Ic090775625fa8fb557e3081ec408ee10bf01aaff
---
 src/jamidht/conversation_module.cpp | 12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)

diff --git a/src/jamidht/conversation_module.cpp b/src/jamidht/conversation_module.cpp
index d389cf777a..6837921edf 100644
--- a/src/jamidht/conversation_module.cpp
+++ b/src/jamidht/conversation_module.cpp
@@ -2859,11 +2859,13 @@ ConversationModule::removeContact(const std::string& uri, bool banned)
     auto removeConvInfo = [&](const auto& conv, const auto& members) {
         if ((isSelf && members.size() == 1)
             || (!isSelf && std::find(members.begin(), members.end(), uri) != members.end())) {
-            // Mark as removed
-            conv->info.removed = std::time(nullptr);
-            updateClient(conv->info.id);
-            pimpl_->addConvInfo(conv->info);
-            return true;
+            // Mark the conversation as removed if it wasn't already
+            if (!conv->info.isRemoved()) {
+                conv->info.removed = std::time(nullptr);
+                updateClient(conv->info.id);
+                pimpl_->addConvInfo(conv->info);
+                return true;
+            }
         }
         return false;
     };
-- 
GitLab