Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bugfix. Federated share activity show 'Decline' action button. #6502

Merged
merged 2 commits into from
Mar 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion src/gui/tray/activitylistmodel.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/*

Check notice on line 1 in src/gui/tray/activitylistmodel.cpp

View workflow job for this annotation

GitHub Actions / build

Run clang-format on src/gui/tray/activitylistmodel.cpp

File src/gui/tray/activitylistmodel.cpp does not conform to Custom style guidelines. (lines 886)
* Copyright (C) by Klaas Freitag <[email protected]>
*
* This program is free software; you can redistribute it and/or modify
Expand Down Expand Up @@ -883,7 +883,9 @@

// Use the isDismissable model role to present custom dismiss button if needed
// Also don't show "View chat" for talk activities, default action will open chat anyway
if (activityLink._verb == "DELETE" || (activityLink._verb == "WEB" && activity._objectType == "chat")) {
const auto isUseCustomDeleteAction = activityLink._verb == "DELETE"
&& activity._objectType != QStringLiteral("remote_share");
if (isUseCustomDeleteAction || (activityLink._verb == "WEB" && activity._objectType == "chat")) {
continue;
}

Expand Down
35 changes: 35 additions & 0 deletions test/activitylistmodeltestutils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -403,6 +403,41 @@ void FakeRemoteActivityStorage::initActivityData()

_startingId++;
}

for (quint32 i = 0; i < _numItemsToInsert; i++) {
QJsonObject activity;
activity.insert(QStringLiteral("activity_id"), _startingId);
activity.insert(QStringLiteral("object_type"), "remote_share");
activity.insert(QStringLiteral("subject"), QStringLiteral("You received document.docx as a remote share from admin@https://example.de"));
activity.insert(QStringLiteral("subjectRich"), QStringLiteral("You received {share} as a remote share from {user}"));
activity.insert(QStringLiteral("message"), QStringLiteral(""));
activity.insert(QStringLiteral("object_name"), QStringLiteral(""));
activity.insert(QStringLiteral("datetime"), QDateTime::currentDateTime().toString(Qt::ISODate));
activity.insert(QStringLiteral("icon"), QStringLiteral("http://example.de/core/img/actions/share.svg"));

QJsonArray actionsArray;

QJsonObject primaryAction;
primaryAction.insert(QStringLiteral("label"), QStringLiteral("Accept"));
primaryAction.insert(QStringLiteral("link"), QStringLiteral("/ocs/v2.php/apps/files_sharing/api/v1/remote_shares/pending/6"));
primaryAction.insert(QStringLiteral("type"), QStringLiteral("POST"));
primaryAction.insert(QStringLiteral("primary"), true);
actionsArray.push_back(primaryAction);

QJsonObject secondaryAction;
secondaryAction.insert(QStringLiteral("label"), QStringLiteral("Decline"));
secondaryAction.insert(QStringLiteral("link"), QString(QStringLiteral("/ocs/v2.php/apps/files_sharing/api/v1/remote_shares/pending/6")));
secondaryAction.insert(QStringLiteral("type"), QStringLiteral("DELETE"));
secondaryAction.insert(QStringLiteral("primary"), false);
actionsArray.push_back(secondaryAction);

activity.insert(QStringLiteral("actions"), actionsArray);

_activityData.push_back(activity);

_startingId++;
}

_startingId--;
}

Expand Down
8 changes: 8 additions & 0 deletions test/testactivitylistmodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -297,6 +297,14 @@ private slots:
QVERIFY(actionsLinksContextMenu.isEmpty());
}

// remote shares must have 'Accept' and 'Decline' actions
if (objectType == QStringLiteral("remote_share")) {
QVERIFY(actionsLinks.size() == 2);
QVERIFY(actionsLinks[0].value<OCC::ActivityLink>()._primary);
QVERIFY(actionsLinks[0].value<OCC::ActivityLink>()._verb == QStringLiteral("POST"));
QVERIFY(actionsLinks[1].value<OCC::ActivityLink>()._verb == QStringLiteral("DELETE"));
}

if ((objectType == QStringLiteral("chat") || objectType == QStringLiteral("call")
|| objectType == QStringLiteral("room"))) {

Expand Down
Loading