From 39da97396cca90701a08dd5b62d5b1aba9200be4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Blin?= <sebastien.blin@savoirfairelinux.com> Date: Mon, 19 Feb 2024 11:14:27 -0500 Subject: [PATCH] contactmodel: fix add on second request GitLab: #1572 Change-Id: If588d22b80ea2f77b21f2ddd081ba32fdffefc7c --- src/app/mainview/components/ChatView.qml | 4 ++-- src/libclient/contactmodel.cpp | 12 ++++++++++++ src/libclient/conversationmodel.cpp | 1 + 3 files changed, 15 insertions(+), 2 deletions(-) diff --git a/src/app/mainview/components/ChatView.qml b/src/app/mainview/components/ChatView.qml index 7c39226dc..1c38d67e5 100644 --- a/src/app/mainview/components/ChatView.qml +++ b/src/app/mainview/components/ChatView.qml @@ -326,9 +326,9 @@ Rectangle { return false; else if (CurrentConversation.needsSyncing) return false; - else if (CurrentConversation.isSwarm && CurrentConversation.isRequest) + else if (CurrentConversation.isRequest) return false; - return CurrentConversation.isSwarm || CurrentConversation.isTemporary; + return CurrentConversation.isSwarm; } onHeightChanged: { diff --git a/src/libclient/contactmodel.cpp b/src/libclient/contactmodel.cpp index 9771b2dd0..914a72b35 100644 --- a/src/libclient/contactmodel.cpp +++ b/src/libclient/contactmodel.cpp @@ -246,32 +246,39 @@ ContactModel::getAddedTs(const QString& contactUri) const void ContactModel::addContact(contact::Info contactInfo) { + qWarning() << "@@@@@XXX?"; 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()) { + qWarning() << "@@@@@XXX"; LC_DBG << QString("Unban-ing contact %1").arg(profile.uri); ConfigurationManager::instance().addContact(owner.id, profile.uri); // bannedContacts will be updated in slotContactAdded return; } + qWarning() << "@@@@@XXX"; if ((owner.profileInfo.type != profile.type) and (profile.type == profile::Type::JAMI or profile.type == profile::Type::SIP)) { + qWarning() << "@@@@@XXX"; LC_DBG << "ContactModel::addContact, types invalid."; return; } + qWarning() << "@@@@@XXX"; MapStringString details = ConfigurationManager::instance() .getContactDetails(owner.id, contactInfo.profileInfo.uri); // if contactInfo is already a contact for the daemon, type should be equals to RING // if the user add a temporary item for a SIP account, should be directly transformed + qWarning() << "@@@@@XXX"; if ((!details.empty() && details.value("removed") == "0") || (profile.type == profile::Type::TEMPORARY && owner.profileInfo.type == profile::Type::SIP)) profile.type = owner.profileInfo.type; + qWarning() << "@@@@@XXX"; switch (profile.type) { case profile::Type::TEMPORARY: { // make a temporary contact available for UI elements, it will be upgraded to @@ -279,6 +286,7 @@ ContactModel::addContact(contact::Info contactInfo) std::lock_guard<std::mutex> lk(pimpl_->contactsMtx_); contactInfo.profileInfo.type = profile::Type::PENDING; pimpl_->contacts.insert(contactInfo.profileInfo.uri, contactInfo); + qWarning() << "@@@@@XXX"; ConfigurationManager::instance().addContact(owner.id, profile.uri); ConfigurationManager::instance() .sendTrustRequest(owner.id, @@ -287,17 +295,21 @@ ContactModel::addContact(contact::Info contactInfo) return; } case profile::Type::PENDING: + qWarning() << "@@@@@XXX"; return; case profile::Type::JAMI: case profile::Type::SIP: + qWarning() << "@@@@@XXX"; break; case profile::Type::INVALID: case profile::Type::COUNT__: default: + qWarning() << "@@@@@XXX?"; LC_DBG << "ContactModel::addContact, cannot add contact with invalid type."; return; } + qWarning() << "@@@@@XXX"; storage::createOrUpdateProfile(owner.id, profile, true); { diff --git a/src/libclient/conversationmodel.cpp b/src/libclient/conversationmodel.cpp index 47aae56f4..a8f6b19c2 100644 --- a/src/libclient/conversationmodel.cpp +++ b/src/libclient/conversationmodel.cpp @@ -1618,6 +1618,7 @@ ConversationModel::acceptConversationRequest(const QString& conversationId) auto notAdded = contact.profileInfo.type == profile::Type::TEMPORARY || contact.profileInfo.type == profile::Type::PENDING; if (notAdded) { + contact.profileInfo.type = profile::Type::TEMPORARY; owner.contactModel->addContact(contact); return; } -- GitLab