Skip to content

Commit

Permalink
Don't query private links if disabled on the server
Browse files Browse the repository at this point in the history
Fixes: #8998
  • Loading branch information
TheOneRing committed Jun 30, 2022
1 parent 8472fd0 commit ec9eed4
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 21 deletions.
3 changes: 3 additions & 0 deletions changelog/unreleased/8998
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Enhancement: Don't query private links if disabled on the server

https://github.com/owncloud/client/issues/8998
7 changes: 5 additions & 2 deletions src/gui/sharedialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -131,8 +131,11 @@ ShareDialog::ShareDialog(AccountStatePtr accountState,
// Server versions >= 9.1 support the "share-permissions" property
// older versions will just return share-permissions: ""
auto job = new PropfindJob(accountState->account(), _baseUrl, _sharePath);
job->setProperties({ QByteArrayLiteral("http://open-collaboration-services.org/ns:share-permissions"),
QByteArrayLiteral("http://owncloud.org/ns:privatelink") });
QList<QByteArray> properties = { QByteArrayLiteral("http://open-collaboration-services.org/ns:share-permissions") };
if (accountState->account()->capabilities().privateLinkPropertyAvailable()) {
properties.append(QByteArrayLiteral("http://owncloud.org/ns:privatelink"));
}
job->setProperties(properties);
job->setTimeout(10s);
connect(job, &PropfindJob::result, this, &ShareDialog::slotPropfindReceived);
connect(job, &PropfindJob::finishedWithError, this, &ShareDialog::slotPropfindError);
Expand Down
14 changes: 7 additions & 7 deletions src/gui/socketapi/socketapi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -938,11 +938,9 @@ void SocketApi::sendSharingContextMenuOptions(const FileData &fileData, SocketLi
}
}

listener->sendMessage(QStringLiteral("MENU_ITEM:COPY_PRIVATE_LINK") + flagString + tr("Copy private link to clipboard"));

// Disabled: only providing email option for private links would look odd,
// and the copy option is more general.
//listener->sendMessage(QLatin1String("MENU_ITEM:EMAIL_PRIVATE_LINK") + flagString + tr("Send private link by email..."));
if (capabilities.privateLinkPropertyAvailable()) {
listener->sendMessage(QStringLiteral("MENU_ITEM:COPY_PRIVATE_LINK") + flagString + tr("Copy private link to clipboard"));
}
}

SocketApi::FileData SocketApi::FileData::get(const QString &localFile)
Expand Down Expand Up @@ -1022,10 +1020,12 @@ void SocketApi::command_GET_MENU_ITEMS(const QString &argument, OCC::SocketListe

if (fileData.folder && fileData.folder->accountState()->isConnected()) {
sendSharingContextMenuOptions(fileData, listener);
listener->sendMessage(QLatin1String("MENU_ITEM:OPEN_PRIVATE_LINK") + flagString + tr("Open in browser"));

// Add link to versions pane if possible
auto &capabilities = folder->accountState()->account()->capabilities();
if (capabilities.privateLinkPropertyAvailable()) {
listener->sendMessage(QLatin1String("MENU_ITEM:OPEN_PRIVATE_LINK") + flagString + tr("Open in browser"));
}
// Add link to versions pane if possible
if (capabilities.versioningEnabled()
&& capabilities.privateLinkDetailsParamAvailable()
&& isOnTheServer
Expand Down
26 changes: 14 additions & 12 deletions src/libsync/networkjobs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@
#include <QPainterPath>
#endif

#include "networkjobs.h"
#include "account.h"
#include "networkjobs.h"
#include "owncloudpropagator.h"

#include "creds/abstractcredentials.h"
Expand Down Expand Up @@ -607,17 +607,19 @@ void SimpleNetworkJob::newReplyHook(QNetworkReply *reply)
void fetchPrivateLinkUrl(AccountPtr account, const QUrl &baseUrl, const QString &remotePath, QObject *target,
std::function<void(const QString &url)> targetFun)
{
// Retrieve the new link by PROPFIND
PropfindJob *job = new PropfindJob(account, baseUrl, remotePath, target);
job->setProperties({ QByteArrayLiteral("http://owncloud.org/ns:privatelink") });
job->setTimeout(10s);
QObject::connect(job, &PropfindJob::result, target, [=](const QMap<QString, QString> &result) {
auto privateLinkUrl = result[QStringLiteral("privatelink")];
if (!privateLinkUrl.isEmpty()) {
targetFun(privateLinkUrl);
}
});
job->start();
if (account->capabilities().privateLinkPropertyAvailable()) {
// Retrieve the new link by PROPFIND
PropfindJob *job = new PropfindJob(account, baseUrl, remotePath, target);
job->setProperties({ QByteArrayLiteral("http://owncloud.org/ns:privatelink") });
job->setTimeout(10s);
QObject::connect(job, &PropfindJob::result, target, [=](const QMap<QString, QString> &result) {
auto privateLinkUrl = result[QStringLiteral("privatelink")];
if (!privateLinkUrl.isEmpty()) {
targetFun(privateLinkUrl);
}
});
job->start();
}
}

} // namespace OCC

0 comments on commit ec9eed4

Please sign in to comment.