diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/Database.cpp | 5 | ||||
-rw-r--r-- | src/DatabaseStorage.cpp | 14 |
2 files changed, 19 insertions, 0 deletions
diff --git a/src/Database.cpp b/src/Database.cpp index 82cb21e..241d9a5 100644 --- a/src/Database.cpp +++ b/src/Database.cpp @@ -665,4 +665,9 @@ namespace odhtdb { return databaseStorage.getStoredUserNodeDataDecrypted(username, password); } + + vector<OwnedMemory> Database::getUserGroups(const Hash &nodeHash, const Signature::PublicKey &userPublicKey) const + { + return databaseStorage.getUserGroups(nodeHash, userPublicKey); + } } diff --git a/src/DatabaseStorage.cpp b/src/DatabaseStorage.cpp index 3140c96..ed190e8 100644 --- a/src/DatabaseStorage.cpp +++ b/src/DatabaseStorage.cpp @@ -1025,6 +1025,20 @@ namespace odhtdb fileOverwrite(remoteNodesFilePath, DataView(remoteNodePacker.serializer.getBuffer().data(), remoteNodePacker.serializer.getBuffer().size())); } + vector<OwnedMemory> DatabaseStorage::getUserGroups(const Hash &nodeHash, const Signature::PublicKey &userPublicKey) const + { + vector<OwnedMemory> result; + SqlQuery query(sqliteDb, "SELECT groupId FROM NodeUserGroupAssoc WHERE node = ? AND userPublicKey = ?", { DataView(nodeHash.getData(), nodeHash.getSize()), DataView((void*)userPublicKey.getData(), userPublicKey.getSize()) }); + while(query.next()) + { + const DataView groupIdRaw = query.getBlob(0); + OwnedMemory groupId(new u8[groupIdRaw.size], groupIdRaw.size); + memcpy(groupId.data, groupIdRaw.data, groupIdRaw.size); + result.emplace_back(move(groupId)); + } + return result; + } + bool DatabaseStorage::decryptNodeData(const Hash &nodeHash, const shared_ptr<OwnedMemory> decryptionKey) { sqlite3_reset(selectNodeStmt); |