From 8070e8b7cd1854511925b72e8d4bce887c0b677d Mon Sep 17 00:00:00 2001
From: Hugo Lefeuvre <hugo.lefeuvre@savoirfairelinux.com>
Date: Mon, 28 May 2018 15:40:39 -0400
Subject: [PATCH] conversationmodel: no file transfer with banned contacts

Currently it is not allowed by the lrc to place video calls, audio
calls or send messages to banned contacts, but files can still be
sent. In order to be consistent with previous changes, this patch
forbids file transfer with banned contacts.

Change-Id: I99b7de9a113df3a4925707ba64a5b904626a5662
Reviewed-by: Andreas Traczyk <andreas.traczyk@savoirfairelinux.com>
---
 src/contactmodel.cpp      | 2 +-
 src/conversationmodel.cpp | 6 ++++++
 2 files changed, 7 insertions(+), 1 deletion(-)

diff --git a/src/contactmodel.cpp b/src/contactmodel.cpp
index 3eed56d9..c4401750 100644
--- a/src/contactmodel.cpp
+++ b/src/contactmodel.cpp
@@ -1,5 +1,5 @@
 /****************************************************************************
- *   Copyright (C) 2017-2018 Savoir-faire Linux                                  *
+ *   Copyright (C) 2017-2018 Savoir-faire Linux                             *
  *   Author: Nicolas Jäger <nicolas.jager@savoirfairelinux.com>             *
  *   Author: Sébastien Blin <sebastien.blin@savoirfairelinux.com>           *
  *   Author: Guillaume Roguez <guillaume.roguez@savoirfairelinux.com>       *
diff --git a/src/conversationmodel.cpp b/src/conversationmodel.cpp
index 3562b137..db4e4b27 100644
--- a/src/conversationmodel.cpp
+++ b/src/conversationmodel.cpp
@@ -1725,6 +1725,12 @@ ConversationModel::sendFile(const std::string& convUid,
     // Retrieve final peer uri after creation of the conversation
     const auto& newPeerUri = isTemporary ? pimpl_->conversations.at(contactIndex).participants.front() : peerUri;
 
+    auto contactInfo = owner.contactModel->getContact(newPeerUri);
+    if (contactInfo.isBanned) {
+        qDebug() << "ContactModel::sendFile: denied, contact is banned";
+        return;
+    }
+
     pimpl_->lrc.getDataTransferModel().sendFile(owner.id.c_str(),
                                                 newPeerUri.c_str(),
                                                 path.c_str(),
-- 
GitLab