chat-view: support %groupify

This upgrades an existing, unmanaged village chat into a full-fledged
group plus chat.
This commit is contained in:
Fang 2020-03-13 18:13:44 +01:00
parent b77ab0f122
commit 9793dccef0
No known key found for this signature in database
GPG Key ID: EB035760C1BBA972
3 changed files with 51 additions and 0 deletions

View File

@ -245,6 +245,46 @@
(permission-hook-poke [%add-synced ship.act group-path])
(metadata-hook-poke [%add-synced ship.act group-path])
==
::
%groupify
?> ?=([%'~' ^] app-path.act)
=/ data=(unit mailbox)
(scry-for (unit mailbox) %chat-store [%mailbox app-path.act])
?~ data
~& [%cannot-groupify-nonexistent app-path.act]
~
=/ permission=(unit permission)
(scry-for (unit permission) %permission-store [%permission app-path.act])
?: |(?=(~ permission) ?=(%black kind.u.permission))
~& [%cannot-groupify-blacklist app-path.act]
~
=/ =metadata
=- (fall - *metadata)
%^ scry-for (unit metadata)
%metadata-store
=/ encoded-path=@ta
(scot %t (spat app-path.act))
/metadata/[encoded-path]/chat/[encoded-path]
=/ new-path=^path (slag 1 `path`app-path.act)
=/ members=(set ship)
%+ fall
(group-scry app-path.act)
*(set ship)
=/ cards-1=(list card)
(poke-chat-view-action %delete app-path.act)
=/ cards-2=(list card)
%- poke-chat-view-action
:* %create
title.metadata
description.metadata
new-path
new-path
%village
members
&
==
%+ snoc (weld cards-1 cards-2)
(chat-poke %messages new-path envelopes.u.data)
==
::
++ create-chat

View File

@ -258,6 +258,7 @@
:~ [%create create]
[%delete delete]
[%join join]
[%groupify groupify]
==
::
++ create
@ -281,6 +282,9 @@
[%ask-history bo]
==
::
++ groupify
(ot [%app-path pa] ~)
::
++ sec
=, dejs:format
^- $-(json rw-security)

View File

@ -12,5 +12,12 @@
==
[%delete app-path=path]
[%join =ship app-path=path ask-history=?]
:: %groupify: for unmanaged %village chats: recreate as group-based chat
::
:: will delete the old chat, recreate it based on a proper group,
:: and invite the current whitelist to that group.
:: existing messages get moved over.
::
[%groupify app-path=path]
==
--