From feab60f8a91c70bf95a52e534cabdddecd3bceeb Mon Sep 17 00:00:00 2001 From: Isaac Visintainer Date: Mon, 30 Nov 2020 13:07:51 -0800 Subject: [PATCH] chat: import/export --- pkg/arvo/app/chat-hook.hoon | 59 ++++++++++++++++++++++++++++++++++-- pkg/arvo/app/chat-store.hoon | 16 ++++++++-- 2 files changed, 70 insertions(+), 5 deletions(-) diff --git a/pkg/arvo/app/chat-hook.hoon b/pkg/arvo/app/chat-hook.hoon index 340d1e6c1..a0f7a4ee9 100644 --- a/pkg/arvo/app/chat-hook.hoon +++ b/pkg/arvo/app/chat-hook.hoon @@ -369,6 +369,10 @@ :: %chat-hook-action (poke-chat-hook-action:cc !<(action:hook vase)) + :: + %import + ?> (team:title our.bol src.bol) + (poke-import:cc q.vase) == [cards this] :: @@ -417,8 +421,28 @@ == :: ++ on-leave on-leave:def - ++ on-peek on-peek:def - ++ on-arvo on-arvo:def + ++ on-peek + |= =path + ^- (unit (unit cage)) + ?+ path (on-peek:def path) + [%x %export ~] + ``noun+!>(state) + == + :: + ++ on-arvo + |= [=wire =sign-arvo] + ^- (quip card _this) + ?. ?=([%try-rejoin @ @ *] wire) + (on-arvo:def wire sign-arvo) + =/ nack-count=@ud (slav %ud i.t.wire) + =/ who=@p (slav %p i.t.t.wire) + =/ pax t.t.t.wire + ?> ?=([%b %wake *] sign-arvo) + ~? ?=(^ error.sign-arvo) + "behn errored in backoff timers, continuing anyway" + :_ this + [(try-rejoin:cc who pax +(nack-count))]~ + :: ++ on-fail on-fail:def -- :: @@ -677,6 +701,27 @@ == == :: +++ poke-import + |= arc=* + ^- (quip card _state) + =/ sty=state-10 ;;(state-10 arc) + :_ sty + %+ turn ~(tap by synced.sty) + |= [=path =ship] + ^- card + =/ watch-path=^path [%mailbox path] + ?: =(our.bol ship) + =/ store-wire=wire [%store path] + [%pass store-wire %agent [our.bol %chat-store] %watch watch-path] + (try-rejoin ship watch-path 0) +:: +++ try-rejoin + |= [who=@p pax=path nack-count=@ud] + ^- card + =/ =wire + [%try-rejoin (scot %ud nack-count) (scot %p who) pax] + [%pass wire %agent [who %chat-hook] %watch pax] +:: ++ watch-synced |= pax=path ^- (list card) @@ -835,6 +880,9 @@ [%pass /permissions %agent [our.bol %permission-store] %watch /updates]~ :: ?+ wir !! + [%try-rejoin @ @ *] + $(wir t.t.t.wir) + :: [%groups ~] [~[watch-groups] state] :: [%store @ *] @@ -909,6 +957,13 @@ ?> ?=(^ chat) (migrate-listen t.chat) [~ state] + :: + [%try-rejoin @ *] + =/ nack-count=@ud (slav %ud i.t.wir) + =/ wakeup=@da + (add now.bol (mul ~s1 (bex (min 19 nack-count)))) + :_ state + [%pass wir %arvo %b %wait wakeup]~ == :: ++ chat-poke diff --git a/pkg/arvo/app/chat-store.hoon b/pkg/arvo/app/chat-store.hoon index 5118babbc..e1fab3631 100644 --- a/pkg/arvo/app/chat-store.hoon +++ b/pkg/arvo/app/chat-store.hoon @@ -89,9 +89,10 @@ ?> (team:title our.bowl src.bowl) =^ cards state ?+ mark (on-poke:def mark vase) - %json (poke-json:cc !<(json vase)) - %chat-action (poke-chat-action:cc !<(action:store vase)) - %noun [~ (poke-noun:cc !<(admin-action vase))] + %json (poke-json:cc !<(json vase)) + %chat-action (poke-chat-action:cc !<(action:store vase)) + %noun [~ (poke-noun:cc !<(admin-action vase))] + %import (poke-import:cc q.vase) == [cards this] :: @@ -139,6 +140,9 @@ ?~ mailbox ~ ``noun+!>(config.u.mailbox) + :: + [%x %export ~] + ``noun+!>(state) == :: ++ on-agent on-agent:def @@ -235,6 +239,12 @@ [(weld message-moves read-moves) state] == :: +++ poke-import + |= arc=* + ^- (quip card _state) + =/ sty=state-3 ;;(state-3 arc) + [~ sty] +:: ++ handle-create |= =action:store ^- (quip card _state)