mirror of
https://github.com/ilyakooo0/urbit.git
synced 2024-11-28 11:40:11 +03:00
chat-*: remove unused logic
This commit is contained in:
parent
82b668cf3a
commit
34751e1bf8
File diff suppressed because it is too large
Load Diff
@ -2,8 +2,8 @@
|
||||
::
|
||||
:: data store that holds linear sequences of chat messages
|
||||
::
|
||||
/- *group
|
||||
/+ store=chat-store, default-agent, verb, dbug, group-store,
|
||||
/- *group, store=chat-store
|
||||
/+ default-agent, verb, dbug, group-store,
|
||||
graph-store, resource, *migrate, grpl=group, mdl=metadata
|
||||
~% %chat-store-top ..part ~
|
||||
|%
|
||||
@ -102,36 +102,12 @@
|
||||
?> (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))
|
||||
%import (poke-import:cc q.vase)
|
||||
==
|
||||
[cards this]
|
||||
::
|
||||
++ on-watch
|
||||
~/ %chat-store-watch
|
||||
|= =path
|
||||
^- (quip card _this)
|
||||
|^
|
||||
?> (team:title our.bowl src.bowl)
|
||||
=/ cards=(list card)
|
||||
?+ path (on-watch:def path)
|
||||
[%keys ~] (give %chat-update !>([%keys ~(key by inbox)]))
|
||||
[%all ~] (give %chat-update !>([%initial inbox]))
|
||||
[%updates ~] ~
|
||||
[%mailbox @ *]
|
||||
?> (~(has by inbox) t.path)
|
||||
(give %chat-update !>([%create t.path]))
|
||||
==
|
||||
[cards this]
|
||||
::
|
||||
++ give
|
||||
|= =cage
|
||||
^- (list card)
|
||||
[%give %fact ~ cage]~
|
||||
--
|
||||
::
|
||||
++ on-watch on-watch:def
|
||||
++ on-leave on-leave:def
|
||||
++ on-peek
|
||||
~/ %chat-store-peek
|
||||
@ -163,13 +139,11 @@
|
||||
++ on-fail on-fail:def
|
||||
--
|
||||
::
|
||||
::
|
||||
~% %chat-store-library ..card ~
|
||||
|_ bol=bowl:gall
|
||||
++ met ~(. mdl bol)
|
||||
++ grp ~(. grpl bol)
|
||||
::
|
||||
::
|
||||
++ peek-x-envelopes
|
||||
|= pax=path
|
||||
^- (unit (unit [%noun vase]))
|
||||
@ -238,27 +212,6 @@
|
||||
[[len len] (flop out)]
|
||||
==
|
||||
::
|
||||
++ poke-json
|
||||
|= jon=json
|
||||
^- (quip card _state)
|
||||
(poke-chat-action (action:dejs:store jon))
|
||||
::
|
||||
++ poke-chat-action
|
||||
|= =action:store
|
||||
^- (quip card _state)
|
||||
?- -.action
|
||||
%create (handle-create action)
|
||||
%delete (handle-delete action)
|
||||
%read (handle-read action)
|
||||
%messages (handle-messages action)
|
||||
%message
|
||||
?. =(our.bol author.envelope.action)
|
||||
(handle-message action)
|
||||
=^ message-moves state (handle-message action)
|
||||
=^ read-moves state (handle-read [%read path.action])
|
||||
[(weld message-moves read-moves) state]
|
||||
==
|
||||
::
|
||||
++ poke-import
|
||||
|= arc=*
|
||||
^- (quip card _state)
|
||||
@ -266,89 +219,6 @@
|
||||
:_ sty
|
||||
(migrate-inbox inbox.sty)
|
||||
::
|
||||
++ handle-create
|
||||
|= =action:store
|
||||
^- (quip card _state)
|
||||
?> ?=(%create -.action)
|
||||
?: (~(has by inbox) path.action) [~ state]
|
||||
:- (send-diff path.action action)
|
||||
state(inbox (~(put by inbox) path.action *mailbox:store))
|
||||
::
|
||||
++ handle-delete
|
||||
|= =action:store
|
||||
^- (quip card _state)
|
||||
?> ?=(%delete -.action)
|
||||
=/ mailbox=(unit mailbox:store)
|
||||
(~(get by inbox) path.action)
|
||||
?~ mailbox [~ state]
|
||||
:- (send-diff path.action action)
|
||||
state(inbox (~(del by inbox) path.action))
|
||||
::
|
||||
++ handle-message
|
||||
|= =action:store
|
||||
^- (quip card _state)
|
||||
?> ?=(%message -.action)
|
||||
=/ mailbox=(unit mailbox:store)
|
||||
(~(get by inbox) path.action)
|
||||
?~ mailbox
|
||||
[~ state]
|
||||
=. letter.envelope.action (evaluate-letter [author letter]:envelope.action)
|
||||
=^ envelope u.mailbox (prepend-envelope u.mailbox envelope.action)
|
||||
:_ state(inbox (~(put by inbox) path.action u.mailbox))
|
||||
(send-diff path.action action(envelope envelope))
|
||||
::
|
||||
++ handle-messages
|
||||
|= act=action:store
|
||||
^- (quip card _state)
|
||||
?> ?=(%messages -.act)
|
||||
=/ mailbox=(unit mailbox:store)
|
||||
(~(get by inbox) path.act)
|
||||
?~ mailbox
|
||||
[~ state]
|
||||
=. envelopes.act (flop envelopes.act)
|
||||
=| evaluated-envelopes=(list envelope:store)
|
||||
|- ^- (quip card _state)
|
||||
?~ envelopes.act
|
||||
:_ state(inbox (~(put by inbox) path.act u.mailbox))
|
||||
%+ send-diff path.act
|
||||
[%messages path.act 0 (lent evaluated-envelopes) evaluated-envelopes]
|
||||
=. letter.i.envelopes.act (evaluate-letter [author letter]:i.envelopes.act)
|
||||
=^ envelope u.mailbox (prepend-envelope u.mailbox i.envelopes.act)
|
||||
=. evaluated-envelopes [envelope evaluated-envelopes]
|
||||
$(envelopes.act t.envelopes.act)
|
||||
::
|
||||
++ handle-read
|
||||
|= act=action:store
|
||||
^- (quip card _state)
|
||||
?> ?=(%read -.act)
|
||||
=/ mailbox=(unit mailbox:store) (~(get by inbox) path.act)
|
||||
?~ mailbox
|
||||
[~ state]
|
||||
=. read.config.u.mailbox length.config.u.mailbox
|
||||
:- (send-diff path.act act)
|
||||
state(inbox (~(put by inbox) path.act u.mailbox))
|
||||
::
|
||||
++ evaluate-letter
|
||||
|= [author=ship =letter:store]
|
||||
^- letter:store
|
||||
=? letter
|
||||
?& ?=(%code -.letter)
|
||||
?=(~ output.letter)
|
||||
(team:title our.bol author)
|
||||
==
|
||||
=/ =hoon (ream expression.letter)
|
||||
letter(output (eval:store bol hoon))
|
||||
letter
|
||||
::
|
||||
++ prepend-envelope
|
||||
|= [=mailbox:store =envelope:store]
|
||||
^+ [envelope mailbox]
|
||||
=. number.envelope +(length.config.mailbox)
|
||||
=: length.config.mailbox +(length.config.mailbox)
|
||||
envelopes.mailbox [envelope envelopes.mailbox]
|
||||
==
|
||||
[envelope mailbox]
|
||||
::
|
||||
++ update-subscribers
|
||||
|= [pax=path =update:store]
|
||||
^- (list card)
|
||||
@ -387,13 +257,28 @@
|
||||
%- poke-graph-store
|
||||
[%0 now.bol %archive-graph rid]
|
||||
::
|
||||
++ nobody
|
||||
^- @p
|
||||
(bex 128)
|
||||
::
|
||||
++ path-to-resource
|
||||
|= =path
|
||||
^- resource
|
||||
?. ?=([@ @ ~] path)
|
||||
nobody^(spat path)
|
||||
=/ m-ship=(unit ship)
|
||||
(slaw %p i.path)
|
||||
?~ m-ship
|
||||
nobody^(spat path)
|
||||
[u.m-ship i.t.path]
|
||||
::
|
||||
++ mailbox-to-updates
|
||||
|= [=path =mailbox:store]
|
||||
^- (list card)
|
||||
=/ app-rid=resource
|
||||
(path-to-resource:store path)
|
||||
(path-to-resource path)
|
||||
=/ group-rid=resource
|
||||
(fall (group-from-app-resource:met %graph app-rid) [nobody:store %bad-group])
|
||||
(fall (group-from-app-resource:met %graph app-rid) [nobody %bad-group])
|
||||
=/ group=(unit group)
|
||||
(scry-group:grp group-rid)
|
||||
:- (add-graph app-rid mailbox)
|
||||
|
@ -1,545 +1,35 @@
|
||||
:: chat-view [landscape]:
|
||||
:: chat-view [landscape]: deprecated
|
||||
::
|
||||
:: sets up chat JS client, paginates data, and combines commands
|
||||
:: into semantic actions for the UI
|
||||
::
|
||||
/- *group,
|
||||
inv=invite-store,
|
||||
*metadata-store,
|
||||
*chat-hook,
|
||||
*metadata-hook,
|
||||
hook=chat-hook,
|
||||
contact-view,
|
||||
pull-hook
|
||||
/+ *server, default-agent, verb, dbug,
|
||||
store=chat-store,
|
||||
view=chat-view,
|
||||
group-store,
|
||||
grpl=group,
|
||||
resource,
|
||||
mdl=metadata
|
||||
::
|
||||
~% %chat-view-top ..part ~
|
||||
/+ default-agent
|
||||
|%
|
||||
+$ versioned-state
|
||||
$% state-0
|
||||
==
|
||||
::
|
||||
+$ state-0
|
||||
$: %0
|
||||
~
|
||||
==
|
||||
+$ poke
|
||||
$% [%chat-action action:store]
|
||||
[%group-action action:group-store]
|
||||
[%chat-hook-action action:hook]
|
||||
==
|
||||
::
|
||||
+$ card card:agent:gall
|
||||
--
|
||||
::
|
||||
=| state-0
|
||||
=* state -
|
||||
::
|
||||
%+ verb |
|
||||
%- agent:dbug
|
||||
^- agent:gall
|
||||
=<
|
||||
~% %chat-view-agent-core ..poke-handle-http-request ~
|
||||
|_ bol=bowl:gall
|
||||
+* this .
|
||||
chat-core +>
|
||||
cc ~(. chat-core bol)
|
||||
def ~(. (default-agent this %|) bol)
|
||||
::
|
||||
++ on-init
|
||||
^- (quip card _this)
|
||||
:_ this
|
||||
:~ :* %pass /srv %agent [our.bol %file-server]
|
||||
%poke %file-server-action
|
||||
!>([%serve-dir /'~chat' /app/landscape %.n %.y])
|
||||
==
|
||||
[%pass / %arvo %e %connect [~ /'chat-view'] %chat-view]
|
||||
[%pass /updates %agent [our.bol %chat-store] %watch /updates]
|
||||
==
|
||||
::
|
||||
++ on-poke
|
||||
~/ %chat-view-poke
|
||||
|= [=mark =vase]
|
||||
^- (quip card _this)
|
||||
?> (team:title our.bol src.bol)
|
||||
?+ mark (on-poke:def mark vase)
|
||||
%handle-http-request
|
||||
=+ !<([eyre-id=@ta =inbound-request:eyre] vase)
|
||||
:_ this
|
||||
%+ give-simple-payload:app eyre-id
|
||||
%+ require-authorization:app inbound-request
|
||||
poke-handle-http-request:cc
|
||||
::
|
||||
%json
|
||||
:_ this
|
||||
(poke-chat-view-action:cc (action:dejs:view !<(json vase)))
|
||||
::
|
||||
%chat-view-action
|
||||
:_ this
|
||||
(poke-chat-view-action:cc !<(action:view vase))
|
||||
==
|
||||
::
|
||||
++ on-watch
|
||||
~/ %chat-view-watch
|
||||
|= =path
|
||||
^- (quip card _this)
|
||||
?> (team:title our.bol src.bol)
|
||||
|^
|
||||
?: ?=([%http-response *] path)
|
||||
[~ this]
|
||||
?: =(/primary path)
|
||||
:: create inbox with 20 messages max per mailbox and send that along
|
||||
:: then quit the subscription
|
||||
:_ this
|
||||
[%give %fact ~ %json !>((update:enjs:store [%initial truncated-inbox]))]~
|
||||
(on-watch:def path)
|
||||
::
|
||||
++ message-limit 20
|
||||
::
|
||||
++ truncated-inbox
|
||||
^- inbox:store
|
||||
=/ =inbox:store
|
||||
=/ our (scot %p our.bol)
|
||||
=/ now (scot %da now.bol)
|
||||
.^(inbox:store %gx /[our]/chat-store/[now]/all/noun)
|
||||
%- ~(run by inbox)
|
||||
|= =mailbox:store
|
||||
^- mailbox:store
|
||||
[config.mailbox (scag message-limit envelopes.mailbox)]
|
||||
--
|
||||
::
|
||||
++ on-agent
|
||||
~/ %chat-view-agent
|
||||
|= [=wire =sign:agent:gall]
|
||||
^- (quip card _this)
|
||||
?+ -.sign (on-agent:def wire sign)
|
||||
%poke-ack
|
||||
?. ?=([%join-group @ @ @ @ @ ~] wire)
|
||||
(on-agent:def wire sign)
|
||||
?^ p.sign
|
||||
(on-agent:def wire sign)
|
||||
=/ =ship
|
||||
(slav %p i.t.wire)
|
||||
=/ ask-history=?
|
||||
=('y' i.t.t.wire)
|
||||
=/ rid=resource
|
||||
(de-path:resource t.t.t.wire)
|
||||
:_ this
|
||||
(joined-group:cc rid ship ask-history)
|
||||
::
|
||||
%kick
|
||||
:_ this
|
||||
[%pass / %agent [our.bol %chat-store] %watch /updates]~
|
||||
::
|
||||
%fact
|
||||
?+ p.cage.sign (on-agent:def wire sign)
|
||||
%chat-update
|
||||
:_ this
|
||||
(diff-chat-update:cc !<(update:store q.cage.sign))
|
||||
==
|
||||
==
|
||||
::
|
||||
++ on-arvo
|
||||
~/ %chat-view-arvo
|
||||
|= [=wire =sign-arvo]
|
||||
^- (quip card _this)
|
||||
?: ?=(%bound +<.sign-arvo) [~ this]
|
||||
(on-arvo:def wire sign-arvo)
|
||||
::
|
||||
++ on-save !>(state)
|
||||
++ on-load
|
||||
|= old-vase=vase
|
||||
^- (quip card _this)
|
||||
=/ old ((soft state-0) q.old-vase)
|
||||
?^ old [~ this]
|
||||
:_ this(state [%0 ~])
|
||||
:~ [%pass / %arvo %e %disconnect [~ /'~chat']]
|
||||
[%pass / %arvo %e %connect [~ /'chat-view'] %chat-view]
|
||||
:* %pass /srv %agent [our.bol %file-server]
|
||||
%poke %file-server-action
|
||||
!>([%serve-dir /'~chat' /app/landscape %.n %.y])
|
||||
==
|
||||
==
|
||||
::
|
||||
++ on-leave on-leave:def
|
||||
++ on-peek on-peek:def
|
||||
++ on-fail on-fail:def
|
||||
--
|
||||
::
|
||||
::
|
||||
~% %chat-view-library ..card ~
|
||||
|_ bol=bowl:gall
|
||||
++ grp ~(. grpl bol)
|
||||
++ md ~(. mdl bol)
|
||||
+* this .
|
||||
def ~(. (default-agent this %|) bol)
|
||||
::
|
||||
++ poke-handle-http-request
|
||||
|= =inbound-request:eyre
|
||||
^- simple-payload:http
|
||||
=+ url=(parse-request-line url.request.inbound-request)
|
||||
?+ site.url not-found:gen
|
||||
[%'chat-view' %paginate @t @t *]
|
||||
=/ start (need (rush i.t.t.site.url dem))
|
||||
=/ end (need (rush i.t.t.t.site.url dem))
|
||||
=/ pax t.t.t.t.site.url
|
||||
=/ envelopes (envelope-scry [(scot %ud start) (scot %ud end) pax])
|
||||
%- json-response:gen
|
||||
%- update:enjs:store
|
||||
[%messages pax start end envelopes]
|
||||
++ on-init
|
||||
^- (quip card _this)
|
||||
:_ this
|
||||
:~ :* %pass /srv %agent [our.bol %file-server]
|
||||
%poke %file-server-action
|
||||
!>([%serve-dir /'~chat' /app/landscape %.n %.y])
|
||||
==
|
||||
==
|
||||
::
|
||||
++ poke-json
|
||||
|= jon=json
|
||||
^- (list card)
|
||||
?> (team:title our.bol src.bol)
|
||||
(poke-chat-view-action (action:dejs:view jon))
|
||||
++ on-poke on-poke:def
|
||||
++ on-watch on-watch:def
|
||||
++ on-agent on-agent:def
|
||||
++ on-arvo on-arvo:def
|
||||
++ on-save !>(~)
|
||||
++ on-load
|
||||
|= old-vase=vase
|
||||
^- (quip card _this)
|
||||
[~ this]
|
||||
::
|
||||
++ poke-chat-view-action
|
||||
|= act=action:view
|
||||
^- (list card)
|
||||
|^
|
||||
?> (team:title our.bol src.bol)
|
||||
?- -.act
|
||||
%create
|
||||
?> ?=(^ app-path.act)
|
||||
?> ?| =(+:group-path.act app-path.act)
|
||||
=(~(tap in members.act) ~)
|
||||
==
|
||||
?^ (chat-scry app-path.act)
|
||||
~& %chat-already-exists
|
||||
~
|
||||
%- zing
|
||||
:~ %- create-group
|
||||
:* group-path.act
|
||||
app-path.act
|
||||
policy.act
|
||||
members.act
|
||||
title.act
|
||||
description.act
|
||||
managed.act
|
||||
==
|
||||
(create-metadata title.act description.act group-path.act app-path.act)
|
||||
(create-chat app-path.act allow-history.act)
|
||||
==
|
||||
::
|
||||
%delete
|
||||
?> ?=(^ app-path.act)
|
||||
:: always just delete the chat from chat-store
|
||||
::
|
||||
:+ (chat-hook-poke [%remove app-path.act])
|
||||
(chat-poke [%delete app-path.act])
|
||||
:: if we still have metadata for the chat, remove it, and the associated
|
||||
:: group if it's unmanaged.
|
||||
::
|
||||
:: we aren't guaranteed to have metadata: the chat might have been
|
||||
:: deleted by the host, which pushes metadata deletion down to us.
|
||||
::
|
||||
=/ maybe-group-path
|
||||
(maybe-group-from-chat app-path.act)
|
||||
?~ maybe-group-path
|
||||
~
|
||||
=* group-path u.maybe-group-path
|
||||
=/ rid=resource
|
||||
(de-path:resource group-path)
|
||||
=/ maybe-group
|
||||
(scry-group:grp rid)
|
||||
=/ hidden
|
||||
?~ maybe-group
|
||||
%.n
|
||||
hidden.u.maybe-group
|
||||
%- zing
|
||||
:~ ?. (is-creator group-path %chat app-path.act)
|
||||
~
|
||||
[(metadata-poke [%remove group-path [%chat app-path.act]])]~
|
||||
::
|
||||
?. hidden
|
||||
~
|
||||
:~ (group-proxy-poke %remove-members rid (sy our.bol ~))
|
||||
(group-poke [%remove-group rid ~])
|
||||
(metadata-hook-poke [%remove group-path])
|
||||
(metadata-store-poke [%remove group-path [%chat app-path.act]])
|
||||
==
|
||||
==
|
||||
::
|
||||
%invite
|
||||
=/ =group-path
|
||||
(need (maybe-group-from-chat app-path.act))
|
||||
=/ rid=resource
|
||||
(de-path:resource group-path)
|
||||
=/ =group
|
||||
(need (scry-group:grp rid))
|
||||
?> ?=(%invite -.policy.group)
|
||||
:- (group-poke %change-policy rid %invite %add-invites ships.act)
|
||||
%+ turn
|
||||
~(tap in ships.act)
|
||||
|= =ship
|
||||
(send-invite group-path app-path.act ship)
|
||||
::
|
||||
%join
|
||||
=/ group-path
|
||||
(maybe-group-from-chat app-path.act)
|
||||
=/ group
|
||||
?~ group-path
|
||||
~
|
||||
(scry-group-path:grp u.group-path)
|
||||
?: &(?=(^ group) =(hidden.u.group %.n))
|
||||
~[(chat-hook-poke %add-synced ship.act app-path.act ask-history.act)]
|
||||
=/ rid=resource
|
||||
(de-path:resource ship+app-path.act)
|
||||
?: =(our.bol entity.rid) ~
|
||||
=/ =cage
|
||||
:- %group-update
|
||||
!> ^- action:group-store
|
||||
[%add-members rid (sy our.bol ~)]
|
||||
:: we need this info in the wire to continue the flow after the
|
||||
:: poke ack
|
||||
=/ =wire
|
||||
:- %join-group
|
||||
[(scot %p ship.act) ?:(ask-history.act %y %n) ship+app-path.act]
|
||||
[%pass wire %agent [entity.rid %group-push-hook] %poke cage]~
|
||||
::
|
||||
%groupify
|
||||
=* app-path app-path.act
|
||||
=/ group-path
|
||||
(snag 0 (groups-from-resource:md %chat app-path))
|
||||
=/ scry-pax=path
|
||||
/metadata/[(scot %t (spat group-path))]/chat/[(scot %t (spat app-path))]
|
||||
=/ =metadata
|
||||
(need (scry-for (unit metadata) %metadata-store scry-pax))
|
||||
=/ old-rid=resource
|
||||
(de-path:resource group-path)
|
||||
?< (is-managed:grp old-rid)
|
||||
?~ existing.act
|
||||
:: just create contacts object for group
|
||||
~[(contact-view-poke %groupify old-rid title.metadata description.metadata)]
|
||||
:: change associations
|
||||
=* group-path group-path.u.existing.act
|
||||
=/ rid=resource
|
||||
(de-path:resource group-path)
|
||||
=/ old-group=group
|
||||
(need (scry-group:grp old-rid))
|
||||
=/ =group
|
||||
(need (scry-group:grp rid))
|
||||
=/ ships=(set ship)
|
||||
(~(dif in members.old-group) members.group)
|
||||
:* (metadata-store-poke %remove ship+app-path %chat app-path)
|
||||
(metadata-store-poke %add group-path [%chat app-path] metadata)
|
||||
(group-poke %remove-group old-rid ~)
|
||||
?. inclusive.u.existing.act
|
||||
~
|
||||
:- (group-poke %add-members rid ships)
|
||||
%+ turn
|
||||
~(tap in ships)
|
||||
|= =ship
|
||||
(send-invite group-path app-path ship)
|
||||
==
|
||||
==
|
||||
::
|
||||
++ create-chat
|
||||
|= [=path history=?]
|
||||
^- (list card)
|
||||
:~ (chat-poke [%create path])
|
||||
(chat-hook-poke [%add-owned path history])
|
||||
==
|
||||
::
|
||||
++ create-group
|
||||
|= [=path app-path=path =policy ships=(set ship) title=@t desc=@t managed=?]
|
||||
^- (list card)
|
||||
?^ (scry-group-path:grp path) ~
|
||||
=/ rid=resource
|
||||
(de-path:resource path)
|
||||
?> =(our.bol entity.rid)
|
||||
:: do not create a contacts object if this is unmanaged
|
||||
::
|
||||
:-
|
||||
?. managed
|
||||
(group-poke %add-group rid policy %.y)
|
||||
(contact-view-poke %create name.rid policy title desc)
|
||||
%+ murn ~(tap in ships)
|
||||
|= =ship
|
||||
^- (unit card)
|
||||
?: =(ship our.bol) ~
|
||||
`(send-invite path app-path ship)
|
||||
::
|
||||
++ create-metadata
|
||||
|= [title=@t description=@t group-path=path app-path=path]
|
||||
^- (list card)
|
||||
=/ =metadata
|
||||
%* . *metadata
|
||||
title title
|
||||
description description
|
||||
date-created now.bol
|
||||
creator
|
||||
(slav %p (snag 0 app-path))
|
||||
==
|
||||
:~ (metadata-poke [%add group-path [%chat app-path] metadata])
|
||||
(metadata-hook-poke [%add-owned group-path])
|
||||
==
|
||||
::
|
||||
++ contact-view-poke
|
||||
|= act=contact-view-action:contact-view
|
||||
^- card
|
||||
[%pass / %agent [our.bol %contact-view] %poke %contact-view-action !>(act)]
|
||||
::
|
||||
++ metadata-poke
|
||||
|= act=metadata-action
|
||||
^- card
|
||||
[%pass / %agent [our.bol %metadata-hook] %poke %metadata-action !>(act)]
|
||||
::
|
||||
++ metadata-store-poke
|
||||
|= act=metadata-action
|
||||
^- card
|
||||
[%pass / %agent [our.bol %metadata-store] %poke %metadata-action !>(act)]
|
||||
::
|
||||
++ send-invite
|
||||
|= [group-path=path app-path=path =ship]
|
||||
^- card
|
||||
=/ managed=?
|
||||
!=(ship+app-path group-path)
|
||||
=/ =invite:inv
|
||||
:* our.bol
|
||||
?:(managed %contact-hook %chat-hook)
|
||||
(de-path:resource ?:(managed group-path ship+app-path))
|
||||
ship ''
|
||||
==
|
||||
=/ act=action:inv
|
||||
[%invite ?:(managed %contacts %chat) (shaf %msg-uid eny.bol) invite]
|
||||
[%pass / %agent [our.bol %invite-hook] %poke %invite-action !>(act)]
|
||||
::
|
||||
++ chat-scry
|
||||
|= pax=path
|
||||
^- (unit mailbox:store)
|
||||
=. pax
|
||||
;: weld
|
||||
/(scot %p our.bol)/chat-store/(scot %da now.bol)/mailbox
|
||||
pax
|
||||
/noun
|
||||
==
|
||||
.^((unit mailbox:store) %gx pax)
|
||||
::
|
||||
++ maybe-group-from-chat
|
||||
|= app-path=path
|
||||
^- (unit path)
|
||||
?. .^(? %gu (scot %p our.bol) %metadata-store (scot %da now.bol) ~)
|
||||
?: ?=([@ ^] app-path)
|
||||
~& [%assuming-ported-legacy-chat app-path]
|
||||
`[%'~' app-path]
|
||||
~& [%weird-chat app-path]
|
||||
!!
|
||||
=/ resource-indices
|
||||
.^ (jug md-resource group-path)
|
||||
%gy
|
||||
(scot %p our.bol)
|
||||
%metadata-store
|
||||
(scot %da now.bol)
|
||||
/resource-indices
|
||||
==
|
||||
=/ groups=(set path)
|
||||
%+ fall
|
||||
(~(get by resource-indices) [%chat app-path])
|
||||
*(set path)
|
||||
?~ groups ~
|
||||
`n.groups
|
||||
::
|
||||
++ group-from-chat
|
||||
(cork maybe-group-from-chat need)
|
||||
::
|
||||
++ is-managed
|
||||
|= =path
|
||||
^- ?
|
||||
?> ?=(^ path)
|
||||
!=(i.path '~')
|
||||
::
|
||||
++ is-creator
|
||||
|= [group-path=path app-name=@ta app-path=path]
|
||||
^- ?
|
||||
=/ meta=(unit metadata)
|
||||
.^ (unit metadata)
|
||||
%gx
|
||||
(scot %p our.bol)
|
||||
%metadata-store
|
||||
(scot %da now.bol)
|
||||
%metadata
|
||||
(scot %t (spat group-path))
|
||||
app-name
|
||||
(scot %t (spat app-path))
|
||||
/noun
|
||||
==
|
||||
?~ meta !!
|
||||
=(our.bol creator.u.meta)
|
||||
--
|
||||
:: +joined-group: Successfully joined unmanaged group, continue flow
|
||||
::
|
||||
++ joined-group
|
||||
|= [rid=resource =ship ask-history=?]
|
||||
^- (list card)
|
||||
=/ =path
|
||||
(en-path:resource rid)
|
||||
?> ?=(^ path)
|
||||
:~ (group-pull-hook-poke %add ship rid)
|
||||
(metadata-hook-poke %add-synced ship path)
|
||||
(chat-hook-poke %add-synced ship t.path ask-history)
|
||||
==
|
||||
::
|
||||
++ diff-chat-update
|
||||
|= upd=update:store
|
||||
^- (list card)
|
||||
[%give %fact ~[/primary] %json !>((update:enjs:store upd))]~
|
||||
::
|
||||
:: +utilities
|
||||
::
|
||||
++ chat-poke
|
||||
|= act=action:store
|
||||
^- card
|
||||
[%pass / %agent [our.bol %chat-store] %poke %chat-action !>(act)]
|
||||
::
|
||||
++ group-poke
|
||||
|= upd=update:group-store
|
||||
^- card
|
||||
[%pass / %agent [our.bol %group-store] %poke %group-update !>(upd)]
|
||||
++ group-pull-hook-poke
|
||||
|= act=action:pull-hook
|
||||
^- card
|
||||
[%pass / %agent [our.bol %group-pull-hook] %poke %pull-hook-action !>(act)]
|
||||
::
|
||||
++ group-proxy-poke
|
||||
|= act=action:group-store
|
||||
^- card
|
||||
[%pass / %agent [entity.resource.act %group-push-hook] %poke %group-update !>(act)]
|
||||
::
|
||||
++ chat-hook-poke
|
||||
|= act=action:hook
|
||||
^- card
|
||||
[%pass / %agent [our.bol %chat-hook] %poke %chat-hook-action !>(act)]
|
||||
::
|
||||
++ metadata-hook-poke
|
||||
|= act=metadata-hook-action
|
||||
^- card
|
||||
:* %pass / %agent
|
||||
[our.bol %metadata-hook]
|
||||
%poke %metadata-hook-action
|
||||
!>(act)
|
||||
==
|
||||
::
|
||||
++ envelope-scry
|
||||
|= pax=path
|
||||
^- (list envelope:store)
|
||||
(scry-for (list envelope:store) %chat-store [%envelopes pax])
|
||||
::
|
||||
|
||||
::
|
||||
++ scry-for
|
||||
|* [=mold app=term =path]
|
||||
.^ mold
|
||||
%gx
|
||||
(scot %p our.bol)
|
||||
app
|
||||
(scot %da now.bol)
|
||||
(snoc `^path`path %noun)
|
||||
==
|
||||
++ on-leave on-leave:def
|
||||
++ on-peek on-peek:def
|
||||
++ on-fail on-fail:def
|
||||
--
|
||||
|
@ -1,51 +0,0 @@
|
||||
/- sur=chat-hook
|
||||
^?
|
||||
=< [sur .]
|
||||
=, sur
|
||||
|%
|
||||
::
|
||||
++ enjs
|
||||
|%
|
||||
++ update
|
||||
|= upd=^update
|
||||
=, enjs:format
|
||||
^- json
|
||||
%+ frond %chat-hook-update
|
||||
%- pairs
|
||||
%+ turn ~(tap by synced.upd)
|
||||
|= [pax=^path shp=^ship]
|
||||
^- [cord json]
|
||||
[(spat pax) s+(scot %p shp)]
|
||||
--
|
||||
++ dejs
|
||||
|%
|
||||
::
|
||||
++ action
|
||||
|= jon=json
|
||||
^- ^action
|
||||
=, dejs:format
|
||||
=< (parse-json jon)
|
||||
|%
|
||||
::
|
||||
++ parse-json
|
||||
%- of
|
||||
:~ [%add-owned add-owned]
|
||||
[%add-synced add-synced]
|
||||
[%remove pa]
|
||||
==
|
||||
::
|
||||
++ add-owned
|
||||
%- ot
|
||||
:~ [%path pa]
|
||||
[%allow-history bo]
|
||||
==
|
||||
::
|
||||
++ add-synced
|
||||
%- ot
|
||||
:~ [%ship (su ;~(pfix sig fed:ag))]
|
||||
[%path pa]
|
||||
[%ask-history bo]
|
||||
==
|
||||
--
|
||||
--
|
||||
--
|
@ -1,242 +0,0 @@
|
||||
|
||||
/- sur=chat-store
|
||||
/+ resource
|
||||
^?
|
||||
=< [sur .]
|
||||
=, sur
|
||||
|%
|
||||
::
|
||||
++ nobody
|
||||
^- @p
|
||||
(bex 128)
|
||||
::
|
||||
++ path-to-resource
|
||||
|= =path
|
||||
^- resource
|
||||
?. ?=([@ @ ~] path)
|
||||
nobody^(spat path)
|
||||
=/ m-ship=(unit ship)
|
||||
(slaw %p i.path)
|
||||
?~ m-ship
|
||||
nobody^(spat path)
|
||||
[u.m-ship i.t.path]
|
||||
::
|
||||
++ enjs
|
||||
=, enjs:format
|
||||
|%
|
||||
::
|
||||
++ letter
|
||||
|= =^letter
|
||||
^- json
|
||||
?- -.letter
|
||||
%text
|
||||
(frond %text s+text.letter)
|
||||
::
|
||||
%me
|
||||
(frond %me s+narrative.letter)
|
||||
::
|
||||
%url
|
||||
(frond %url s+url.letter)
|
||||
::
|
||||
%code
|
||||
%+ frond %code
|
||||
%- pairs
|
||||
:- [%expression s+expression.letter]
|
||||
:_ ~
|
||||
:- %output
|
||||
:: virtualize output rendering, +tank:enjs:format might crash
|
||||
::
|
||||
=/ result=(each (list json) tang)
|
||||
(mule |.((turn output.letter tank)))
|
||||
?- -.result
|
||||
%& a+p.result
|
||||
%| a+[a+[%s '[[output rendering error]]']~]~
|
||||
==
|
||||
==
|
||||
::
|
||||
++ envelope
|
||||
|= =^envelope
|
||||
^- json
|
||||
%- pairs
|
||||
:~ [%uid s+(scot %uv uid.envelope)]
|
||||
[%number (numb number.envelope)]
|
||||
[%author (ship author.envelope)]
|
||||
[%when (time when.envelope)]
|
||||
[%letter (letter letter.envelope)]
|
||||
==
|
||||
::
|
||||
++ config
|
||||
|= =^config
|
||||
^- json
|
||||
%- pairs
|
||||
:~ [%length (numb length.config)]
|
||||
[%read (numb read.config)]
|
||||
==
|
||||
::
|
||||
++ update
|
||||
|= upd=^update
|
||||
^- json
|
||||
%+ frond %chat-update
|
||||
%- pairs
|
||||
:_ ~
|
||||
?- -.upd
|
||||
%initial
|
||||
:- %initial
|
||||
%- pairs
|
||||
%+ turn ~(tap by inbox.upd)
|
||||
|= [pax=^path =mailbox]
|
||||
^- [cord json]
|
||||
:- (spat pax)
|
||||
%- pairs
|
||||
:~ [%envelopes [%a (turn envelopes.mailbox envelope)]]
|
||||
[%config (config config.mailbox)]
|
||||
==
|
||||
::
|
||||
%message
|
||||
:- %message
|
||||
%- pairs
|
||||
:~ [%path (path path.upd)]
|
||||
[%envelope (envelope envelope.upd)]
|
||||
==
|
||||
::
|
||||
%messages
|
||||
:- %messages
|
||||
%- pairs
|
||||
:~ [%path (path path.upd)]
|
||||
[%start (numb start.upd)]
|
||||
[%end (numb end.upd)]
|
||||
[%envelopes [%a (turn envelopes.upd envelope)]]
|
||||
==
|
||||
::
|
||||
%read
|
||||
[%read (pairs [%path (path path.upd)]~)]
|
||||
::
|
||||
%create
|
||||
[%create (pairs [%path (path path.upd)]~)]
|
||||
::
|
||||
%delete
|
||||
[%delete (pairs [%path (path path.upd)]~)]
|
||||
::
|
||||
%keys
|
||||
:- %keys
|
||||
:- %a
|
||||
%+ turn ~(tap by keys.upd)
|
||||
|= pax=^path (path pax)
|
||||
==
|
||||
--
|
||||
++ dejs
|
||||
=, dejs:format
|
||||
|%
|
||||
::
|
||||
++ action
|
||||
|= jon=json
|
||||
^- ^action
|
||||
=< (parse-json jon)
|
||||
|%
|
||||
++ parse-json
|
||||
%- of
|
||||
:~ [%create create]
|
||||
[%delete delete]
|
||||
[%message message]
|
||||
[%messages messages]
|
||||
[%read read]
|
||||
==
|
||||
::
|
||||
++ create
|
||||
(ot [%path pa]~)
|
||||
::
|
||||
++ delete
|
||||
(ot [%path pa]~)
|
||||
::
|
||||
++ message
|
||||
%- ot
|
||||
:~ [%path pa]
|
||||
[%envelope envelope]
|
||||
==
|
||||
::
|
||||
++ messages
|
||||
%- ot
|
||||
:~ [%path pa]
|
||||
[%envelopes (ar envelope)]
|
||||
==
|
||||
::
|
||||
++ read
|
||||
(ot [%path pa] ~)
|
||||
::
|
||||
++ envelope
|
||||
%- ot
|
||||
:~ [%uid serial]
|
||||
[%number ni]
|
||||
[%author (su ;~(pfix sig fed:ag))]
|
||||
[%when di]
|
||||
[%letter letter]
|
||||
==
|
||||
::
|
||||
++ letter
|
||||
%- of
|
||||
:~ [%text so]
|
||||
[%url so]
|
||||
[%code eval]
|
||||
[%me so]
|
||||
==
|
||||
::
|
||||
++ serial
|
||||
^- $-(json ^serial)
|
||||
(cu (cury slav %uv) so)
|
||||
::
|
||||
++ re :: recursive reparsers
|
||||
|* [gar=* sef=_|.(fist:dejs-soft:format)]
|
||||
|= jon=json
|
||||
^- (unit _gar)
|
||||
=- ~! gar ~! (need -) -
|
||||
((sef) jon)
|
||||
::
|
||||
++ dank :: tank
|
||||
^- $-(json (unit tank))
|
||||
=, ^? dejs-soft:format
|
||||
%+ re *tank |. ~+
|
||||
%- of :~
|
||||
leaf+sa
|
||||
palm+(ot style+(ot mid+sa cap+sa open+sa close+sa ~) lines+(ar dank) ~)
|
||||
rose+(ot style+(ot mid+sa open+sa close+sa ~) lines+(ar dank) ~)
|
||||
==
|
||||
:: %exp speech
|
||||
++ eval
|
||||
::: extract contents of an %exp speech, evaluating
|
||||
::: the {exp} if there is no {res} yet.
|
||||
::
|
||||
|= a=json
|
||||
^- [cord (list tank)]
|
||||
=, ^? dejs-soft:format
|
||||
=+ exp=((ot expression+so ~) a)
|
||||
%- need
|
||||
?~ exp [~ '' ~]
|
||||
:+ ~ u.exp
|
||||
::NOTE when sending, if output is an empty list, chat-store will evaluate
|
||||
(fall ((ot output+(ar dank) ~) a) ~)
|
||||
::
|
||||
--
|
||||
--
|
||||
::
|
||||
++ eval
|
||||
|= [=bowl:gall =hoon]
|
||||
^- (list tank)
|
||||
=/ fowl=[our=@p now=@da eny=@uvJ]
|
||||
:+ our.bowl
|
||||
now.bowl
|
||||
(shaz (cat 3 (mix [now eny]:bowl) %eny))
|
||||
::
|
||||
=/ subject [fowl ..zuse]
|
||||
=/ minted=(each [=type =nock] (list tank))
|
||||
%- mule |.
|
||||
(~(mint ut -:!>(subject)) %noun hoon)
|
||||
?: ?=(%| -.minted) p.minted
|
||||
=/ =toon
|
||||
(mock [subject nock.p.minted] |=(^ ~))
|
||||
?- -.toon
|
||||
%0 [(sell type.p.minted p.toon) ~]
|
||||
%1 :- leaf+".^ unsupported in chat eval"
|
||||
(turn ;;((list path) p.toon) smyt)
|
||||
%2 [leaf+"crash!" p.toon]
|
||||
==
|
||||
--
|
@ -1,56 +0,0 @@
|
||||
/- sur=chat-view, *rw-security
|
||||
/+ group-store
|
||||
^?
|
||||
=< [sur .]
|
||||
=, sur
|
||||
|%
|
||||
++ dejs
|
||||
|%
|
||||
++ action
|
||||
|= jon=json
|
||||
^- ^action
|
||||
=, dejs:format
|
||||
=< (parse-json jon)
|
||||
|%
|
||||
++ parse-json
|
||||
%- of
|
||||
:~ [%create create]
|
||||
[%delete delete]
|
||||
[%join join]
|
||||
[%groupify groupify]
|
||||
[%invite invite]
|
||||
==
|
||||
::
|
||||
++ create
|
||||
%- ot
|
||||
:~ [%title so]
|
||||
[%description so]
|
||||
[%app-path pa]
|
||||
[%group-path pa]
|
||||
[%policy policy:dejs:group-store]
|
||||
[%members (as (su ;~(pfix sig fed:ag)))]
|
||||
[%allow-history bo]
|
||||
[%managed bo]
|
||||
==
|
||||
::
|
||||
++ delete
|
||||
(ot [%app-path pa]~)
|
||||
::
|
||||
++ join
|
||||
%- ot
|
||||
:~ [%ship (su ;~(pfix sig fed:ag))]
|
||||
[%app-path pa]
|
||||
[%ask-history bo]
|
||||
==
|
||||
::
|
||||
++ groupify
|
||||
=- (ot [%app-path pa] [%existing -] ~)
|
||||
(mu (ot [%group-path pa] [%inclusive bo] ~))
|
||||
++ invite
|
||||
%- ot
|
||||
:~ app-path+pa
|
||||
ships+(as (su ;~(pfix sig fed:ag)))
|
||||
==
|
||||
--
|
||||
--
|
||||
--
|
@ -1,13 +0,0 @@
|
||||
/+ *chat-store
|
||||
|_ act=action
|
||||
++ grad %noun
|
||||
++ grow
|
||||
|%
|
||||
++ noun act
|
||||
--
|
||||
++ grab
|
||||
|%
|
||||
++ noun action
|
||||
++ json action:dejs
|
||||
--
|
||||
--
|
@ -1,14 +0,0 @@
|
||||
/+ *chat-hook
|
||||
|_ act=action
|
||||
++ grad %noun
|
||||
++ grow
|
||||
|%
|
||||
++ noun act
|
||||
--
|
||||
++ grab
|
||||
|%
|
||||
++ noun action
|
||||
++ json action:dejs
|
||||
--
|
||||
--
|
||||
|
@ -1,15 +0,0 @@
|
||||
/+ *chat-hook
|
||||
|_ upd=update
|
||||
++ grad %noun
|
||||
++ grow
|
||||
|%
|
||||
++ noun upd
|
||||
++ json (update:enjs upd)
|
||||
--
|
||||
::
|
||||
++ grab
|
||||
|%
|
||||
++ noun update
|
||||
--
|
||||
::
|
||||
--
|
@ -1,15 +0,0 @@
|
||||
/+ *chat-store
|
||||
|_ upd=update
|
||||
++ grad %noun
|
||||
++ grow
|
||||
|%
|
||||
++ noun upd
|
||||
++ json (update:enjs upd)
|
||||
--
|
||||
::
|
||||
++ grab
|
||||
|%
|
||||
++ noun update
|
||||
--
|
||||
::
|
||||
--
|
@ -1,13 +0,0 @@
|
||||
/+ *chat-view
|
||||
|_ act=action
|
||||
++ grad %noun
|
||||
++ grow
|
||||
|%
|
||||
++ noun act
|
||||
--
|
||||
++ grab
|
||||
|%
|
||||
++ noun action
|
||||
++ json action:dejs
|
||||
--
|
||||
--
|
Loading…
Reference in New Issue
Block a user