2019-06-05 00:29:53 +03:00
|
|
|
/- hall
|
|
|
|
/+ *server, chat, hall-json
|
|
|
|
/= index
|
|
|
|
/^ octs
|
|
|
|
/; as-octs:mimes:html
|
|
|
|
/: /===/app/chat/index
|
|
|
|
/| /html/
|
|
|
|
/~ ~
|
|
|
|
==
|
|
|
|
/= tile-js
|
|
|
|
/^ octs
|
|
|
|
/; as-octs:mimes:html
|
|
|
|
/: /===/app/chat/js/tile
|
|
|
|
/| /js/
|
|
|
|
/~ ~
|
|
|
|
==
|
|
|
|
/= script
|
|
|
|
/^ octs
|
|
|
|
/; as-octs:mimes:html
|
|
|
|
/: /===/app/chat/js/index
|
|
|
|
/| /js/
|
|
|
|
/~ ~
|
|
|
|
==
|
|
|
|
/= style
|
|
|
|
/^ octs
|
|
|
|
/; as-octs:mimes:html
|
|
|
|
/: /===/app/chat/css/index
|
|
|
|
/| /css/
|
|
|
|
/~ ~
|
|
|
|
==
|
|
|
|
/= chat-png
|
|
|
|
/^ (map knot @)
|
|
|
|
/: /===/app/chat/img /_ /png/
|
|
|
|
::
|
|
|
|
=, chat
|
|
|
|
::
|
2019-08-11 21:59:59 +03:00
|
|
|
|%
|
|
|
|
+$ state
|
|
|
|
$% [%0 str=streams]
|
|
|
|
==
|
|
|
|
::
|
|
|
|
+$ move [bone card]
|
|
|
|
::
|
|
|
|
+$ card
|
|
|
|
$% [%http-response =http-event:http]
|
|
|
|
[%connect wire binding:eyre term]
|
|
|
|
[%peer wire dock path]
|
|
|
|
[%quit ~]
|
|
|
|
[%poke wire dock poke]
|
|
|
|
[%peer wire dock path]
|
|
|
|
[%pull wire dock ~]
|
|
|
|
[%diff diff]
|
|
|
|
==
|
|
|
|
--
|
|
|
|
::
|
2019-08-14 21:09:02 +03:00
|
|
|
|_ [bol=bowl:gall state]
|
2019-06-05 00:29:53 +03:00
|
|
|
::
|
|
|
|
++ this .
|
|
|
|
::
|
2019-08-14 21:09:02 +03:00
|
|
|
:: +prep: set up the app, migrate the state
|
2019-06-05 00:29:53 +03:00
|
|
|
::
|
|
|
|
++ prep
|
|
|
|
|= old=(unit state)
|
|
|
|
^- (quip move _this)
|
2019-08-16 21:22:19 +03:00
|
|
|
?^ old
|
|
|
|
:_ this(+<+ u.old)
|
|
|
|
[(launch-poke [/chattile '/~chat/js/tile.js'])]~
|
|
|
|
::
|
|
|
|
=/ inbox-path /circle/inbox/config/group
|
|
|
|
::
|
|
|
|
:_ this
|
|
|
|
:* [ost.bol %connect / [~ /'~chat'] %chat]
|
|
|
|
(launch-poke [/chattile '/~chat/js/tile.js'])
|
|
|
|
(hall-peer /circle/(scot %p our.bol)/inbox/config/group inbox-path)
|
|
|
|
(hall-peer /circles/(scot %p our.bol) /circles/(scot %p our.bol))
|
|
|
|
(hall-source [our.bol %i])
|
2019-07-15 20:50:22 +03:00
|
|
|
?: =((clan:title our.bol) %czar)
|
|
|
|
~
|
|
|
|
?: =(our.bol ~marzod)
|
2019-08-14 21:09:02 +03:00
|
|
|
:- (hall-create %announcements 'Announcements from Tlon' %journal)
|
2019-08-16 21:22:19 +03:00
|
|
|
[(hall-source [~marzod %announcements])]~
|
2019-07-15 20:50:22 +03:00
|
|
|
?: =(our.bol ~dopzod)
|
2019-08-14 21:09:02 +03:00
|
|
|
:- (hall-create %urbit-dev 'Chat about developing on Urbit' %channel)
|
|
|
|
[(hall-create %urbit-help 'Help about Urbit' %channel)]~
|
|
|
|
:~ (hall-create %hall-internal-announcements '' %village)
|
|
|
|
(hall-source [our.bol %hall-internal-announcements])
|
2019-08-16 21:22:19 +03:00
|
|
|
(hall-source [~marzod %announcements])
|
2019-08-14 21:09:02 +03:00
|
|
|
==
|
2019-08-16 21:22:19 +03:00
|
|
|
==
|
|
|
|
::
|
|
|
|
:: +peer-chattile: subscribe to data necessary for chat tile
|
2019-06-21 21:35:28 +03:00
|
|
|
::
|
2019-06-05 00:29:53 +03:00
|
|
|
++ peer-chattile
|
|
|
|
|= wir=wire
|
|
|
|
^- (quip move _this)
|
2019-06-21 21:35:28 +03:00
|
|
|
:_ this
|
2019-08-14 21:09:02 +03:00
|
|
|
[ost.bol %diff %json (construct-tile-json str)]~
|
2019-06-05 00:29:53 +03:00
|
|
|
::
|
|
|
|
:: +peer-messages: subscribe to subset of messages and updates
|
|
|
|
::
|
|
|
|
++ peer-primary
|
|
|
|
|= wir=wire
|
|
|
|
^- (quip move _this)
|
2019-08-14 21:09:02 +03:00
|
|
|
=* messages messages.str
|
2019-06-11 21:21:59 +03:00
|
|
|
:_ this
|
2019-08-15 02:32:35 +03:00
|
|
|
:- [ost.bol %diff %chat-config str]
|
|
|
|
%+ murn ~(tap by messages)
|
2019-08-16 21:22:19 +03:00
|
|
|
|= [cir=circle:hall envelopes=(list envelope:hall)]
|
2019-08-15 02:32:35 +03:00
|
|
|
^- (unit move)
|
2019-08-16 21:22:19 +03:00
|
|
|
=/ length=@ (lent envelopes)
|
|
|
|
=/ start=@
|
2019-08-15 02:32:35 +03:00
|
|
|
?: (gte length 100)
|
|
|
|
(sub length 100)
|
|
|
|
0
|
2019-08-16 21:22:19 +03:00
|
|
|
=/ end=@ length
|
|
|
|
=/ offset=@ (sub end start)
|
2019-08-15 02:32:35 +03:00
|
|
|
:- ~
|
|
|
|
:* ost.bol
|
|
|
|
%diff
|
|
|
|
%chat-update
|
2019-08-16 21:22:19 +03:00
|
|
|
[%messages cir start end (swag [start offset] envelopes)]
|
2019-08-15 02:32:35 +03:00
|
|
|
==
|
2019-06-05 00:29:53 +03:00
|
|
|
::
|
2019-08-16 21:22:19 +03:00
|
|
|
:: +poke-chat: send a list of actions to hall
|
2019-06-05 00:29:53 +03:00
|
|
|
::
|
|
|
|
++ poke-chat-action
|
|
|
|
|= act=action:chat
|
|
|
|
^- (quip move _this)
|
|
|
|
:_ this
|
|
|
|
%+ turn lis.act
|
2019-08-14 21:09:02 +03:00
|
|
|
|= hac=action:hall
|
|
|
|
^- move
|
2019-08-16 21:22:19 +03:00
|
|
|
[ost.bol %poke /p/(scot %da now.bol) [our.bol %hall] [%hall-action hac]]
|
2019-06-05 00:29:53 +03:00
|
|
|
::
|
|
|
|
:: +diff-hall-prize: handle full state initially handed to us by hall
|
|
|
|
::
|
|
|
|
++ diff-hall-prize
|
|
|
|
|= [wir=wire piz=prize:hall]
|
|
|
|
^- (quip move _this)
|
|
|
|
?~ wir
|
|
|
|
(mean [leaf+"invalid wire for diff: {(spud wir)}"]~)
|
|
|
|
?+ i.wir
|
|
|
|
(mean [leaf+"invalid wire for diff: {(spud wir)}"]~)
|
2019-08-14 21:09:02 +03:00
|
|
|
::
|
2019-08-16 21:22:19 +03:00
|
|
|
%circles
|
|
|
|
?> ?=(%circles -.piz)
|
|
|
|
=. str str(circles cis.piz)
|
|
|
|
:_ this(str str)
|
|
|
|
(send-chat-update [[%circles cis.piz] str])
|
2019-08-14 21:09:02 +03:00
|
|
|
::
|
2019-08-16 21:22:19 +03:00
|
|
|
%circle
|
|
|
|
?> ?=(%circle -.piz)
|
|
|
|
?. =([our.bol &3:wir] [our.bol %inbox])
|
2019-06-05 00:29:53 +03:00
|
|
|
::
|
2019-08-16 21:22:19 +03:00
|
|
|
:: fill remote configs with message data
|
2019-06-05 00:29:53 +03:00
|
|
|
::
|
2019-08-16 21:22:19 +03:00
|
|
|
=* messages messages.str
|
2019-08-28 23:35:36 +03:00
|
|
|
=/ circle [`@p`(slav %p &2:wir) &3:wir]
|
2019-08-16 21:22:19 +03:00
|
|
|
=/ peers=(map circle:hall (set @p))
|
|
|
|
%- ~(rep by rem.pes.piz)
|
|
|
|
|= [[cir=circle:hall grp=group:hall] acc=(map circle:hall (set @p))]
|
|
|
|
^+ acc
|
|
|
|
(~(put by acc) cir (silt (turn ~(tap by grp) head)))
|
|
|
|
::
|
|
|
|
=. str
|
|
|
|
%= str
|
|
|
|
messages (~(put by messages) circle nes.piz)
|
|
|
|
peers
|
|
|
|
%- ~(uni by peers.str)
|
|
|
|
(~(put by peers) circle ~(key by loc.pes.piz))
|
|
|
|
==
|
|
|
|
:_ this(str str)
|
|
|
|
(send-chat-update [[%messages circle 0 (lent messages) nes.piz] str])
|
|
|
|
::
|
|
|
|
:: fill inbox config and remote configs with prize data
|
2019-06-05 00:29:53 +03:00
|
|
|
::
|
2019-08-16 21:22:19 +03:00
|
|
|
=/ circles=(list circle:hall) (turn ~(tap in src.loc.cos.piz) head)
|
2019-06-05 00:29:53 +03:00
|
|
|
::
|
2019-08-15 02:19:24 +03:00
|
|
|
=/ peers=(map circle:hall (set @p))
|
2019-08-14 21:09:02 +03:00
|
|
|
%- ~(rep by rem.pes.piz)
|
|
|
|
|= [[cir=circle:hall grp=group:hall] acc=(map circle:hall (set @p))]
|
2019-08-16 21:22:19 +03:00
|
|
|
^+ acc
|
2019-08-14 21:09:02 +03:00
|
|
|
(~(put by acc) cir (silt (turn ~(tap by grp) head)))
|
2019-06-05 00:29:53 +03:00
|
|
|
::
|
2019-08-14 21:09:02 +03:00
|
|
|
:-
|
2019-08-28 23:35:36 +03:00
|
|
|
%+ turn
|
|
|
|
%~ tap in
|
|
|
|
%- ~(del in (silt circles))
|
|
|
|
[our.bol %inbox]
|
2019-08-14 21:09:02 +03:00
|
|
|
|= cir=circle:hall
|
2019-08-16 21:22:19 +03:00
|
|
|
%+ hall-peer
|
|
|
|
/circle/(scot %p our.bol)/[nom.cir]/config/group
|
|
|
|
/circle/[nom.cir]/config/group
|
2019-08-14 21:09:02 +03:00
|
|
|
%= this
|
|
|
|
inbox.str loc.cos.piz
|
2019-08-16 21:22:19 +03:00
|
|
|
peers.str (~(put by peers) [our.bol %inbox] ~(key by loc.pes.piz))
|
2019-06-05 00:29:53 +03:00
|
|
|
::
|
2019-08-16 21:22:19 +03:00
|
|
|
configs.str
|
2019-08-28 23:35:36 +03:00
|
|
|
%- ~(uni by configs.str)
|
2019-08-16 21:22:19 +03:00
|
|
|
^- (map circle:hall (unit config:hall))
|
|
|
|
(~(run by rem.cos.piz) some)
|
|
|
|
::
|
|
|
|
messages.str
|
|
|
|
%- molt
|
|
|
|
%+ turn circles
|
|
|
|
|= cir=circle:hall
|
|
|
|
^- [circle:hall (list envelope:hall)]
|
|
|
|
[cir ~]
|
|
|
|
==
|
2019-06-05 00:29:53 +03:00
|
|
|
==
|
|
|
|
::
|
|
|
|
:: +diff-hall-rumor: handle updates to hall state
|
|
|
|
::
|
|
|
|
++ diff-hall-rumor
|
|
|
|
|= [wir=wire rum=rumor:hall]
|
|
|
|
^- (quip move _this)
|
|
|
|
?~ wir
|
|
|
|
(mean [leaf+"invalid wire for diff: {(spud wir)}"]~)
|
|
|
|
?+ i.wir
|
|
|
|
(mean [leaf+"invalid wire for diff: {(spud wir)}"]~)
|
|
|
|
::
|
2019-08-16 21:22:19 +03:00
|
|
|
%circles
|
|
|
|
(handle-rumor-circles rum)
|
|
|
|
::
|
|
|
|
%circle
|
|
|
|
(handle-rumor-circle wir rum)
|
2019-08-14 21:09:02 +03:00
|
|
|
::
|
2019-08-16 21:22:19 +03:00
|
|
|
==
|
|
|
|
::
|
|
|
|
:: +handle-rumor-circles
|
|
|
|
::
|
|
|
|
++ handle-rumor-circles
|
|
|
|
|= rum=rumor:hall
|
|
|
|
^- (quip move _this)
|
2019-08-14 21:09:02 +03:00
|
|
|
?> ?=(%circles -.rum)
|
|
|
|
=/ cis
|
|
|
|
?: add.rum
|
|
|
|
(~(put in circles.str) cir.rum)
|
|
|
|
(~(del in circles.str) cir.rum)
|
2019-08-16 21:22:19 +03:00
|
|
|
=. str
|
2019-08-14 21:09:02 +03:00
|
|
|
%= str
|
|
|
|
circles cis
|
|
|
|
peers
|
2019-06-21 21:35:28 +03:00
|
|
|
?: add.rum
|
2019-08-14 21:09:02 +03:00
|
|
|
(~(put by peers.str) [our.bol cir.rum] ~)
|
|
|
|
(~(del by peers.str) [our.bol cir.rum])
|
|
|
|
==
|
2019-08-16 21:22:19 +03:00
|
|
|
:_ this(str str)
|
|
|
|
(send-chat-update [[%circles cis] str])
|
|
|
|
::
|
|
|
|
++ handle-rumor-circle
|
|
|
|
|= [wir=wire rum=rumor:hall]
|
|
|
|
^- (quip move _this)
|
|
|
|
?> ?=(%circle -.rum)
|
|
|
|
?+ -.rum.rum
|
|
|
|
[~ this]
|
2019-06-05 00:29:53 +03:00
|
|
|
::
|
2019-08-16 21:22:19 +03:00
|
|
|
:: %gram: new message
|
2019-06-05 00:29:53 +03:00
|
|
|
::
|
2019-08-16 21:22:19 +03:00
|
|
|
%gram
|
|
|
|
(handle-rumor-circle-gram wir rum.rum)
|
2019-06-05 00:29:53 +03:00
|
|
|
::
|
2019-08-16 21:22:19 +03:00
|
|
|
:: status: status update
|
2019-08-14 21:09:02 +03:00
|
|
|
::
|
2019-08-16 21:22:19 +03:00
|
|
|
%status
|
|
|
|
(handle-rumor-circle-status rum.rum)
|
2019-08-14 21:09:02 +03:00
|
|
|
::
|
2019-08-16 21:22:19 +03:00
|
|
|
:: %config: config has changed
|
|
|
|
::
|
|
|
|
%config
|
|
|
|
?+ -.dif.rum.rum
|
|
|
|
[~ this]
|
|
|
|
::
|
|
|
|
:: %full: set all of config without side effects
|
|
|
|
::
|
|
|
|
%full
|
|
|
|
=* conf cof.dif.rum.rum
|
|
|
|
=. configs.str (~(put by configs.str) cir.rum.rum `conf)
|
|
|
|
:_ this(str str)
|
|
|
|
(send-chat-update [[%config cir.rum.rum conf] str])
|
|
|
|
::
|
|
|
|
:: %read: the read count of one of our configs has changed
|
|
|
|
::
|
|
|
|
%read
|
|
|
|
(handle-rumor-circle-config-read rum.rum)
|
|
|
|
::
|
|
|
|
:: %source: the sources of our inbox have changed
|
|
|
|
::
|
|
|
|
%source
|
|
|
|
(handle-rumor-circle-config-source rum.rum)
|
|
|
|
::
|
|
|
|
:: %remove: remove a circle
|
|
|
|
::
|
|
|
|
%remove
|
|
|
|
=. str
|
|
|
|
%= str
|
|
|
|
configs (~(del by configs.str) cir.rum.rum)
|
|
|
|
messages (~(del by messages.str) cir.rum.rum)
|
|
|
|
peers (~(del by peers.str) cir.rum.rum)
|
|
|
|
==
|
|
|
|
:_ this(str str)
|
|
|
|
(send-chat-update [[%delete cir.rum.rum] str])
|
|
|
|
::
|
|
|
|
==
|
|
|
|
==
|
|
|
|
::
|
|
|
|
++ handle-rumor-circle-gram
|
|
|
|
|= [wir=wire sto=rumor-story:hall]
|
|
|
|
^- (quip move _this)
|
2019-08-14 21:09:02 +03:00
|
|
|
?> ?=(%gram -.sto)
|
|
|
|
=* messages messages.str
|
2019-08-28 23:35:36 +03:00
|
|
|
=/ circle [`@p`(slav %p &2:wir) &3:wir]
|
|
|
|
=/ nes=(unit (list envelope:hall))
|
|
|
|
(~(get by messages) circle)
|
2019-08-14 21:09:02 +03:00
|
|
|
?~ nes
|
|
|
|
[~ this]
|
2019-08-16 21:22:19 +03:00
|
|
|
=. messages.str (~(put by messages) circle (snoc u.nes nev.sto))
|
|
|
|
:_ this(str str)
|
|
|
|
(send-chat-update [[%message circle nev.sto] str])
|
|
|
|
::
|
|
|
|
++ handle-rumor-circle-status
|
|
|
|
|= sto=rumor-story:hall
|
|
|
|
^- (quip move _this)
|
2019-08-14 21:09:02 +03:00
|
|
|
?> ?=(%status -.sto)
|
|
|
|
=/ upeers=(unit (set @p)) (~(get by peers.str) cir.sto)
|
|
|
|
?~ upeers
|
|
|
|
[~ this]
|
|
|
|
=/ peers=(set @p)
|
|
|
|
?: =(%remove -.dif.sto)
|
|
|
|
(~(del in u.upeers) who.sto)
|
|
|
|
(~(put in u.upeers) who.sto)
|
2019-08-16 21:22:19 +03:00
|
|
|
=. peers.str (~(put by peers.str) cir.sto peers)
|
|
|
|
:_ this(str str)
|
|
|
|
(send-chat-update [[%peers cir.sto peers] str])
|
|
|
|
::
|
|
|
|
++ handle-rumor-circle-config-read
|
|
|
|
|= sto=rumor-story:hall
|
|
|
|
^- (quip move _this)
|
|
|
|
?> ?=(%config -.sto)
|
|
|
|
?> ?=(%read -.dif.sto)
|
|
|
|
?: =(cir.sto [our.bol %inbox])
|
|
|
|
:: ignore when cir.sto is inbox
|
2019-08-14 21:09:02 +03:00
|
|
|
[~ this]
|
2019-08-16 21:22:19 +03:00
|
|
|
=/ conf=(unit config:hall) (~(got by configs.str) cir.sto)
|
|
|
|
?~ conf
|
|
|
|
[~ this]
|
|
|
|
=. red.u.conf red.dif.sto
|
|
|
|
=. configs.str (~(put by configs.str) cir.sto conf)
|
|
|
|
:_ this(str str)
|
|
|
|
(send-chat-update [[%config cir.sto u.conf] str])
|
|
|
|
::
|
|
|
|
:: +handle-rumor-circle-config-source: on source, subscribe and add to inbox
|
|
|
|
:: on remove source, send delete and remove data from state
|
|
|
|
::
|
|
|
|
++ handle-rumor-circle-config-source
|
|
|
|
|= sto=rumor-story:hall
|
|
|
|
^- (quip move _this)
|
|
|
|
?> ?=(%config -.sto)
|
|
|
|
?> ?=(%source -.dif.sto)
|
|
|
|
?. =(cir.sto [our.bol %inbox])
|
|
|
|
:: ignore when cir.sto is not inbox
|
|
|
|
[~ this]
|
|
|
|
=* circ cir.src.dif.sto
|
|
|
|
=/ wir /circle/(scot %p hos.circ)/[nom.circ]/grams/0/config/group
|
|
|
|
:: we've added a source to our inbox
|
|
|
|
::
|
|
|
|
?: add.dif.sto
|
|
|
|
=. str
|
|
|
|
%_ str
|
|
|
|
src.inbox (~(put in src.inbox.str) src.dif.sto)
|
|
|
|
::
|
|
|
|
configs
|
|
|
|
?: (~(has by configs.str) circ)
|
|
|
|
configs.str
|
|
|
|
(~(put by configs.str) circ ~)
|
2019-06-21 21:35:28 +03:00
|
|
|
==
|
2019-08-16 21:22:19 +03:00
|
|
|
::
|
|
|
|
=/ pax /circle/[nom.circ]/grams/0/config/group
|
|
|
|
:_ this(str str)
|
|
|
|
:- [ost.bol %peer wir [hos.circ %hall] pax]
|
|
|
|
(send-chat-update [[%inbox inbox.str] str])
|
2019-08-14 21:09:02 +03:00
|
|
|
::
|
2019-08-16 21:22:19 +03:00
|
|
|
=. src.inbox.str (~(del in src.inbox.str) src.dif.sto)
|
|
|
|
:: we've removed a source from our inbox
|
2019-08-14 21:09:02 +03:00
|
|
|
::
|
2019-08-16 21:22:19 +03:00
|
|
|
=. str
|
|
|
|
%= str
|
|
|
|
inbox inbox.str
|
2019-08-14 21:09:02 +03:00
|
|
|
::
|
2019-08-16 21:22:19 +03:00
|
|
|
configs (~(del by configs.str) circ)
|
|
|
|
messages (~(del by messages.str) circ)
|
|
|
|
peers (~(del by peers.str) circ)
|
2019-08-14 21:09:02 +03:00
|
|
|
==
|
2019-08-16 21:22:19 +03:00
|
|
|
=/ fake=circle:hall
|
|
|
|
[our.bol (crip (weld (trip 'hall-internal-') (trip nom.circ)))]
|
|
|
|
::
|
|
|
|
:_ this(str str)
|
|
|
|
;: weld
|
|
|
|
^- (list move)
|
|
|
|
:: just forward the delete to our clients
|
2019-08-14 21:09:02 +03:00
|
|
|
::
|
2019-08-16 21:22:19 +03:00
|
|
|
?~ (~(get by configs.str) fake)
|
|
|
|
[ost.bol %pull wir [hos.circ %hall] ~]~
|
2019-08-14 21:09:02 +03:00
|
|
|
:: if we get a delete from another ship, delete our fake circle copy
|
|
|
|
::
|
2019-08-16 21:22:19 +03:00
|
|
|
:- [ost.bol %pull wir [hos.circ %hall] ~]
|
|
|
|
[ost.bol %poke /f [our.bol %hall] [%hall-action [%delete nom.fake ~]]]~
|
|
|
|
::
|
|
|
|
(send-chat-update [[%inbox inbox.str] str])
|
|
|
|
(send-chat-update [[%delete circ] str])
|
2019-06-05 00:29:53 +03:00
|
|
|
==
|
|
|
|
::
|
|
|
|
:: +bound: lient tells us we successfully bound our server to the ~chat url
|
|
|
|
::
|
|
|
|
++ bound
|
2019-07-04 09:09:44 +03:00
|
|
|
|= [wir=wire success=? binding=binding:eyre]
|
2019-06-05 00:29:53 +03:00
|
|
|
^- (quip move _this)
|
|
|
|
[~ this]
|
|
|
|
::
|
|
|
|
:: +poke-handle-http-request: serve pages from file system based on URl path
|
|
|
|
::
|
|
|
|
++ poke-handle-http-request
|
|
|
|
%- (require-authorization:app ost.bol move this)
|
2019-07-04 09:09:44 +03:00
|
|
|
|= =inbound-request:eyre
|
2019-06-05 00:29:53 +03:00
|
|
|
^- (quip move _this)
|
|
|
|
::
|
|
|
|
=+ request-line=(parse-request-line url.request.inbound-request)
|
|
|
|
=/ name=@t
|
|
|
|
=+ back-path=(flop site.request-line)
|
|
|
|
?~ back-path
|
|
|
|
''
|
|
|
|
i.back-path
|
|
|
|
?: =(name 'tile')
|
|
|
|
[[ost.bol %http-response (js-response:app tile-js)]~ this]
|
|
|
|
?+ site.request-line
|
|
|
|
:_ this
|
|
|
|
[ost.bol %http-response not-found:app]~
|
|
|
|
::
|
|
|
|
:: styling
|
|
|
|
::
|
|
|
|
[%'~chat' %css %index ~]
|
|
|
|
:_ this
|
|
|
|
[ost.bol %http-response (css-response:app style)]~
|
|
|
|
::
|
|
|
|
:: javascript
|
|
|
|
::
|
|
|
|
[%'~chat' %js %index ~]
|
|
|
|
:_ this
|
|
|
|
[ost.bol %http-response (js-response:app script)]~
|
|
|
|
::
|
|
|
|
:: images
|
|
|
|
::
|
|
|
|
[%'~chat' %img *]
|
|
|
|
=/ img (as-octs:mimes:html (~(got by chat-png) `@ta`name))
|
|
|
|
:_ this
|
|
|
|
[ost.bol %http-response (png-response:app img)]~
|
|
|
|
::
|
2019-06-11 21:21:59 +03:00
|
|
|
:: paginated message data
|
|
|
|
::
|
|
|
|
[%'~chat' %scroll @t @t @t @t ~]
|
2019-08-28 23:35:36 +03:00
|
|
|
=/ cir [(slav %p &3:site.request-line) &4:site.request-line]
|
2019-08-15 02:19:24 +03:00
|
|
|
=/ start=@ud (need (rush &5:site.request-line dem))
|
|
|
|
=/ parsedend=@ud (need (rush &6:site.request-line dem))
|
2019-08-14 21:09:02 +03:00
|
|
|
=* messages messages.str
|
2019-08-28 23:35:36 +03:00
|
|
|
=/ envs=(unit (list envelope:hall)) (~(get by messages) cir)
|
2019-06-11 21:21:59 +03:00
|
|
|
?~ envs
|
|
|
|
[~ this]
|
|
|
|
?: (gte start (lent u.envs))
|
|
|
|
[~ this]
|
2019-08-15 02:19:24 +03:00
|
|
|
=/ end=@
|
2019-06-11 21:21:59 +03:00
|
|
|
?: (gte parsedend (lent u.envs))
|
|
|
|
(dec (lent u.envs))
|
|
|
|
parsedend
|
|
|
|
=/ offset (sub end start)
|
2019-08-28 23:35:36 +03:00
|
|
|
=/ jon
|
|
|
|
%- msg-to-json
|
|
|
|
:* %messages
|
|
|
|
cir
|
|
|
|
start
|
|
|
|
end
|
|
|
|
(swag [start offset] u.envs)
|
|
|
|
==
|
2019-06-11 21:21:59 +03:00
|
|
|
:_ this
|
|
|
|
[ost.bol %http-response (json-response:app (json-to-octs jon))]~
|
|
|
|
::
|
|
|
|
::
|
2019-06-05 00:29:53 +03:00
|
|
|
:: inbox page
|
|
|
|
::
|
|
|
|
[%'~chat' *]
|
|
|
|
:_ this
|
|
|
|
[ost.bol %http-response (html-response:app index)]~
|
|
|
|
==
|
|
|
|
::
|
|
|
|
::
|
|
|
|
:: +subscription-retry arms
|
|
|
|
::
|
|
|
|
::
|
|
|
|
:: +reap: recieve acknowledgement for peer, retry on failure
|
|
|
|
::
|
|
|
|
++ reap
|
|
|
|
|= [wir=wire err=(unit tang)]
|
|
|
|
^- (quip move _this)
|
|
|
|
?~ err
|
|
|
|
[~ this]
|
|
|
|
?~ wir
|
|
|
|
(mean [leaf+"invalid wire for diff: {(spud wir)}"]~)
|
|
|
|
?+ i.wir
|
|
|
|
(mean [leaf+"invalid wire for diff: {(spud wir)}"]~)
|
|
|
|
::
|
|
|
|
%circle
|
2019-08-15 02:19:24 +03:00
|
|
|
=/ shp=@p (slav %p &2:wir)
|
2019-06-28 00:36:50 +03:00
|
|
|
=/ pat /circle/[&3:wir]/config/group
|
|
|
|
?: =(&3:wir 'inbox')
|
|
|
|
:_ this
|
|
|
|
[ost.bol %peer wir [shp %hall] pat]~
|
2019-08-14 21:09:02 +03:00
|
|
|
?: (~(has in src.inbox.str) [[shp &3:wir] ~])
|
2019-06-28 00:36:50 +03:00
|
|
|
:_ this
|
|
|
|
[ost.bol %peer wir [shp %hall] pat]~
|
|
|
|
[~ this]
|
2019-06-05 00:29:53 +03:00
|
|
|
::
|
|
|
|
%circles
|
|
|
|
:_ this
|
|
|
|
[ost.bol %peer wir [our.bol %hall] wir]~
|
|
|
|
==
|
|
|
|
::
|
|
|
|
:: +quit: subscription failed/quit at some point, retry
|
|
|
|
::
|
|
|
|
++ quit
|
|
|
|
|= wir=wire
|
|
|
|
^- (quip move _this)
|
|
|
|
?~ wir
|
|
|
|
(mean [leaf+"invalid wire for diff: {(spud wir)}"]~)
|
|
|
|
?+ i.wir
|
|
|
|
(mean [leaf+"invalid wire for diff: {(spud wir)}"]~)
|
|
|
|
::
|
|
|
|
%circle
|
2019-08-15 02:19:24 +03:00
|
|
|
=/ shp=@p (slav %p &2:wir)
|
2019-06-28 00:36:50 +03:00
|
|
|
=/ pat /circle/[&3:wir]/config/group
|
|
|
|
?: =(&3:wir 'inbox')
|
|
|
|
:_ this
|
|
|
|
[ost.bol %peer wir [shp %hall] pat]~
|
2019-08-14 21:09:02 +03:00
|
|
|
?: (~(has in src.inbox.str) [[shp &3:wir] ~])
|
2019-06-28 00:36:50 +03:00
|
|
|
:_ this
|
|
|
|
[ost.bol %peer wir [shp %hall] pat]~
|
|
|
|
[~ this]
|
2019-06-05 00:29:53 +03:00
|
|
|
::
|
|
|
|
%circles
|
|
|
|
:_ this
|
|
|
|
[ost.bol %peer wir [our.bol %hall] wir]~
|
|
|
|
==
|
|
|
|
::
|
2019-08-14 21:09:02 +03:00
|
|
|
:: +utilities
|
|
|
|
::
|
|
|
|
::
|
|
|
|
:: +send-chat-update: utility func for sending updates to all our subscribers
|
|
|
|
::
|
|
|
|
++ send-chat-update
|
|
|
|
|= [upd=update str=streams]
|
|
|
|
^- (list move)
|
2019-09-19 20:56:57 +03:00
|
|
|
=/ jon-one (update-to-json upd)
|
|
|
|
=/ jon-two (construct-tile-json str)
|
2019-08-16 21:22:19 +03:00
|
|
|
::
|
|
|
|
%+ weld
|
|
|
|
^- (list move)
|
2019-08-14 21:09:02 +03:00
|
|
|
%+ turn (prey:pubsub:userlib /primary bol)
|
|
|
|
|= [=bone *]
|
2019-09-19 20:56:57 +03:00
|
|
|
[bone %diff %json jon-one]
|
2019-08-16 21:22:19 +03:00
|
|
|
^- (list move)
|
|
|
|
%+ turn (prey:pubsub:userlib /chattile bol)
|
|
|
|
|= [=bone *]
|
2019-09-19 20:56:57 +03:00
|
|
|
[bone %diff %json jon-two]
|
2019-08-14 21:09:02 +03:00
|
|
|
::
|
|
|
|
++ construct-tile-json
|
|
|
|
|= str=streams
|
|
|
|
^- json
|
2019-08-16 21:22:19 +03:00
|
|
|
:- %o
|
|
|
|
%- my
|
|
|
|
:~ ['config' (config-to-json str)]
|
|
|
|
::
|
|
|
|
:- 'numbers'
|
|
|
|
%- numbers-to-json
|
|
|
|
^- (list [circle:hall @ud])
|
|
|
|
%+ turn ~(tap by messages.str)
|
2019-08-14 21:09:02 +03:00
|
|
|
|= [cir=circle:hall lis=(list envelope:hall)]
|
|
|
|
^- [circle:hall @ud]
|
|
|
|
?~ lis
|
|
|
|
[cir 0]
|
|
|
|
=/ last (snag (dec (lent lis)) `(list envelope:hall)`lis)
|
|
|
|
[cir (add num.last 1)]
|
2019-08-16 21:22:19 +03:00
|
|
|
==
|
2019-08-14 21:09:02 +03:00
|
|
|
::
|
|
|
|
++ launch-poke
|
|
|
|
|= [=path =cord]
|
|
|
|
^- move
|
|
|
|
[ost.bol %poke /chat [our.bol %launch] [%launch-action %chat path cord]]
|
|
|
|
::
|
|
|
|
++ hall-peer
|
|
|
|
|= [wir=wire pat=path]
|
|
|
|
^- move
|
|
|
|
[ost.bol %peer wir [our.bol %hall] pat]
|
|
|
|
::
|
|
|
|
++ hall-create
|
|
|
|
|= [name=@tas description=@t =security:hall]
|
|
|
|
^- move
|
|
|
|
=/ poke [%hall-action [%create name description security]]
|
|
|
|
[ost.bol %poke /chat [our.bol %hall] poke]
|
|
|
|
::
|
|
|
|
++ hall-source
|
|
|
|
|= cir=circle:hall
|
|
|
|
^- move
|
|
|
|
=/ poke [%hall-action [%source %inbox %.y (silt [cir ~]~)]]
|
|
|
|
[ost.bol %poke /chat [our.bol %hall] poke]
|
|
|
|
::
|
2019-06-05 00:29:53 +03:00
|
|
|
--
|