Skip to content

Commit efa2113

Browse files
committed
Don't query private links if disabled on the server
Fixes: #8998
1 parent 8472fd0 commit efa2113

File tree

4 files changed

+29
-21
lines changed

4 files changed

+29
-21
lines changed

changelog/unreleased/8998

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
Enhancement: Don't query private links if disabled on the server
2+
3+
https://github.com/owncloud/client/issues/8998

src/gui/sharedialog.cpp

+5-2
Original file line numberDiff line numberDiff line change
@@ -131,8 +131,11 @@ ShareDialog::ShareDialog(AccountStatePtr accountState,
131131
// Server versions >= 9.1 support the "share-permissions" property
132132
// older versions will just return share-permissions: ""
133133
auto job = new PropfindJob(accountState->account(), _baseUrl, _sharePath);
134-
job->setProperties({ QByteArrayLiteral("http://open-collaboration-services.org/ns:share-permissions"),
135-
QByteArrayLiteral("http://owncloud.org/ns:privatelink") });
134+
QList<QByteArray> properties = { QByteArrayLiteral("http://open-collaboration-services.org/ns:share-permissions") };
135+
if (accountState->account()->capabilities().privateLinkPropertyAvailable()) {
136+
properties.append(QByteArrayLiteral("http://owncloud.org/ns:privatelink"));
137+
}
138+
job->setProperties(properties);
136139
job->setTimeout(10s);
137140
connect(job, &PropfindJob::result, this, &ShareDialog::slotPropfindReceived);
138141
connect(job, &PropfindJob::finishedWithError, this, &ShareDialog::slotPropfindError);

src/gui/socketapi/socketapi.cpp

+7-7
Original file line numberDiff line numberDiff line change
@@ -938,11 +938,9 @@ void SocketApi::sendSharingContextMenuOptions(const FileData &fileData, SocketLi
938938
}
939939
}
940940

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

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

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

1027-
// Add link to versions pane if possible
10281024
auto &capabilities = folder->accountState()->account()->capabilities();
1025+
if (capabilities.privateLinkPropertyAvailable()) {
1026+
listener->sendMessage(QLatin1String("MENU_ITEM:OPEN_PRIVATE_LINK") + flagString + tr("Open in browser"));
1027+
}
1028+
// Add link to versions pane if possible
10291029
if (capabilities.versioningEnabled()
10301030
&& capabilities.privateLinkDetailsParamAvailable()
10311031
&& isOnTheServer

src/libsync/networkjobs.cpp

+14-12
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,8 @@
3232
#include <QPainterPath>
3333
#endif
3434

35-
#include "networkjobs.h"
3635
#include "account.h"
36+
#include "networkjobs.h"
3737
#include "owncloudpropagator.h"
3838

3939
#include "creds/abstractcredentials.h"
@@ -607,17 +607,19 @@ void SimpleNetworkJob::newReplyHook(QNetworkReply *reply)
607607
void fetchPrivateLinkUrl(AccountPtr account, const QUrl &baseUrl, const QString &remotePath, QObject *target,
608608
std::function<void(const QString &url)> targetFun)
609609
{
610-
// Retrieve the new link by PROPFIND
611-
PropfindJob *job = new PropfindJob(account, baseUrl, remotePath, target);
612-
job->setProperties({ QByteArrayLiteral("http://owncloud.org/ns:privatelink") });
613-
job->setTimeout(10s);
614-
QObject::connect(job, &PropfindJob::result, target, [=](const QMap<QString, QString> &result) {
615-
auto privateLinkUrl = result[QStringLiteral("privatelink")];
616-
if (!privateLinkUrl.isEmpty()) {
617-
targetFun(privateLinkUrl);
618-
}
619-
});
620-
job->start();
610+
if (account->capabilities().privateLinkPropertyAvailable()) {
611+
// Retrieve the new link by PROPFIND
612+
PropfindJob *job = new PropfindJob(account, baseUrl, remotePath, target);
613+
job->setProperties({ QByteArrayLiteral("http://owncloud.org/ns:privatelink") });
614+
job->setTimeout(10s);
615+
QObject::connect(job, &PropfindJob::result, target, [=](const QMap<QString, QString> &result) {
616+
auto privateLinkUrl = result[QStringLiteral("privatelink")];
617+
if (!privateLinkUrl.isEmpty()) {
618+
targetFun(privateLinkUrl);
619+
}
620+
});
621+
job->start();
622+
}
621623
}
622624

623625
} // namespace OCC

0 commit comments

Comments
 (0)