From 08dab6c5b03710226c25a3b418198afff71feecf Mon Sep 17 00:00:00 2001 From: Liam Fitzgerald Date: Thu, 3 Sep 2020 15:07:18 +1000 Subject: [PATCH] graph-view: add delete, leave threads --- pkg/arvo/sur/graph-view.hoon | 23 +++++++++---- pkg/arvo/ted/graph/delete.hoon | 61 ++++++++++++++++++++++++++++++++++ pkg/arvo/ted/graph/join.hoon | 6 ++-- pkg/arvo/ted/graph/leave.hoon | 61 ++++++++++++++++++++++++++++++++++ 4 files changed, 142 insertions(+), 9 deletions(-) create mode 100644 pkg/arvo/ted/graph/delete.hoon create mode 100644 pkg/arvo/ted/graph/leave.hoon diff --git a/pkg/arvo/sur/graph-view.hoon b/pkg/arvo/sur/graph-view.hoon index 0c0bfdc27..00cf4fe94 100644 --- a/pkg/arvo/sur/graph-view.hoon +++ b/pkg/arvo/sur/graph-view.hoon @@ -2,12 +2,23 @@ /+ resource ^? |% -++ error - $% - [%offline =ship] - [%no-permissions ~] - == -++ action +:: $error: An error from a graph-view poke +:: +:: %offline: Ship is offline +:: %bad-perms: Not permitted +:: %unknown: Anything not described above +:: ++$ error + ?(%offline %bad-perms %unknown) +:: $action: A semantic action on graphs +:: +:: %create: Create a graph and associated metadata +:: %delete: Delete a graph +:: %join: Join a graph +:: %invite: Invite users to a graph +:: %groupify: Make graph into managed group +:: ++$ action $% $: %create rid=resource diff --git a/pkg/arvo/ted/graph/delete.hoon b/pkg/arvo/ted/graph/delete.hoon new file mode 100644 index 000000000..0df982b67 --- /dev/null +++ b/pkg/arvo/ted/graph/delete.hoon @@ -0,0 +1,61 @@ +/- spider, graph-view, graph=graph-store, *metadata-store, *group +/+ strandio, resource +=> +|% +++ strand strand:spider +++ poke poke:strandio +++ poke-our poke-our:strandio +++ scry-metadata + |= rid=resource + =/ m (strand ,(unit resource)) + ;< pax=(unit path) bind:m + %+ scry:strandio ,(unit path) + ;: weld + /gx/metadata-store/resource/graph + (en-path:resource rid) + /noun + == + (pure:m (bind pax de-path:resource)) +++ scry-group + |= rid=resource + =/ m (strand ,(unit resource)) + ;< ugroup=(unit group) bind:m + %+ scry:strandio ,(unit group) + ;: weld + /gx/group-store/resource/graph + (en-path:resource rid) + /noun + == + (pure:m (need ugroup)) +++ delete-graph + |= rid=resource + =/ m (strand ,~) + ;< ~ bind:m + (poke-our %graph-push-hook %push-hook-action [%remove rid.action]) + ;< ~ bind:m + (poke-our %graph-store %graph-update [%archive-graph rid.action]) + (pure:m ~) +-- +^- thread:spider +|= arg=vase +=/ m (strand ,vase) +^- form:m +=+ !<([=action:graph-view ~] arg) +?> ?=(%delete -.action) +;< =bowl:spider bind:m get-bowl:strandio +?> =(our.bowl entity.rid.action) +;< ugroup-rid=(unit resource) bind:m + (scry-metadata rid.action) +?~ ugroup-rid (fail:m %nonexistent) +;< ugroup=(unit group) + (scry-group u.ugroup-rid) +?~ ugroup (fail:m %nonexistent) +?. hidden.u.ugroup + (delete-graph rid.action) +;< ~ bind:m + (poke-our %group-push-hook %pull-hook-action [%remove rid.action]) +;< ~ bind:m + (poke-our %group-store %group-action !>([%remove-group rid.action]) +;< ~ bind:m (delete-graph rid.action) +(pure:m !>(~)) + diff --git a/pkg/arvo/ted/graph/join.hoon b/pkg/arvo/ted/graph/join.hoon index 968e84212..588278567 100644 --- a/pkg/arvo/ted/graph/join.hoon +++ b/pkg/arvo/ted/graph/join.hoon @@ -29,9 +29,9 @@ (scry-metadata rid.action) ?^ group :: We have group, graph is managed - :: ;< ~ bind:m - :: %+ poke-our %graph-pull-hook - :: pull-hook-action+!>([%add ship.action rid.action]) + ;< ~ bind:m + %+ poke-our %graph-pull-hook + pull-hook-action+!>([%add ship.action rid.action]) (pure:m !>(~)) :: Else, add group then join ;< ~ bind:m diff --git a/pkg/arvo/ted/graph/leave.hoon b/pkg/arvo/ted/graph/leave.hoon new file mode 100644 index 000000000..aa2fe45e3 --- /dev/null +++ b/pkg/arvo/ted/graph/leave.hoon @@ -0,0 +1,61 @@ +/- spider, graph-view, graph=graph-store, *metadata-store, *group +/+ strandio, resource +=> +|% +++ strand strand:spider +++ poke poke:strandio +++ poke-our poke-our:strandio +++ scry-metadata + |= rid=resource + =/ m (strand ,(unit resource)) + ;< pax=(unit path) bind:m + %+ scry:strandio ,(unit path) + ;: weld + /gx/metadata-store/resource/graph + (en-path:resource rid) + /noun + == + (pure:m (bind pax de-path:resource)) +++ scry-group + |= rid=resource + =/ m (strand ,(unit resource)) + ;< ugroup=(unit group) bind:m + %+ scry:strandio ,(unit group) + ;: weld + /gx/group-store/resource/graph + (en-path:resource rid) + /noun + == + (pure:m (need ugroup)) +++ delete-graph + |= rid=resource + =/ m (strand ,~) + ;< ~ bind:m + (poke-our %graph-pull-hook %pull-hook-action [%remove rid.action]) + ;< ~ bind:m + (poke-our %graph-store %graph-update [%archive-graph rid.action]) + (pure:m ~) +-- +^- thread:spider +|= arg=vase +=/ m (strand ,vase) +^- form:m +=+ !<([=action:graph-view ~] arg) +?> ?=(%leave -.action) +;< =bowl:spider bind:m get-bowl:strandio +?< =(our.bowl entity.rid.action) +;< ugroup-rid=(unit resource) bind:m + (scry-metadata rid.action) +?~ ugroup-rid (fail:m %nonexistent) +;< ugroup=(unit group) + (scry-group u.ugroup-rid) +?~ ugroup (fail:m %nonexistent) +?. hidden.u.ugroup + (delete-graph rid.action) +;< ~ bind:m + (poke-our %group-push-hook %pull-hook-action [%remove rid.action]) +;< ~ bind:m + (poke-our %group-store %group-action !>([%remove-group rid.action]) +;< ~ bind:m (delete-graph rid.action) +(pure:m !>(~)) +