summaryrefslogtreecommitdiff
path: root/app/lib
diff options
context:
space:
mode:
Diffstat (limited to 'app/lib')
-rw-r--r--app/lib/json/nostr.hoon2
-rw-r--r--app/lib/nostr/client.hoon12
-rw-r--r--app/lib/websockets.hoon12
3 files changed, 19 insertions, 7 deletions
diff --git a/app/lib/json/nostr.hoon b/app/lib/json/nostr.hoon
index 887e0d8..cd7e95f 100644
--- a/app/lib/json/nostr.hoon
+++ b/app/lib/json/nostr.hoon
@@ -121,7 +121,7 @@
=/ second i.t.p.jon
?. ?=(%s -.head) ~
:: TODO make sure they're always caps
- ~& dejson=[p.head second]
+ ~& dejson=[p.head subid=second]
?+ p.head ~
%'EVENT'
=/ d (so second) ?~ d ~
diff --git a/app/lib/nostr/client.hoon b/app/lib/nostr/client.hoon
index 41c3080..2438a47 100644
--- a/app/lib/nostr/client.hoon
+++ b/app/lib/nostr/client.hoon
@@ -48,9 +48,9 @@
++ get-posts
^- (quip card _state)
=/ kinds (silt ~[1])
- =/ last-week (sub now.bowl ~d7)
+ =/ since (sub now.bowl ~m1)
:: =/ since (to-unix-secs:jikan:sr last-week)
- =/ =filter:nsur [~ ~ `kinds ~ `last-week ~ ~]
+ =/ =filter:nsur [~ ~ `kinds ~ `since ~ ~]
(send-req ~[filter])
++ get-user-feed
@@ -92,7 +92,7 @@
++ test-connection
|= relay-url=@t
=/ kinds (silt ~[1])
- =/ since (sub now.bowl ~h1)
+ =/ since (sub now.bowl ~m1)
=/ =filter:nsur [~ ~ `kinds ~ `since ~ ~]
=/ sub-id (gen-sub-id:nostr-keys eny.bowl)
=/ req=client-msg:nsur [%req sub-id ~[filter]]
@@ -103,14 +103,14 @@
~& >>> send=relay-url
=/ req-body=json (req:en:js req)
=/ octs (json-to-octs:server req-body)
- =/ wev=websocket-event:eyre [%message 1 `octs]
+ =/ wmsg=websocket-message:eyre [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])]
+ [%pass (weld /ws pat) %arvo %k %fard dap.bowl %ws %noun !>([relay-url wmsg])]
::
- (give-ws-payload-client:ws id.u.conn [1 `octs])
+ (give-ws-payload-client:ws id.u.conn wmsg)
:: ++ send-http
diff --git a/app/lib/websockets.hoon b/app/lib/websockets.hoon
index 98ea25b..8e6d45c 100644
--- a/app/lib/websockets.hoon
+++ b/app/lib/websockets.hoon
@@ -6,6 +6,13 @@
[%message !>(msg)]
=/ wsid (scot %ud wid)
[%give %fact ~[/websocket-client/[wsid]] cage]
+ ++ close-ws-client
+ |= wid=@
+ ^- card:agent:gall
+ =/ =cage
+ [%disconnect !>(~)]
+ =/ wsid (scot %ud wid)
+ [%give %fact ~[/websocket-client/[wsid]] cage]
++ give-ws-payload-server
|= [wid=@ event=websocket-event:eyre]
@@ -26,6 +33,11 @@
(give-ws-payload-server wid response)
==
+ ++ get-url
+ |= [wid=@ud =bowl:gall] ^- @t
+ =/ scry-path=path /(scot %p our.bowl)/ws/(scot %da now.bowl)/id/(scot %ud wid)
+ =/ conn .^(websocket-connection:iris %ix scry-path)
+ url.conn
++ check-connected
|= [url=@t =bowl:gall] ^- (unit websocket-connection:iris)
=/ scry-path=path /(scot %p our.bowl)/ws/(scot %da now.bowl)/url/[url]