summaryrefslogtreecommitdiff
path: root/desk/app/nostrill.hoon
diff options
context:
space:
mode:
authorpolwex <polwex@sortug.com>2025-09-18 10:04:43 +0700
committerpolwex <polwex@sortug.com>2025-09-18 10:04:43 +0700
commite69afcff1c1f42436998ca0b070162d556dd577c (patch)
treeceaf1e3c7f654902eb3029483a4a2af37591c320 /desk/app/nostrill.hoon
parent7bac4927e8895719a91011da9a2b997579238145 (diff)
Diffstat (limited to 'desk/app/nostrill.hoon')
-rw-r--r--desk/app/nostrill.hoon101
1 files changed, 34 insertions, 67 deletions
diff --git a/desk/app/nostrill.hoon b/desk/app/nostrill.hoon
index 721a590..ddbcd61 100644
--- a/desk/app/nostrill.hoon
+++ b/desk/app/nostrill.hoon
@@ -1,7 +1,11 @@
-/- sur=nostrill, nsur=nostr, tf=trill-feed
-/+ lib=nostrill, nlib=nostr, sr=sortug, scri,
- shim, dbug, muta=nostrill-mutations, jsonlib=json-nostrill,
- trill=trill-post, comms=nostrill-comms, followlib=nostrill-follows
+/- sur=nostrill, nsur=nostr, tf=trill-feed, comms=nostrill-comms
+/+ lib=nostrill, nostr-keys, sr=sortug, scri,
+ shim, dbug,
+ evlib=nostr-events,
+ mutations-nostr,
+ mutations-trill,
+ jsonlib=json-nostrill,
+ trill=trill-post, commlib=nostrill-comms, followlib=nostrill-follows
/= web /web/router
|%
+$ versioned-state $%(state-0:sur)
@@ -14,10 +18,11 @@
+* this .
rout ~(. router:web [state bowl])
cards ~(. cards:lib bowl)
- mutat ~(. muta [state bowl])
+ mutan ~(. mutations-nostr [state bowl])
+ mutat ~(. mutations-trill [state bowl])
shimm ~(. shim [state bowl])
scry ~(. scri [state bowl])
- coms ~(. comms [state bowl])
+ coms ~(. commlib [state bowl])
fols ~(. followlib [state bowl])
++ on-init
^- (quip card:agent:gall agent:gall)
@@ -65,7 +70,7 @@
?~ msg `this
?> ?=(%ws -.u.msg)
:: =^ cards state (handle-shim-msg:mutat u.msg)
- =^ cards state (handle-ws:mutat +.u.msg)
+ =^ cards state (handle-ws:mutan +.u.msg)
[cards this]
::
@@ -82,63 +87,19 @@
%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)
+ %post =^ cs state
+ (handle-post:mutat +.u.upoke)
+ [cs this]
==
++ handle-cycle-keys
- =/ ks (gen-keys:nlib eny.bowl)
+ =/ ks (gen-keys:nostr-keys eny.bowl)
=. keys [ks keys]
:: =/ nkeys keys(i ks, t `(list keys:nsur)`keys)
:: :: =. keys nkeys
~& new-keys=keys
`this
- ++ handle-post |= poke=post-poke:ui:sur
- ?- -.poke
- %add
- =/ sp (build-sp:trill our.bowl our.bowl content.poke ~ ~)
- =/ p (build-post:trill now.bowl pub.i.keys sp)
- =. state (add-to-feed:mutat p)
- =/ profile (~(get by profiles) [%urbit our.bowl])
- =/ pw [p (some pub.i.keys) ~ ~ profile]
- =/ =fact:ui:sur [%post %add pw]
- =/ card (update-ui:cards fact)
- :_ this :~(card)
- %quote
- =/ sp (build-sp:trill our.bowl our.bowl content.poke ~ ~)
- =/ quote [%ref %trill host.poke /(crip (scow:sr %ud id.poke))]
- =. contents.sp (snoc contents.sp quote)
- =/ p (build-post:trill now.bowl pub.i.keys sp)
- =. state (add-to-feed:mutat p)
- =/ profile (~(get by profiles) [%urbit our.bowl])
- =/ pw [p (some pub.i.keys) ~ ~ profile]
- =/ =fact:ui:sur [%post %add pw]
- =/ card (update-ui:cards fact)
- :_ this :~(card)
- %reply
- =/ sp (build-sp:trill host.poke our.bowl content.poke `id.poke `thread.poke)
- =/ p (build-post:trill now.bowl pub.i.keys sp)
- =. state (add-to-feed:mutat p)
- =/ profile (~(get by profiles) [%urbit our.bowl])
- =/ pw [p (some pub.i.keys) ~ ~ profile]
- =/ =fact:ui:sur [%post %add pw]
- =/ card (update-ui:cards fact)
- :_ this :~(card)
- %rp
- =/ quote [%ref %trill host.poke /(crip (scow:sr %ud id.poke))]
- =/ sp (build-sp:trill host.poke our.bowl '' ~ ~)
- =. contents.sp ~[quote]
- =/ p (build-post:trill now.bowl pub.i.keys sp)
- =. state (add-to-feed:mutat p)
- =/ profile (~(get by profiles) [%urbit our.bowl])
- =/ pw [p (some pub.i.keys) ~ ~ profile]
- =/ =fact:ui:sur [%post %add pw]
- =/ card (update-ui:cards fact)
- :_ this :~(card)
-
- :: %rt `this
- :: %del `this
- ==
++ handle-begs |= poke=begs-poke:ui:sur
?- -.poke
%feed
@@ -177,9 +138,9 @@
[cs this]
::
%send
- =/ upoast (get-poast:mutat host.poke id.poke)
+ =/ upoast (get-poast:scry host.poke id.poke)
?~ upoast `this
- =/ event (post-to-event:lib i.keys eny.bowl u.upoast)
+ =/ event (post-to-event:evlib i.keys eny.bowl u.upoast)
=/ req=bulk-req:shim:nsur [relays.poke %event event]
=/ cards :~((send:shimm req))
[cards this]
@@ -194,7 +155,7 @@
=/ l ~| "wtf" (need lol)
`this
%genkey
- =/ keys (gen-keys:nlib eny.bowl)
+ =/ keys (gen-keys:nostr-keys eny.bowl)
~& pub=(scow:sr %ux -.keys)
~& priv=(scow:sr %ux +.keys)
`this
@@ -229,7 +190,7 @@
- (~(put in -.acc) id.ev)
+ (~(put in +.acc) pubkey.ev)
==
- =^ cards state (populate-profiles:mutat -.ids)
+ =^ cards state (populate-profiles:mutan -.ids)
:: (get-profiles:shimm +.ids)
:: (get-engagement:shimm -.ids)
[cards this]
@@ -254,7 +215,7 @@
~& >>> invalid=invalid
`this
=/ p=event:nsur +.i.poasts
- =/ valid (validate-pubkey:nlib pubkey.p)
+ =/ valid (validate-pubkey:nostr-keys pubkey.p)
?. valid
=/ ids (crip (scow:sr %ux id.p))
~& ids
@@ -270,7 +231,7 @@
=/ npks (~(put in pubkeys) pubkey.p)
$(poasts t.poasts, pubkeys npks)
::
- =^ cards state (populate-profiles:mutat pks)
+ =^ cards state (populate-profiles:mutan pks)
[cards this]
%ui
=/ =fact:ui:sur [%post %add *post-wrapper:sur]
@@ -326,16 +287,22 @@
~& on-agent=[wire -.sign]
:: if p.sign is not ~ here that means it's intentional
?+ wire `this
- [%refollow ~]
- ?. ?=(%watch-ack -.sign) `this
- ?~ p.sign `this
- =^ cs state (handle-kick-nack:fols src.bowl) [cs this]
[%follow ~]
+ ?: ?=(%watch-ack -.sign)
+ ?~ p.sign `this
+ =^ cs state (handle-kick-nack:fols src.bowl) [cs this]
?: ?=(%kick -.sign)
=^ cs state (handle-refollow:fols src.bowl)
[cs this]
?. ?=(%fact -.sign) `this
- =^ cs state (handle-agent-res:fols q.q.cage.sign)
+
+ =/ =fact:comms ;; fact:comms q.q.cage.sign
+ =^ cs state
+ ?- -.fact
+ %init (handle-follow-res:fols +.fact)
+ %post (handle-post-fact:mutat +.fact)
+ %prof (handle-prof-fact:mutan +.fact)
+ ==
[cs this]
==
@@ -351,7 +318,7 @@
=/ msg (parse-body:shimm jstring)
?~ msg ~& `@t`jstring `this
?> ?=(%http -.u.msg)
- =^ cards state (handle-http:mutat sub-id.wire +.u.msg)
+ =^ cards state (handle-http:mutan sub-id.wire +.u.msg)
`this
==
::