diff options
Diffstat (limited to 'desk/app/nostrill.hoon')
-rw-r--r-- | desk/app/nostrill.hoon | 59 |
1 files changed, 48 insertions, 11 deletions
diff --git a/desk/app/nostrill.hoon b/desk/app/nostrill.hoon index e311b5f..17732e7 100644 --- a/desk/app/nostrill.hoon +++ b/desk/app/nostrill.hoon @@ -1,7 +1,7 @@ /- sur=nostrill, nsur=nostr /+ lib=nostrill, nlib=nostr, sr=sortug, shim, dbug, muta=nostrill-mutations, jsonlib=json-nostrill, - trill=trill-post + trill=trill-post, comms=nostrill-comms /= web /web/router |% +$ versioned-state $%(state-0:sur) @@ -16,6 +16,7 @@ cards ~(. cards:lib bowl) mutat ~(. muta [state bowl]) shimm ~(. shim [state bowl]) + coms ~(. comms [state bowl]) ++ on-init ^- (quip card:agent:gall agent:gall) =/ default (default-state:lib bowl) @@ -34,17 +35,26 @@ ?- -.old-state %0 `this(state old-state) == + :: `this(state (default-state:lib bowl)) :: ++ on-poke |~ [=mark =vase] ^- (quip card:agent:gall agent:gall) |^ ?+ mark `this - %noun debug - %json on-ui + %noun handle-comms + %json on-ui %handle-http-request handle-shim == - :: handling shim events + ++ handle-comms + =/ pok (cast-poke:coms q.vase) + ?: ?=(%dbug -.pok) (debug +.pok) + =^ cs state + ?- -.pok + %req (handle-req:coms +.pok) + %res (handle-res:coms +.pok) + == + [cs this] ++ handle-shim =/ order !<(order:web vase) :: ~& request.req.order @@ -68,6 +78,7 @@ ?- -.u.upoke %keys handle-cycle-keys %fols (handle-fols +.u.upoke) + %begs (handle-begs +.u.upoke) %prof (handle-prof +.u.upoke) %post (handle-post +.u.upoke) %rela (handle-rela +.u.upoke) @@ -95,19 +106,39 @@ %rt `this %del `this == + ++ handle-begs |= poke=begs-poke:ui:sur + ?- -.poke + %feed + =/ cs ~ + [cs this] + %thread + =/ cs ~ + [cs this] + == ++ handle-fols |= poke=fols-poke:ui:sur - `this + ?- -.poke + %add `this + %del `this + == ++ handle-prof |= poke=prof-poke:ui:sur ?- -.poke %add - =. profiles (~(put by profiles) +<.poke +>.poke) + =. profiles (~(put by profiles) pub.i.keys +.poke) `this %del - =. profiles (~(del by profiles) +.poke) + =. profiles (~(del by profiles) pub.i.keys) `this == ++ handle-rela |= poke=relay-poke:ui:sur ?- -.poke + %add =. relays (~(put by relays) +.poke *relay-stats:nsur) + `this + %del =. relays (~(del by relays) +.poke) + `this + :: + %sync =^ cs state get-posts:shimm + [cs this] + :: %send =/ upoast (get-poast:mutat host.poke id.poke) ?~ upoast `this @@ -119,8 +150,7 @@ :: - ++ debug - =/ noun !<(* vase) + ++ debug |= noun=* ?+ noun `this %wtf =/ lol=(unit @) ~ @@ -211,12 +241,19 @@ :: ++ on-watch |= =(pole knot) - ?> .=(our.bowl src.bowl) + ~& on-watch=`path`pole ?+ pole !! + [%beg %feed ~] + :_ this give-feed:coms + [%beg %thread ids=@t ~] + =/ id (slaw:sr %uw ids.pole) + ?~ id ~& error-parsing-ted-id=pole `this + :_ this (give-ted:coms u.id) [%ui ~] + ?> .=(our.bowl src.bowl) :_ this =/ jon (state:en:jsonlib state) - [%give %fact ~ [%json !>(jon)]]^~ + [%give %fact ~[/ui] [%json !>(jon)]]^~ == :: ++ on-leave |