urbit/pkg/arvo/mar/graph/validator/post.hoon
2021-03-23 21:09:24 -05:00

46 lines
982 B
Plaintext

/- *post, met=metadata-store
|_ i=indexed-post
++ grow
|%
++ noun i
++ graph-permissions-add
|= vip=vip-metadata:met
?: ?=([@ ~] index.p.i)
[%yes %yes %no]
[%yes %yes ?:(?=(%reader-comments vip) %yes %no)]
::
++ graph-permissions-remove
|= vip=vip-metadata:met
[%yes %self %self]
:: +notification-kind: no notifications for now
::
++ notification-kind
=/ len (lent index.p.i)
`[%post [(dec len) len] %none %children]
::
++ transform-add-nodes
|= [=index =post =atom was-parent-modified=?]
^- [^index ^post]
=- [- post(index -)]
?~ index !!
?: ?=([@ ~] index)
[atom ~]
?: was-parent-modified
~|(%cannot-submit-parents-with-prepopulated-children !!)
=/ ind=^index index
(snoc (snip ind) atom)
--
++ grab
|%
:: +noun: validate post
::
++ noun
|= p=*
=/ ip ;;(indexed-post p)
?> ?=(^ contents.p.ip)
ip
--
::
++ grad %noun
--