chat-hook: recreate all foreign dms as local dms
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=*
$% [%chat-update update:store]
==
--
-=| state-3
+=| state-4
=* state -
::
%- agent:dbug
=/ 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
?+ mark (on-poke:def mark vase)
%json (poke-json:cc !<(json vase))
%chat-action (poke-chat-action:cc !<(action:store vase))
- %noun [~ state]
+ %noun (poke-fix-dms:cc %fix-dms)
::
%chat-hook-action
(poke-chat-hook-action:cc !<(action:hook vase))
|_ 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)
