diff options
Diffstat (limited to 'desk/lib')
-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 |
4 files changed, 100 insertions, 18 deletions
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) |