From aa05ab71c7628f8790700c7281d6f4527c8283b3 Mon Sep 17 00:00:00 2001 From: Brian Botha Date: Fri, 7 Jun 2024 15:17:34 +1000 Subject: [PATCH 1/2] wip: initial commit [ci skip] --- src/discovery/Discovery.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/discovery/Discovery.ts b/src/discovery/Discovery.ts index 3ec2e4af0..efc545c3b 100644 --- a/src/discovery/Discovery.ts +++ b/src/discovery/Discovery.ts @@ -42,6 +42,8 @@ import { never } from '../utils'; import Token from '../tokens/Token'; import { decodeClaimId } from '../ids'; +// TODO: add social and permission level discovery + /** * This is the reason used to cancel duplicate tasks for vertices */ From 83784f184de7e7380a864ff73acaaca7d2be079e Mon Sep 17 00:00:00 2001 From: Brian Botha Date: Fri, 7 Jun 2024 17:50:43 +1000 Subject: [PATCH 2/2] feat: setting node or vault permissions doesn't require the node to already be in the `GestaltGraph` now [ci skip] --- src/discovery/Discovery.ts | 2 -- src/gestalts/GestaltGraph.ts | 8 +++++++- tests/client/handlers/gestalts.test.ts | 11 +++++++++++ tests/client/handlers/vaults.test.ts | 6 +++--- 4 files changed, 21 insertions(+), 6 deletions(-) diff --git a/src/discovery/Discovery.ts b/src/discovery/Discovery.ts index efc545c3b..3ec2e4af0 100644 --- a/src/discovery/Discovery.ts +++ b/src/discovery/Discovery.ts @@ -42,8 +42,6 @@ import { never } from '../utils'; import Token from '../tokens/Token'; import { decodeClaimId } from '../ids'; -// TODO: add social and permission level discovery - /** * This is the reason used to cancel duplicate tasks for vertices */ diff --git a/src/gestalts/GestaltGraph.ts b/src/gestalts/GestaltGraph.ts index d44994865..3fba340da 100644 --- a/src/gestalts/GestaltGraph.ts +++ b/src/gestalts/GestaltGraph.ts @@ -1104,7 +1104,12 @@ class GestaltGraph { switch (type) { case 'node': { if ((await tran.get([...this.dbNodesPath, gestaltKey], true)) == null) { - throw new gestaltsErrors.ErrorGestaltsGraphNodeIdMissing(); + await this.setNode( + { + nodeId: id, + }, + tran, + ); } await this.acl.setNodeAction(id, action, tran); return; @@ -1498,6 +1503,7 @@ class GestaltGraph { return gestalt; } + // FIXME: this returns only 1 node that is linked to an identity, It should really return all of them. Maybe convert to a generator? protected async getIdentityLinkedNodeId( providerIdentityId: ProviderIdentityId, tran: DBTransaction, diff --git a/tests/client/handlers/gestalts.test.ts b/tests/client/handlers/gestalts.test.ts index c2d4311bd..b4cdc7f2f 100644 --- a/tests/client/handlers/gestalts.test.ts +++ b/tests/client/handlers/gestalts.test.ts @@ -1948,6 +1948,17 @@ describe('gestaltsGestaltTrustByNode', () => { notify: null, }); }); + test('trusts a node (not in gestalt graph)', async () => { + const request = { + nodeIdEncoded: nodeIdEncodedRemote, + }; + await rpcClient.methods.gestaltsGestaltTrustByNode(request); + expect( + await gestaltGraph.getGestaltActions(['node', nodeIdRemote!]), + ).toEqual({ + notify: null, + }); + }); test('trusts a node (new node)', async () => { const request = { nodeIdEncoded: nodeIdEncodedRemote, diff --git a/tests/client/handlers/vaults.test.ts b/tests/client/handlers/vaults.test.ts index af274acea..86e97efdc 100644 --- a/tests/client/handlers/vaults.test.ts +++ b/tests/client/handlers/vaults.test.ts @@ -468,9 +468,9 @@ describe('vaultsPermissionSet and vaultsPermissionUnset and vaultsPermissionGet' acl, logger, }); - await gestaltGraph.setNode({ - nodeId: nodeId, - }); + // Await gestaltGraph.setNode({ + // nodeId: nodeId, + // }); taskManager = await TaskManager.createTaskManager({ db, logger,