graph-push-hook: compiles and handles %add and %remove forwarding
|= $: [=index:store =node:store]
[indices=(set index:store) lis=(list [index:store node:store])]
==
+ ~| "cannot put a deleted post into %add-nodes {<post.node>}"
+ ?> ?=(%& -.post.node)
=/ l (lent index)
=/ parent-modified=?
%- ~(rep in indices)
%.n
=((swag [0 k] index) i)
=/ [ind=index:store =post:store]
- (transform index post.node now.bowl parent-modified)
+ (transform index p.post.node now.bowl parent-modified)
:- (~(put in indices) index)
- (snoc lis [ind node(post post)])
+ (snoc lis [ind node(p.post post)])
--
::
- %remove-nodes
+ %remove-posts
?. (is-allowed-remove:hc resource.q.update indices.q.update)
~
`vas
++ node-to-indexed-post
|= =node:store
^- indexed-post:store
- =* index index.post.node
- [(snag (dec (lent index)) index) post.node]
+ ?> ?=(%& -.post.node)
+ =* index index.p.post.node
+ [(snag (dec (lent index)) index) p.post.node]
::
++ is-allowed-add
|= [=resource:res nodes=(map index:store node:store)]
%- (bond |.(%.n))
%+ biff (get-roles-writers-variation resource)
|= [is-admin=? writers=(set ship) vip=vip-metadata:metadata]
+ ^- (unit ?)
%- some
%+ levy ~(tap by nodes)
|= [=index:store =node:store]
=/ parent-index=index:store
(scag (dec (lent index)) index)
?: (~(has by nodes) parent-index) %.y
- ?. =(author.post.node src.bowl)
+ ?- -.post.node
+ %| %.n
+ ::
+ %&
+ ?. =(author.p.post.node src.bowl)
%.n
=/ =permissions:store
%^ add-mark resource vip
%self
=/ parent-node=node:store
(got-node:gra resource parent-index)
- =(author.post.parent-node src.bowl)
+ ?- -.post.parent-node
+ %| %.n
+ %& =(author.p.post.parent-node src.bowl)
+ ==
+ ==
==
::
++ is-allowed-remove
%- some
%+ levy ~(tap by indices)
|= =index:store
+ ^- ?
=/ =node:store
(got-node:gra resource index)
+ ?- -.post.node
+ %| %.n
+ ::
+ %&
=/ =permissions:store
%^ remove-mark resource vip
(node-to-indexed-post node)
?- permission-level
%yes %.y
%no %.n
- %self =(author.post.node src.bowl)
+ %self =(author.p.post.node src.bowl)
+ ==
==
::
++ build-permissions
