Skip to content

Commit

Permalink
Fix notification actions
Browse files Browse the repository at this point in the history
Fixes: #10322
  • Loading branch information
TheOneRing committed Nov 29, 2022
1 parent c141ead commit 140ad53
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 12 deletions.
6 changes: 1 addition & 5 deletions src/gui/activitywidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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] {
Expand Down
5 changes: 5 additions & 0 deletions src/gui/notificationconfirmjob.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion src/gui/notificationconfirmjob.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 5 additions & 0 deletions src/libsync/networkjobs/jsonjob.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
8 changes: 2 additions & 6 deletions src/libsync/networkjobs/jsonjob.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
};

Expand Down

0 comments on commit 140ad53

Please sign in to comment.