Do not add a second DELETE to the list of actions in one notification.
authorCamila <hello@camila.codes>
Wed, 11 May 2022 20:05:28 +0000 (22:05 +0200)
committerMatthieu Gallien <matthieu_gallien@yahoo.fr>
Mon, 16 May 2022 20:03:53 +0000 (22:03 +0200)
Signed-off-by: Camila <hello@camila.codes>
src/gui/tray/notificationhandler.cpp

index 3be035a1011364c2af351c9ca6b7f3fd73f8b75e..b429093ad7fd7d011be96c1cf6a57ded5ff45120 100644 (file)
@@ -149,12 +149,17 @@ void ServerNotificationHandler::slotNotificationsReceived(const QJsonDocument &j
 
         // Add another action to dismiss notification on server
         // https://github.com/owncloud/notifications/blob/master/docs/ocs-endpoint-v1.md#deleting-a-notification-for-a-user
-        ActivityLink al;
-        al._label = tr("Dismiss");
-        al._link = Utility::concatUrlPath(ai->account()->url(), notificationsPath + "/" + QString::number(a._id)).toString();
-        al._verb = "DELETE";
-        al._primary = false;
-        a._links.append(al);
+        constexpr auto deleteVerb = "DELETE";
+        if (std::find_if(std::cbegin(a._links), std::cend(a._links), [](const ActivityLink& link) {
+                return link._verb == deleteVerb;
+            }) == std::cend(a._links)) {
+            ActivityLink al;
+            al._label = tr("Dismiss");
+            al._link = Utility::concatUrlPath(ai->account()->url(), notificationsPath + "/" + QString::number(a._id)).toString();
+            al._verb = deleteVerb;
+            al._primary = false;
+            a._links.append(al);
+        }
 
         list.append(a);
     }