From 35b92aa3a45e0365e153597accf041d9243144b7 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?S=C3=A9bastien=20Blin?=
 <sebastien.blin@savoirfairelinux.com>
Date: Wed, 13 Jul 2022 09:16:57 -0400
Subject: [PATCH] misc: cleanup

Change-Id: Ie8124ce30e81ae47c92837dfe339a494139f7f36
---
 src/libclient/authority/storagehelper.cpp |  5 +++++
 src/libclient/conversationmodel.cpp       | 27 +++++++++--------------
 2 files changed, 15 insertions(+), 17 deletions(-)

diff --git a/src/libclient/authority/storagehelper.cpp b/src/libclient/authority/storagehelper.cpp
index 02979e095..dc3b440cc 100644
--- a/src/libclient/authority/storagehelper.cpp
+++ b/src/libclient/authority/storagehelper.cpp
@@ -289,6 +289,11 @@ setProfile(const QString& accountId, const api::profile::Info& profileInfo, cons
     auto path = profileVcardPath(accountId, isPeer ? profileInfo.uri : "");
     QLockFile lf(path + ".lock");
     QFile file(path);
+    QFileInfo fileInfo(path);
+    auto dir = fileInfo.dir();
+    if (!dir.exists()) {
+        dir.mkdir(".");
+    }
     if (!lf.lock()) {
         qWarning().noquote() << "Can't lock file for writing: " << file.fileName();
         return;
diff --git a/src/libclient/conversationmodel.cpp b/src/libclient/conversationmodel.cpp
index 67804e5fa..cdaef0240 100644
--- a/src/libclient/conversationmodel.cpp
+++ b/src/libclient/conversationmodel.cpp
@@ -1627,12 +1627,17 @@ ConversationModel::acceptConversationRequest(const QString& conversationId)
     if (peers.isEmpty()) {
         return;
     }
-    switch (conversation.mode) {
-    case conversation::Mode::NON_SWARM:
+
+    if (conversation.isSwarm()) {
+        conversation.needsSyncing = true;
+        Q_EMIT conversationUpdated(conversation.uid);
+        pimpl_->invalidateModel();
+        Q_EMIT modelChanged();
+        ConfigurationManager::instance().acceptConversationRequest(owner.id, conversationId);
+    } else {
         pimpl_->sendContactRequest(peers.front());
-        return;
-    case conversation::Mode::ONE_TO_ONE: {
-        // add contact if not added. Otherwise, accept the conversation request
+    }
+    if (conversation.isCoreDialog()) {
         try {
             auto contact = owner.contactModel->getContact(peers.front());
             auto notAdded = contact.profileInfo.type == profile::Type::TEMPORARY
@@ -1643,19 +1648,7 @@ ConversationModel::acceptConversationRequest(const QString& conversationId)
             }
         } catch (std::out_of_range& e) {
         }
-        break;
-    }
-    case conversation::Mode::ADMIN_INVITES_ONLY:
-    case conversation::Mode::INVITES_ONLY:
-    case conversation::Mode::PUBLIC:
-    default:
-        break;
     }
-    conversation.needsSyncing = true;
-    Q_EMIT conversationUpdated(conversation.uid);
-    pimpl_->invalidateModel();
-    Q_EMIT modelChanged();
-    ConfigurationManager::instance().acceptConversationRequest(owner.id, conversationId);
 }
 
 const VectorString
-- 
GitLab