diff options
author | polwex <polwex@sortug.com> | 2025-09-18 03:48:14 +0700 |
---|---|---|
committer | polwex <polwex@sortug.com> | 2025-09-18 03:48:14 +0700 |
commit | ad7ebd1756956724e0b167d88f924e707401a9aa (patch) | |
tree | 5f29ab38e41224245a93a2a00318b835278ac596 /desk | |
parent | 4b016c908dda2019f3bf89e5a3d2eae535e5fbd2 (diff) |
fuck yeah
Diffstat (limited to 'desk')
-rw-r--r-- | desk/app/nostrill.hoon | 36 | ||||
-rw-r--r-- | desk/lib/json/nostrill.hoon | 15 | ||||
-rw-r--r-- | desk/lib/nostrill/comms.hoon | 24 | ||||
-rw-r--r-- | desk/lib/nostrill/follows.hoon | 69 | ||||
-rw-r--r-- | desk/lib/shim.hoon | 10 | ||||
-rw-r--r-- | desk/sur/nostrill.hoon | 5 |
6 files changed, 132 insertions, 27 deletions
diff --git a/desk/app/nostrill.hoon b/desk/app/nostrill.hoon index cbd1c2f..611830f 100644 --- a/desk/app/nostrill.hoon +++ b/desk/app/nostrill.hoon @@ -1,7 +1,7 @@ /- sur=nostrill, nsur=nostr /+ lib=nostrill, nlib=nostr, sr=sortug, shim, dbug, muta=nostrill-mutations, jsonlib=json-nostrill, - trill=trill-post, comms=nostrill-comms, followlib=follows + trill=trill-post, comms=nostrill-comms, followlib=nostrill-follows /= web /web/router |% +$ versioned-state $%(state-0:sur) @@ -32,11 +32,11 @@ ++ on-load |~ old-state=vase ^- (quip card:agent:gall agent:gall) - :: =/ old-state !<(versioned-state old-state) - :: ?- -.old-state - :: %0 `this(state old-state) - :: == - `this(state (default-state:lib bowl)) + =/ old-state !<(versioned-state old-state) + ?- -.old-state + %0 `this(state old-state) + == + :: `this(state (default-state:lib bowl)) :: ++ on-poke |~ [=mark =vase] @@ -239,6 +239,11 @@ =/ =fact:ui:sur [%post %add *post-wrapper:sur] =/ card (update-ui:cards fact) :_ this :~(card) + %kick + :_ this =/ subs ~(tap by sup.bowl) + %+ turn subs |= [* p=@p pat=path] + [%give %kick ~[pat] ~] + == :: @@ -279,9 +284,22 @@ ++ on-agent |~ [wire=(pole knot) =sign:agent:gall] ^- (quip card:agent:gall agent:gall) - ~& on-agent=wire - ~& on-agent=sign - `this + ~& on-agent=[wire -.sign] + :: if p.sign is not ~ here that means it's intentional + ?+ wire `this + [%refollow ~] + ?. ?=(%watch-ack -.sign) `this + ?~ p.sign `this + =^ cs state (handle-kick-nack:fols src.bowl) [cs this] + [%follow ~] + ?: ?=(%kick -.sign) + =^ cs state (handle-refollow:fols src.bowl) + [cs this] + ?. ?=(%fact -.sign) `this + =^ cs state (handle-agent-res:fols q.q.cage.sign) + [cs this] + + == :: ++ on-arvo |~ [wire=(pole knot) =sign-arvo] diff --git a/desk/lib/json/nostrill.hoon b/desk/lib/json/nostrill.hoon index 2edf7f4..3c6f21b 100644 --- a/desk/lib/json/nostrill.hoon +++ b/desk/lib/json/nostrill.hoon @@ -49,7 +49,8 @@ %- pairs %+ turn ~(tap by m) |= [key=user:sur f=feed:feed] =/ jkey (user key) ?> ?=(%s -.jkey) - :- +.jkey (feed:en:trill f) + :: TODO proper cursor stuff + :- +.jkey (feed-with-cursor:en:trill f ~ ~) ++ engraph |= m=(map user:sur (set user:sur)) @@ -80,6 +81,18 @@ %nostr (en-nostr-feed +.f) %post (postfact +.f) %enga (enga +.f) + %fols (fols +.f) + == + ++ fols |= ff=fols-fact:ui:sur ^- json + %+ frond -.ff + ?- -.ff + %quit (user +.ff) + %new %: pairs + user+(user user.ff) + feed+(feed-with-cursor:en:trill fc.ff) + :- 'profile' ?~ meta.ff ~ (user-meta:en:nostr u.meta.ff) + ~ + == == ++ tedfact |= pf=post-fact:ui:sur ^- json %+ frond -.pf diff --git a/desk/lib/nostrill/comms.hoon b/desk/lib/nostrill/comms.hoon index 87a63b2..23e442a 100644 --- a/desk/lib/nostrill/comms.hoon +++ b/desk/lib/nostrill/comms.hoon @@ -38,7 +38,8 @@ =/ prof (~(get by profiles.state) [%urbit our.bowl]) (res-fact [%ok %feed fc prof] pat) -++ give-ted |= [id=@ pat=path] + +++ give-ted |= [id=@ pat=path] =/ ted (get:orm:feed feed.state id) ?~ ted (res-fact [%ng 'no such thread'] pat) @@ -70,15 +71,20 @@ =/ =poke:comms [%res res] =/ cage [%noun !>(poke)] [%pass /poke %agent [src.bowl dap.bowl] %poke cage] + ++ res-fact |= [=res:comms pat=path] ^- (list card:agent:gall) + =/ beg ?=([%beg *] pat) =/ paths ~[pat] - =/ =poke:comms [%res res] - ~& > giving-res-fact=res - =/ jon (beg-res:en:jsonlib res) - =/ cage [%json !>(jon)] - :~ - [%give %fact paths cage] - [%give %kick paths ~] - == + ~& > giving-res-fact=pat + ?: beg :: for the thread that goes directly to the frontend + =/ jon (beg-res:en:jsonlib res) + =/ cage [%json !>(jon)] + =/ c1 [%give %fact paths cage] + =/ c2 [%give %kick paths ~] + :~(c1 c2) + :: for the follow flow + =/ cage [%noun !>(res)] + =/ c1 [%give %fact paths cage] + :~(c1) -- diff --git a/desk/lib/nostrill/follows.hoon b/desk/lib/nostrill/follows.hoon index c2eb987..1cf8a66 100644 --- a/desk/lib/nostrill/follows.hoon +++ b/desk/lib/nostrill/follows.hoon @@ -1,12 +1,20 @@ /- sur=nostrill, nsur=nostr, comms=nostrill-comms, feed=trill-feed -/+ js=json-nostr, sr=sortug, nlib=nostr, constants, gatelib=trill-gate, feedlib=trill-feed, jsonlib=json-nostrill +/+ lib=nostrill, js=json-nostr, shim, sr=sortug, nlib=nostr, constants, gatelib=trill-gate, feedlib=trill-feed, jsonlib=json-nostrill |_ [=state:sur =bowl:gall] ++ handle-add |= =user:sur ^- (quip card:agent:gall _state) ?- -.user %urbit =/ c (urbit-watch +.user) :- :~(c) state - %nostr `state + %nostr =/ shimm ~(. shim [state bowl]) + :: TODO now or on receival? + =. following.state (~(put by following.state) user *feed:feed) + =/ graph (~(get by follow-graph.state) [%urbit our.bowl]) + =/ follows ?~ graph (silt ~[user]) (~(put in u.graph) user) + =. follow-graph.state (~(put by follow-graph.state) [%urbit our.bowl] follows) + + =^ cards state (get-user-feed:shimm +.user) + [cards state] == ++ handle-del |= =user:sur ^- (quip card:agent:gall _state) @@ -15,16 +23,61 @@ ?~ graph `state =/ nset (~(del in u.graph) user) =. follow-graph.state (~(put by follow-graph.state) [%urbit our.bowl] nset) - `state -++ handle-follow-ok |= [=user:sur =feed:feed profile=(unit user-meta:nsur)] + :_ state + =/ =fact:ui:sur [%fols %quit user] + =/ c1 (update-ui:cards:lib fact) + ?. ?=(%urbit -.user) :~(c1) + ~& >> leaving=user + =/ c2 (urbit-leave +.user) + :~(c1 c2) + +++ handle-agent-res |= raw=* + ~& "handling-agent-res" + =/ =res:comms ;; res:comms raw + ~& res=-.res + ?- -.res + %ng :: bruh + `state + %ok + ?- -.p.res + %feed (handle-follow-ok [%urbit src.bowl] fc.+.p.res profile.+.p.res) + %thread `state + == + == +++ handle-refollow |= sip=@p + :_ state :_ ~ + :: (urbit-watch sip) + [%pass /refollow %agent [sip dap.bowl] %watch /followre] + +++ handle-follow-ok |= [=user:sur =fc:feed profile=(unit user-meta:nsur)] + ^- (quip card:agent:gall _state) + =. following.state (~(put by following.state) user feed.fc) + =/ graph (~(get by follow-graph.state) [%urbit our.bowl]) + =/ follows ?~ graph (silt ~[user]) (~(put in u.graph) user) + =. follow-graph.state (~(put by follow-graph.state) [%urbit our.bowl] follows) + =. profiles.state ?~ profile profiles.state (~(put by profiles.state) user u.profile) + :_ state + =/ =fact:ui:sur [%fols %new [%urbit src.bowl] fc profile] + =/ c (update-ui:cards:lib fact) :~(c) + + +++ handle-kick-nack |= p=@p ^- (quip card:agent:gall _state) - =. following (~(put by following) user feed) - =. profiles ?~ profile profiles (~(put by profiles) user u.profile) - `state + =. following.state (~(del by following.state) [%urbit p]) + =/ graph (~(get by follow-graph.state) [%urbit our.bowl]) + ?~ graph `state + =/ ngraph (~(del in u.graph) [%urbit p]) + =. follow-graph.state (~(put by follow-graph.state) [%urbit our.bowl] ngraph) + :_ state + =/ =fact:ui:sur [%fols %quit %urbit src.bowl] + =/ c (update-ui:cards:lib fact) :~(c) +++ urbit-leave |= sip=@p ^- card:agent:gall + [%pass /follow %agent [sip dap.bowl] %leave ~] + ++ urbit-watch |= sip=@p ^- card:agent:gall - [%pass /watch %agent [sip dap.bowl] %watch /follow] + [%pass /follow %agent [sip dap.bowl] %watch /follow] :: ++ res-fact |= =res:comms ^- (list card:agent:gall) :: =/ paths ~[/beg/feed] diff --git a/desk/lib/shim.hoon b/desk/lib/shim.hoon index 1b78f0a..d9a5e6e 100644 --- a/desk/lib/shim.hoon +++ b/desk/lib/shim.hoon @@ -42,6 +42,16 @@ =^ req=bulk-req:shim:nsur state (get-req ~[filter]) :- :~((send req)) state +++ get-user-feed + |= pubkey=@ux + ^- (quip card _state) + =/ kinds (silt ~[1]) + :: =/ since (to-unix-secs:jikan:sr last-week) + =/ pubkeys (silt ~[pubkey]) + =/ =filter:nsur [~ `pubkeys `kinds ~ ~ ~ ~] + =^ req=bulk-req:shim:nsur state (get-req ~[filter]) + :- :~((send req)) state + ++ get-profiles |= pubkeys=(set @ux) ^- (quip card _state) diff --git a/desk/sur/nostrill.hoon b/desk/sur/nostrill.hoon index a091dd0..b443ca8 100644 --- a/desk/sur/nostrill.hoon +++ b/desk/sur/nostrill.hoon @@ -73,10 +73,15 @@ $: pub=(unit @ux) $% [%nostr feed=nostr-feed] [%post post-fact] [%enga p=post-wrapper reaction=*] + [%fols fols-fact] == +$ post-fact $% [%add post-wrapper] [%del post-wrapper] == + +$ fols-fact + $% [%new =user =fc:trill meta=(unit user-meta:nostr)] + [%quit =user] + == -- -- |