Skip to content

Commit

Permalink
Use different endpoint (V2) for metadata and lock-unlock for sharing.
Browse files Browse the repository at this point in the history
Signed-off-by: alex-z <[email protected]>
  • Loading branch information
allexzander committed Jan 17, 2024
1 parent 8661140 commit 43faef6
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 6 deletions.
5 changes: 5 additions & 0 deletions src/libsync/clientsideencryption.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,11 @@ QString e2eeBaseUrl()
return QStringLiteral("ocs/v2.php/apps/end_to_end_encryption/api/v1/");
}

QString e2eeBaseUrlForMetadataAndLockUnlock()
{
return QStringLiteral("ocs/v2.php/apps/end_to_end_encryption/api/v2/");
}

namespace {
constexpr char accountProperty[] = "account";

Expand Down
1 change: 1 addition & 0 deletions src/libsync/clientsideencryption.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ class ReadPasswordJob;
namespace OCC {

QString e2eeBaseUrl();
QString e2eeBaseUrlForMetadataAndLockUnlock();

namespace EncryptionHelper {
OWNCLOUDSYNC_EXPORT QByteArray generateRandomFilename();
Expand Down
13 changes: 7 additions & 6 deletions src/libsync/clientsideencryptionjobs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@ namespace OCC {
GetMetadataApiJob::GetMetadataApiJob(const AccountPtr& account,
const QByteArray& fileId,
QObject* parent)
: AbstractNetworkJob(account, e2eeBaseUrl() + QStringLiteral("meta-data/") + fileId, parent), _fileId(fileId)
: AbstractNetworkJob(account, e2eeBaseUrlForMetadataAndLockUnlock() + QStringLiteral("meta-data/") + fileId, parent)
, _fileId(fileId)
{
}

Expand Down Expand Up @@ -85,7 +86,7 @@ StoreMetaDataApiJob::StoreMetaDataApiJob(const AccountPtr& account,
const QByteArray& b64Metadata,
const QByteArray &signature,
QObject* parent)
: AbstractNetworkJob(account, e2eeBaseUrl() + QStringLiteral("meta-data/") + fileId, parent),
: AbstractNetworkJob(account, e2eeBaseUrlForMetadataAndLockUnlock() + QStringLiteral("meta-data/") + fileId, parent),
_fileId(fileId),
_b64Metadata(b64Metadata),
_token(token),
Expand Down Expand Up @@ -151,7 +152,7 @@ UpdateMetadataApiJob::UpdateMetadataApiJob(const AccountPtr& account,
const QByteArray& token,
const QByteArray& signature,
QObject* parent)
: AbstractNetworkJob(account, e2eeBaseUrl() + QStringLiteral("meta-data/") + fileId, parent)
: AbstractNetworkJob(account, e2eeBaseUrlForMetadataAndLockUnlock() + QStringLiteral("meta-data/") + fileId, parent)
, _fileId(fileId),
_b64Metadata(b64Metadata),
_token(token),
Expand Down Expand Up @@ -223,7 +224,7 @@ UnlockEncryptFolderApiJob::UnlockEncryptFolderApiJob(const AccountPtr& account,
const QByteArray& token,
SyncJournalDb *journalDb,
QObject* parent)
: AbstractNetworkJob(account, e2eeBaseUrl() + QStringLiteral("lock/") + fileId, parent)
: AbstractNetworkJob(account, e2eeBaseUrlForMetadataAndLockUnlock() + QStringLiteral("lock/") + fileId, parent)
, _fileId(fileId)
, _token(token)
, _journalDb(journalDb)
Expand Down Expand Up @@ -289,7 +290,7 @@ bool UnlockEncryptFolderApiJob::finished()


DeleteMetadataApiJob::DeleteMetadataApiJob(const AccountPtr& account, const QByteArray& fileId, const QByteArray &token, QObject* parent)
: AbstractNetworkJob(account, e2eeBaseUrl() + QStringLiteral("meta-data/") + fileId, parent),
: AbstractNetworkJob(account, e2eeBaseUrlForMetadataAndLockUnlock() + QStringLiteral("meta-data/") + fileId, parent),
_fileId(fileId),
_token(token)
{
Expand Down Expand Up @@ -326,7 +327,7 @@ LockEncryptFolderApiJob::LockEncryptFolderApiJob(const AccountPtr &account,
SyncJournalDb *journalDb,
const QSslKey publicKey,
QObject *parent)
: AbstractNetworkJob(account, e2eeBaseUrl() + QStringLiteral("lock/") + fileId, parent)
: AbstractNetworkJob(account, e2eeBaseUrlForMetadataAndLockUnlock() + QStringLiteral("lock/") + fileId, parent)
, _fileId(fileId)
, _journalDb(journalDb)
, _publicKey(publicKey)
Expand Down
10 changes: 10 additions & 0 deletions src/libsync/foldermetadata.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,11 @@ void FolderMetadata::initMetadata()

void FolderMetadata::setupExistingMetadata(const QByteArray &metadata)
{
if (!_isRootEncryptedFolder) {
int a = 5;
a = 6;
}

const auto doc = QJsonDocument::fromJson(metadata);
qCDebug(lcCseMetadata()) << "Got existing metadata:" << doc.toJson(QJsonDocument::Compact);

Expand Down Expand Up @@ -677,6 +682,11 @@ QByteArray FolderMetadata::encryptedMetadata()

_encryptedMetadataVersion = latestSupportedMetadataVersion();

if (!_isRootEncryptedFolder) {
int a = 5;
a = 6;
}

return jsonString;
}

Expand Down

0 comments on commit 43faef6

Please sign in to comment.