graph-push-hook: compiles and handles %add and %remove forwarding

This commit is contained in:
Logan Allen 2021-04-14 13:49:25 -05:00
parent 2dd6e9a661
commit 52b04c515a

View File

@ -134,6 +134,8 @@
|= $: [=index:store =node:store] |= $: [=index:store =node:store]
[indices=(set index:store) lis=(list [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) =/ l (lent index)
=/ parent-modified=? =/ parent-modified=?
%- ~(rep in indices) %- ~(rep in indices)
@ -144,12 +146,12 @@
%.n %.n
=((swag [0 k] index) i) =((swag [0 k] index) i)
=/ [ind=index:store =post:store] =/ [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) :- (~(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) ?. (is-allowed-remove:hc resource.q.update indices.q.update)
~ ~
`vas `vas
@ -281,8 +283,9 @@
++ node-to-indexed-post ++ node-to-indexed-post
|= =node:store |= =node:store
^- indexed-post:store ^- indexed-post:store
=* index index.post.node ?> ?=(%& -.post.node)
[(snag (dec (lent index)) index) post.node] =* index index.p.post.node
[(snag (dec (lent index)) index) p.post.node]
:: ::
++ is-allowed-add ++ is-allowed-add
|= [=resource:res nodes=(map index:store node:store)] |= [=resource:res nodes=(map index:store node:store)]
@ -290,27 +293,36 @@
%- (bond |.(%.n)) %- (bond |.(%.n))
%+ biff (get-roles-writers-variation resource) %+ biff (get-roles-writers-variation resource)
|= [is-admin=? writers=(set ship) vip=vip-metadata:metadata] |= [is-admin=? writers=(set ship) vip=vip-metadata:metadata]
^- (unit ?)
%- some %- some
%+ levy ~(tap by nodes) %+ levy ~(tap by nodes)
|= [=index:store =node:store] |= [=index:store =node:store]
=/ parent-index=index:store =/ parent-index=index:store
(scag (dec (lent index)) index) (scag (dec (lent index)) index)
?: (~(has by nodes) parent-index) %.y ?: (~(has by nodes) parent-index) %.y
?. =(author.post.node src.bowl) ?- -.post.node
%.n %| %.n
=/ =permissions:store ::
%^ add-mark resource vip %&
(node-to-indexed-post node) ?. =(author.p.post.node src.bowl)
=/ =permission-level:store %.n
(get-permission permissions is-admin writers) =/ =permissions:store
?- permission-level %^ add-mark resource vip
%yes %.y (node-to-indexed-post node)
%no %.n =/ =permission-level:store
:: (get-permission permissions is-admin writers)
%self ?- permission-level
=/ parent-node=node:store %yes %.y
(got-node:gra resource parent-index) %no %.n
=(author.post.parent-node src.bowl) ::
%self
=/ parent-node=node:store
(got-node:gra resource parent-index)
?- -.post.parent-node
%| %.n
%& =(author.p.post.parent-node src.bowl)
==
==
== ==
:: ::
++ is-allowed-remove ++ is-allowed-remove
@ -322,17 +334,23 @@
%- some %- some
%+ levy ~(tap by indices) %+ levy ~(tap by indices)
|= =index:store |= =index:store
^- ?
=/ =node:store =/ =node:store
(got-node:gra resource index) (got-node:gra resource index)
=/ =permissions:store ?- -.post.node
%^ remove-mark resource vip %| %.n
(node-to-indexed-post node) ::
=/ =permission-level:store %&
(get-permission permissions is-admin writers) =/ =permissions:store
?- permission-level %^ remove-mark resource vip
%yes %.y (node-to-indexed-post node)
%no %.n =/ =permission-level:store
%self =(author.post.node src.bowl) (get-permission permissions is-admin writers)
?- permission-level
%yes %.y
%no %.n
%self =(author.p.post.node src.bowl)
==
== ==
:: ::
++ build-permissions ++ build-permissions