aboutsummaryrefslogtreecommitdiff
path: root/src/DatabaseStorage.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/DatabaseStorage.cpp')
-rw-r--r--src/DatabaseStorage.cpp14
1 files changed, 14 insertions, 0 deletions
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);