summaryrefslogtreecommitdiff
path: root/app/lib/json/nostr.hoon
diff options
context:
space:
mode:
authorpolwex <polwex@sortug.com>2025-10-28 02:54:55 +0700
committerpolwex <polwex@sortug.com>2025-10-28 02:54:55 +0700
commitc61bca793741959fdcd87f70854bc75cf263495f (patch)
tree042f5b37f89ce82e552e70364bb708450f2cd685 /app/lib/json/nostr.hoon
parent53ca6679beb5cc7c5d9016d0af4adc4e31ccd69d (diff)
refactor of nostrill backend to deal with websockets on Iris. almost complete
Diffstat (limited to 'app/lib/json/nostr.hoon')
-rw-r--r--app/lib/json/nostr.hoon73
1 files changed, 42 insertions, 31 deletions
diff --git a/app/lib/json/nostr.hoon b/app/lib/json/nostr.hoon
index 0000234..887e0d8 100644
--- a/app/lib/json/nostr.hoon
+++ b/app/lib/json/nostr.hoon
@@ -4,23 +4,7 @@
++ en
=, enjs:format
|%
- :: shim comms
- ++ bulk-req |= [relays=(list @t) r=client-msg:sur] ^- json
- %+ frond %ws
- %: pairs
- relays+a+(turn relays cord:en:common)
- req+(req r)
- ~
- ==
- ++ http-req |= [relay=@t delay=@ud sub-id=@t fs=(list filter:sur)]
- %+ frond %http
- %: pairs
- relay+s+relay
- delay+(numb delay)
- ['subscription_id' %s sub-id]
- filters+a+(turn fs filter)
- ~
- ==
+ :: relay comms
++ req |= req=client-msg:sur ^- json
=/ en-ev event
:- %a :- s+(crip (cuss (trip -.req)))
@@ -117,31 +101,58 @@
%closed ~[[%s sub-id.msg]]
%notice ~[[%s msg.msg]]
%auth ~[[%s challenge.msg]]
- %error ~
==
--
++ de
=, dejs-soft:format
|%
- :: shim
- ++ shim-res
- %- of :~
- http+(ar relay-msg)
- ws+msg
- ==
+ :: relay
++ msg
%- ot :~
relay+so
msg+relay-msg
==
++ relay-msg
- %- of :~
- event+event-sub
- ok+relay-ok
- eose+so
- closed+closed
- notice+so
- error+so
+ |= jon=json ^- (unit relay-msg:sur)
+ ?. ?=(%a -.jon) ~
+ ?~ p.jon ~
+ =/ head i.p.jon
+ ?~ t.p.jon ~
+ =/ second i.t.p.jon
+ ?. ?=(%s -.head) ~
+ :: TODO make sure they're always caps
+ ~& dejson=[p.head second]
+ ?+ p.head ~
+ %'EVENT'
+ =/ d (so second) ?~ d ~
+ ?~ t.t.p.jon ~
+ =/ third i.t.t.p.jon
+ =/ t (event third) ?~ t ~
+ `[%event u.d u.t]
+ %'OK'
+ =/ d (hex:de:common second) ?~ d ~
+ ?~ t.t.p.jon ~
+ =/ third i.t.t.p.jon
+ =/ t (bo third) ?~ t ~
+ ?~ t.t.t.p.jon ~
+ =/ fourth i.t.t.t.p.jon
+ =/ f (so fourth) ?~ f ~
+ `[%ok u.d u.t u.f]
+ %'CLOSED'
+ =/ d (so second) ?~ d ~
+ ?~ t.t.p.jon ~
+ =/ third i.t.t.p.jon
+ =/ t (so third) ?~ t ~
+ `[%closed u.d u.t]
+ %'EOSE'
+ =/ d (so second) ?~ d ~
+ `[%eose u.d]
+ %'NOTICE'
+ =/ d (so second) ?~ d ~
+ `[%notice u.d]
+ %'AUTH'
+ =/ d (so second) ?~ d ~
+ `[%auth u.d]
==
++ client-msg
|= jon=json ^- (unit client-msg:sur)