2021-02-03 22:08:53 +03:00
|
|
|
/- *group, metadata=metadata-store
|
|
|
|
/+ store=graph-store, mdl=metadata, res=resource, graph, group, default-agent,
|
|
|
|
dbug, verb, push-hook
|
|
|
|
::
|
2020-12-05 07:32:17 +03:00
|
|
|
~% %graph-push-hook-top ..part ~
|
2020-08-19 22:22:20 +03:00
|
|
|
|%
|
|
|
|
+$ card card:agent:gall
|
|
|
|
++ config
|
|
|
|
^- config:push-hook
|
|
|
|
:* %graph-store
|
|
|
|
/updates
|
|
|
|
update:store
|
|
|
|
%graph-update
|
|
|
|
%graph-pull-hook
|
2021-04-14 23:49:54 +03:00
|
|
|
2 2
|
2020-08-19 22:22:20 +03:00
|
|
|
==
|
|
|
|
::
|
|
|
|
+$ agent (push-hook:push-hook config)
|
2020-09-15 20:29:26 +03:00
|
|
|
::
|
2021-01-26 05:42:44 +03:00
|
|
|
+$ state-null ~
|
|
|
|
+$ state-zero [%0 marks=(set mark)]
|
|
|
|
+$ versioned-state
|
|
|
|
$@ state-null
|
|
|
|
state-zero
|
2020-08-19 22:22:20 +03:00
|
|
|
--
|
|
|
|
::
|
|
|
|
%- agent:dbug
|
2021-02-03 22:08:53 +03:00
|
|
|
%+ verb |
|
2020-08-19 22:22:20 +03:00
|
|
|
^- agent:gall
|
|
|
|
%- (agent:push-hook config)
|
|
|
|
^- agent
|
2021-03-30 20:40:31 +03:00
|
|
|
=-
|
|
|
|
=| state-zero
|
|
|
|
=* state -
|
2020-08-19 22:22:20 +03:00
|
|
|
|_ =bowl:gall
|
|
|
|
+* this .
|
|
|
|
def ~(. (default-agent this %|) bowl)
|
|
|
|
grp ~(. group bowl)
|
|
|
|
gra ~(. graph bowl)
|
2021-03-30 20:40:31 +03:00
|
|
|
hc ~(. hook-core bowl)
|
2020-08-19 22:22:20 +03:00
|
|
|
::
|
|
|
|
++ on-init on-init:def
|
2021-01-26 05:42:44 +03:00
|
|
|
++ on-save !>(state)
|
|
|
|
++ on-load
|
|
|
|
|= =vase
|
|
|
|
=+ !<(old=versioned-state vase)
|
|
|
|
=? old ?=(~ old)
|
|
|
|
[%0 ~]
|
|
|
|
?> ?=(%0 -.old)
|
|
|
|
`this(state old)
|
|
|
|
::
|
2020-08-19 22:22:20 +03:00
|
|
|
++ on-poke on-poke:def
|
|
|
|
++ on-agent on-agent:def
|
|
|
|
++ on-watch on-watch:def
|
|
|
|
++ on-leave on-leave:def
|
|
|
|
++ on-peek on-peek:def
|
2021-01-26 05:42:44 +03:00
|
|
|
++ on-arvo
|
|
|
|
|= [=wire =sign-arvo]
|
|
|
|
^- (quip card _this)
|
|
|
|
?+ wire (on-arvo:def wire sign-arvo)
|
|
|
|
::
|
|
|
|
[%perms @ @ ~]
|
|
|
|
?> ?=(?(%add %remove) i.t.t.wire)
|
|
|
|
=* mark i.t.wire
|
|
|
|
:_ this
|
2021-03-30 20:40:31 +03:00
|
|
|
(build-permissions:hc mark i.t.t.wire %next)^~
|
2021-03-02 23:01:06 +03:00
|
|
|
::
|
|
|
|
[%transform-add @ ~]
|
|
|
|
=* mark i.t.wire
|
|
|
|
:_ this
|
2021-03-30 20:40:31 +03:00
|
|
|
(build-transform-add:hc mark %next)^~
|
2021-01-26 05:42:44 +03:00
|
|
|
==
|
|
|
|
::
|
2020-08-19 22:22:20 +03:00
|
|
|
++ on-fail on-fail:def
|
2021-02-22 23:26:56 +03:00
|
|
|
++ transform-proxy-update
|
|
|
|
|= vas=vase
|
|
|
|
^- (unit vase)
|
|
|
|
=/ =update:store !<(update:store vas)
|
2021-01-26 05:42:44 +03:00
|
|
|
=* rid resource.q.update
|
2021-02-22 23:26:56 +03:00
|
|
|
=. p.update now.bowl
|
2020-08-19 22:22:20 +03:00
|
|
|
?- -.q.update
|
2021-02-22 23:26:56 +03:00
|
|
|
%add-nodes
|
2021-02-23 01:54:45 +03:00
|
|
|
?. (is-allowed-add:hc rid nodes.q.update)
|
2021-02-22 23:26:56 +03:00
|
|
|
~
|
2021-02-23 01:54:45 +03:00
|
|
|
=/ mark (get-mark:gra rid)
|
|
|
|
?~ mark `vas
|
|
|
|
|^
|
2021-02-25 21:41:17 +03:00
|
|
|
=/ transform
|
2021-02-24 21:25:53 +03:00
|
|
|
!< $-([index:store post:store atom ?] [index:store post:store])
|
2021-02-23 01:54:45 +03:00
|
|
|
%. !>(*indexed-post:store)
|
|
|
|
.^(tube:clay (scry:hc %cc %home /[u.mark]/transform-add-nodes))
|
2021-02-25 00:30:49 +03:00
|
|
|
=/ [* result=(list [index:store node:store])]
|
2021-02-24 21:25:53 +03:00
|
|
|
%+ roll
|
|
|
|
(flatten-node-map ~(tap by nodes.q.update))
|
2021-02-23 01:54:45 +03:00
|
|
|
(transform-list transform)
|
2021-02-24 21:25:53 +03:00
|
|
|
=. nodes.q.update
|
2021-02-25 00:30:49 +03:00
|
|
|
%- ~(gas by *(map index:store node:store))
|
|
|
|
result
|
2021-02-23 01:54:45 +03:00
|
|
|
[~ !>(update)]
|
|
|
|
::
|
2021-02-24 21:25:53 +03:00
|
|
|
++ flatten-node-map
|
|
|
|
|= lis=(list [index:store node:store])
|
|
|
|
^- (list [index:store node:store])
|
|
|
|
|^
|
|
|
|
%- sort-nodes
|
2021-02-25 00:30:49 +03:00
|
|
|
%+ welp
|
2021-02-24 21:25:53 +03:00
|
|
|
(turn lis empty-children)
|
|
|
|
%- zing
|
|
|
|
%+ turn lis
|
2021-02-23 01:54:45 +03:00
|
|
|
|= [=index:store =node:store]
|
|
|
|
^- (list [index:store node:store])
|
|
|
|
?: ?=(%empty -.children.node)
|
|
|
|
~
|
2021-02-25 04:14:18 +03:00
|
|
|
%+ turn
|
|
|
|
(tap-deep:gra index p.children.node)
|
|
|
|
empty-children
|
2021-02-24 21:25:53 +03:00
|
|
|
::
|
|
|
|
++ empty-children
|
|
|
|
|= [=index:store =node:store]
|
|
|
|
^- [index:store node:store]
|
|
|
|
[index node(children [%empty ~])]
|
|
|
|
::
|
|
|
|
++ sort-nodes
|
2021-02-25 00:30:49 +03:00
|
|
|
|= unsorted=(list [index:store node:store])
|
2021-02-24 21:25:53 +03:00
|
|
|
^- (list [index:store node:store])
|
2021-02-25 00:30:49 +03:00
|
|
|
%+ sort unsorted
|
2021-02-24 21:25:53 +03:00
|
|
|
|= [p=[=index:store *] q=[=index:store *]]
|
|
|
|
^- ?
|
|
|
|
(lth (lent index.p) (lent index.q))
|
|
|
|
--
|
|
|
|
::
|
|
|
|
++ transform-list
|
|
|
|
|= transform=$-([index:store post:store atom ?] [index:store post:store])
|
|
|
|
|= $: [=index:store =node:store]
|
|
|
|
[indices=(set index:store) lis=(list [index:store node:store])]
|
|
|
|
==
|
2021-04-14 21:49:25 +03:00
|
|
|
~| "cannot put a deleted post into %add-nodes {<post.node>}"
|
|
|
|
?> ?=(%& -.post.node)
|
2021-02-24 21:25:53 +03:00
|
|
|
=/ l (lent index)
|
|
|
|
=/ parent-modified=?
|
|
|
|
%- ~(rep in indices)
|
2021-02-25 21:41:17 +03:00
|
|
|
|= [i=index:store out=_|]
|
2021-02-24 21:25:53 +03:00
|
|
|
?: out out
|
2021-02-25 21:41:17 +03:00
|
|
|
=/ k (lent i)
|
|
|
|
?: (lte l k)
|
2021-02-24 21:25:53 +03:00
|
|
|
%.n
|
2021-02-25 21:41:17 +03:00
|
|
|
=((swag [0 k] index) i)
|
2021-02-24 21:25:53 +03:00
|
|
|
=/ [ind=index:store =post:store]
|
2021-04-14 21:49:25 +03:00
|
|
|
(transform index p.post.node now.bowl parent-modified)
|
2021-02-24 21:25:53 +03:00
|
|
|
:- (~(put in indices) index)
|
2021-04-14 21:49:25 +03:00
|
|
|
(snoc lis [ind node(p.post post)])
|
2021-02-23 01:54:45 +03:00
|
|
|
--
|
2021-02-22 23:26:56 +03:00
|
|
|
::
|
2021-04-14 21:49:25 +03:00
|
|
|
%remove-posts
|
2021-02-22 23:26:56 +03:00
|
|
|
?. (is-allowed-remove:hc resource.q.update indices.q.update)
|
|
|
|
~
|
|
|
|
`vas
|
|
|
|
::
|
|
|
|
%add-graph ~
|
|
|
|
%remove-graph ~
|
|
|
|
%add-signatures ~
|
|
|
|
%remove-signatures ~
|
|
|
|
%archive-graph ~
|
|
|
|
%unarchive-graph ~
|
|
|
|
%add-tag ~
|
|
|
|
%remove-tag ~
|
|
|
|
%keys ~
|
|
|
|
%tags ~
|
|
|
|
%tag-queries ~
|
|
|
|
%run-updates ~
|
2020-08-19 22:22:20 +03:00
|
|
|
==
|
2021-02-22 23:26:56 +03:00
|
|
|
::
|
2021-02-02 07:30:48 +03:00
|
|
|
++ resource-for-update resource-for-update:gra
|
2021-02-01 23:49:14 +03:00
|
|
|
::
|
2020-08-19 22:22:20 +03:00
|
|
|
++ initial-watch
|
|
|
|
|= [=path =resource:res]
|
|
|
|
^- vase
|
2021-02-03 22:08:53 +03:00
|
|
|
?> (is-allowed:hc resource)
|
2020-08-19 22:22:20 +03:00
|
|
|
!> ^- update:store
|
|
|
|
?~ path
|
|
|
|
:: new subscribe
|
|
|
|
::
|
2020-09-15 23:46:00 +03:00
|
|
|
(get-graph:gra resource)
|
2020-08-19 22:22:20 +03:00
|
|
|
:: resubscribe
|
|
|
|
::
|
2020-11-10 22:56:19 +03:00
|
|
|
?~ (get-update-log:gra resource)
|
|
|
|
(get-graph:gra resource)
|
2020-08-19 22:22:20 +03:00
|
|
|
=/ =time (slav %da i.path)
|
|
|
|
=/ =update-log:store (get-update-log-subset:gra resource time)
|
2021-03-18 04:50:14 +03:00
|
|
|
[now.bowl [%run-updates resource update-log]]
|
2020-08-19 22:22:20 +03:00
|
|
|
::
|
|
|
|
++ take-update
|
|
|
|
|= =vase
|
|
|
|
^- [(list card) agent]
|
|
|
|
=/ =update:store !<(update:store vase)
|
2021-02-23 01:54:45 +03:00
|
|
|
?+ -.q.update [~ this]
|
2021-01-26 05:42:44 +03:00
|
|
|
%add-graph
|
|
|
|
?~ mark.q.update `this
|
|
|
|
=* mark u.mark.q.update
|
|
|
|
?: (~(has in marks) mark) `this
|
|
|
|
:_ this(marks (~(put in marks) mark))
|
|
|
|
:~ (build-permissions:hc mark %add %sing)
|
|
|
|
(build-permissions:hc mark %remove %sing)
|
2021-03-02 23:01:06 +03:00
|
|
|
(build-transform-add:hc mark %sing)
|
2021-01-26 05:42:44 +03:00
|
|
|
==
|
|
|
|
::
|
2020-08-19 22:22:20 +03:00
|
|
|
%remove-graph
|
|
|
|
:_ this
|
|
|
|
[%give %kick ~[resource+(en-path:res resource.q.update)] ~]~
|
|
|
|
::
|
|
|
|
%archive-graph
|
|
|
|
:_ this
|
|
|
|
[%give %kick ~[resource+(en-path:res resource.q.update)] ~]~
|
|
|
|
==
|
|
|
|
--
|
2021-03-30 20:40:31 +03:00
|
|
|
^| ^= hook-core
|
2021-01-26 05:42:44 +03:00
|
|
|
|_ =bowl:gall
|
|
|
|
+* grp ~(. group bowl)
|
2021-01-29 08:45:06 +03:00
|
|
|
met ~(. mdl bowl)
|
2021-02-23 01:54:45 +03:00
|
|
|
gra ~(. graph bowl)
|
|
|
|
::
|
2021-01-26 05:42:44 +03:00
|
|
|
++ scry
|
|
|
|
|= [care=@t desk=@t =path]
|
|
|
|
%+ weld
|
|
|
|
/[care]/(scot %p our.bowl)/[desk]/(scot %da now.bowl)
|
|
|
|
path
|
|
|
|
::
|
2021-01-26 07:47:35 +03:00
|
|
|
++ perm-mark-name
|
|
|
|
|= perm=@t
|
|
|
|
^- @t
|
|
|
|
(cat 3 'graph-permissions-' perm)
|
|
|
|
::
|
|
|
|
++ perm-mark
|
2021-01-29 08:45:06 +03:00
|
|
|
|= [=resource:res perm=@t vip=vip-metadata:metadata =indexed-post:store]
|
2021-01-26 05:42:44 +03:00
|
|
|
^- permissions:store
|
|
|
|
=- (check vip)
|
2021-01-29 08:45:06 +03:00
|
|
|
!< check=$-(vip-metadata:metadata permissions:store)
|
2021-01-26 05:42:44 +03:00
|
|
|
%. !>(indexed-post)
|
2021-01-26 07:47:35 +03:00
|
|
|
=/ mark (get-mark:gra resource)
|
|
|
|
?~ mark |=(=vase !>([%no %no %no]))
|
|
|
|
.^(tube:clay (scry %cc %home /[u.mark]/(perm-mark-name perm)))
|
|
|
|
::
|
|
|
|
++ add-mark
|
2021-01-29 08:45:06 +03:00
|
|
|
|= [=resource:res vip=vip-metadata:metadata =indexed-post:store]
|
2021-01-26 07:47:35 +03:00
|
|
|
(perm-mark resource %add vip indexed-post)
|
|
|
|
::
|
|
|
|
++ remove-mark
|
2021-01-29 08:45:06 +03:00
|
|
|
|= [=resource:res vip=vip-metadata:metadata =indexed-post:store]
|
2021-01-26 07:47:35 +03:00
|
|
|
(perm-mark resource %remove vip indexed-post)
|
2021-01-26 05:42:44 +03:00
|
|
|
::
|
|
|
|
++ get-permission
|
2021-01-26 07:47:35 +03:00
|
|
|
|= [=permissions:store is-admin=? writers=(set ship)]
|
2021-01-26 05:42:44 +03:00
|
|
|
^- permission-level:store
|
2021-01-26 07:47:35 +03:00
|
|
|
?: is-admin
|
2021-01-26 05:42:44 +03:00
|
|
|
admin.permissions
|
|
|
|
?: =(~ writers)
|
|
|
|
writer.permissions
|
|
|
|
?: (~(has in writers) src.bowl)
|
|
|
|
writer.permissions
|
|
|
|
reader.permissions
|
|
|
|
::
|
|
|
|
++ is-allowed
|
2021-02-03 03:34:16 +03:00
|
|
|
|= =resource:res
|
|
|
|
=/ group-res=resource:res
|
|
|
|
(need (peek-group:met %graph resource))
|
|
|
|
(is-member:grp src.bowl group-res)
|
2021-01-26 05:42:44 +03:00
|
|
|
::
|
2021-01-26 07:47:35 +03:00
|
|
|
++ get-roles-writers-variation
|
|
|
|
|= =resource:res
|
2021-01-29 08:45:06 +03:00
|
|
|
^- (unit [is-admin=? writers=(set ship) vip=vip-metadata:metadata])
|
|
|
|
=/ assoc=(unit association:metadata)
|
2021-01-26 05:42:44 +03:00
|
|
|
(peek-association:met %graph resource)
|
2021-01-26 07:47:35 +03:00
|
|
|
?~ assoc ~
|
2021-01-26 05:42:44 +03:00
|
|
|
=/ role=(unit (unit role-tag))
|
|
|
|
(role-for-ship:grp group.u.assoc src.bowl)
|
|
|
|
=/ writers=(set ship)
|
|
|
|
(get-tagged-ships:grp group.u.assoc [%graph resource %writers])
|
2021-01-26 07:47:35 +03:00
|
|
|
?~ role ~
|
2021-01-26 05:42:44 +03:00
|
|
|
=/ is-admin=?
|
|
|
|
?=(?([~ %admin] [~ %moderator]) u.role)
|
2021-01-29 08:45:06 +03:00
|
|
|
`[is-admin writers vip.metadatum.u.assoc]
|
2021-01-26 07:47:35 +03:00
|
|
|
::
|
|
|
|
++ node-to-indexed-post
|
|
|
|
|= =node:store
|
|
|
|
^- indexed-post:store
|
2021-04-14 21:49:25 +03:00
|
|
|
?> ?=(%& -.post.node)
|
|
|
|
=* index index.p.post.node
|
|
|
|
[(snag (dec (lent index)) index) p.post.node]
|
2021-01-26 07:47:35 +03:00
|
|
|
::
|
|
|
|
++ is-allowed-add
|
|
|
|
|= [=resource:res nodes=(map index:store node:store)]
|
|
|
|
^- ?
|
|
|
|
%- (bond |.(%.n))
|
|
|
|
%+ biff (get-roles-writers-variation resource)
|
2021-01-29 08:45:06 +03:00
|
|
|
|= [is-admin=? writers=(set ship) vip=vip-metadata:metadata]
|
2021-04-14 21:49:25 +03:00
|
|
|
^- (unit ?)
|
2021-01-26 07:47:35 +03:00
|
|
|
%- some
|
2021-01-26 05:42:44 +03:00
|
|
|
%+ levy ~(tap by nodes)
|
|
|
|
|= [=index:store =node:store]
|
2021-04-01 08:08:21 +03:00
|
|
|
=/ parent-index=index:store
|
|
|
|
(scag (dec (lent index)) index)
|
|
|
|
?: (~(has by nodes) parent-index) %.y
|
2021-04-14 21:49:25 +03:00
|
|
|
?- -.post.node
|
|
|
|
%| %.n
|
|
|
|
::
|
|
|
|
%&
|
|
|
|
?. =(author.p.post.node src.bowl)
|
|
|
|
%.n
|
|
|
|
=/ =permissions:store
|
|
|
|
%^ add-mark resource vip
|
|
|
|
(node-to-indexed-post node)
|
|
|
|
=/ =permission-level:store
|
|
|
|
(get-permission permissions is-admin writers)
|
|
|
|
?- permission-level
|
|
|
|
%yes %.y
|
|
|
|
%no %.n
|
|
|
|
::
|
|
|
|
%self
|
|
|
|
=/ parent-node=node:store
|
|
|
|
(got-node:gra resource parent-index)
|
|
|
|
?- -.post.parent-node
|
|
|
|
%| %.n
|
|
|
|
%& =(author.p.post.parent-node src.bowl)
|
|
|
|
==
|
|
|
|
==
|
2021-01-26 05:42:44 +03:00
|
|
|
==
|
|
|
|
::
|
|
|
|
++ is-allowed-remove
|
2021-01-26 07:47:35 +03:00
|
|
|
|= [=resource:res indices=(set index:store)]
|
2021-01-26 05:42:44 +03:00
|
|
|
^- ?
|
2021-01-26 07:47:35 +03:00
|
|
|
%- (bond |.(%.n))
|
2021-02-16 04:07:51 +03:00
|
|
|
%+ biff (get-roles-writers-variation resource)
|
2021-01-29 08:45:06 +03:00
|
|
|
|= [is-admin=? writers=(set ship) vip=vip-metadata:metadata]
|
2021-01-26 07:47:35 +03:00
|
|
|
%- some
|
|
|
|
%+ levy ~(tap by indices)
|
2021-01-26 05:42:44 +03:00
|
|
|
|= =index:store
|
2021-04-14 21:49:25 +03:00
|
|
|
^- ?
|
2021-01-26 05:42:44 +03:00
|
|
|
=/ =node:store
|
|
|
|
(got-node:gra resource index)
|
2021-04-14 21:49:25 +03:00
|
|
|
?- -.post.node
|
|
|
|
%| %.n
|
|
|
|
::
|
|
|
|
%&
|
|
|
|
=/ =permissions:store
|
|
|
|
%^ remove-mark resource vip
|
|
|
|
(node-to-indexed-post node)
|
|
|
|
=/ =permission-level:store
|
|
|
|
(get-permission permissions is-admin writers)
|
|
|
|
?- permission-level
|
|
|
|
%yes %.y
|
|
|
|
%no %.n
|
|
|
|
%self =(author.p.post.node src.bowl)
|
|
|
|
==
|
2021-01-26 05:42:44 +03:00
|
|
|
==
|
|
|
|
::
|
|
|
|
++ build-permissions
|
|
|
|
|= [=mark kind=?(%add %remove) mode=?(%sing %next)]
|
|
|
|
^- card
|
|
|
|
=/ =wire /perms/[mark]/[kind]
|
2021-01-26 07:47:35 +03:00
|
|
|
=/ =mood:clay [%c da+now.bowl /[mark]/(perm-mark-name kind)]
|
2021-01-26 05:42:44 +03:00
|
|
|
=/ =rave:clay ?:(?=(%sing mode) [mode mood] [mode mood])
|
|
|
|
[%pass wire %arvo %c %warp our.bowl %home `rave]
|
2021-03-02 23:01:06 +03:00
|
|
|
::
|
|
|
|
++ build-transform-add
|
|
|
|
|= [=mark mode=?(%sing %next)]
|
|
|
|
^- card
|
|
|
|
=/ =wire /transform-add/[mark]
|
|
|
|
=/ =mood:clay [%c da+now.bowl /[mark]/transform-add-nodes]
|
|
|
|
=/ =rave:clay ?:(?=(%sing mode) [mode mood] [mode mood])
|
|
|
|
[%pass wire %arvo %c %warp our.bowl %home `rave]
|
2021-01-26 05:42:44 +03:00
|
|
|
--
|
|
|
|
|