diff options
Diffstat (limited to 'desk/lib/nostrill')
-rw-r--r-- | desk/lib/nostrill/comms.hoon | 24 | ||||
-rw-r--r-- | desk/lib/nostrill/follows.hoon | 69 |
2 files changed, 76 insertions, 17 deletions
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] |