Skip to content

Commit

Permalink
Merge pull request nextcloud#5530 from nextcloud/feature/obeyShouldNo…
Browse files Browse the repository at this point in the history
…tifyFlag

follow shouldNotify flag to hide notifications when needed
  • Loading branch information
mgallien authored Mar 21, 2023
2 parents 5e505d9 + e0bdbd1 commit 54a11e8
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/gui/tray/activitydata.h
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,7 @@ class Activity
* @return
*/

bool _shouldNotify = true;

[[nodiscard]] Identifier ident() const;
};
Expand Down
4 changes: 4 additions & 0 deletions src/gui/tray/notificationhandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
9 changes: 9 additions & 0 deletions src/gui/tray/usermodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
});
Expand Down Expand Up @@ -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);
}
}
Expand Down

0 comments on commit 54a11e8

Please sign in to comment.