summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--app/app/nostrill.hoon5
-rw-r--r--app/lib/json/nostr.hoon2
-rw-r--r--app/lib/json/nostrill.hoon27
-rw-r--r--app/lib/json/trill.hoon18
-rw-r--r--app/lib/mutations/nostr.hoon16
-rw-r--r--app/lib/mutations/trill.hoon48
-rw-r--r--app/lib/nostr/client.hoon8
-rw-r--r--app/lib/nostr/events.hoon30
-rw-r--r--app/lib/nostrill.hoon6
-rw-r--r--app/sur/nostrill.hoon13
10 files changed, 131 insertions, 42 deletions
diff --git a/app/app/nostrill.hoon b/app/app/nostrill.hoon
index ca5314a..8f42b8c 100644
--- a/app/app/nostrill.hoon
+++ b/app/app/nostrill.hoon
@@ -193,6 +193,9 @@
%del
=. profiles (~(del by profiles) [%urbit our.bowl])
`this
+ %fetch
+ :: TODO
+ `this
==
++ handle-rela |= poke=relay-poke:ui:sur
:: TODO fix this somehow
@@ -401,6 +404,8 @@
++ on-leave
|~ =(pole knot)
^- (quip card:agent:gall agent:gall)
+ ~& >>> on-leave=pole
+ :: TODO fix the relays when we doing this
`this
::
++ on-peek
diff --git a/app/lib/json/nostr.hoon b/app/lib/json/nostr.hoon
index 0b1a79a..05713a5 100644
--- a/app/lib/json/nostr.hoon
+++ b/app/lib/json/nostr.hoon
@@ -42,7 +42,7 @@
|= e=event:sur ^- json
=/ pubkey ?. nostr
(hex:en:common pubkey.e)
- =/ pubkeyt (scow:sr %ux pubkey.e)
+ =/ pubkeyt (scow:parsing:sr %ux pubkey.e)
?~ pubkeyt !!
[%s (crip t.pubkeyt)]
%: pairs
diff --git a/app/lib/json/nostrill.hoon b/app/lib/json/nostrill.hoon
index 01cdb13..e6bfd4c 100644
--- a/app/lib/json/nostrill.hoon
+++ b/app/lib/json/nostrill.hoon
@@ -82,6 +82,7 @@
?- -.f
%nostr (en-nostr +.f)
%post (postfact +.f)
+ %prof (en-profiles +.f)
%enga (enga +.f)
%fols (fols +.f)
%hark (hark +.f)
@@ -228,6 +229,7 @@
%- of :~
add+ui-meta
del+ul
+ fetch+(ar user)
==
++ ui-meta
%- ot :~
@@ -255,25 +257,25 @@
++ reply
%- ot :~
content+so
- host+(se:de:common %p)
- id+de-atom-id
- thread+de-atom-id
+ host+user
+ id+de-post-id
+ id+de-post-id
==
++ quote
%- ot :~
content+so
- host+(se:de:common %p)
- id+de-atom-id
+ host+user
+ id+de-post-id
==
++ pid
%- ot :~
- host+(se:de:common %p)
+ host+user
id+de-atom-id
==
++ reaction
%- ot :~
- host+(se:de:common %p)
- id+de-atom-id
+ host+user
+ id+de-post-id
reaction+so
==
++ rt
@@ -287,6 +289,7 @@
add+so
del+de-atom-id
sync+ul
+ prof+ul
user+hex:de:common
thread+hex:de:common
send+de-relay-send
@@ -296,6 +299,14 @@
id+de-atom-id
relays+(ar so)
==
+
+++ de-post-id
+ |= jon=json ^- (unit @)
+ ?. ?=([%s @t] jon) ~
+ =/ tryatom (rush p.jon dem)
+ ?^ tryatom tryatom
+ ^- (unit @) (hex:de:common jon)
+
++ de-atom-id
|= jon=json ^- (unit @)
?. ?=([%s @t] jon) ~
diff --git a/app/lib/json/trill.hoon b/app/lib/json/trill.hoon
index 415d2f4..c3ef3b6 100644
--- a/app/lib/json/trill.hoon
+++ b/app/lib/json/trill.hoon
@@ -1,4 +1,4 @@
-/- feed=trill-feed, post=trill-post
+/- feed=trill-feed, post=trill-post, sur=nostrill
/+ common=json-common, sr=sortug
|%
++ en
@@ -23,16 +23,26 @@
:- (crip (scow:sr %ud `@ud`post-id))
(poast p)
+ ++ branch-user |= p=@p ^- user:sur
+ =/ bitsize (met 3 p)
+ :: TODO surely there's proper verification methods
+ ?: .=(32 bitsize) [%nostr `@ux`p] [%urbit p]
+ ++ user |= u=user:sur ^- json
+ ?- -.u
+ %urbit (patp:en:common +.u)
+ %nostr (hex:en:common +.u)
+ ==
++ poast
|= p=post:post ^- json
%- pairs
:~ id+(ud:en:common id.p)
- host+(patp:en:common host.p)
- author+(patp:en:common author.p)
+ host+(user (branch-user host.p))
+ author+(user (branch-user author.p))
thread+(ud:en:common thread.p)
parent+?~(parent.p ~ (ud:en:common u.parent.p))
contents+(content contents.p)
- hash+(b64:en:common hash.p)
+ :: hash+(b64:en:common hash.p)
+ hash+(hex:en:common `@ux`hash.p)
engagement+(engagement engagement.p)
children+a+(turn ~(tap in children.p) ud:en:common)
time+(time id.p)
diff --git a/app/lib/mutations/nostr.hoon b/app/lib/mutations/nostr.hoon
index 66fdc35..55cffe7 100644
--- a/app/lib/mutations/nostr.hoon
+++ b/app/lib/mutations/nostr.hoon
@@ -126,7 +126,7 @@
:: increment event count in relay state
~& >> parsing-nostr-event=kind.event
~& >> sub-id=sub-id
- ~& > relay-subs=~(key by reqs.relay)
+ :: ~& > relay-subs=~(key by reqs.relay)
=/ req (~(get by reqs.relay) sub-id)
?~ req ~& >>> "sub id not found in relay state" `state
@@ -244,20 +244,22 @@
:: if there's a queue we setup the next subscription
=^ cards relay
?: (is-feed:evlib filters.u.creq)
+ ~& >> "eose on global feed request"
=/ c (update-ui:cardslib [%nostr %feed nostr-feed.state])
=^ mc relay get-profiles:nclient
[[c mc] relay]
::
=/ users=(set @ux) (user-req:evlib filters.u.creq)
?: (gth ~(wyt in users) 0)
+ ~& >>> "eose on user feed request"
=/ poasts (tap:norm:sur nostr-feed.state)
=/ subset %+ skim poasts |= [* ev=event:nsur] (~(has in users) pubkey.ev)
=/ f (gas:norm:sur *nostr-feed:sur subset)
=/ c (update-ui:cardslib [%nostr %user f])
- =^ mc relay get-profiles:nclient
- [[c mc] relay]
+ [:~(c) relay]
=/ thread-id (thread-req:evlib filters.u.creq)
?^ thread-id
+ ~& >>> "eose on thread request"
=/ poasts (tap:norm:sur nostr-feed.state)
=/ subset %+ skim poasts |= [* ev=event:nsur]
?| .=(u.thread-id id.ev)
@@ -266,8 +268,11 @@
==
=/ f (gas:norm:sur *nostr-feed:sur subset)
=/ c (update-ui:cardslib [%nostr %thread f])
- =^ mc relay get-profiles:nclient
- [[c mc] relay]
+ [:~(c) relay]
+ ::
+ ?: (profs-req:evlib filters.u.creq)
+ =/ c (update-ui:cardslib [%prof profiles.state])
+ [:~(c) relay]
::
[~ relay]
::
@@ -320,6 +325,7 @@
%sync get-posts:nclient
%user (get-user-feed:nclient +.rh)
%thread (get-thread:nclient +.rh)
+ %prof get-profiles:nclient
::
==
=. relays.state (~(put by relays.state) -.u.rl relay)
diff --git a/app/lib/mutations/trill.hoon b/app/lib/mutations/trill.hoon
index d5cfb67..ffcba1c 100644
--- a/app/lib/mutations/trill.hoon
+++ b/app/lib/mutations/trill.hoon
@@ -7,7 +7,11 @@
trill=trill-post,
njs=json-nostr,
postlib=trill-post,
- sr=sortug
+ sr=sortug,
+ ::
+ mutations-nostr,
+ nostr-client,
+ evlib=nostr-events
|_ [=state:sur =bowl:gall]
+$ card card:agent:gall
@@ -47,7 +51,8 @@
%del =. feed.state =< + (del:orm:feed feed.state id.poke)
:: TODO cascade children
=/ p *post:post
- =/ p p(id id.poke, host host.poke)
+ =/ host (user-to-atom:lib host.poke)
+ =/ p p(id id.poke, host host)
=/ pw [p (some pubkey) ~ ~ profile]
=/ jfact=fact:ui:sur [%post %del pw]
=/ ui-card (update-ui:cards:lib jfact)
@@ -76,8 +81,9 @@
fact-card
==
%quote
+ =/ host (user-to-atom:lib host.poke)
=/ sp (build-sp:trill our.bowl our.bowl content.poke ~ ~)
- =/ quote [%ref %trill host.poke /(crip (scow:sr %ud id.poke))]
+ =/ quote [%ref %trill host /(crip (scow:sr %ud id.poke))]
=. contents.sp (snoc contents.sp quote)
=/ p=post:post
(build-post:trill now.bowl pubkey sp)
@@ -89,7 +95,7 @@
=/ eng-card (poke-host:crds host.p eng-poke)
:_ state
- ?: .=(our.bowl host.poke)
+ ?: .=(our.bowl host)
=/ =fact:comms [%post %add p]
=/ fact-card (update-followers:cards:lib fact)
:~ ui-card
@@ -102,7 +108,23 @@
==
%reply
- =/ sp (build-sp:trill host.poke our.bowl content.poke `id.poke `thread.poke)
+ ?: ?=(%nostr -.host.poke)
+ =/ mutan ~(. mutations-nostr [state bowl])
+ =/ rl get-relay:mutan
+ ?~ rl ~& >>> "no-relay!" `state
+ =/ wid=@ -.u.rl
+ =/ relay=relay-stats:nsur +.u.rl
+ =/ nclient ~(. nostr-client [state bowl wid relay])
+ =/ ev (build-event:evlib i.keys.state eny.bowl now.bowl content.poke)
+ =/ parent-id (crip (scow:parsing:sr %ux id.poke))
+ =/ reply-tag=(list @t) ['e' parent-id url.relay 'reply' ~]
+ =. tags.ev ~[reply-tag]
+ :_ state
+ :~ (send:nclient url.relay [%event ev])
+ ==
+ ::
+ =/ host (user-to-atom:lib host.poke)
+ =/ sp (build-sp:trill host our.bowl content.poke `id.poke `thread.poke)
=/ p=post:post
(build-post:trill now.bowl pubkey sp)
=. state (add-to-feed p)
@@ -113,7 +135,7 @@
=/ eng-card (poke-host:crds host.p eng-poke)
:_ state
- ?: .=(our.bowl host.poke)
+ ?: .=(our.bowl host)
=/ =fact:comms [%post %add p]
=/ fact-card (update-followers:cards:lib fact)
:~ ui-card
@@ -125,8 +147,9 @@
eng-card
==
%rp
- =/ quote [%ref %trill host.poke /(crip (scow:sr %ud id.poke))]
- =/ sp (build-sp:trill host.poke our.bowl '' ~ ~)
+ =/ host (user-to-atom:lib host.poke)
+ =/ quote [%ref %trill host /(crip (scow:sr %ud id.poke))]
+ =/ sp (build-sp:trill host our.bowl '' ~ ~)
=. contents.sp ~[quote]
=/ p=post:post
(build-post:trill now.bowl pubkey sp)
@@ -138,7 +161,7 @@
=/ eng-card (poke-host:crds host.p eng-poke)
:_ state
- ?: .=(our.bowl host.poke)
+ ?: .=(our.bowl host)
=/ =fact:comms [%post %add p]
=/ fact-card (update-followers:cards:lib fact)
:~ ui-card
@@ -150,7 +173,8 @@
eng-card
==
%reaction
- ?: .=(host.poke our.bowl)
+ =/ host (user-to-atom:lib host.poke)
+ ?: .=(host our.bowl)
=/ p (got:orm:feed feed.state id.poke)
=. reacts.engagement.p %+ ~(put by reacts.engagement.p)
our.bowl [reaction.poke *signature:post]
@@ -159,7 +183,7 @@
=/ jfact=fact:ui:sur [%post %add pw]
=/ ui-card (update-ui:cards:lib jfact)
=/ eng-poke [%eng (headsup-poke poke p)]
- =/ eng-card (poke-host:crds host.poke eng-poke)
+ =/ eng-card (poke-host:crds host eng-poke)
:_ state
=/ =fact:comms [%post %add p]
@@ -172,7 +196,7 @@
=/ up (get:orm:feed following2.state id.poke)
?~ up
=/ eng-poke [%eng (headsup-poke poke *post:post)]
- =/ eng-card (poke-host:crds host.poke eng-poke)
+ =/ eng-card (poke-host:crds host eng-poke)
:_ state :~(eng-card)
::
=/ p u.up
diff --git a/app/lib/nostr/client.hoon b/app/lib/nostr/client.hoon
index 259852e..2ed5b0a 100644
--- a/app/lib/nostr/client.hoon
+++ b/app/lib/nostr/client.hoon
@@ -47,9 +47,10 @@
++ get-user-feed
|= pubkey=@ux
=/ kinds (silt ~[1])
- :: =/ since (to-unix-secs:jikan:sr last-week)
+ :: =/ since (sub now.bowl ~d30)
+ =/ since (sub now.bowl ~d5)
=/ pubkeys (silt ~[pubkey])
- =/ =filter:nsur [~ `pubkeys `kinds ~ ~ ~ ~]
+ =/ =filter:nsur [~ `pubkeys `kinds ~ `since ~ ~]
(send-req ~[filter] `.n ~)
++ get-thread |= id=@ux
@@ -60,6 +61,7 @@
=/ tag ['e' ids]
=/ tags=(map @t (list @t)) (malt :~(tag))
=/ f2=filter:nsur [~ ~ `kinds `tags ~ ~ ~]
+ ~& >>> getting-thread=[f1 f2]
(send-req ~[f1 f2] `.n ~)
++ get-post |= id=@ux
@@ -139,7 +141,7 @@
++ send
|= [relay-url=@t req=client-msg:nsur] ^- card
- ~& >>> sendws=relay-url
+ ~& >>> sendws=[relay-url req]
=/ req-body=json (req:en:js req)
=/ octs (json-to-octs:server req-body)
=/ wmsg=websocket-message:eyre [1 `octs]
diff --git a/app/lib/nostr/events.hoon b/app/lib/nostr/events.hoon
index 16beabc..9182af3 100644
--- a/app/lib/nostr/events.hoon
+++ b/app/lib/nostr/events.hoon
@@ -14,13 +14,19 @@
== .y
$(fs t.fs)
+++ profs-req |= fs=(list filter:nsur) ^- ?
+ |- ?~ fs .n
+ =/ filter i.fs
+ ?~ kinds.filter .n
+ ?: (~(has in u.kinds.filter) 0) .y
+ $(fs t.fs)
+
++ user-req |= fs=(list filter:nsur) ^- (set @ux)
=| pubkeys=(set @ux)
|- ?~ fs pubkeys
=/ filter i.fs
?~ kinds.filter ~
?~ authors.filter ~
- ?: (~(has in u.kinds.filter) 0) ~
=? pubkeys
?& (~(has in u.kinds.filter) 1)
?=(%~ ids.filter)
@@ -100,6 +106,23 @@
=? ids ?=(^ ref) (~(put in ids) u.ref)
$(tags t.tags)
+++ build-event |= [=keys:nsur eny=@ time=@da content=@t] ^- event:nsur
+ =/ ts (to-unix-secs:jikan:sr time)
+ =/ raw=raw-event:nsur [pub.keys ts 1 ~ content]
+ =/ event-id (hash-event:nostr-keys raw)
+ =/ signature (sign-event:nostr-keys priv.keys event-id eny)
+ ~& hash-and-signed=[event-id signature]
+ =/ =event:nsur :*
+ event-id
+ pub.keys
+ created-at.raw
+ kind.raw
+ tags.raw
+ content.raw
+ signature
+ ==
+ event
+
++ post-to-event |= [=keys:nsur eny=@ p=post:post] ^- event:nsur
=/ cl (latest-post-content:trill contents.p)
=/ string (crip (content-list-to-md:trill cl))
@@ -122,11 +145,10 @@
++ event-to-post
|= [=event:nsur profile=(unit user-meta:nsur) relay=(unit @t)]
^- post-wrapper:sur
-
+ :: most people on nostr don't use markdown, they just spam links like retards
=/ cl (tokenize:trill content.event)
=/ ts (from-unix:jikan:sr created-at.event)
=/ cm=content-map:post (init-content-map:trill cl ts)
-
:: TODO more about @ps and stuff
=/ p=post:post :*
id=ts
@@ -139,7 +161,7 @@
read=*lock:gate
write=*lock:gate
*engagement:post
- 0v0
+ `@`id.event
*signature:post
tags=~
==
diff --git a/app/lib/nostrill.hoon b/app/lib/nostrill.hoon
index 32099b2..bdc6d4a 100644
--- a/app/lib/nostrill.hoon
+++ b/app/lib/nostrill.hoon
@@ -32,6 +32,12 @@
=/ res-event=websocket-event:eyre [%message 1 `octs]
:~ (give-ws-payload-server:ws wid res-event)
==
+
+++ user-to-atom |= u=user:sur ^- @
+ ?- -.u
+ %urbit +.u
+ %nostr +.u
+ ==
::
diff --git a/app/sur/nostrill.hoon b/app/sur/nostrill.hoon
index b6aeb3a..192553b 100644
--- a/app/sur/nostrill.hoon
+++ b/app/sur/nostrill.hoon
@@ -69,12 +69,12 @@ $% [%reply p=post:tp]
==
+$ post-poke
$% [%add content=@t]
- [%reply content=@t host=@p id=@da thread=@da]
- [%quote content=@t host=@p id=@da]
- [%rp host=@p id=@da] :: NIP-18
- [%reaction host=@p id=@da reaction=@t]
+ [%reply content=@t host=user id=@da thread=@da]
+ [%quote content=@t host=user id=@da]
+ [%rp host=user id=@da] :: NIP-18
+ [%reaction host=user id=@da reaction=@t]
:: [%rt id=@ux pubkey=@ux relay=@t] :: NIP-18
- [%del host=@p id=@da]
+ [%del host=user id=@da]
==
+$ fols-poke
$% [%add =user]
@@ -83,6 +83,7 @@ $% [%reply p=post:tp]
+$ prof-poke
$% [%add meta=user-meta:nostr]
[%del ~]
+ [%fetch p=(list user)]
==
+$ relay-poke
$% [%add p=@t]
@@ -92,6 +93,7 @@ $% [%reply p=post:tp]
==
+$ relay-handling
$% [%sync ~]
+ [%prof ~]
[%user pubkey=@ux]
[%thread id=@ux]
:: send event for... relaying
@@ -101,6 +103,7 @@ $% [%reply p=post:tp]
+$ fact
$% [%nostr nostr-fact]
[%post post-fact]
+ [%prof (map user user-meta:nostr)]
[%enga p=post-wrapper reaction=*]
[%fols fols-fact]
[%hark =notif]