From 8dd6d76216c6166a4130ef9a98ef8fec6e978a98 Mon Sep 17 00:00:00 2001
From: Moritz Brunner <moritzbrunner@freenet.de>
Date: Tue, 6 Aug 2019 21:26:49 +0200
Subject: [PATCH] ringnotify: make notification id for chat unique
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Gitlab: #1025
Change-Id: I6e643cd8a4dc3276a07f51385713232419eafab1
Reviewed-by: Sébastien Blin <sebastien.blin@savoirfairelinux.com>
---
 src/ringmainwindow.cpp | 15 ++++++++-------
 1 file changed, 8 insertions(+), 7 deletions(-)

diff --git a/src/ringmainwindow.cpp b/src/ringmainwindow.cpp
index e49eb738..57f6c64b 100644
--- a/src/ringmainwindow.cpp
+++ b/src/ringmainwindow.cpp
@@ -402,8 +402,8 @@ private:
     void slotNewTrustRequest(const std::string& id, const std::string& contactUri);
     void slotCloseTrustRequest(const std::string& id, const std::string& contactUri);
     void slotNewInteraction(const std::string& accountId, const std::string& conversation,
-                                uint64_t, const lrc::api::interaction::Info& interaction);
-    void slotCloseInteraction(const std::string& accountId, const std::string& conversation, uint64_t);
+                                uint64_t interactionId, const lrc::api::interaction::Info& interaction);
+    void slotCloseInteraction(const std::string& accountId, const std::string& conversation, uint64_t interactionId);
     void slotProfileUpdated(const std::string& id);
 };
 
@@ -850,10 +850,11 @@ action_notification(gchar* title, RingMainWindow* self, Action action)
     if (firstMarker == std::string::npos) return;
     auto secondMarker = titleStr.find(":", firstMarker + 1);
     if (secondMarker == std::string::npos) return;
+    auto thirdMarker = titleStr.find(":", secondMarker + 1);
 
     auto id = titleStr.substr(0, firstMarker);
     auto type = titleStr.substr(firstMarker + 1, secondMarker - firstMarker - 1);
-    auto information = titleStr.substr(secondMarker + 1);
+    auto information = titleStr.substr(secondMarker + 1, thirdMarker - secondMarker - 1);
 
     if (action == Action::SELECT) {
         // Select conversation
@@ -2375,7 +2376,7 @@ CppImpl::slotCloseTrustRequest(const std::string& id, const std::string& contact
 
 void
 CppImpl::slotNewInteraction(const std::string& accountId, const std::string& conversation,
-                            uint64_t, const lrc::api::interaction::Info& interaction)
+                            uint64_t interactionId, const lrc::api::interaction::Info& interaction)
 {
     if (chatViewConversation_ && chatViewConversation_->uid == conversation) {
         auto *old_view = gtk_bin_get_child(GTK_BIN(widgets->frame_call));
@@ -2388,7 +2389,7 @@ CppImpl::slotNewInteraction(const std::string& accountId, const std::string& con
     }
     try {
         auto& accountInfo = lrc_->getAccountModel().getAccountInfo(accountId);
-        auto notifId = accountInfo.id + ":interaction:" + conversation;
+        auto notifId = accountInfo.id + ":interaction:" + conversation + ":" + std::to_string(interactionId);
         auto& contactModel = accountInfo.contactModel;
         auto& conversationModel = accountInfo.conversationModel;
         for (const auto& conv : conversationModel->allFilteredConversations())
@@ -2425,7 +2426,7 @@ CppImpl::slotNewInteraction(const std::string& accountId, const std::string& con
 }
 
 void
-CppImpl::slotCloseInteraction(const std::string& accountId, const std::string& conversation, uint64_t)
+CppImpl::slotCloseInteraction(const std::string& accountId, const std::string& conversation, uint64_t interactionId)
 {
     if (!gtk_window_is_active(GTK_WINDOW(self))
         || (chatViewConversation_ && chatViewConversation_->uid != conversation)) {
@@ -2433,7 +2434,7 @@ CppImpl::slotCloseInteraction(const std::string& accountId, const std::string& c
     }
     try {
         auto& accountInfo = lrc_->getAccountModel().getAccountInfo(accountId);
-        auto notifId = accountInfo.id + ":interaction:" + conversation;
+        auto notifId = accountInfo.id + ":interaction:" + conversation + ":" + std::to_string(interactionId);
         ring_hide_notification(RING_NOTIFIER(widgets->notifier), notifId);
     } catch (...) {
         g_warning("Can't get account %s", accountId.c_str());
-- 
GitLab