urbit/pkg/arvo/ted/graph/create-group-feed.hoon

72 lines
1.8 KiB
Plaintext
Raw Normal View History

/- spider,
graph=graph-store,
met=metadata-store,
push-hook
/+ strandio, resource, graph-view
::
=* strand strand:spider
=* poke poke:strandio
=* poke-our poke-our:strandio
::
^- thread:spider
|= arg=vase
=/ m (strand ,vase)
^- form:m
=+ !<([~ =action:graph-view] arg)
?> ?=(%create-group-feed -.action)
;< =bowl:spider bind:m get-bowl:strandio
?. =(our.bowl entity.group.action)
(strand-fail:strandio %bad-request ~)
=/ feed-rid=resource
:- entity.group.action
%- crip
%+ weld (trip name.group.action)
%+ weld "-"
(trip (scot %ud (mod eny.bowl 10.000)))
;< association=(unit association:met) bind:m
%+ scry:strandio (unit association:met)
%- zing
:~ /gx/metadata-store/metadata/groups
(en-path:resource group.action)
/noun
==
?~ association
~|('No group exists, cannot make group feed.' !!)
=* metadatum metadatum.u.association
?> ?=(%group -.config.metadatum)
?> ?| ?=(~ feed.config.metadatum)
?=([~ ~] feed.config.metadatum)
==
;< ~ bind:m
%+ poke-our %graph-store
:- %graph-update-1
!> ^- update:graph
[now.bowl %add-graph feed-rid *graph:graph `%graph-validator-post %&]
;< ~ bind:m
(poke-our %graph-push-hook %push-hook-action !>([%add feed-rid]))
;< ~ bind:m
%+ poke-our %metadata-push-hook
:- %metadata-update-1
!> ^- action:met
:^ %add
group.action
groups+group.action
metadatum(feed.config ``[%graph feed-rid])
;< ~ bind:m
%+ poke-our %metadata-push-hook
:- %metadata-update-1
!> ^- action:met
:^ %add
group.action
graph+feed-rid
%* . *metadatum:met
title 'Group Feed'
date-created now.bowl
creator our.bowl
config [%graph %post]
preview %.n
hidden %.y
vip vip.action
==
2021-03-23 07:03:34 +03:00
(pure:m !>(feed-rid))