From 66d9fd8426960ab242c70b725640379a8378a207 Mon Sep 17 00:00:00 2001 From: Liam Fitzgerald Date: Tue, 16 Feb 2021 10:50:16 +1000 Subject: [PATCH] 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 --- pkg/arvo/app/group-push-hook.hoon | 9 +++++++-- pkg/arvo/app/group-store.hoon | 26 +++++++++++++++++++++++++- pkg/arvo/ted/sane.hoon | 16 +++++++++------- 3 files changed, 41 insertions(+), 10 deletions(-) diff --git a/pkg/arvo/app/group-push-hook.hoon b/pkg/arvo/app/group-push-hook.hoon index 5924db566..29bd83629 100644 --- a/pkg/arvo/app/group-push-hook.hoon +++ b/pkg/arvo/app/group-push-hook.hoon @@ -42,7 +42,7 @@ |^ ?. =(mark %sane) (on-poke:def mark vase) - [sane this] + [(sane !<(?(%check %fix) vase)) this] :: ++ scry-sharing .^ (set resource) @@ -54,7 +54,12 @@ == :: ++ sane + |= input=?(%check %fix) ^- (list card) + =; cards=(list card) + ?: =(%check input) + ~&(cards ~) + cards %+ murn ~(tap in scry-sharing) |= rid=resource @@ -67,7 +72,7 @@ =/ subs=(set ship) (get-subscribers-for-group rid) =/ to-remove=(set ship) - (~(dif in members.group) subs) + (~(dif in members.group) (~(gas in subs) our.bowl ~)) ?~ to-remove ~ `(poke-store %remove-members rid to-remove) :: diff --git a/pkg/arvo/app/group-store.hoon b/pkg/arvo/app/group-store.hoon index d1e0d9ebd..10f6afb4b 100644 --- a/pkg/arvo/app/group-store.hoon +++ b/pkg/arvo/app/group-store.hoon @@ -30,7 +30,7 @@ :: :: /- *group -/+ store=group-store, default-agent, verb, dbug, resource, *migrate +/+ store=group-store, default-agent, verb, dbug, resource, *migrate, agentio |% +$ card card:agent:gall :: @@ -111,6 +111,8 @@ ?> (team:title our.bowl src.bowl) =^ cards state ?+ mark (on-poke:def mark vase) + %sane (poke-sane:gc !<(?(%check %fix) vase)) + :: ?(%group-update %group-action) (poke-group-update:gc !<(update:store vase)) :: @@ -189,6 +191,7 @@ -- :: |_ bol=bowl:gall ++* io ~(. agentio bol) ++ peek-group |= rid=resource ^- (unit group) @@ -213,6 +216,27 @@ (~(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 |= arc=* diff --git a/pkg/arvo/ted/sane.hoon b/pkg/arvo/ted/sane.hoon index e02d38f12..e4207d2de 100644 --- a/pkg/arvo/ted/sane.hoon +++ b/pkg/arvo/ted/sane.hoon @@ -3,15 +3,16 @@ => |% ++ strand strand:spider ++$ input ?(%fix %check) :: ++ supported-apps ^- (list term) - :~ %graph-pull-hook - %group-pull-hook - %group-push-hook + :~ %group-push-hook + %group-store == :: ++ poke-all-sane + |= =input =/ m (strand ,~) ^- form:m =/ apps supported-apps @@ -19,13 +20,14 @@ ?~ apps (pure:m ~) =* app i.apps - ;< ~ bind:m (poke-our app sane+!>(%sane)) + ;< ~ bind:m (poke-our app sane+!>(input)) loop(apps t.apps) -- :: ^- thread:spider -|= vase +|= vas=vase =/ m (strand ,vase) -;< ~ bind:m poke-all-sane -;< ~ bind:m (poke-our %sane noun+!>(%fix)) +=+ !<([~ in=input] vas) +;< ~ bind:m (poke-all-sane in) +;< ~ bind:m (poke-our %sane noun+!>(in)) (pure:m !>("Done"))