summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorpolwex <polwex@sortug.com>2025-10-06 08:25:12 +0700
committerpolwex <polwex@sortug.com>2025-10-06 08:25:12 +0700
commit6704650dcfccf609ccc203308df9004e0b511bb6 (patch)
treebcc36657b338decb84a44e08fb42ffadf7e51924
parent8426c0c275fc824ab55edef4fa99b3a9bacf64d8 (diff)
fixes to nostrill ws
-rw-r--r--app/app/nostrill.hoon2
-rw-r--r--app/lib/json/common.hoon2
-rw-r--r--app/lib/json/nostr.hoon34
-rw-r--r--app/lib/mutations/nostr.hoon7
-rw-r--r--app/lib/nostr/req.hoon9
-rw-r--r--app/lib/shim.hoon2
6 files changed, 32 insertions, 24 deletions
diff --git a/app/app/nostrill.hoon b/app/app/nostrill.hoon
index 7a737ac..2a1fa2f 100644
--- a/app/app/nostrill.hoon
+++ b/app/app/nostrill.hoon
@@ -82,7 +82,7 @@
%auth `state
%close `state
==
- [cs state]
+ [cs this]
::
::
++ handle-comms
diff --git a/app/lib/json/common.hoon b/app/lib/json/common.hoon
index 97513cb..be076c2 100644
--- a/app/lib/json/common.hoon
+++ b/app/lib/json/common.hoon
@@ -22,7 +22,7 @@
=/ atom=(unit @) (slaw:sr %ux p.jon)
?~ atom ~
atom
- ++ du |= jon=json ^- (unit @da)
+ ++ du
(cu from-unix:chrono:userlib ni)
++ se |= aur=@tas |= jon=json
?. ?=(%s -.jon) ~
diff --git a/app/lib/json/nostr.hoon b/app/lib/json/nostr.hoon
index 8695a23..0000234 100644
--- a/app/lib/json/nostr.hoon
+++ b/app/lib/json/nostr.hoon
@@ -5,7 +5,7 @@
=, enjs:format
|%
:: shim comms
- ++ bulk-req |= [relays=(list @t) r=req:shim:sur] ^- json
+ ++ bulk-req |= [relays=(list @t) r=client-msg:sur] ^- json
%+ frond %ws
%: pairs
relays+a+(turn relays cord:en:common)
@@ -153,10 +153,20 @@
?. ?=(%s -.head) ~
:: TODO make sure they're always caps
?+ p.head ~
- %'EVENT' `[%event ((event second))]
- %'REQ' `[%req (so second) (turn t.t.p.jon filter)]
- %'CLOSE' `[%close (so second)]
- %'AUTH' [%auth (event second)]
+ %'EVENT'
+ =/ d (event second) ?~ d ~
+ `[%event u.d]
+ %'REQ'
+ =/ d (so second) ?~ d ~
+ =/ rest=(list json) t.t.p.jon
+ =/ d2 ((ar filter) [%a rest]) ?~ d2 ~
+ `[%req u.d u.d2]
+ %'CLOSE'
+ =/ d (so second) ?~ d ~
+ `[%close u.d]
+ %'AUTH'
+ =/ d (event second) ?~ d ~
+ `[%auth u.d]
==
++ filter |= jon=json ^- (unit filter:sur)
?. ?=(%o -.jon) ~
@@ -166,17 +176,17 @@
=/ entry=[@t json] i.entries
=. f
?: .=('ids' -.entry)
- =/ vl (ar +.entry hex:de:common)
+ =/ vl ((ar hex:de:common) +.entry)
?~ vl f
=/ values (silt u.vl)
f(ids `values)
?: .=('authors' -.entry)
- =/ vl (ar +.entry hex:de:common)
+ =/ vl ((ar hex:de:common) +.entry)
?~ vl f
=/ values (silt u.vl)
f(authors `values)
?: .=('kinds' -.entry)
- =/ vl (ar +.entry ud:de:common)
+ =/ vl ((ar ni) +.entry)
?~ vl f
=/ values (silt u.vl)
f(kinds `values)
@@ -189,13 +199,13 @@
?: .=('until' -.entry)
=/ value (du:de:common +.entry)
f(until value)
- :: anything else is a tag
- =/ ctags ?~ tags.f *(map @t (set @t)) u.tags.f
- =/ vl (ar +.entry so)
+ :: :: anything else is a tag
+ =/ vl ((ar so) +.entry)
?~ vl f
+ =/ ctags ?~ tags.f *(map @t (set @t)) u.tags.f
=/ values (silt u.vl)
=/ ntags (~(put by ctags) -.entry values)
- f(tags ntags)
+ f(tags `ntags)
$(entries t.entries)
diff --git a/app/lib/mutations/nostr.hoon b/app/lib/mutations/nostr.hoon
index 96ea6c6..6e1ab3e 100644
--- a/app/lib/mutations/nostr.hoon
+++ b/app/lib/mutations/nostr.hoon
@@ -3,7 +3,6 @@
/+ appjs=json-nostrill,
lib=nostrill,
- nlib=nostr,
nreq=nostr-req,
server,
njs=json-nostr,
@@ -17,11 +16,11 @@
++ handle-client-event |= [wid=@ =event:nsur] ^- (quip card _state)
~& handling-client-event=event
=. nostr-feed.state (put:norm:sur nostr-feed.state created-at.event event)
- =/ profile (~(get by profiles.state [%nostr author.event]))
+ =/ profile (~(get by profiles.state) [%nostr pubkey.event])
:: TODO save if we're following?
:: =/ pw (event-to-post:nlib event profile)
- =/ response (ok-client-event event .n 'we\'re full')
- =/ cs (ws-response:nreq response)
+ =/ response (ok-client-event:nreq event .n 'we\'re full')
+ =/ cs (ws-response:nreq wid response)
[cs state]
:: =/ l events.state
:: =| cards=(list card:agent:gall)
diff --git a/app/lib/nostr/req.hoon b/app/lib/nostr/req.hoon
index ce566bc..e53159c 100644
--- a/app/lib/nostr/req.hoon
+++ b/app/lib/nostr/req.hoon
@@ -1,17 +1,16 @@
/- sur=nostr
/+ js=json-nostr, sr=sortug,
- lib=nostr,
server,
ws=websockets
|%
++ parse-client-msg
- |= jon=json ^- (unit client-msg:nsur)
+ |= jon=json ^- (unit client-msg:sur)
(client-msg:de:js jon)
-++ ok-client-event |= [=event:nsur ok=? msg=@t]
- ^- relay-msg
+++ ok-client-event |= [=event:sur ok=? msg=@t]
+ ^- relay-msg:sur
[%ok id.event ok msg]
++ ws-response
- |= msg=relay-msg:sur ^- (list card:agent:gall)
+ |= [wid=@ msg=relay-msg:sur] ^- (list card:agent:gall)
=/ jon (relay-msg:en:js msg)
=/ octs (json-to-octs:server jon)
=/ res-event=websocket-event:eyre [%message 1 `octs]
diff --git a/app/lib/shim.hoon b/app/lib/shim.hoon
index af2d142..77d5eed 100644
--- a/app/lib/shim.hoon
+++ b/app/lib/shim.hoon
@@ -22,7 +22,7 @@
=/ rls ~(tap by relays.state)
=| urls=(list @t)
=/ sub-id (gen-sub-id:nostr-keys eny.bowl)
- =/ =req:shim:nsur [%req sub-id fs]
+ =/ req=client-msg:nsur [%req sub-id fs]
|- ?~ rls [[urls req] state]
:: build http card
=/ [url=@t rs=relay-stats:nsur] i.rls