push-hook: replace +should-proxy-update with +transform-proxy-update

This commit is contained in:
Logan Allen 2021-02-22 14:26:56 -06:00
parent 9a777e84de
commit 4753ba5506
5 changed files with 99 additions and 70 deletions

View File

@ -67,18 +67,20 @@
++ on-arvo on-arvo:def
++ on-fail on-fail:def
::
++ should-proxy-update
|= =vase
^- ?
=/ =update:store !<(update:store vase)
++ transform-proxy-update
|= vas=vase
^- (unit vase)
:: TODO: should check if user is allowed to %add, %remove, %edit
:: contact
=/ =update:store !<(update:store vas)
?- -.update
%initial %.n
%add %.y
%remove %.y
%edit %.y
%allow %.n
%disallow %.n
%set-public %.n
%initial ~
%add `vas
%remove `vas
%edit `vas
%allow ~
%disallow ~
%set-public ~
==
::
++ resource-for-update resource-for-update:con

View File

@ -66,28 +66,38 @@
==
::
++ on-fail on-fail:def
::
++ should-proxy-update
|= =vase
^- ?
=/ =update:store !<(update:store vase)
++ transform-proxy-update
|= vas=vase
^- (unit vase)
=/ =update:store !<(update:store vas)
=* rid resource.q.update
=. p.update now.bowl
?- -.q.update
%add-graph %.n
%remove-graph %.n
%add-nodes (is-allowed-add:hc resource.q.update nodes.q.update)
%remove-nodes (is-allowed-remove:hc resource.q.update indices.q.update)
%add-signatures %.n
%remove-signatures %.n
%archive-graph %.n
%unarchive-graph %.n
%add-tag %.n
%remove-tag %.n
%keys %.n
%tags %.n
%tag-queries %.n
%run-updates %.n
%add-nodes
?. (is-allowed-add:hc resource.q.update nodes.q.update)
~
:: TODO: use marks to transform based on graph-type
`vas
::
%remove-nodes
?. (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 ~
==
::
++ resource-for-update resource-for-update:gra
::
++ initial-watch

View File

@ -110,12 +110,12 @@
++ on-arvo on-arvo:def
++ on-fail on-fail:def
::
++ should-proxy-update
|= =vase
=/ =update:store
!<(update:store vase)
++ transform-proxy-update
|= vas=vase
^- (unit vase)
=/ =update:store !<(update:store vas)
?: ?=(%initial -.update)
%.n
~
|^
=/ role=(unit (unit role-tag))
(role-for-ship:grp resource.update src.bowl)
@ -128,24 +128,36 @@
%moderator moderator
%janitor member
==
::
++ member
?: ?=(%add-members -.update)
=(~(tap in ships.update) ~[src.bowl])
?: ?=(%remove-members -.update)
=(~(tap in ships.update) ~[src.bowl])
%.n
?: ?| ?& ?=(%add-members -.update)
=(~(tap in ships.update) ~[src.bowl])
==
?& ?=(%remove-members -.update)
=(~(tap in ships.update) ~[src.bowl])
== ==
`vas
~
::
++ admin
!?=(?(%remove-group %add-group) -.update)
?. ?=(?(%remove-group %add-group) -.update)
`vas
~
::
++ moderator
?= $? %add-members %remove-members
%add-tag %remove-tag ==
-.update
?: ?=(?(%add-members %remove-members %add-tag %remove-tag) -.update)
`vas
~
::
++ non-member
?& ?=(%add-members -.update)
(can-join:grp resource.update src.bowl)
=(~(tap in ships.update) ~[src.bowl])
==
?: ?& ?=(%add-members -.update)
(can-join:grp resource.update src.bowl)
=(~(tap in ships.update) ~[src.bowl])
==
`vas
~
--
::
++ resource-for-update resource-for-update:grp
::
++ take-update

View File

@ -56,22 +56,27 @@
++ on-arvo on-arvo:def
++ on-fail on-fail:def
::
++ should-proxy-update
|= =vase
=+ !<(=update:store vase)
++ transform-proxy-update
|= vas=vase
^- (unit vase)
=/ =update:store !<(update:store vas)
?. ?=(?(%add %remove) -.update)
%.n
~
=/ role=(unit (unit role-tag))
(role-for-ship:grp group.update src.bowl)
=/ =metadatum:store
(need (peek-metadatum:met %groups group.update))
?~ role %.n
?~ role ~
?^ u.role
?=(?(%admin %moderator) u.u.role)
?. ?=(%add -.update) %.n
?& =(src.bowl entity.resource.resource.update)
?=(%member-metadata vip.metadatum)
==
?: ?=(?(%admin %moderator) u.u.role)
`vas
~
?. ?=(%add -.update) ~
?: ?& =(src.bowl entity.resource.resource.update)
?=(%member-metadata vip.metadatum)
==
`vas
~
::
++ resource-for-update resource-for-update:met
++ take-update

View File

@ -85,15 +85,15 @@
++ take-update
|~ vase
*[(list card) _^|(..on-init)]
:: +should-proxy-update: should forward update to store
:: +transform-proxy-update: optionally transform update
::
:: If %.y is produced, then the update is forwarded to the local
:: store. If %.n is produced then the update is not forwarded and
:: the poke fails.
:: If ^ is produced, then the update is forwarded to the local
:: store. If ~ is produced, the update is not forwarded and the
:: poke fails.
::
++ should-proxy-update
++ transform-proxy-update
|~ vase
*?
*(unit vase)
:: +initial-watch: produce initial state for a subscription
::
:: .resource is the resource being subscribed to.
@ -301,20 +301,20 @@
+* og ~(. push-hook bowl)
::
++ poke-update
|= =vase
|= vas=vase
^- (quip card:agent:gall _state)
?> (should-proxy-update:og vase)
=/ wire
(make-wire /store)
=/ vax=(unit vase) (transform-proxy-update:og vas)
?> ?=(^ vax)
=/ wire (make-wire /store)
:_ state
[%pass wire %agent [our.bowl store-name.config] %poke update-mark.config vase]~
[%pass wire %agent [our.bowl store-name.config] %poke update-mark.config u.vax]~
::
++ poke-hook-action
|= =action
^- (quip card:agent:gall _state)
|^
?- -.action
%add (add +.action)
%add (add +.action)
%remove (remove +.action)
%revoke (revoke +.action)
==