From d737cb28ae3b259033f7d9f58cb5d87bcd4dda70 Mon Sep 17 00:00:00 2001 From: Logan Allen Date: Fri, 24 Jul 2020 13:59:15 -0700 Subject: [PATCH] chat-hook: recreate all foreign dms as local dms --- pkg/arvo/app/chat-hook.hoon | 71 ++++++++++++++++++++++++++++++------- 1 file changed, 58 insertions(+), 13 deletions(-) diff --git a/pkg/arvo/app/chat-hook.hoon b/pkg/arvo/app/chat-hook.hoon index cdc102c9f5..d0cf7e5613 100644 --- a/pkg/arvo/app/chat-hook.hoon +++ b/pkg/arvo/app/chat-hook.hoon @@ -18,17 +18,13 @@ state-1 state-2 state-3 + state-4 == :: -+$ state-3 - $: %3 - state-base - == ++$ state-4 [%4 state-base] ++$ state-3 [%3 state-base] ++$ state-2 [%2 state-base] :: -+$ state-2 - $: %2 - state-base - == +$ state-1 $: %1 loaded-cards=* @@ -52,7 +48,7 @@ $% [%chat-update update:store] == -- -=| state-3 +=| state-4 =* state - :: %- agent:dbug @@ -81,8 +77,14 @@ =/ old !<(versioned-state old-vase) =| cards=(list card) |- - ?: ?=(%3 -.old) + ?: ?=(%4 -.old) [cards this(state old)] + ?: ?=(%3 -.old) + =. cards + %+ weld cards + ^- (list card) + [%pass /pokeme %agent [our.bol %chat-hook] %poke %noun !>(%fix-dm)]~ + $(-.old %4) ?: ?=(%2 -.old) =. cards %+ weld cards @@ -319,9 +321,9 @@ ^- (quip card _this) =^ cards state ?+ mark (on-poke:def mark vase) - %json (poke-json:cc !<(json vase)) - %chat-action (poke-chat-action:cc !<(action:store vase)) - %noun [~ state] + %json (poke-json:cc !<(json vase)) + %chat-action (poke-chat-action:cc !<(action:store vase)) + %noun (poke-fix-dms:cc %fix-dms) :: %chat-hook-action (poke-chat-hook-action:cc !<(action:hook vase)) @@ -383,6 +385,49 @@ |_ bol=bowl:gall ++ grp ~(. grpl bol) :: +++ poke-fix-dms + |= a=%fix-dms + ^- (quip card _state) + :_ state + %- zing + %+ turn + ~(tap by synced) + |= [=path host=ship] + ^- (list card) + ?> ?=([@ @ *] path) + ?. =('~' i.path) + ~ + :: is local dm + ?: =((slav %p i.t.path) our.bol) + ~ + :: is foreign dm + :- =- [%pass /fixdm %agent [our.bol %chat-view] %poke %chat-view-action -] + !> + ^- action:store + [%delete path] + =/ mailbox=(unit mailbox:store) (chat-scry path) + ?~ mailbox + ~ + :~ =- [%pass /fixdm %agent [our.bol %chat-view] %poke %chat-view-action -] + !> + ^- action:view + :* %create + (crip "<(scot %p our.bol)> <-> [i.t.path]") + '' + /ship/(scot %p our.bol)/(crip (weld "dm--" (trip i.t.path))) + /ship/(scot %p our.bol)/(crip (weld "dm--" (trip i.t.path))) + [%invite (silt ~[(slav %p i.t.path)])] + (silt ~[(slav %p i.t.path)]) + %.y + %.n + == + :: + =- [%pass /fixdm %agent [our.bol %chat-store] %poke %chat-action -] + !> + ^- action:store + [%messages path envelopes.u.mailbox] + == +:: ++ poke-json |= jon=json ^- (quip card _state)