From c84e76ca40cd8995dd526a5cfef3e114e5ef7cc9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Blin?= <sebastien.blin@savoirfairelinux.com> Date: Mon, 28 Jun 2021 16:33:03 -0400 Subject: [PATCH] conversationmodel: simplify send message for swarm Change-Id: I0b8ffe73ed055148ae01829a2395e8ee2ea60147 --- src/conversationmodel.cpp | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/src/conversationmodel.cpp b/src/conversationmodel.cpp index 43d4fe97..3e88ed3e 100644 --- a/src/conversationmodel.cpp +++ b/src/conversationmodel.cpp @@ -1030,6 +1030,11 @@ ConversationModel::sendMessage(const QString& uid, const QString& body, const QS { try { auto& conversation = pimpl_->getConversationForUid(uid, true).get(); + if (!conversation.isNotASwarm()) { + ConfigurationManager::instance().sendMessage(owner.id, uid, body, parentId); + return; + } + auto& peers = pimpl_->peersForConversation(conversation); if (peers.isEmpty()) { // Should not @@ -1037,16 +1042,6 @@ ConversationModel::sendMessage(const QString& uid, const QString& body, const QS "with no participant"; return; } - - /* isTemporary, and conversationReady callback used only for non-swarm conversation, - because for swarm, conversation already configured at this point. - Conversations for new contact from search result are NON_SWARM but after receiving - conversationReady callback could be updated to ONE_TO_ONE. We still use conversationReady - callback for swarm conversation with one participant to check if contact is blocked*/ - if (peers.size() != 1) { - ConfigurationManager::instance().sendMessage(owner.id, uid, body, parentId); - } - auto convId = uid; auto& peerId = peers.front(); bool isTemporary = peerId == convId; -- GitLab