shrub/pkg/arvo/ted/graph/create.hoon

102 lines
2.5 KiB
Plaintext
Raw Normal View History

/- spider,
graph=graph-store,
met=metadata-store,
*group,
group-store,
inv=invite-store,
push-hook
2020-09-04 10:42:20 +03:00
/+ strandio, resource, graph-view
2020-09-02 08:18:07 +03:00
=>
|%
++ strand strand:spider
++ poke poke:strandio
++ poke-our poke-our:strandio
2020-09-04 10:51:28 +03:00
::
2020-09-02 08:18:07 +03:00
++ handle-group
2020-09-04 10:42:20 +03:00
|= [rid=resource =associated:graph-view]
2020-09-02 08:18:07 +03:00
=/ m (strand ,resource)
2020-09-04 10:42:20 +03:00
?: ?=(%group -.associated)
(pure:m rid.associated)
=/ push-hook-act=cage
:- %push-hook-action
!> ^- action:push-hook
[%add rid]
;< ~ bind:m
(poke-our %metadata-push-hook push-hook-act)
;< ~ bind:m
%+ poke-our %group-store
:- %group-update
!> ^- update:group-store
[%add-group rid policy.associated %.y]
;< =bowl:spider bind:m get-bowl:strandio
;< ~ bind:m
(poke-our %group-store group-update+!>([%add-members rid (sy our.bowl ~)]))
;< ~ bind:m
(poke-our %group-push-hook push-hook-act)
2020-09-02 08:18:07 +03:00
(pure:m rid)
--
2020-09-04 10:51:28 +03:00
::
2020-09-02 08:18:07 +03:00
=, strand=strand:spider
^- thread:spider
|= arg=vase
=/ m (strand ,vase)
^- form:m
=+ !<([~ =action:graph-view] arg)
2020-09-02 08:18:07 +03:00
?> ?=(%create -.action)
;< =bowl:spider bind:m get-bowl:strandio
::
2020-09-02 08:18:07 +03:00
:: Add graph to graph-store
::
2020-09-11 06:08:16 +03:00
?. =(our.bowl entity.rid.action)
(strand-fail:strandio %bad-request ~)
=/ overwrite=?
?=(%policy -.associated.action)
2020-09-02 08:18:07 +03:00
=/ =update:graph
[%0 now.bowl %add-graph rid.action *graph:graph mark.action overwrite]
2020-09-04 10:42:20 +03:00
;< ~ bind:m
(poke-our %graph-store graph-update+!>(update))
;< ~ bind:m
(poke-our %graph-push-hook %push-hook-action !>([%add rid.action]))
::
2020-09-02 08:18:07 +03:00
:: Add group, if graph is unmanaged
::
;< group=resource bind:m
(handle-group rid.action associated.action)
::
2020-09-02 08:18:07 +03:00
:: Setup metadata
::
=/ =metadatum:met
%* . *metadatum:met
title title.action
description description.action
2020-09-02 08:18:07 +03:00
date-created now.bowl
creator our.bowl
module module.action
preview %.n
2020-09-02 08:18:07 +03:00
==
=/ met-action=action:met
[%add group graph+rid.action metadatum]
2020-09-02 08:18:07 +03:00
;< ~ bind:m
(poke-our %metadata-push-hook metadata-update+!>(met-action))
::
:: Send invites
::
?: ?=(%group -.associated.action)
(pure:m !>(~))
2020-10-27 23:45:26 +03:00
?- -.policy.associated.action
%open (pure:m !>(~))
%invite
=/ inv-action=action:inv
:^ %invites %graph (shaf %graph-uid eny.bowl)
^- multi-invite:inv
:* our.bowl
%graph-push-hook
rid.action
pending.policy.associated.action
description.action
==
;< ~ bind:m
(poke-our %invite-hook %invite-action !>(inv-action))
(pure:m !>(~))
==