From dd83e5f7332c26cd120a2461b1cea4c3a44f9047 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Blin?= <sebastien.blin@savoirfairelinux.com> Date: Mon, 4 Dec 2023 16:10:43 -0500 Subject: [PATCH] conversation_module: avoid contact duplication on requests sync If conversation is accepted then removed, it should still be considered as an already handled conversation and must not generate a new trust request. Change-Id: I16e410a03b78c08d61ec4bb986b23286c35c1552 --- src/jamidht/conversation_module.cpp | 17 ++++------------- 1 file changed, 4 insertions(+), 13 deletions(-) diff --git a/src/jamidht/conversation_module.cpp b/src/jamidht/conversation_module.cpp index 8754de7f6c..085f932704 100644 --- a/src/jamidht/conversation_module.cpp +++ b/src/jamidht/conversation_module.cpp @@ -232,15 +232,6 @@ public: return c != conversations_.end() && c->second; } - /** - * @return if a convId is an accepted conversation - */ - bool isAcceptedConversation(const std::string& convId) const - { - auto conv = getConversation(convId); - return conv && !conv->info.removed; - } - void addConvInfo(const ConvInfo& info) { std::lock_guard<std::mutex> lk(convInfosMtx_); @@ -1642,7 +1633,7 @@ ConversationModule::onTrustRequest(const std::string& uri, "clone the old one"); return; } - if (pimpl_->isAcceptedConversation(conversationId)) { + if (pimpl_->isConversation(conversationId)) { JAMI_DEBUG("[Account {}] Received a request for a conversation " "already handled. Ignore", pimpl_->accountId_); @@ -1686,7 +1677,7 @@ ConversationModule::onConversationRequest(const std::string& from, const Json::V req.from = from; // Already accepted request, do nothing - if (pimpl_->isAcceptedConversation(convId)) + if (pimpl_->isConversation(convId)) return; auto oldReq = pimpl_->getRequest(convId); if (oldReq != std::nullopt) { @@ -2146,8 +2137,8 @@ ConversationModule::onSyncData(const SyncMsg& msg, } for (const auto& [convId, req] : msg.cr) { - if (pimpl_->isAcceptedConversation(convId)) { - // Already accepted request + if (pimpl_->isConversation(convId)) { + // Already handled request pimpl_->rmConversationRequest(convId); continue; } -- GitLab