2020-09-01 04:54:39 +03:00
|
|
|
:: chat-store [landscape]:
|
|
|
|
::
|
|
|
|
:: data store that holds linear sequences of chat messages
|
2019-11-05 22:30:58 +03:00
|
|
|
::
|
2020-12-11 06:41:25 +03:00
|
|
|
/- *group, store=chat-store
|
|
|
|
/+ default-agent, verb, dbug, group-store,
|
2020-12-10 05:36:26 +03:00
|
|
|
graph-store, resource, *migrate, grpl=group, mdl=metadata
|
2020-12-05 07:32:17 +03:00
|
|
|
~% %chat-store-top ..part ~
|
2019-11-05 22:30:58 +03:00
|
|
|
|%
|
2019-11-23 01:04:36 +03:00
|
|
|
+$ card card:agent:gall
|
2019-11-06 02:50:56 +03:00
|
|
|
+$ versioned-state
|
2020-06-26 22:51:55 +03:00
|
|
|
$% state-0
|
|
|
|
state-1
|
|
|
|
state-2
|
2020-07-02 05:38:12 +03:00
|
|
|
state-3
|
2020-12-10 00:45:26 +03:00
|
|
|
state-4
|
2019-11-05 22:30:58 +03:00
|
|
|
==
|
|
|
|
::
|
2020-06-26 22:51:55 +03:00
|
|
|
+$ state-0 [%0 =inbox:store]
|
|
|
|
+$ state-1 [%1 =inbox:store]
|
|
|
|
+$ state-2 [%2 =inbox:store]
|
2020-07-02 05:38:12 +03:00
|
|
|
+$ state-3 [%3 =inbox:store]
|
2020-12-03 07:30:18 +03:00
|
|
|
+$ state-4 [%4 =inbox:store]
|
2020-06-19 21:10:22 +03:00
|
|
|
+$ admin-action
|
|
|
|
$% [%trim ~]
|
2020-12-10 05:36:26 +03:00
|
|
|
[%migrate-graph ~]
|
2020-06-19 21:10:22 +03:00
|
|
|
==
|
2019-11-05 22:30:58 +03:00
|
|
|
--
|
|
|
|
::
|
2020-12-10 00:45:26 +03:00
|
|
|
=| state-4
|
2019-11-07 09:19:32 +03:00
|
|
|
=* state -
|
2020-01-21 23:36:03 +03:00
|
|
|
::
|
|
|
|
%- agent:dbug
|
|
|
|
%+ verb |
|
2019-11-19 07:36:21 +03:00
|
|
|
^- agent:gall
|
2019-11-06 05:52:27 +03:00
|
|
|
=<
|
2020-04-03 00:43:03 +03:00
|
|
|
~% %chat-store-agent-core ..peek-x-envelopes ~
|
2019-11-19 07:36:21 +03:00
|
|
|
|_ =bowl:gall
|
2019-11-07 09:19:32 +03:00
|
|
|
+* this .
|
2019-11-06 05:52:27 +03:00
|
|
|
chat-core +>
|
2019-11-07 09:19:32 +03:00
|
|
|
cc ~(. chat-core bowl)
|
2019-11-09 00:56:35 +03:00
|
|
|
def ~(. (default-agent this %|) bowl)
|
2019-11-05 22:30:58 +03:00
|
|
|
::
|
2019-11-07 09:19:32 +03:00
|
|
|
++ on-init on-init:def
|
|
|
|
++ on-save !>(state)
|
|
|
|
++ on-load
|
2020-03-07 02:15:03 +03:00
|
|
|
|= old-vase=vase
|
2020-06-26 22:51:55 +03:00
|
|
|
^- (quip card _this)
|
|
|
|
|^
|
2020-03-07 02:15:03 +03:00
|
|
|
=/ old !<(versioned-state old-vase)
|
2020-06-27 03:29:09 +03:00
|
|
|
=| cards=(list card)
|
2020-06-24 03:28:57 +03:00
|
|
|
|-
|
|
|
|
^- (quip card _this)
|
|
|
|
?- -.old
|
2020-12-10 00:45:26 +03:00
|
|
|
%4 [cards this(state old)]
|
2020-12-03 07:30:18 +03:00
|
|
|
::
|
|
|
|
%3
|
2020-12-10 05:36:26 +03:00
|
|
|
=. cards :_(cards (poke-admin %migrate-graph ~))
|
|
|
|
$(old [%4 inbox.old])
|
2020-06-27 03:29:09 +03:00
|
|
|
::
|
2020-07-02 05:38:12 +03:00
|
|
|
%2
|
2020-06-24 03:28:57 +03:00
|
|
|
=/ =inbox:store
|
|
|
|
(migrate-path-map:group-store inbox.old)
|
|
|
|
=/ kick-paths
|
|
|
|
%~ tap in
|
|
|
|
%+ roll
|
|
|
|
~(val by sup.bowl)
|
|
|
|
|= [[=ship sub=path] subs=(set path)]
|
|
|
|
^- (set path)
|
|
|
|
?. ?=([@ @ *] sub)
|
|
|
|
subs
|
|
|
|
?. &(=(%mailbox i.sub) =('~' i.t.sub))
|
|
|
|
subs
|
|
|
|
(~(put in subs) sub)
|
2020-06-27 03:29:09 +03:00
|
|
|
=? cards ?=(^ kick-paths)
|
|
|
|
:_ cards
|
|
|
|
[%give %kick kick-paths ~]
|
2020-07-22 15:54:34 +03:00
|
|
|
$(old [%3 inbox])
|
2020-06-24 03:28:57 +03:00
|
|
|
::
|
2020-07-02 06:08:47 +03:00
|
|
|
?(%0 %1) $(old (old-to-2 inbox.old))
|
2020-06-24 03:28:57 +03:00
|
|
|
::
|
|
|
|
==
|
2020-12-10 05:36:26 +03:00
|
|
|
++ poke-admin
|
|
|
|
|= =admin-action
|
|
|
|
^- card
|
|
|
|
[%pass / %agent [our dap]:bowl %poke noun+!>(admin-action)]
|
2020-12-03 07:30:18 +03:00
|
|
|
::
|
2020-06-26 22:51:55 +03:00
|
|
|
++ old-to-2
|
|
|
|
|= =inbox:store
|
|
|
|
^- state-2
|
|
|
|
:- %2
|
|
|
|
%- ~(run by inbox)
|
2020-04-25 06:51:28 +03:00
|
|
|
|= =mailbox:store
|
|
|
|
^- mailbox:store
|
2020-03-27 23:39:22 +03:00
|
|
|
[config.mailbox (flop envelopes.mailbox)]
|
2020-06-26 22:51:55 +03:00
|
|
|
--
|
2019-11-05 22:30:58 +03:00
|
|
|
::
|
2019-11-07 09:19:32 +03:00
|
|
|
++ on-poke
|
2020-04-03 00:43:03 +03:00
|
|
|
~/ %chat-store-poke
|
2019-11-05 22:30:58 +03:00
|
|
|
|= [=mark =vase]
|
|
|
|
^- (quip card _this)
|
2019-11-06 02:50:56 +03:00
|
|
|
?> (team:title our.bowl src.bowl)
|
2019-11-05 22:30:58 +03:00
|
|
|
=^ cards state
|
2019-11-07 09:19:32 +03:00
|
|
|
?+ mark (on-poke:def mark vase)
|
2020-12-10 05:36:26 +03:00
|
|
|
%noun (poke-noun:cc !<(admin-action vase))
|
2020-12-01 00:07:51 +03:00
|
|
|
%import (poke-import:cc q.vase)
|
2019-11-05 22:30:58 +03:00
|
|
|
==
|
|
|
|
[cards this]
|
|
|
|
::
|
2020-12-11 06:41:25 +03:00
|
|
|
++ on-watch on-watch:def
|
2019-11-07 09:19:32 +03:00
|
|
|
++ on-leave on-leave:def
|
|
|
|
++ on-peek
|
2020-04-03 00:43:03 +03:00
|
|
|
~/ %chat-store-peek
|
2019-11-05 22:30:58 +03:00
|
|
|
|= =path
|
|
|
|
^- (unit (unit cage))
|
2019-11-07 09:19:32 +03:00
|
|
|
?+ path (on-peek:def path)
|
2019-11-06 05:52:27 +03:00
|
|
|
[%x %all ~] ``noun+!>(inbox)
|
|
|
|
[%x %keys ~] ``noun+!>(~(key by inbox))
|
2019-12-05 23:18:21 +03:00
|
|
|
[%x %envelopes *] (peek-x-envelopes:cc t.t.path)
|
2019-11-05 22:30:58 +03:00
|
|
|
[%x %mailbox *]
|
|
|
|
?~ t.t.path
|
|
|
|
~
|
2019-11-06 05:52:27 +03:00
|
|
|
``noun+!>((~(get by inbox) t.t.path))
|
2019-11-05 22:30:58 +03:00
|
|
|
::
|
|
|
|
[%x %config *]
|
|
|
|
?~ t.t.path
|
|
|
|
~
|
2019-11-06 05:52:27 +03:00
|
|
|
=/ mailbox (~(get by inbox) t.t.path)
|
2019-11-05 22:30:58 +03:00
|
|
|
?~ mailbox
|
|
|
|
~
|
|
|
|
``noun+!>(config.u.mailbox)
|
2020-12-01 00:07:51 +03:00
|
|
|
::
|
|
|
|
[%x %export ~]
|
|
|
|
``noun+!>(state)
|
2019-11-05 22:30:58 +03:00
|
|
|
==
|
|
|
|
::
|
2019-11-07 09:19:32 +03:00
|
|
|
++ on-agent on-agent:def
|
|
|
|
++ on-arvo on-arvo:def
|
|
|
|
++ on-fail on-fail:def
|
2019-11-05 22:30:58 +03:00
|
|
|
--
|
|
|
|
::
|
2020-04-03 00:43:03 +03:00
|
|
|
~% %chat-store-library ..card ~
|
2019-11-19 07:36:21 +03:00
|
|
|
|_ bol=bowl:gall
|
2020-12-10 05:36:26 +03:00
|
|
|
++ met ~(. mdl bol)
|
|
|
|
++ grp ~(. grpl bol)
|
|
|
|
::
|
2019-11-05 22:30:58 +03:00
|
|
|
++ peek-x-envelopes
|
|
|
|
|= pax=path
|
|
|
|
^- (unit (unit [%noun vase]))
|
|
|
|
?+ pax ~
|
|
|
|
[@ @ *]
|
|
|
|
=/ mail-path t.t.pax
|
|
|
|
=/ mailbox (~(get by inbox) mail-path)
|
|
|
|
?~ mailbox
|
|
|
|
[~ ~ %noun !>(~)]
|
|
|
|
=* envelopes envelopes.u.mailbox
|
|
|
|
=/ sign-test=[?(%neg %pos) @]
|
|
|
|
%- need
|
|
|
|
%+ rush i.pax
|
|
|
|
;~ pose
|
|
|
|
%+ cook
|
|
|
|
|= n=@
|
|
|
|
[%neg n]
|
|
|
|
;~(pfix hep dem:ag)
|
|
|
|
::
|
|
|
|
%+ cook
|
|
|
|
|= n=@
|
|
|
|
[%pos n]
|
|
|
|
dem:ag
|
|
|
|
==
|
|
|
|
=* length length.config.u.mailbox
|
|
|
|
=* start +.sign-test
|
|
|
|
?: =(-.sign-test %neg)
|
|
|
|
?: (gth start length)
|
|
|
|
[~ ~ %noun !>(envelopes)]
|
|
|
|
[~ ~ %noun !>((swag [(sub length start) start] envelopes))]
|
|
|
|
::
|
|
|
|
=/ end (slav %ud i.t.pax)
|
|
|
|
?. (lte start end)
|
|
|
|
~
|
|
|
|
=. end ?:((lth end length) end length)
|
|
|
|
[~ ~ %noun !>((swag [start (sub end start)] envelopes))]
|
|
|
|
==
|
|
|
|
::
|
2020-06-19 21:10:22 +03:00
|
|
|
++ poke-noun
|
|
|
|
|= nou=admin-action
|
2020-12-10 05:36:26 +03:00
|
|
|
^- (quip card _state)
|
|
|
|
?: ?=([%migrate-graph ~] nou)
|
|
|
|
:_ state
|
|
|
|
(migrate-inbox inbox)
|
2020-06-19 21:10:22 +03:00
|
|
|
~& %trimming-chat-store
|
2020-12-10 05:36:26 +03:00
|
|
|
:- ~
|
2020-06-26 22:51:55 +03:00
|
|
|
%_ state
|
|
|
|
inbox
|
|
|
|
%- ~(urn by inbox)
|
|
|
|
|= [=path mailbox:store]
|
|
|
|
^- mailbox:store
|
|
|
|
=/ [a=* out=(list envelope:store)]
|
|
|
|
%+ roll envelopes
|
|
|
|
|= $: =envelope:store
|
|
|
|
o=[[hav=(set serial:store) curr=@] out=(list envelope:store)]
|
|
|
|
==
|
|
|
|
?: (~(has in hav.o) uid.envelope)
|
|
|
|
[[hav.o curr.o] out.o]
|
|
|
|
:-
|
|
|
|
^- [(set serial:store) @]
|
|
|
|
[(~(put in hav.o) uid.envelope) +(curr.o)]
|
|
|
|
^- (list envelope:store)
|
|
|
|
[envelope(number curr.o) out.o]
|
|
|
|
=/ len (lent out)
|
2020-06-30 00:30:33 +03:00
|
|
|
~? !=(len (lent envelopes)) [path [%old (lent envelopes)] [%new len]]
|
2020-06-26 22:51:55 +03:00
|
|
|
[[len len] (flop out)]
|
|
|
|
==
|
2020-06-19 21:10:22 +03:00
|
|
|
::
|
2020-12-01 00:07:51 +03:00
|
|
|
++ poke-import
|
|
|
|
|= arc=*
|
|
|
|
^- (quip card _state)
|
2020-12-10 00:45:26 +03:00
|
|
|
=/ sty=state-4 [%4 (remake-map ;;((tree [path mailbox:store]) +.arc))]
|
|
|
|
:_ sty
|
|
|
|
(migrate-inbox inbox.sty)
|
2020-12-01 00:07:51 +03:00
|
|
|
::
|
2019-11-05 22:30:58 +03:00
|
|
|
++ update-subscribers
|
2020-04-25 06:51:28 +03:00
|
|
|
|= [pax=path =update:store]
|
2019-11-05 22:30:58 +03:00
|
|
|
^- (list card)
|
2019-12-22 23:12:28 +03:00
|
|
|
[%give %fact ~[pax] %chat-update !>(update)]~
|
2019-11-05 22:30:58 +03:00
|
|
|
::
|
|
|
|
++ send-diff
|
2020-04-25 06:51:28 +03:00
|
|
|
|= [pax=path upd=update:store]
|
2019-11-05 22:30:58 +03:00
|
|
|
^- (list card)
|
|
|
|
%- zing
|
2019-11-14 03:53:47 +03:00
|
|
|
:~ (update-subscribers /all upd)
|
|
|
|
(update-subscribers /updates upd)
|
|
|
|
(update-subscribers [%mailbox pax] upd)
|
|
|
|
?. |(|(=(%read -.upd) =(%message -.upd)) =(%messages -.upd))
|
2019-11-05 22:30:58 +03:00
|
|
|
~
|
2019-11-14 03:53:47 +03:00
|
|
|
?. |(=(%create -.upd) =(%delete -.upd))
|
2019-11-05 22:30:58 +03:00
|
|
|
~
|
2019-11-14 03:53:47 +03:00
|
|
|
(update-subscribers /keys upd)
|
2019-11-05 22:30:58 +03:00
|
|
|
==
|
2020-12-10 00:45:26 +03:00
|
|
|
::
|
|
|
|
++ migrate-inbox
|
|
|
|
|= =inbox:store
|
|
|
|
^- (list card)
|
2020-12-10 05:36:26 +03:00
|
|
|
%- zing
|
|
|
|
(turn ~(tap by inbox) mailbox-to-updates)
|
2020-12-10 00:45:26 +03:00
|
|
|
::
|
2020-12-10 05:36:26 +03:00
|
|
|
++ add-graph
|
|
|
|
|= [rid=resource =mailbox:store]
|
|
|
|
%- poke-graph-store
|
2020-12-10 01:00:13 +03:00
|
|
|
:+ %0 now.bol
|
2020-12-10 05:36:26 +03:00
|
|
|
:+ %add-graph rid
|
2020-12-10 00:45:26 +03:00
|
|
|
:- (mailbox-to-graph mailbox)
|
|
|
|
[`%graph-validator-chat %.y]
|
|
|
|
::
|
2020-12-10 05:36:26 +03:00
|
|
|
++ archive-graph
|
|
|
|
|= rid=resource
|
|
|
|
%- poke-graph-store
|
|
|
|
[%0 now.bol %archive-graph rid]
|
|
|
|
::
|
2020-12-11 06:41:25 +03:00
|
|
|
++ 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]
|
|
|
|
::
|
2020-12-10 05:36:26 +03:00
|
|
|
++ mailbox-to-updates
|
|
|
|
|= [=path =mailbox:store]
|
|
|
|
^- (list card)
|
|
|
|
=/ app-rid=resource
|
2020-12-11 06:41:25 +03:00
|
|
|
(path-to-resource path)
|
2020-12-10 05:36:26 +03:00
|
|
|
=/ group-rid=resource
|
2021-01-13 07:05:22 +03:00
|
|
|
(fall (peek-group:met %graph app-rid) [nobody %bad-group])
|
2020-12-10 05:36:26 +03:00
|
|
|
=/ group=(unit group)
|
|
|
|
(scry-group:grp group-rid)
|
|
|
|
:- (add-graph app-rid mailbox)
|
2020-12-10 06:52:25 +03:00
|
|
|
?~ group (archive-graph app-rid)^~
|
|
|
|
?. &(=(~ members.u.group) hidden.u.group) ~
|
2020-12-10 05:36:26 +03:00
|
|
|
~& >>> "archiving {<app-rid>}"
|
|
|
|
:~ (archive-graph app-rid)
|
|
|
|
(remove-group group-rid)
|
|
|
|
==
|
|
|
|
::
|
|
|
|
++ remove-group
|
|
|
|
|= group=resource
|
|
|
|
^- card
|
|
|
|
=- [%pass / %agent [our.bol %group-store] %poke -]
|
2021-03-18 06:53:57 +03:00
|
|
|
group-update-0+!>([%remove-group group ~])
|
2020-12-10 00:45:26 +03:00
|
|
|
::
|
|
|
|
++ poke-graph-store
|
|
|
|
|= =update:graph-store
|
|
|
|
^- card
|
2021-03-18 06:53:57 +03:00
|
|
|
[%pass / %agent [our.bol %graph-store] %poke %graph-update-0 !>(update)]
|
2020-12-10 00:45:26 +03:00
|
|
|
::
|
|
|
|
++ letter-to-contents
|
|
|
|
|= =letter:store
|
|
|
|
^- (list content:graph-store)
|
|
|
|
:_ ~
|
|
|
|
?. ?=(%me -.letter)
|
|
|
|
letter
|
|
|
|
[%text narrative.letter]
|
|
|
|
::
|
|
|
|
++ envelope-to-node
|
|
|
|
|= =envelope:store
|
|
|
|
^- [atom:graph-store node:graph-store]
|
|
|
|
=/ contents=(list content:graph-store)
|
|
|
|
(letter-to-contents letter.envelope)
|
|
|
|
=/ =index:graph-store
|
|
|
|
[when.envelope ~]
|
|
|
|
=, envelope
|
|
|
|
:- when.envelope
|
|
|
|
:_ [%empty ~]
|
|
|
|
^- post:graph-store
|
|
|
|
:* author
|
|
|
|
index
|
|
|
|
when
|
|
|
|
contents
|
|
|
|
~ ~
|
|
|
|
==
|
|
|
|
::
|
|
|
|
++ mailbox-to-graph
|
|
|
|
|= =mailbox:store
|
|
|
|
^- graph:graph-store
|
|
|
|
%+ gas:orm:graph-store *graph:graph-store
|
|
|
|
(turn envelopes.mailbox envelope-to-node)
|
2019-11-05 22:30:58 +03:00
|
|
|
--
|