From 24a0a384ffa2917a48f22396413bd94e2778bf12 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Blin?= <sebastien.blin@savoirfairelinux.com> Date: Sun, 25 Jun 2023 08:20:52 -0400 Subject: [PATCH] contactmodel: no need to call both addContact/acceptConversationRequest only acceptConversationRequest is enough to accept a request Change-Id: I4720ea70def6cd35153167ef9577b1c7528e7140 --- src/libclient/contactmodel.cpp | 1 - src/libclient/conversationmodel.cpp | 12 ++++-------- 2 files changed, 4 insertions(+), 9 deletions(-) diff --git a/src/libclient/contactmodel.cpp b/src/libclient/contactmodel.cpp index 01e6b8765..c48e08359 100644 --- a/src/libclient/contactmodel.cpp +++ b/src/libclient/contactmodel.cpp @@ -239,7 +239,6 @@ void ContactModel::addContact(contact::Info contactInfo) { auto& profile = contactInfo.profileInfo; - // If passed contact is a banned contact, call the daemon to unban it auto it = std::find(pimpl_->bannedContacts.begin(), pimpl_->bannedContacts.end(), profile.uri); if (it != pimpl_->bannedContacts.end()) { diff --git a/src/libclient/conversationmodel.cpp b/src/libclient/conversationmodel.cpp index d6c625704..d84bbf229 100644 --- a/src/libclient/conversationmodel.cpp +++ b/src/libclient/conversationmodel.cpp @@ -1755,14 +1755,12 @@ void ConversationModel::acceptConversationRequest(const QString& conversationId) { auto conversationOpt = getConversationForUid(conversationId); - if (!conversationOpt.has_value()) { + if (!conversationOpt.has_value()) return; - } auto& conversation = conversationOpt->get(); auto& peers = pimpl_->peersForConversation(conversation); - if (peers.isEmpty()) { + if (peers.isEmpty()) return; - } if (conversation.isSwarm()) { conversation.needsSyncing = true; @@ -1772,8 +1770,6 @@ ConversationModel::acceptConversationRequest(const QString& conversationId) ConfigurationManager::instance().acceptConversationRequest(owner.id, conversationId); } else { pimpl_->sendContactRequest(peers.front()); - } - if (conversation.isCoreDialog()) { try { auto contact = owner.contactModel->getContact(peers.front()); auto notAdded = contact.profileInfo.type == profile::Type::TEMPORARY @@ -1783,6 +1779,7 @@ ConversationModel::acceptConversationRequest(const QString& conversationId) return; } } catch (std::out_of_range& e) { + qWarning() << e.what(); } } } @@ -2731,9 +2728,8 @@ ConversationModelPimpl::slotConversationRequestReceived(const QString& accountId const QString&, const MapStringString& metadatas) { - if (accountId != linked.owner.id) { + if (accountId != linked.owner.id) return; - } addConversationRequest(metadatas, true); } -- GitLab