From a48299e302ff87fd0460f3aed2779c8b303b6695 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?S=C3=A9bastien=20Blin?=
 <sebastien.blin@savoirfairelinux.com>
Date: Thu, 22 Feb 2018 16:29:46 -0500
Subject: [PATCH] conversationmodel: fix transfer interaction's author in the
 database

Change-Id: I6fbbd7d50d44f68d8f249e474a93a233ad606df7
Reviewed-by: Guillaume Roguez <guillaume.roguez@savoirfairelinux.com>
---
 src/authority/databasehelper.cpp | 3 +--
 src/conversationmodel.cpp        | 2 +-
 2 files changed, 2 insertions(+), 3 deletions(-)

diff --git a/src/authority/databasehelper.cpp b/src/authority/databasehelper.cpp
index 124b3ae5..8c571a3d 100644
--- a/src/authority/databasehelper.cpp
+++ b/src/authority/databasehelper.cpp
@@ -219,7 +219,6 @@ addDataTransferToConversation(Database& db,
                               const api::datatransfer::Info& infoFromDaemon)
 {
     auto peerProfileId = getProfileId(db, infoFromDaemon.peerUri);
-    auto authorId = peerProfileId;
 
     return db.insertInto("interactions", {
             {":account_id", "account_id"},
@@ -231,7 +230,7 @@ addDataTransferToConversation(Database& db,
             {":status", "status"}
         }, {
             {":account_id", accountProfileId},
-            {":author_id", authorId},
+            {":author_id", infoFromDaemon.isOutgoing? accountProfileId : peerProfileId},
             {":conversation_id", conversationId},
             {":timestamp", std::to_string(std::time(nullptr))},
             {":body", infoFromDaemon.displayName},
diff --git a/src/conversationmodel.cpp b/src/conversationmodel.cpp
index c5793e39..9829a537 100644
--- a/src/conversationmodel.cpp
+++ b/src/conversationmodel.cpp
@@ -1403,7 +1403,7 @@ ConversationModelPimpl::slotTransferStatusCreated(long long dringId, datatransfe
         auto interactioType = info.isOutgoing ?
             interaction::Type::OUTGOING_DATA_TRANSFER :
             interaction::Type::INCOMING_DATA_TRANSFER;
-        auto interaction = interaction::Info {contactProfileId,
+        auto interaction = interaction::Info {info.isOutgoing? accountProfileId : contactProfileId,
                                               info.displayName,
                                               std::time(nullptr),
                                               interactioType,
-- 
GitLab