diff options
Diffstat (limited to 'desk/lib')
-rw-r--r-- | desk/lib/json/nostrill.hoon | 70 | ||||
-rw-r--r-- | desk/lib/nostrill/comms.hoon | 41 | ||||
-rw-r--r-- | desk/lib/nostrill/follows.hoon | 40 | ||||
-rw-r--r-- | desk/lib/nostrill/mutations.hoon | 4 |
4 files changed, 103 insertions, 52 deletions
diff --git a/desk/lib/json/nostrill.hoon b/desk/lib/json/nostrill.hoon index b5a619c..2edf7f4 100644 --- a/desk/lib/json/nostrill.hoon +++ b/desk/lib/json/nostrill.hoon @@ -36,35 +36,42 @@ :: TODO do we even need this :- sub-id (numb received.es) - ++ en-profiles |= m=(map @ux user-meta:nsur) + ++ en-profiles |= m=(map user:sur user-meta:nsur) %- pairs - %+ turn ~(tap by m) |= [key=@ux p=user-meta:nsur] - =/ jkey (hex:en:common key) + %+ turn ~(tap by m) |= [key=user:sur p=user-meta:nsur] + =/ jkey (user key) ?> ?=(%s -.jkey) :- +.jkey (user-meta:en:nostr p) ++ enfollowing - |= m=(map @ux feed:feed) + |= m=(map user:sur feed:feed) ^- json - %- pairs %+ turn ~(tap by m) |= [key=@ux f=feed:feed] - =/ jkey (hex:en:common key) + %- pairs %+ turn ~(tap by m) |= [key=user:sur f=feed:feed] + =/ jkey (user key) ?> ?=(%s -.jkey) :- +.jkey (feed:en:trill f) ++ engraph - |= m=(map @ux (set follow:sur)) + |= m=(map user:sur (set user:sur)) ^- json - %- pairs %+ turn ~(tap by m) |= [key=@ux s=(set follow:sur)] - =/ jkey (hex:en:common key) + %- pairs %+ turn ~(tap by m) |= [key=user:sur s=(set user:sur)] + =/ jkey (user 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 - == + :- %a %+ turn ~(tap in s) user + ++ follow + |= f=follow:sur + %- pairs + :~ pubkey+(hex:en:common pubkey.f) + name+s+name.f + :- %relay ?~ relay.f ~ s+u.relay.f + == + ++ user |= u=user:sur ^- json + ?- -.u + %urbit (patp:en:common +.u) + %nostr (hex:en:common +.u) + == :: ui facts ++ fact |= f=fact:ui:sur ^- json %+ frond %fact @@ -105,17 +112,27 @@ %ng [%s msg.res] == ++ resd |= rd=res-data:comms ^- json - %+ frond -.rd ?- -.rd - %feed (feed-with-cursor:en:trill +.rd) + %feed (user-data +.rd) :: TODO wrap it for nostr shit - %thread (full-node:en:trill +.rd) - %prof (user-meta:en:nostr +.rd) + %thread (frond -.rd (full-node:en:trill +.rd)) + == + ++ user-data + |= ud=[=fc:feed profile=(unit user-meta:nsur)] + %: pairs + feed+(feed-with-cursor:en:trill fc.ud) + :- %profile ?~ profile.ud ~ (user-meta:en:nostr u.profile.ud) + ~ == -- ++ de =, dejs-soft:format |% +++ user + %- of :~ + urbit+(se:de:common %p) + nostr+hex:de:common + == :: ui ++ ui %- of :~ @@ -128,8 +145,8 @@ == ++ ui-fols %- of :~ - add+hex:de:common - del+hex:de:common + add+user + del+user == ++ ui-begs %- of :~ @@ -143,9 +160,18 @@ == ++ ui-prof %- of :~ - add+user-meta:de:nostr + add+ui-meta del+ul == +++ ui-meta + %- ot :~ + name+so + about+so + picture+so + other+other-meta + == +++ other-meta |= jon=json + ?. ?=(%o -.jon) ~ (some p.jon) ++ ui-post %- of :~ add+de-post diff --git a/desk/lib/nostrill/comms.hoon b/desk/lib/nostrill/comms.hoon index 833c07d..87a63b2 100644 --- a/desk/lib/nostrill/comms.hoon +++ b/desk/lib/nostrill/comms.hoon @@ -9,7 +9,6 @@ ?- -.req %feed handle-feed %thread (handle-thread +.req) - %prof handle-prof == ++ handle-feed =/ can (can-access:gatelib src.bowl lock.feed-perms.state bowl) @@ -21,49 +20,35 @@ =/ lp latest-page:feedlib =/ lp2 lp(count backlog.feed-perms.state) =/ =fc:feed (lp2 feed.state) - =/ crd (res-poke [%ok %feed fc]) + =/ prof (~(get by profiles.state) [%urbit our.bowl]) + =/ crd (res-poke [%ok %feed fc prof]) :_ state :~(crd) -++ give-feed +++ give-feed + |= pat=path ~& give-feed=src.bowl =/ can (can-access:gatelib src.bowl lock.feed-perms.state bowl) ?. can :: TODO keep track of the requests at the feed-perms struct - (res-fact [%ng 'not allowed']) + (res-fact [%ng 'not allowed'] pat) :: =/ lp latest-page:feedlib =/ lp2 lp(count backlog.feed-perms.state) =/ =fc:feed (lp2 feed.state) - (res-fact [%ok %feed fc]) + =/ prof (~(get by profiles.state) [%urbit our.bowl]) + (res-fact [%ok %feed fc prof] pat) -++ give-ted |= id=@ +++ give-ted |= [id=@ pat=path] =/ ted (get:orm:feed feed.state id) ?~ ted - (res-fact [%ng 'no such thread']) + (res-fact [%ng 'no such thread'] pat) =/ can (can-access:gatelib src.bowl read.u.ted bowl) ?. can - (res-fact [%ng 'not allowed']) + (res-fact [%ng 'not allowed'] pat) :: =/ fn (node-to-full:feedlib u.ted feed.state) - (res-fact [%ok %thread fn]) + (res-fact [%ok %thread fn] pat) :: -++ handle-prof - =/ can (can-access:gatelib src.bowl lock.feed-perms.state bowl) - ?. can - :: TODO keep track of the requests at the feed-perms struct - =/ crd (res-poke [%ng 'not allowed']) - :_ state :~(crd) - :: - :: TODO @p or keys... wat do - :: =/ up (~(get by profiles.state) our.bowl) - =/ up (~(get by profiles.state) pub.i.keys.state) - ?~ up - =/ crd (res-poke [%ng 'dont have one']) - :_ state :~(crd) - - =/ crd (res-poke [%ok %prof u.up]) - :_ state :~(crd) - ++ handle-thread |= id=@da =/ ted (get:orm:feed feed.state id) ?~ ted @@ -85,8 +70,8 @@ =/ =poke:comms [%res res] =/ cage [%noun !>(poke)] [%pass /poke %agent [src.bowl dap.bowl] %poke cage] -++ res-fact |= =res:comms ^- (list card:agent:gall) - =/ paths ~[/beg/feed] +++ res-fact |= [=res:comms pat=path] ^- (list card:agent:gall) + =/ paths ~[pat] =/ =poke:comms [%res res] ~& > giving-res-fact=res =/ jon (beg-res:en:jsonlib res) diff --git a/desk/lib/nostrill/follows.hoon b/desk/lib/nostrill/follows.hoon new file mode 100644 index 0000000..c2eb987 --- /dev/null +++ b/desk/lib/nostrill/follows.hoon @@ -0,0 +1,40 @@ +/- 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 +|_ [=state:sur =bowl:gall] +++ handle-add |= =user:sur + ^- (quip card:agent:gall _state) + ?- -.user + %urbit =/ c (urbit-watch +.user) + :- :~(c) state + %nostr `state + == +++ handle-del |= =user:sur + ^- (quip card:agent:gall _state) + =. following.state (~(del by following.state) user) + =/ graph (~(get by follow-graph.state) [%urbit our.bowl]) + ?~ 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)] + ^- (quip card:agent:gall _state) + =. following (~(put by following) user feed) + =. profiles ?~ profile profiles (~(put by profiles) user u.profile) + `state + + +++ urbit-watch |= sip=@p ^- card:agent:gall + [%pass /watch %agent [sip dap.bowl] %watch /follow] + +:: ++ res-fact |= =res:comms ^- (list card:agent:gall) +:: =/ paths ~[/beg/feed] +:: =/ =poke:comms [%res res] +:: ~& > giving-res-fact=res +:: =/ jon (beg-res:en:jsonlib res) +:: =/ cage [%json !>(jon)] +:: :~ +:: [%give %fact paths cage] +:: [%give %kick paths ~] +:: == + +-- diff --git a/desk/lib/nostrill/mutations.hoon b/desk/lib/nostrill/mutations.hoon index f493bcf..8fca2b2 100644 --- a/desk/lib/nostrill/mutations.hoon +++ b/desk/lib/nostrill/mutations.hoon @@ -181,7 +181,7 @@ ?~ ujon ~& failed-parse-metadata=ujon `state =/ umeta (user-meta:de:njs u.ujon) ?~ umeta ~& >> failed-dejs-metadata=ujon `state - =. profiles.state (~(put by profiles.state) pubkey.event u.umeta) + =. profiles.state (~(put by profiles.state) [%nostr pubkey.event] u.umeta) `state @@ -224,7 +224,7 @@ `state ++ parse-follow ^- (quip card _state) - =/ following (~(get by follow-graph.state) pubkey.event) + =/ following (~(get by follow-graph.state) [%nostr pubkey.event]) =/ follow-set ?~ following *(set follow:sur) u.following |- ?~ tags.event `state =/ t=tag:nsur i.tags.event |