Use addQueryParams for checkTokenForEditLocally SimpleApiJob

Signed-off-by: Claudio Cambra <claudio.cambra@nextcloud.com>
This commit is contained in:
Claudio Cambra 2022-10-27 16:32:51 +02:00
parent 0b33ce2b40
commit 734c986cd1
No known key found for this signature in database
GPG key ID: C839200C384636B0

View file

@ -1554,13 +1554,14 @@ void FolderMan::editFileLocally(const QString &userId, const QString &relPath, c
return;
}
// Sanitise the token
const auto encodedToken = QString::fromUtf8(QUrl::toPercentEncoding(token));
// Sanitise the relPath
const auto encodedRelPath = QUrl::toPercentEncoding(relPath);
const auto encodedToken = QString::fromUtf8(QUrl::toPercentEncoding(token)); // Sanitise the token
const auto encodedRelPath = QUrl::toPercentEncoding(slashPrefixedPath); // Sanitise the relPath
const auto checkTokenForEditLocally = new SimpleApiJob(accountFound->account(), QStringLiteral("/ocs/v2.php/apps/files/api/v1/openlocaleditor/%1").arg(encodedToken));
QUrlQuery params;
params.addQueryItem(QStringLiteral("path"), slashPrefixedPath);
checkTokenForEditLocally->addQueryParams(params);
checkTokenForEditLocally->setVerb(SimpleApiJob::Verb::Post);
checkTokenForEditLocally->setBody(QByteArray{"path=/"}.append(encodedRelPath));
connect(checkTokenForEditLocally, &SimpleApiJob::resultReceived, checkTokenForEditLocally, [this, folderForFile, localFilePath, showError, accountFound, relPath] (int statusCode) {
constexpr auto HTTP_OK_CODE = 200;
if (statusCode != HTTP_OK_CODE) {