diff options
| author | polwex <polwex@sortug.com> | 2025-10-31 22:59:42 +0700 |
|---|---|---|
| committer | polwex <polwex@sortug.com> | 2025-10-31 22:59:42 +0700 |
| commit | f019da2e338733dd88d3a8efe60f260d74b9a7ad (patch) | |
| tree | ecccfab6926dd89c3ec0597653cca6e30c62dc41 /app/lib/nostr | |
| parent | 54fb3abb81621bd2a5fafbdd9b96a8be8464878e (diff) | |
fixes to iris request flow with threads
Diffstat (limited to 'app/lib/nostr')
| -rw-r--r-- | app/lib/nostr/client.hoon | 20 | ||||
| -rw-r--r-- | app/lib/nostr/req.hoon | 4 |
2 files changed, 21 insertions, 3 deletions
diff --git a/app/lib/nostr/client.hoon b/app/lib/nostr/client.hoon index 908b360..41c3080 100644 --- a/app/lib/nostr/client.hoon +++ b/app/lib/nostr/client.hoon @@ -1,5 +1,5 @@ /- sur=nostrill, nsur=nostr -/+ js=json-nostr, sr=sortug, nostr-keys, constants, server +/+ js=json-nostr, sr=sortug, nostr-keys, constants, server, ws=websockets /= web /web/router |_ [=state:sur =bowl:gall] @@ -88,14 +88,30 @@ =/ =filter:nsur [~ ~ `kinds `tags ~ ~ ~] (send-req ~[filter]) -:: TODO URGENT +:: +++ test-connection + |= relay-url=@t + =/ kinds (silt ~[1]) + =/ since (sub now.bowl ~h1) + =/ =filter:nsur [~ ~ `kinds ~ `since ~ ~] + =/ sub-id (gen-sub-id:nostr-keys eny.bowl) + =/ req=client-msg:nsur [%req sub-id ~[filter]] + :- :~ (send relay-url req) == state + ++ send |= [relay-url=@t req=client-msg:nsur] ^- card:agent:gall + ~& >>> send=relay-url =/ req-body=json (req:en:js req) =/ octs (json-to-octs:server req-body) =/ wev=websocket-event:eyre [%message 1 `octs] + =/ conn (check-connected:ws relay-url bowl) + ~& >>> send-client-conn=conn + ?~ conn :: if no ws connection we start a thread which will connect first, then send the message =/ pat /to-nostr-relay [%pass (weld /ws pat) %arvo %k %fard dap.bowl %ws %noun !>([relay-url wev])] + :: + (give-ws-payload-client:ws id.u.conn [1 `octs]) + :: ++ send-http :: |= req=http-req:shim:nsur diff --git a/app/lib/nostr/req.hoon b/app/lib/nostr/req.hoon index e53159c..89cd262 100644 --- a/app/lib/nostr/req.hoon +++ b/app/lib/nostr/req.hoon @@ -14,5 +14,7 @@ =/ jon (relay-msg:en:js msg) =/ octs (json-to-octs:server jon) =/ res-event=websocket-event:eyre [%message 1 `octs] - (give-ws-payload:ws wid res-event) + :~ + (give-ws-payload-server:ws wid res-event) + == -- |
