From cbc9c5e2b9e2259537d1a4149c2fa12d2bed3421 Mon Sep 17 00:00:00 2001 From: Gaelle Braud Date: Wed, 3 Sep 2025 12:05:23 +0200 Subject: [PATCH] fix double notification for messages --- Linphone/core/chat/ChatList.cpp | 1 + Linphone/model/core/CoreModel.cpp | 19 +++++++++++++++---- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/Linphone/core/chat/ChatList.cpp b/Linphone/core/chat/ChatList.cpp index 07545b264..e34294eab 100644 --- a/Linphone/core/chat/ChatList.cpp +++ b/Linphone/core/chat/ChatList.cpp @@ -121,6 +121,7 @@ void ChatList::setSelf(QSharedPointer me) { const std::shared_ptr &room, const std::shared_ptr &message) { mustBeInLinphoneThread(log().arg(Q_FUNC_INFO)); + if (!message) return; auto receiverAddress = message->getToAddress(); if (!receiverAddress) { qWarning() << log().arg("Receiver account has no address, return"); diff --git a/Linphone/model/core/CoreModel.cpp b/Linphone/model/core/CoreModel.cpp index 7915cf189..06a4ea34f 100644 --- a/Linphone/model/core/CoreModel.cpp +++ b/Linphone/model/core/CoreModel.cpp @@ -526,18 +526,29 @@ void CoreModel::onLogCollectionUploadProgressIndication(const std::shared_ptr
  • &core, const std::shared_ptr &room, const std::shared_ptr &message) { + if (message->isOutgoing()) return; emit unreadNotificationsChanged(); std::list> messages; messages.push_back(message); - if (App::getInstance()->getNotifier()) App::getInstance()->getNotifier()->notifyReceivedMessages(room, messages); + if (App::getInstance()->getNotifier()) { + App::getInstance()->getNotifier()->notifyReceivedMessages(room, messages); + } emit messageReceived(core, room, message); } void CoreModel::onMessagesReceived(const std::shared_ptr &core, const std::shared_ptr &room, const std::list> &messages) { - emit unreadNotificationsChanged(); - if (App::getInstance()->getNotifier()) App::getInstance()->getNotifier()->notifyReceivedMessages(room, messages); - emit messagesReceived(core, room, messages); + std::list> finalMessages; + for (auto &message : messages) { + if (message->isOutgoing()) continue; + finalMessages.push_back(message); + } + if (finalMessages.size() > 0) { + emit unreadNotificationsChanged(); + emit messagesReceived(core, room, finalMessages); + } + if (App::getInstance()->getNotifier()) + App::getInstance()->getNotifier()->notifyReceivedMessages(room, finalMessages); } void CoreModel::onNewMessageReaction(const std::shared_ptr &core,