From d0102c71e738d26cccabd87f8d820998dcb109bb Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?S=C3=A9bastien=20Blin?=
 <sebastien.blin@savoirfairelinux.com>
Date: Wed, 14 Jul 2021 11:08:44 -0400
Subject: [PATCH] conversationmodel: fix one to one with self

https://git.jami.net/savoirfairelinux/jami-client-qt/-/issues/455

Change-Id: Ife21f239d1edbd8b49e4976141cc22de2b1fb73d
---
 src/conversationmodel.cpp | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/src/conversationmodel.cpp b/src/conversationmodel.cpp
index efe54532..a8a137f8 100644
--- a/src/conversationmodel.cpp
+++ b/src/conversationmodel.cpp
@@ -1979,6 +1979,9 @@ ConversationModelPimpl::peersForConversation(const conversation::Info& conversat
     default:
         break;
     }
+    // Note: for one to one, we must return self
+    if (conversation.participants.size() == 1)
+        return conversation.participants;
     for (const auto& participant : conversation.participants)
         if (participant != linked.owner.profileInfo.uri)
             result.push_back(participant);
@@ -2723,7 +2726,8 @@ ConversationModelPimpl::addSwarmConversation(const QString& convId)
     for (auto& member : members) {
         // this check should be removed once all usage of participants replaced by
         // peersForConversation. We should have ourself in participants list
-        if (member["uri"] != accountURI) {
+        // Note: if members.size() == 1, it's a conv with self so we're also the peer
+        if (member["uri"] != accountURI || members.size() == 1) {
             participants.append(member["uri"]);
             if (mode == conversation::Mode::ONE_TO_ONE) {
                 otherMember = member["uri"];
-- 
GitLab