From 8ba843e15ac720629b836c16bb4011310576e2d6 Mon Sep 17 00:00:00 2001
From: Moritz Brunner <moritzbrunner@freenet.de>
Date: Tue, 30 Jul 2019 17:34:28 +0200
Subject: [PATCH] contactmodel: hang up call if contact gets deleted

Hang up call when contact gets removed during call

Change-Id: Id02abeace50030048055a304dfc961d83200b51e
Reviewed-by: Philippe Gorley <philippe.gorley@savoirfairelinux.com>
---
 src/contactmodel.cpp | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/src/contactmodel.cpp b/src/contactmodel.cpp
index a4ea9c99..71578a43 100644
--- a/src/contactmodel.cpp
+++ b/src/contactmodel.cpp
@@ -309,6 +309,11 @@ ContactModel::removeContact(const std::string& contactUri, bool banned)
             emitContactRemoved = true;
         }
     }
+    // hang up calls with the removed contact as peer
+    try{
+        auto callinfo = owner.callModel->getCallFromURI(contactUri, true);
+        owner.callModel->hangUp(callinfo.id);
+    } catch (std::out_of_range& e){}
     if (emitContactRemoved) {
         emit contactRemoved(contactUri);
     } else {
-- 
GitLab