From a259cd97ab88bade6e3fb7ba696727512d77a7b9 Mon Sep 17 00:00:00 2001 From: hanfel-dovned Date: Wed, 29 May 2024 15:25:18 -0700 Subject: [PATCH] lift permissions from message-pub to groupchat --- pkg/arvo/neo/cod/std/src/imp/groupchat.hoon | 46 ++++++++++++++----- pkg/arvo/neo/cod/std/src/imp/message-pub.hoon | 29 +++++------- pkg/arvo/neo/cod/std/src/imp/messenger.hoon | 10 ++-- .../neo/cod/std/src/pro/groupchat-diff.hoon | 6 ++- pkg/arvo/neo/cod/std/src/pro/groupchat.hoon | 5 +- 5 files changed, 58 insertions(+), 38 deletions(-) diff --git a/pkg/arvo/neo/cod/std/src/imp/groupchat.hoon b/pkg/arvo/neo/cod/std/src/imp/groupchat.hoon index 2398df27ee..6ab9fb86db 100644 --- a/pkg/arvo/neo/cod/std/src/imp/groupchat.hoon +++ b/pkg/arvo/neo/cod/std/src/imp/groupchat.hoon @@ -23,7 +23,8 @@ :: and subscribe to that publisher :: XX - maybe move ordering is unpredictable here ?~ old - :_ groupchat/!>([~ (snoc here.bowl %pub)]) + :_ :- %groupchat + !>([(sy our.bowl ~) ~ (snoc here.bowl %pub)]) :~ :- (snoc here.bowl %pub) [%make %message-pub ~ ~] :: @@ -36,11 +37,11 @@ =/ poke !<(groupchat-diff q.u.old) ?+ -.poke !! %invited - :_ groupchat/!>([~ (snoc chat.poke %pub)]) + :_ groupchat/!>([~ ~ host.poke]) :~ :- (snoc here.bowl %sub) - [%make %message-sub ~ (malt ~[[%pub (snoc chat.poke %pub)]])] + [%make %message-sub ~ (malt ~[[%pub (snoc host.poke %pub)]])] :: - :- chat.poke + :- host.poke [%poke groupchat-diff/!>([%acked ~])] == == @@ -54,27 +55,48 @@ :: if I'm the host, poke someone's provider to invite them to chat %invite ?> =(our ship.src):bowl - :: ?> =(our.bowl ->.publisher.sta) :: XX need @p, have @t ? + ?< (~(has in members.sta) ship.poke) + :: ?> =(our.bowl ->.host.sta) :: XX need @p, have @t ? :_ :- %groupchat !>(sta(pending (~(put in pending.sta) ship.poke))) :~ :- provider.poke [%poke groupchat-diff/!>([%invited here.bowl])] == + :: + :: remove someone from chat. this only removes their ability to post; + :: they'll still be receiving new messages! + %remove + ?> =(our ship.src):bowl + ?> (~(has in members.sta) ship.poke) + :- ~ + :- %groupchat + !> %= sta + pending (~(del in pending.sta) ship.src.bowl) + members (~(del in members.sta) ship.src.bowl) + == :: :: when invitee acks, remove them from pending :: and add them to pub's permissions %acked ?> (~(has in pending.sta) ship.src.bowl) - :_ :- %groupchat - !>(sta(pending (~(del in pending.sta) ship.src.bowl))) - :~ :- publisher.sta - [%poke ships-diff/!>([%put ship.src.bowl])] + :- ~ + :- %groupchat + !> %= sta + pending (~(del in pending.sta) ship.src.bowl) + members (~(put in members.sta) ship.src.bowl) + == + :: + %post-to-host + :_ state + :~ :- host.sta + [%poke groupchat-diff/!>([%host-to-pub text.poke])] == :: - %post + %host-to-pub + ?> (~(has in members.sta) ship.src.bowl) :_ state - :~ :- publisher.sta - [%poke txt/!>(text.poke)] + :~ :- (snoc here.bowl %pub) + [%poke message/!>([ship.src.bowl now.bowl text.poke])] == == -- diff --git a/pkg/arvo/neo/cod/std/src/imp/message-pub.hoon b/pkg/arvo/neo/cod/std/src/imp/message-pub.hoon index 704a9f40e2..c8ada9ae56 100644 --- a/pkg/arvo/neo/cod/std/src/imp/message-pub.hoon +++ b/pkg/arvo/neo/cod/std/src/imp/message-pub.hoon @@ -1,11 +1,10 @@ -/@ ships -/@ ships-diff /@ txt +/@ message :: ^- kook:neo |% -++ state pro/%ships :: ships that are allowed to post -++ poke (sy %txt %ships-diff ~) +++ state pro/%sig +++ poke (sy %message %txt ~) ++ kids :+ ~ %y %- ~(gas by *lads:neo) @@ -19,30 +18,24 @@ ++ init |= old=(unit pail:neo) ^- (quip card:neo pail:neo) - [~ ships/!>((sy our.bowl ~))] + [~ sig/!>(~)] :: ++ poke |= [=stud:neo vax=vase] ^- (quip card:neo pail:neo) - =/ members !<(ships q.state) + ?> =(our ship.src):bowl + :_ state ?+ stud !! + %message + =/ msg !<(message vax) + :~ :- (welp here.bowl ~[da/now.msg]) + [%make %message `message/vax ~] + == %txt - ?> (~(has in members) ship.src.bowl) =/ contents=@t !<(txt vax) - :_ state :~ :- (welp here.bowl ~[da/now.bowl]) [%make %message `message/!>([ship.src.bowl now.bowl contents]) ~] == - :: - %ships-diff - ?> =(our ship.src):bowl - =/ poke !<(ships-diff vax) - ?- -.poke - %put - [~ ships/!>((~(put in members) ship.poke))] - %del - [~ ships/!>((~(del in members) ship.poke))] - == == -- -- \ No newline at end of file diff --git a/pkg/arvo/neo/cod/std/src/imp/messenger.hoon b/pkg/arvo/neo/cod/std/src/imp/messenger.hoon index 607d86235a..1bf0ccf67f 100644 --- a/pkg/arvo/neo/cod/std/src/imp/messenger.hoon +++ b/pkg/arvo/neo/cod/std/src/imp/messenger.hoon @@ -36,10 +36,12 @@ :: %groupchat-diff =/ poke !<(groupchat-diff vax) - ?> =(%invited -.poke) - :_ state - :~ :- (snoc here.bowl (rear pith.src.bowl)) - [%make %groupchat `groupchat-diff/vax ~] + ?+ -.poke !! + %invited + :_ state + :~ :- (snoc here.bowl (rear host.poke)) + [%make %groupchat `groupchat-diff/vax ~] + == == :: %messenger-diff diff --git a/pkg/arvo/neo/cod/std/src/pro/groupchat-diff.hoon b/pkg/arvo/neo/cod/std/src/pro/groupchat-diff.hoon index 4a4ac29eb9..bdb8eb46a9 100644 --- a/pkg/arvo/neo/cod/std/src/pro/groupchat-diff.hoon +++ b/pkg/arvo/neo/cod/std/src/pro/groupchat-diff.hoon @@ -1,5 +1,7 @@ $% [%invite =ship provider=pith] - [%invited chat=pith] + [%remove =ship] + [%invited host=pith] [%acked ~] - [%post text=@t] + [%post-to-host text=@t] + [%host-to-pub text=@t] == \ No newline at end of file diff --git a/pkg/arvo/neo/cod/std/src/pro/groupchat.hoon b/pkg/arvo/neo/cod/std/src/pro/groupchat.hoon index 5b6c499ab0..eacd003d4a 100644 --- a/pkg/arvo/neo/cod/std/src/pro/groupchat.hoon +++ b/pkg/arvo/neo/cod/std/src/pro/groupchat.hoon @@ -1,3 +1,4 @@ -$: pending=(set ship) - publisher=pith +$: members=(set ship) + pending=(set ship) + host=pith == \ No newline at end of file