follow shouldNotify flag to hide notifications when needed

Signed-off-by: Matthieu Gallien <matthieu.gallien@nextcloud.com>
This commit is contained in:
Matthieu Gallien 2023-03-16 21:28:22 +01:00
parent 5e505d9ee3
commit e0bdbd1387
No known key found for this signature in database
GPG key ID: 7D0F74F05C22F553
3 changed files with 14 additions and 0 deletions

View file

@ -157,6 +157,7 @@ public:
* @return
*/
bool _shouldNotify = true;
[[nodiscard]] Identifier ident() const;
};

View file

@ -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

View file

@ -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);
}
}