sane: fix accidental self kick

Does not remove ourselves from the group when run. Additionally adds
card preview support to the inside app pokes.

Fixes urbit/landscape#442
This commit is contained in:
Liam Fitzgerald 2021-02-16 10:50:16 +10:00
parent 79f461f5c9
commit 66d9fd8426
No known key found for this signature in database
GPG Key ID: D390E12C61D1CFFB
3 changed files with 41 additions and 10 deletions

View File

@ -42,7 +42,7 @@
|^ |^
?. =(mark %sane) ?. =(mark %sane)
(on-poke:def mark vase) (on-poke:def mark vase)
[sane this] [(sane !<(?(%check %fix) vase)) this]
:: ::
++ scry-sharing ++ scry-sharing
.^ (set resource) .^ (set resource)
@ -54,7 +54,12 @@
== ==
:: ::
++ sane ++ sane
|= input=?(%check %fix)
^- (list card) ^- (list card)
=; cards=(list card)
?: =(%check input)
~&(cards ~)
cards
%+ murn %+ murn
~(tap in scry-sharing) ~(tap in scry-sharing)
|= rid=resource |= rid=resource
@ -67,7 +72,7 @@
=/ subs=(set ship) =/ subs=(set ship)
(get-subscribers-for-group rid) (get-subscribers-for-group rid)
=/ to-remove=(set ship) =/ to-remove=(set ship)
(~(dif in members.group) subs) (~(dif in members.group) (~(gas in subs) our.bowl ~))
?~ to-remove ~ ?~ to-remove ~
`(poke-store %remove-members rid to-remove) `(poke-store %remove-members rid to-remove)
:: ::

View File

@ -30,7 +30,7 @@
:: ::
:: ::
/- *group /- *group
/+ store=group-store, default-agent, verb, dbug, resource, *migrate /+ store=group-store, default-agent, verb, dbug, resource, *migrate, agentio
|% |%
+$ card card:agent:gall +$ card card:agent:gall
:: ::
@ -111,6 +111,8 @@
?> (team:title our.bowl src.bowl) ?> (team:title our.bowl src.bowl)
=^ cards state =^ cards state
?+ mark (on-poke:def mark vase) ?+ mark (on-poke:def mark vase)
%sane (poke-sane:gc !<(?(%check %fix) vase))
::
?(%group-update %group-action) ?(%group-update %group-action)
(poke-group-update:gc !<(update:store vase)) (poke-group-update:gc !<(update:store vase))
:: ::
@ -189,6 +191,7 @@
-- --
:: ::
|_ bol=bowl:gall |_ bol=bowl:gall
+* io ~(. agentio bol)
++ peek-group ++ peek-group
|= rid=resource |= rid=resource
^- (unit group) ^- (unit group)
@ -213,6 +216,27 @@
(~(has in ban-ranks.policy) (clan:title ship)) (~(has in ban-ranks.policy) (clan:title ship))
== ==
== ==
++ poke-sane
|= input=?(%check %fix)
^- (quip card _state)
=; cards=(list card)
?: =(%check input)
~& cards
`state
[cards state]
%+ roll ~(tap in ~(key by groups))
|= [rid=resource out=(list card)]
?. ?& =(entity.rid our.bol)
!(~(has in members:(~(got by groups) rid)) our.bol)
==
out
=/ =wire
sane+(en-path:resource rid)
=* poke-self ~(poke-self pass:io wire)
%+ weld out
:~ (poke-self group-update+!>([%add-members rid (silt our.bol ~)]))
(poke-self group-update+!>([%add-tag rid %admin (silt our.bol ~)]))
==
:: ::
++ poke-import ++ poke-import
|= arc=* |= arc=*

View File

@ -3,15 +3,16 @@
=> =>
|% |%
++ strand strand:spider ++ strand strand:spider
+$ input ?(%fix %check)
:: ::
++ supported-apps ++ supported-apps
^- (list term) ^- (list term)
:~ %graph-pull-hook :~ %group-push-hook
%group-pull-hook %group-store
%group-push-hook
== ==
:: ::
++ poke-all-sane ++ poke-all-sane
|= =input
=/ m (strand ,~) =/ m (strand ,~)
^- form:m ^- form:m
=/ apps supported-apps =/ apps supported-apps
@ -19,13 +20,14 @@
?~ apps ?~ apps
(pure:m ~) (pure:m ~)
=* app i.apps =* app i.apps
;< ~ bind:m (poke-our app sane+!>(%sane)) ;< ~ bind:m (poke-our app sane+!>(input))
loop(apps t.apps) loop(apps t.apps)
-- --
:: ::
^- thread:spider ^- thread:spider
|= vase |= vas=vase
=/ m (strand ,vase) =/ m (strand ,vase)
;< ~ bind:m poke-all-sane =+ !<([~ in=input] vas)
;< ~ bind:m (poke-our %sane noun+!>(%fix)) ;< ~ bind:m (poke-all-sane in)
;< ~ bind:m (poke-our %sane noun+!>(in))
(pure:m !>("Done")) (pure:m !>("Done"))