Skip to content

Commit

Permalink
Do not add a second DELETE to the list of actions in one notification.
Browse files Browse the repository at this point in the history
Signed-off-by: Camila <hello@camila.codes>
  • Loading branch information
Camila authored and mgallien committed May 17, 2022
1 parent 73bff0a commit b2db31e
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions src/gui/tray/notificationhandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down

0 comments on commit b2db31e

Please sign in to comment.