urbit/pkg/arvo/ted/graph/join.hoon

62 lines
1.5 KiB
Plaintext
Raw Normal View History

2020-09-02 08:18:07 +03:00
/- spider, graph-view, graph=graph-store, *metadata-store, *group
/+ strandio, resource
=>
|%
++ strand strand:spider
2020-09-11 06:08:16 +03:00
++ fail strand-fail:strand
2020-09-02 08:18:07 +03:00
++ poke poke:strandio
++ poke-our poke-our:strandio
2020-09-04 10:51:28 +03:00
::
2020-09-02 08:18:07 +03:00
++ scry-metadata
|= rid=resource
2020-09-02 08:18:07 +03:00
=/ m (strand ,(unit resource))
2020-09-04 10:42:20 +03:00
^- form:m
;< pax=(unit (set path)) bind:m
%+ scry:strandio ,(unit (set path))
2020-09-02 08:18:07 +03:00
;: weld
/gx/metadata-store/resource/graph
2020-09-02 08:18:07 +03:00
(en-path:resource rid)
/noun
==
2020-09-04 10:42:20 +03:00
%- pure:m
?~ pax ~
?~ u.pax ~
`(de-path:resource n.u.pax)
2020-09-02 08:18:07 +03:00
--
2020-09-04 10:51:28 +03:00
::
2020-09-02 08:18:07 +03:00
^- thread:spider
|= arg=vase
=/ m (strand ,vase)
^- form:m
=+ !<([~ =action:graph-view] arg)
2020-09-02 08:18:07 +03:00
?> ?=(%join -.action)
;< =bowl:spider bind:m get-bowl:strandio
2020-09-11 06:08:16 +03:00
?: =(our.bowl entity.rid.action)
(fail %bad-request ~)
;< group=(unit resource) bind:m (scry-metadata rid.action)
2020-09-02 08:18:07 +03:00
?^ group
:: We have group, graph is managed
2020-09-03 08:07:18 +03:00
;< ~ bind:m
%+ poke-our %graph-pull-hook
2020-09-03 08:07:18 +03:00
pull-hook-action+!>([%add ship.action rid.action])
2020-09-02 08:18:07 +03:00
(pure:m !>(~))
:: Else, add group then join
;< ~ bind:m
2020-09-11 06:08:16 +03:00
%+ (map-err:strandio ,~) |=(* [%forbidden ~])
2020-09-02 08:18:07 +03:00
%+ poke
[ship.action %group-push-hook]
group-update+!>([%add-members rid.action (sy our.bowl ~)])
::
;< ~ bind:m
%+ poke-our %group-pull-hook
pull-hook-action+!>([%add ship.action rid.action])
::
;< ~ bind:m
%+ poke-our %metadata-hook
metadata-hook-action+!>([%add-synced ship.action (en-path:resource rid.action)])
2020-09-10 13:20:00 +03:00
::
2020-09-02 08:18:07 +03:00
;< ~ bind:m
2020-09-04 10:42:20 +03:00
%+ poke-our %graph-pull-hook
2020-09-10 13:20:00 +03:00
pull-hook-action+!>([%add ship.action rid.action])
2020-09-02 08:18:07 +03:00
(pure:m !>(~))