From e0bdbd138764e1406c5ca2a183c6fa719f428660 Mon Sep 17 00:00:00 2001 From: Matthieu Gallien Date: Thu, 16 Mar 2023 21:28:22 +0100 Subject: [PATCH] follow shouldNotify flag to hide notifications when needed Signed-off-by: Matthieu Gallien --- src/gui/tray/activitydata.h | 1 + src/gui/tray/notificationhandler.cpp | 4 ++++ src/gui/tray/usermodel.cpp | 9 +++++++++ 3 files changed, 14 insertions(+) diff --git a/src/gui/tray/activitydata.h b/src/gui/tray/activitydata.h index 947cea5fb..c4e894724 100644 --- a/src/gui/tray/activitydata.h +++ b/src/gui/tray/activitydata.h @@ -157,6 +157,7 @@ public: * @return */ + bool _shouldNotify = true; [[nodiscard]] Identifier ident() const; }; diff --git a/src/gui/tray/notificationhandler.cpp b/src/gui/tray/notificationhandler.cpp index d0fc7b4c8..f87a717b7 100644 --- a/src/gui/tray/notificationhandler.cpp +++ b/src/gui/tray/notificationhandler.cpp @@ -105,6 +105,10 @@ void ServerNotificationHandler::slotNotificationsReceived(const QJsonDocument &j } } + if (json.contains("shouldNotify")) { + a._shouldNotify = json.value("shouldNotify").toBool(true); + } + // 2 cases to consider: // 1. server == 24 & has Talk: object_type is chat/call/room & object_id contains conversationToken/messageId // 2. server < 24 & has Talk: object_type is chat/call/room & object_id contains _only_ conversationToken diff --git a/src/gui/tray/usermodel.cpp b/src/gui/tray/usermodel.cpp index 5c6f24e5f..deae25c51 100644 --- a/src/gui/tray/usermodel.cpp +++ b/src/gui/tray/usermodel.cpp @@ -193,6 +193,10 @@ void User::slotBuildNotificationDisplay(const ActivityList &list) qCInfo(lcActivity) << "Activity already notified, skip"; return false; } + if (!activity._shouldNotify) { + qCDebug(lcActivity) << "Activity should not be notified"; + return false; + } return true; }); @@ -226,6 +230,11 @@ void User::slotBuildIncomingCallDialogs(const ActivityList &list) if(systray) { for(const auto &activity : list) { + if (!activity._shouldNotify) { + qCDebug(lcActivity) << "Activity should not be notified"; + continue; + } + systray->createCallDialog(activity, _account); } } -- 2.39.5