diff --git a/desk/app/channels-server.hoon b/desk/app/channels-server.hoon index 47a7bb4f49..acd012d44a 100644 --- a/desk/app/channels-server.hoon +++ b/desk/app/channels-server.hoon @@ -16,7 +16,7 @@ |% +$ card card:agent:gall +$ current-state - $: %2 + $: %3 =v-channels:c == -- @@ -86,12 +86,19 @@ =+ !<(old=versioned-state vase) =? old ?=(%0 -.old) (state-0-to-1 old) =? old ?=(%1 -.old) (state-1-to-2 old) - ?> ?=(%2 -.old) + =? cor ?=(%2 -.old) (emit %pass /trim %agent [our.bowl %chat] %poke %chat-trim !>(~)) + =? old ?=(%2 -.old) (state-2-to-3 old) + ?> ?=(%3 -.old) =. state old inflate-io :: - +$ versioned-state $%(state-2 state-1 state-0) - +$ state-2 current-state + +$ versioned-state $%(state-3 state-2 state-1 state-0) + +$ state-3 current-state + +$ state-2 [%2 =v-channels:c] + ++ state-2-to-3 + |= old=state-2 + ^- state-3 + [%3 +.old] :: :: %1 to %2 :: @@ -204,17 +211,15 @@ ^+ cor =. cor %- emil - %- turn :_ |=(=note:agent:gall [%pass /migrate note]) - ^- (list note:agent:gall) - :~ [%agent [our.bowl %diary] %poke %diary-migrate-server !>(~)] - [%agent [our.bowl %heap] %poke %heap-migrate-server !>(~)] - [%agent [our.bowl %chat] %poke %chat-migrate-server !>(~)] + :~ [%pass /migrate %agent [our.bowl %diary] %poke %diary-migrate-server !>(~)] + [%pass /migrate %agent [our.bowl %heap] %poke %heap-migrate-server !>(~)] + [%pass /migrate %agent [our.bowl %chat] %poke %chat-migrate-server !>(~)] ::NOTE we do these here and not in /app/channels, because it's :: important that the server migration happens first, so that :: the client migration may successfully establish subscriptions. - [%agent [our.bowl %diary] %poke %diary-migrate !>(~)] - [%agent [our.bowl %heap] %poke %heap-migrate !>(~)] - [%agent [our.bowl %chat] %poke %chat-migrate !>(~)] + [%pass /migrate %agent [our.bowl %diary] %poke %diary-migrate !>(~)] + [%pass /migrate %agent [our.bowl %heap] %poke %heap-migrate !>(~)] + [%pass /migrate/final %agent [our.bowl %chat] %poke %chat-migrate !>(~)] == inflate-io :: @@ -325,6 +330,19 @@ %- (slog 'channels-server: migration poke failure' >wire< u.p.sign) cor == + [%migrate %final ~] + ?+ -.sign !! + %poke-ack + ?~ p.sign + (emit %pass /trim %agent [our.bowl %chat] %poke %chat-trim !>(~)) + %- (slog 'channels-server: migration poke failure' >wire< u.p.sign) + cor + == + [%trim ~] + ?+ -.sign !! + %poke-ack + cor + == == :: ++ watch-groups (safe-watch /groups [our.bowl %groups] /groups) diff --git a/desk/app/chat.hoon b/desk/app/chat.hoon index b29883c7fb..d67bc3d886 100644 --- a/desk/app/chat.hoon +++ b/desk/app/chat.hoon @@ -518,6 +518,9 @@ ?> from-self =+ !<(flag=[ship term] vase) (refs:migrate flag) + %chat-trim + ?> from-self + trim:migrate :: backwards compatibility :: %dm-rsvp @@ -902,6 +905,51 @@ !>(`a-channels:d`[%channel [%chat flag] %post u.command]) `[%pass /migrate %agent [our.bowl %channels] %poke cage] :: + ++ trim + =- =. old-chats - cor + ^- (map flag:two:old:c chat:two:old:c) + %- ~(run by old-chats) + |= old-chat=chat:two:old:c + =/ citations=(set [ship time]) + %- sy + ^- (list [ship time]) + %- zing + ^- (list (list [ship time])) + %+ murn (tap:on:writs:old wit.pact.old-chat) + |= [=time =writ:old] + ^- (unit (list [ship ^time])) + :: return citer message and cited message + ?. =(our.bowl author.writ) ~ + =/ cite-targets=(list [ship ^time]) + ?. ?=(%story -.content.writ) ~ + %+ murn p.p.content.writ + |= =block:old + ^- (unit [ship ^time]) + ?. ?=([%cite %chan [%chat *] *] block) ~ + ?. ?=([%msg @ @ ~] wer.cite.block) ~ + =/ who (slaw %p i.t.wer.cite.block) + ?~ who ~ + =/ tim (slaw %ud i.t.t.wer.cite.block) + ?~ tim ~ + `[u.who u.tim] + ?~ cite-targets + ~ + `[id.writ cite-targets] + %= old-chat + log ~ + dex.pact + %- malt + %+ murn ~(tap by dex.pact.old-chat) + |= [=id:old =time] + ?. (~(has in citations) id) ~ + `[id time] + wit.pact + %- malt + %+ murn (tap:on:writs:old wit.pact.old-chat) + |= [=time =writ:old] + ?. (~(has in citations) id.writ) ~ + `[time writ] + == ++ convert-pin |= =whom:t ^- whom:u