neo: self hosting chat

This commit is contained in:
Liam Fitzgerald 2024-03-14 14:27:59 -04:00
parent cbc36f52aa
commit 7b95a245bc
7 changed files with 62 additions and 141 deletions

View File

@ -0,0 +1,50 @@
/@ message
:: sender ship namesapce (~bus)
:: /messages/1
:: host ship namespace
:: /chat/foo
:: /chat/foo/messages/1 :: symlink to /+bus/messages/1
::
:: /~zod/chat/foo/messages/1 <- []
:: /~zod/chat/foo/messages/1 <-
:: /~zod/chat/foo/messages/1 <-
::
:: /~bus/subs/foo -> /~zod/chat/foo
::
:: [/~bus/subs/foo/messages/1 %make ]
:: possibly optimisticaly update, then forward note to foreign ship
::
:: %make
:: ^- firm:neo
|%
+$ state %message
+$ poke ~
++ kids *kids:neo
++ deps *deps:neo
++ form
^- form:neo
|_ [=bowl:neo case=@ud vase-state=vase *]
++ call
|= [old-state=* act=*]
:: =+ ;;(=action act)
:: ~& call/act
*(list card:neo)
++ reduce
|= act=*
^- vase
vase-state
++ init
|= vas=(unit vase)
?> ?=(^ vas)
=+ !<(state=message u.vas)
!>(state)
++ echo
|= [=pith val=*]
*(list card:neo)
++ born
*(list card:neo)
++ take
|= =sign:neo
*(list card:neo)
--
--

View File

@ -0,0 +1,7 @@
/@ message
$% [%title title=@t] :: update
[%add =ship]
[%del =ship]
[%msg pro=pith message]
[%dbug ~]
==

View File

@ -1,91 +1 @@
/@ message
=>
|%
++ card card:neo
++ msg-loc
|= =bowl:neo
^- path
/(scot %p our.bowl)/base/(scot %da now.bowl)/lib/message/hoon
--
^- firm:neo
|%
:: $state: state for chat container
:: .who: set of ships allowed to poke
:: .title: human-readable title of chat
::
+$ state [%0 who=(set ship) title=@t]
:: $poke: update for chat container
::
:: %title:
:: %add: add .ship to .who in $state
:: %del: remove .ship from .who in $state
::
+$ poke
$% [%title title=@t] :: update
[%add =ship]
[%del =ship]
[%msg msg=state:message]
[%dbug ~]
==
++ kids
=< apex
|%
++ apex
%- ~(gas by *kids:neo)
:~ messages
==
++ messages
:- ~[&/%messages |/%da]
[state:message poke:message]
--
++ deps
=< apex
|%
++ apex
%- ~(gas by *deps:neo)
:~ open/open
==
++ open
[| ,? ,?]
--
++ form
^- form:neo
|_ [=bowl:neo case=@ud state-vase=vase *]
+* sta !<(state state-vase)
++ call
|= [old-state=vase act=*]
=+ ;;(=poke act)
?: ?=(%dbug -.poke)
~& dbug/bowl
*(list card)
?. ?=(%msg -.poke)
*(list card)
[%neo (welp were.bowl ~[da/now.bowl]) %make %message `!>(msg.poke) ~]^~
++ reduce
|= pok=*
^- vase
=+ ;;(=poke pok)
=/ sta sta
?. ;;(? +:(~(gut by deps.bowl) %open [*pith &]))
~&(dropping-poke/poke !>(sta))
?> |(=(our src):bowl (~(has in who.sta) src.bowl))
=- !>(-)
^- state
?- -.poke
%title !! :: sta(title title.poke)
%add sta(who (~(put in who.sta) ship.poke))
%del sta(who (~(del in who.sta) ship.poke))
?(%dbug %msg) sta
==
++ init
|= old=(unit vase)
!>(*state)
++ born *(list card:neo)
++ echo
|= [=pith val=*]
*(list card:neo)
++ take
|= =sign:neo
*(list card:neo)
--
--
,[%0 who=(set ship) title=@t]

View File

@ -0,0 +1 @@
[cache=(unit vase) =hoon]

View File

@ -0,0 +1 @@
[%dep ~]

View File

@ -0,0 +1 @@
[cache=(unit vase) ~]

View File

@ -1,50 +1 @@
:: sender ship namesapce (~bus)
:: /messages/1
:: host ship namespace
:: /chat/foo
:: /chat/foo/messages/1 :: symlink to /+bus/messages/1
::
:: /~zod/chat/foo/messages/1 <- []
:: /~zod/chat/foo/messages/1 <-
:: /~zod/chat/foo/messages/1 <-
::
:: /~bus/subs/foo -> /~zod/chat/foo
::
:: [/~bus/subs/foo/messages/1 %make ]
:: possibly optimisticaly update, then forward note to foreign ship
::
:: %make
:: ^- firm:neo
|%
+$ state [from=ship now=time message=@t]
+$ poke ~
++ kids *kids:neo
++ deps *deps:neo
++ form
^- form:neo
|_ [=bowl:neo case=@ud vase-state=vase *]
+* sta !<(state vase-state)
++ call
|= [old-state=* act=*]
:: =+ ;;(=action act)
:: ~& call/act
*(list card:neo)
++ reduce
|= act=*
^- vase
!>(sta)
++ init
|= vas=(unit vase)
?> ?=(^ vas)
=+ !<(=state u.vas)
!>(state)
++ echo
|= [=pith val=*]
*(list card:neo)
++ born
*(list card:neo)
++ take
|= =sign:neo
*(list card:neo)
--
--
,[from=ship now=time contents=@t]