From 140ad5359462df078aa15d9c4fb996627af1d805 Mon Sep 17 00:00:00 2001 From: Hannah von Reth Date: Tue, 29 Nov 2022 11:33:41 +0100 Subject: [PATCH] Fix notification actions Fixes: #10322 --- src/gui/activitywidget.cpp | 6 +----- src/gui/notificationconfirmjob.cpp | 5 +++++ src/gui/notificationconfirmjob.h | 2 +- src/libsync/networkjobs/jsonjob.cpp | 5 +++++ src/libsync/networkjobs/jsonjob.h | 8 ++------ 5 files changed, 14 insertions(+), 12 deletions(-) diff --git a/src/gui/activitywidget.cpp b/src/gui/activitywidget.cpp index c99cbc6abdd..92d71555501 100644 --- a/src/gui/activitywidget.cpp +++ b/src/gui/activitywidget.cpp @@ -333,12 +333,8 @@ void ActivityWidget::slotSendNotificationRequest(const QString &accountName, con if (validVerbs.contains(verb)) { if (auto acc = AccountManager::instance()->account(accountName)) { - const auto url = QUrl::fromUserInput(link); // TODO: host validation? - QNetworkRequest req; - req.setUrl(url); - - auto *job = new NotificationConfirmJob(acc->account(), {}, verb, {}, req, this); + auto *job = new NotificationConfirmJob(acc->account(), QUrl(link), verb, this); job->setWidget(theSender); connect(job, &NotificationConfirmJob::finishedSignal, this, [job, this] { diff --git a/src/gui/notificationconfirmjob.cpp b/src/gui/notificationconfirmjob.cpp index f40b896a775..2412abcdc3d 100644 --- a/src/gui/notificationconfirmjob.cpp +++ b/src/gui/notificationconfirmjob.cpp @@ -23,6 +23,11 @@ namespace OCC { Q_DECLARE_LOGGING_CATEGORY(lcNotifications) +NotificationConfirmJob::NotificationConfirmJob(AccountPtr account, const QUrl &rootUrl, const QByteArray &verb, QObject *parent) + : JsonApiJob(account, rootUrl, {}, verb, {}, {}, parent) +{ +} + void NotificationConfirmJob::setWidget(NotificationWidget *widget) { _widget = widget; diff --git a/src/gui/notificationconfirmjob.h b/src/gui/notificationconfirmjob.h index d895be40973..6a4356c839c 100644 --- a/src/gui/notificationconfirmjob.h +++ b/src/gui/notificationconfirmjob.h @@ -41,7 +41,7 @@ class NotificationConfirmJob : public JsonApiJob Q_OBJECT public: - using JsonApiJob::JsonApiJob; + explicit NotificationConfirmJob(AccountPtr account, const QUrl &root, const QByteArray &verb, QObject *parent = nullptr); /** * @brief Start the OCS request diff --git a/src/libsync/networkjobs/jsonjob.cpp b/src/libsync/networkjobs/jsonjob.cpp index 703b4edb457..6d1e02006fb 100644 --- a/src/libsync/networkjobs/jsonjob.cpp +++ b/src/libsync/networkjobs/jsonjob.cpp @@ -75,6 +75,11 @@ JsonApiJob::JsonApiJob(AccountPtr account, const QString &path, const QByteArray setQuery(q); } +JsonApiJob::JsonApiJob(AccountPtr account, const QString &path, const UrlQuery &arguments, const QNetworkRequest &req, QObject *parent) + : JsonApiJob(account, path, QByteArrayLiteral("GET"), arguments, req, parent) +{ +} + int JsonApiJob::ocsStatus() const { return _ocsStatus; diff --git a/src/libsync/networkjobs/jsonjob.h b/src/libsync/networkjobs/jsonjob.h index 147a89ed845..f34cc825b4f 100644 --- a/src/libsync/networkjobs/jsonjob.h +++ b/src/libsync/networkjobs/jsonjob.h @@ -64,10 +64,7 @@ class OWNCLOUDSYNC_EXPORT JsonApiJob : public JsonJob Q_OBJECT public: explicit JsonApiJob(AccountPtr account, const QString &path, const QByteArray &verb, const UrlQuery &arguments, const QNetworkRequest &req, QObject *parent); - explicit JsonApiJob(AccountPtr account, const QString &path, const UrlQuery &arguments, const QNetworkRequest &req, QObject *parent) - : JsonApiJob(account, path, QByteArrayLiteral("GET"), arguments, req, parent) - { - } + explicit JsonApiJob(AccountPtr account, const QString &path, const UrlQuery &arguments, const QNetworkRequest &req, QObject *parent); // the OCS status code: 100 (!) for success int ocsStatus() const; @@ -78,12 +75,11 @@ class OWNCLOUDSYNC_EXPORT JsonApiJob : public JsonJob bool ocsSuccess() const; private: - // using JsonJob::JsonJob;/ - int _ocsStatus = 0; QString _ocsMessage; protected: + using JsonJob::JsonJob; virtual void parse(const QByteArray &data) override; };