diff --git a/src/gui/tray/ActivityItem.qml b/src/gui/tray/ActivityItem.qml index 30c122238c847..b067ce8a8da61 100644 --- a/src/gui/tray/ActivityItem.qml +++ b/src/gui/tray/ActivityItem.qml @@ -15,7 +15,6 @@ ItemDelegate { readonly property bool isChatActivity: model.objectType === "chat" || model.objectType === "room" || model.objectType === "call" readonly property bool isTalkReplyPossible: model.conversationToken !== "" property bool isTalkReplyOptionVisible: model.messageSent !== "" - readonly property bool isCallActivity: model.objectType === "call" property color adjustedHeaderColor: Theme.darkMode ? Qt.lighter(UserModel.currentUser.headerColor, 2) : Qt.darker(UserModel.currentUser.headerColor, 1.5) diff --git a/src/gui/tray/activitylistmodel.cpp b/src/gui/tray/activitylistmodel.cpp index ebcd646e1a0c4..de4d79c026307 100644 --- a/src/gui/tray/activitylistmodel.cpp +++ b/src/gui/tray/activitylistmodel.cpp @@ -782,11 +782,7 @@ QVariantList ActivityListModel::convertLinksToActionButtons(const Activity &acti } for (const auto &activityLink : activity._links) { - if (activityLink._primary - || activityLink._verb == QStringLiteral("DELETE") - || activityLink._verb == QStringLiteral("WEB")) { - customList << ActivityListModel::convertLinkToActionButton(activityLink); - } + customList << ActivityListModel::convertLinkToActionButton(activityLink); } return customList; diff --git a/src/gui/tray/notificationhandler.cpp b/src/gui/tray/notificationhandler.cpp index 5ab8ea213f821..02105bf934fee 100644 --- a/src/gui/tray/notificationhandler.cpp +++ b/src/gui/tray/notificationhandler.cpp @@ -110,27 +110,36 @@ void ServerNotificationHandler::slotNotificationsReceived(const QJsonDocument &j if (a._objectType == "chat" || a._objectType == "call" || a._objectType == "room") { const auto objectId = json.value("object_id").toString(); const auto objectIdData = objectId.split("/"); + + ActivityLink al; + al._label = tr("Reply"); + al._verb = "REPLY"; + al._primary = true; + a._talkNotificationData.conversationToken = objectIdData.first(); + if (a._objectType == "chat" && objectIdData.size() > 1) { a._talkNotificationData.messageId = objectIdData.last(); } else { qCInfo(lcServerNotification) << "Replying directly to Talk conversation" << a._talkNotificationData.conversationToken << "will not be possible because the notification doesn't contain the message ID."; } - ActivityLink al; - al._label = tr("Reply"); - al._verb = "REPLY"; - al._primary = true; - a._links.insert(0, al); + if (a._subjectRichParameters.contains("user")) { + + // callback then it is the primary action + if (a._objectType == "call") { + al._primary = false; + } - if(a._subjectRichParameters.contains("user")) { a._talkNotificationData.userAvatar = ai->account()->url().toString() + QStringLiteral("/index.php/avatar/") + a._subjectRichParameters["user"].id + QStringLiteral("/128"); } // We want to serve incoming call dialogs to the user for calls that - if(a._objectType == "call" && a._dateTime.secsTo(QDateTime::currentDateTime()) < 120) { + if (a._objectType == "call" && a._dateTime.secsTo(QDateTime::currentDateTime()) < 120) { callList.append(a); } + + a._links.insert(al._primary? 0 : a._links.size(), al); } QUrl link(json.value("link").toString()); diff --git a/test/testactivitylistmodel.cpp b/test/testactivitylistmodel.cpp index 16c1267f50c2d..a30ad2a168a42 100644 --- a/test/testactivitylistmodel.cpp +++ b/test/testactivitylistmodel.cpp @@ -236,20 +236,20 @@ class FakeRemoteActivityStorage QJsonArray actionsArray; - QJsonObject replyAction; - replyAction.insert(QStringLiteral("label"), QStringLiteral("Reply")); - replyAction.insert(QStringLiteral("link"), QStringLiteral("")); - replyAction.insert(QStringLiteral("type"), QStringLiteral("REPLY")); - replyAction.insert(QStringLiteral("primary"), true); - actionsArray.push_back(replyAction); - QJsonObject primaryAction; primaryAction.insert(QStringLiteral("label"), QStringLiteral("Call back")); primaryAction.insert(QStringLiteral("link"), QStringLiteral("http://cloud.example.de/call/9p4vjdzd")); primaryAction.insert(QStringLiteral("type"), QStringLiteral("WEB")); - primaryAction.insert(QStringLiteral("primary"), false); + primaryAction.insert(QStringLiteral("primary"), true); actionsArray.push_back(primaryAction); + QJsonObject replyAction; + replyAction.insert(QStringLiteral("label"), QStringLiteral("Reply")); + replyAction.insert(QStringLiteral("link"), QStringLiteral("")); + replyAction.insert(QStringLiteral("type"), QStringLiteral("REPLY")); + replyAction.insert(QStringLiteral("primary"), false); + actionsArray.push_back(replyAction); + QJsonObject secondaryAction; secondaryAction.insert(QStringLiteral("label"), QStringLiteral("Dismiss")); secondaryAction.insert(QStringLiteral("link"), @@ -660,7 +660,7 @@ private slots: index.data(OCC::ActivityListModel::ActionsLinksContextMenuRole).toList(); // context menu must be shorter than total action links - QVERIFY(actionsLinks.isEmpty() || actionsLinksContextMenu.size() < actionsLinks.size()); + QVERIFY(actionsLinksContextMenu.isEmpty() || actionsLinksContextMenu.size() < actionsLinks.size()); // context menu must not contain the primary action QVERIFY(std::find_if(std::begin(actionsLinksContextMenu), std::end(actionsLinksContextMenu), @@ -674,13 +674,18 @@ private slots: const auto actionButtonsLinks = index.data(OCC::ActivityListModel::ActionsLinksForActionButtonsRole).toList(); - // both action links and buttons must contain a "REPLY" verb element at the beginning - QVERIFY(actionsLinks[0].value()._verb == QStringLiteral("REPLY")); - QVERIFY(actionButtonsLinks[0].value()._verb == QStringLiteral("REPLY")); + auto replyActionPos = 0; + if (objectType == QStringLiteral("call")) { + replyActionPos = 1; + } + + // both action links and buttons must contain a "REPLY" verb element as secondary action + QVERIFY(actionsLinks[replyActionPos].value()._verb == QStringLiteral("REPLY")); + QVERIFY(actionButtonsLinks[replyActionPos].value()._verb == QStringLiteral("REPLY")); // the first action button for chat must have image set - QVERIFY(!actionButtonsLinks[0].value()._imageSource.isEmpty()); - QVERIFY(!actionButtonsLinks[0].value()._imageSourceHovered.isEmpty()); + QVERIFY(!actionButtonsLinks[replyActionPos].value()._imageSource.isEmpty()); + QVERIFY(!actionButtonsLinks[replyActionPos].value()._imageSourceHovered.isEmpty()); // logic for "chat" and other types of activities with multiple actions if ((objectType == QStringLiteral("chat") @@ -703,7 +708,7 @@ private slots: } } else if ((objectType == QStringLiteral("call"))) { QVERIFY( - actionButtonsLinks[1].value()._label == QStringLiteral("Call back")); + actionButtonsLinks[0].value()._label == QStringLiteral("Call back")); } } else { QVERIFY(actionsLinks[0].value()._label == QStringLiteral("Dismiss"));