diff options
Diffstat (limited to 'desk')
-rw-r--r-- | desk/app/nostrill.hoon | 40 | ||||
-rw-r--r-- | desk/lib/constants.hoon | 1 | ||||
-rw-r--r-- | desk/lib/json/nostr.hoon | 16 | ||||
-rw-r--r-- | desk/lib/json/nostrill.hoon | 53 | ||||
-rw-r--r-- | desk/lib/nostrill.hoon | 35 | ||||
-rw-r--r-- | desk/lib/shim.hoon | 3 | ||||
-rw-r--r-- | desk/lib/trill/feed.hoon | 51 | ||||
-rw-r--r-- | desk/sur/nostrill.hoon | 25 |
8 files changed, 181 insertions, 43 deletions
diff --git a/desk/app/nostrill.hoon b/desk/app/nostrill.hoon index 575fa3e..e311b5f 100644 --- a/desk/app/nostrill.hoon +++ b/desk/app/nostrill.hoon @@ -83,10 +83,15 @@ ++ handle-post |= poke=post-poke:ui:sur ?- -.poke %add - =/ sp (build-sp:trill our.bowl our.bowl content.poke) - =/ p (build-post:trill now.bowl pubkey.poke sp) + =/ sp (build-sp:trill our.bowl our.bowl content.poke) + =/ p (build-post:trill now.bowl pub.i.keys sp) =. state (add-to-feed:mutat p) - `this + =/ profile (~(get by profiles) pub.i.keys) + =/ pw [p (some pub.i.keys) ~ ~ profile] + =/ =fact:ui:sur [%post %add pw] + =/ card (update-ui:cards fact) + :_ this :~(card) + %rt `this %del `this == @@ -140,7 +145,6 @@ `this %http - ~& pending=pending `this %rt :: relay test =^ cards state get-posts:shimm @@ -157,20 +161,18 @@ :: (get-profiles:shimm +.ids) :: (get-engagement:shimm -.ids) [cards this] - %rt1 - =/ l ~(tap by pending) - =/ l (scag 1 l) - =| cards=(list card:agent:gall) - |- - ?~ l - ~& cards=(lent cards) [cards this] - =/ [sub-id=@t pf=filter:nsur done=filter:nsur] i.l - =/ diff (diff-filters:nlib pf done) - :: ~& > diff=diff - ?~ authors.pf $(l t.l) - =^ cs state (populate-profiles:mutat u.authors.pf) + :: %rt1 + :: =| cards=(list card:agent:gall) + :: |- + :: ?~ l + :: ~& cards=(lent cards) [cards this] + :: =/ [sub-id=@t pf=filter:nsur done=filter:nsur] i.l + :: =/ diff (diff-filters:nlib pf done) + :: :: ~& > diff=diff + :: ?~ authors.pf $(l t.l) + :: =^ cs state (populate-profiles:mutat u.authors.pf) - $(l t.l, cards (weld cards cs)) + :: $(l t.l, cards (weld cards cs)) %rt2 =/ poasts (tap:norm:sur nostr-feed) @@ -198,6 +200,10 @@ :: =^ cards state (populate-profiles:mutat pks) [cards this] + %ui + =/ =fact:ui:sur [%post %add *post-wrapper:sur] + =/ card (update-ui:cards fact) + :_ this :~(card) == :: diff --git a/desk/lib/constants.hoon b/desk/lib/constants.hoon index c7f72b7..9beab32 100644 --- a/desk/lib/constants.hoon +++ b/desk/lib/constants.hoon @@ -1,3 +1,4 @@ |% +++ feed-page-size 100 ++ http-delay 3.000 -- diff --git a/desk/lib/json/nostr.hoon b/desk/lib/json/nostr.hoon index 9c36eb0..6f93c1c 100644 --- a/desk/lib/json/nostr.hoon +++ b/desk/lib/json/nostr.hoon @@ -38,9 +38,11 @@ :: ++ raw-event |= raw-event:sur :: WTF nostr doesn't want the prefix on the pubkey - =/ pubkeyt (scow:sr %ux pubkey) + =/ scw scow:sr + =/ pubkeyt (scw(min-chars 64) %ux pubkey) ?~ pubkeyt !! - =/ pubkeyj [%s (crip t.pubkeyt)] + :: =/ pubkeyj [%s (crip t.pubkeyt)] + =/ pubkeyj [%s (crip pubkeyt)] :- %a :~ [%n '0'] pubkeyj @@ -51,13 +53,13 @@ == ++ event |= e=event:sur ^- json - =/ pubkeyt (scow:sr %ux pubkey.e) - ?~ pubkeyt !! - =/ pubkeyj [%s (crip t.pubkeyt)] + :: =/ pubkeyt (scow:sr %ux pubkey.e) + :: ?~ pubkeyt !! + :: =/ pubkeyj [%s (crip t.pubkeyt)] %: pairs id+(hex:en:common id.e) - :: pubkey+(hex:en:common pubkey.e) - pubkey+pubkeyj + pubkey+(hex:en:common pubkey.e) + :: pubkey+pubkeyj sig+(hex:en:common sig.e) ['created_at' (numb created-at.e)] kind+(numb kind.e) diff --git a/desk/lib/json/nostrill.hoon b/desk/lib/json/nostrill.hoon index 43f7708..bd34acc 100644 --- a/desk/lib/json/nostrill.hoon +++ b/desk/lib/json/nostrill.hoon @@ -6,6 +6,7 @@ |% :: UI comms ++ state |= state-0:sur ^- json + %+ frond %state %: pairs relays+(en-relays relays) key+(hex:en:common pub.i.keys) @@ -38,27 +39,60 @@ ++ en-profiles |= m=(map @ux user-meta:nsur) %- pairs %+ turn ~(tap by m) |= [key=@ux p=user-meta:nsur] - :- (crip (scow:sr %ux key)) (user-meta:en:nostr p) + =/ jkey (hex:en:common key) + ?> ?=(%s -.jkey) + :- +.jkey (user-meta:en:nostr p) ++ enfollowing |= m=(map @ux feed:feed) ^- json %- pairs %+ turn ~(tap by m) |= [key=@ux f=feed:feed] - :- (crip (scow:sr %ux key)) (feed:en:trill f) + =/ jkey (hex:en:common key) + ?> ?=(%s -.jkey) + :- +.jkey (feed:en:trill f) ++ engraph |= m=(map @ux (set follow:sur)) ^- json %- pairs %+ turn ~(tap by m) |= [key=@ux s=(set follow:sur)] - :- (crip (scow:sr %ux key)) - :- %a %+ turn ~(tap in s) |= f=follow:sur - %- pairs - :~ pubkey+(hex:en:common pubkey.f) - name+s+name.f - :- %relay ?~ relay.f ~ s+u.relay.f - == + =/ jkey (hex:en:common key) + ?> ?=(%s -.jkey) + :- +.jkey + :- %a %+ turn ~(tap in s) |= f=follow:sur + %- pairs + :~ pubkey+(hex:en:common pubkey.f) + name+s+name.f + :- %relay ?~ relay.f ~ s+u.relay.f + == + + :: ui facts + ++ fact |= f=fact:ui:sur ^- json + %+ frond %fact + %+ frond -.f + ?- -.f + %post (postfact +.f) + %enga (enga +.f) + == + ++ postfact |= pf=post-fact:ui:sur ^- json + %+ frond -.pf + (post-wrapper +.pf) + ++ enga |= [pw=post-wrapper:sur reaction=*] + ^- json + ~ + ++ post-wrapper |= p=post-wrapper:sur + %- pairs + :~ post+(poast:en:trill post.p) + ['nostrMeta' (nostr-meta nostr-meta.p)] + == + ++ nostr-meta |= p=nostr-meta:sur + =| l=(list [@t json]) + =. l ?~ pub.p l :_ l ['pubkey' (hex:en:common u.pub.p)] + =. l ?~ ev-id.p l :_ l ['eventId' (hex:en:common u.ev-id.p)] + =. l ?~ relay.p l :_ l ['relay' %s u.relay.p] + =. l ?~ pr.p l :_ l ['profile' (user-meta:en:nostr u.pr.p)] + %- pairs l -- ++ de =, dejs-soft:format @@ -94,7 +128,6 @@ == ++ de-post %- ot :~ - pubkey+hex:de:common content+so == ++ de-rt diff --git a/desk/lib/nostrill.hoon b/desk/lib/nostrill.hoon index c7e940c..0570dbc 100644 --- a/desk/lib/nostrill.hoon +++ b/desk/lib/nostrill.hoon @@ -1,5 +1,5 @@ -/- post=trill-post, nsur=nostr, sur=nostrill -/+ trill=trill-post, nostr, sr=sortug +/- post=trill-post, nsur=nostr, sur=nostrill, gate=trill-gate +/+ trill=trill-post, nostr, sr=sortug, jsonlib=json-nostrill |% :: ++ default-state |= =bowl:gall ^- state:sur @@ -47,9 +47,40 @@ signature == event + +++ event-to-post + |= [=event:nsur profile=(unit user-meta:nsur) relay=(unit @t)] + ^- post-wrapper:sur + + =/ 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 + host=`@p`pubkey.event + author=`@p`pubkey.event + thread=ts + parent=~ + children=~ + contents=cm + read=*lock:gate + write=*lock:gate + *engagement:post + 0v0 + *signature:post + tags=~ + == + =/ meta [(some pubkey.event) (some id.event) relay profile] + [p meta] + ++ cards |_ =bowl:gall ++ shim-binding ^- card:agent:gall [%pass /binding %arvo %e %connect [~ /nostr-shim] dap.bowl] + ++ update-ui |= =fact:ui:sur ^- card:agent:gall + =/ jon (fact:en:jsonlib fact) + [%give %fact ~[/ui] %json !>(jon)] -- -- diff --git a/desk/lib/shim.hoon b/desk/lib/shim.hoon index 4afdf2b..f2e0b8a 100644 --- a/desk/lib/shim.hoon +++ b/desk/lib/shim.hoon @@ -105,9 +105,6 @@ =/ sub-id (gen-sub-id:nlib eny.bowl) =/ kinds (silt ~[0]) =/ total=filter:nsur [~ `pubkeys `kinds ~ ~ ~ ~] - =/ chunk (silt (scag 10 ~(tap in pubkeys))) - =/ =filter:nsur [~ `chunk `kinds ~ ~ ~ ~] - =. pending.state (~(put by pending.state) sub-id [total *filter:nsur]) =/ req=http-req:shim:nsur [relay http-delay:constants sub-id ~[total]] =/ =card (send-http req) :- :~(card) state diff --git a/desk/lib/trill/feed.hoon b/desk/lib/trill/feed.hoon new file mode 100644 index 0000000..c21feb3 --- /dev/null +++ b/desk/lib/trill/feed.hoon @@ -0,0 +1,51 @@ +/- feed=trill-feed, sur=nostrill +/+ sr=sortug, constants +|% +++ latest-page |= f=feed:feed ^- fc:feed + =/ nodelist (tap:orm:feed f) + =/ subset (scag feed-page-size:constants nodelist) + ?~ subset [f ~ ~] + =/ start `id.i.subset + =/ rev (flop subset) + ?~ rev [f ~ ~] + =/ end `id.i.rev + =/ nf (gas:orm:feed *feed:feed subset) + [nf start end] +:: +++ latest-page-nostr |= f=nostr-feed:sur ^- nfc:sur + =/ nodelist (tap:norm:sur f) + =/ subset (scag feed-page-size:constants nodelist) + ?~ subset [f ~ ~] + =/ start `id.i.subset + =/ rev (flop subset) + ?~ rev [f ~ ~] + =/ end `id.i.rev + =/ nf (gas:norm:sur *nostr-feed:sur subset) + [nf start end] +:: +:: NOTE START IS OLD, END IS NEW + +++ subset +|= [=fc:feed replies=? now=@da] ^- fc:feed + ?: ?&(?=(%~ start.fc) ?=(%~ end.fc)) (latest-page feed.fc) + + =/ count feed-page-size:constants + =/ start ?~ start.fc 0 u.start.fc + =/ end ?~ end.fc now u.end.fc + =/ nodelist (tap:orm:feed feed.fc) + + =/ threads %+ skim nodelist + |= [=id:post =post:post] ^- ? + ?. replies + ?& + ?= %~ parent.post + (lte id start) (gte id end) + == + ?& (lte id start) (gte id end) == + =/ thread-count (lent threads) + =/ result=(list [id:post post:post]) ?: newest (scag count threads) (flop (scag count (flop threads))) + =/ cursors=[(unit @da) (unit @da)] ?~ result [~ ~] ?~ threads [~ ~] :- + ?: .=((head result) (head threads)) ~ `id:(head result) + ?: .=((rear result) (rear threads)) ~ `id:(rear result) + [(gas:orm:feed *feed:feed result) -.cursors +.cursors] +-- diff --git a/desk/sur/nostrill.hoon b/desk/sur/nostrill.hoon index ad82661..a9ef8f3 100644 --- a/desk/sur/nostrill.hoon +++ b/desk/sur/nostrill.hoon @@ -1,4 +1,4 @@ -/- trill=trill-feed, nostr +/- trill=trill-feed, tp=trill-post, nostr |% +$ state state-0 +$ state-0 @@ -14,13 +14,21 @@ profiles=(map @ux user-meta:nostr) following=(map @ux =feed:trill) follow-graph=(map @ux (set follow)) - :: for http requests - pending=(map @t [pending=filter:nostr done=filter:nostr]) :: TODO global feed somehow? == +$ nostr-feed ((mop @ud event:nostr) gth) ++ norm ((on @ud event:nostr) gth) ++$ nfc [feed=nostr-feed start=cursor:trill end=cursor:trill] + ++$ post-wrapper [=post:tp nostr-meta=nostr-meta] ++$ nostr-meta +$: pub=(unit @ux) + ev-id=(unit @ux) + relay=(unit @t) + pr=(unit user-meta:nostr) +== + +$ follow [pubkey=@ux name=@t relay=(unit @t)] ++ ui |% @@ -33,7 +41,7 @@ [%rela relay-poke] == +$ post-poke - $% [%add pubkey=@ux content=@t] + $% [%add content=@t] [%rt id=@ux pubkey=@ux relay=@t] :: NIP-18 [%del pubkey=@ux] == @@ -48,5 +56,14 @@ +$ relay-poke $% [%send host=@p id=@ relays=(list @t)] == + :: facts + +$ fact + $% [%post post-fact] + [%enga p=post-wrapper reaction=*] + == + +$ post-fact + $% [%add post-wrapper] + [%del post-wrapper] + == -- -- |