summaryrefslogtreecommitdiff
path: root/desk
diff options
context:
space:
mode:
authorpolwex <polwex@sortug.com>2025-09-18 00:24:39 +0700
committerpolwex <polwex@sortug.com>2025-09-18 00:24:39 +0700
commit4b016c908dda2019f3bf89e5a3d2eae535e5fbd2 (patch)
tree639613aa8bcc3d36b5165a32ece4a421dabde4c8 /desk
parent985fa2f7c99832cdf3c3351d2273c8fd05402b78 (diff)
oioi
Diffstat (limited to 'desk')
-rw-r--r--desk/app/nostrill.hoon40
-rw-r--r--desk/lib/json/nostrill.hoon70
-rw-r--r--desk/lib/nostrill/comms.hoon41
-rw-r--r--desk/lib/nostrill/follows.hoon40
-rw-r--r--desk/lib/nostrill/mutations.hoon4
-rw-r--r--desk/sur/nostrill.hoon11
-rw-r--r--desk/sur/nostrill/comms.hoon4
7 files changed, 134 insertions, 76 deletions
diff --git a/desk/app/nostrill.hoon b/desk/app/nostrill.hoon
index 17732e7..cbd1c2f 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
+ trill=trill-post, comms=nostrill-comms, followlib=follows
/= web /web/router
|%
+$ versioned-state $%(state-0:sur)
@@ -17,6 +17,7 @@
mutat ~(. muta [state bowl])
shimm ~(. shim [state bowl])
coms ~(. comms [state bowl])
+ fols ~(. followlib [state bowl])
++ on-init
^- (quip card:agent:gall agent:gall)
=/ default (default-state:lib bowl)
@@ -31,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]
@@ -97,7 +98,7 @@
=/ 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)
- =/ profile (~(get by profiles) pub.i.keys)
+ =/ profile (~(get by profiles) [%urbit our.bowl])
=/ pw [p (some pub.i.keys) ~ ~ profile]
=/ =fact:ui:sur [%post %add pw]
=/ card (update-ui:cards fact)
@@ -116,17 +117,21 @@
[cs this]
==
++ handle-fols |= poke=fols-poke:ui:sur
- ?- -.poke
- %add `this
- %del `this
- ==
+ =^ cs state
+ ?- -.poke
+ %add (handle-add:fols +.poke)
+
+ %del (handle-del:fols +.poke)
+ ==
+ [cs this]
+
++ handle-prof |= poke=prof-poke:ui:sur
?- -.poke
%add
- =. profiles (~(put by profiles) pub.i.keys +.poke)
+ =. profiles (~(put by profiles) [%urbit our.bowl] +.poke)
`this
%del
- =. profiles (~(del by profiles) pub.i.keys)
+ =. profiles (~(del by profiles) [%urbit our.bowl])
`this
==
++ handle-rela |= poke=relay-poke:ui:sur
@@ -243,12 +248,13 @@
|= =(pole knot)
~& on-watch=`path`pole
?+ pole !!
+ [%follow ~] :_ this (give-feed:coms pole)
[%beg %feed ~]
- :_ this give-feed:coms
+ :_ this (give-feed:coms pole)
[%beg %thread ids=@t ~]
=/ id (slaw:sr %uw ids.pole)
?~ id ~& error-parsing-ted-id=pole `this
- :_ this (give-ted:coms u.id)
+ :_ this (give-ted:coms u.id pole)
[%ui ~]
?> .=(our.bowl src.bowl)
:_ this
@@ -271,8 +277,10 @@
==
::
++ on-agent
- |~ [wire sign:agent:gall]
+ |~ [wire=(pole knot) =sign:agent:gall]
^- (quip card:agent:gall agent:gall)
+ ~& on-agent=wire
+ ~& on-agent=sign
`this
::
++ on-arvo
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
diff --git a/desk/sur/nostrill.hoon b/desk/sur/nostrill.hoon
index 70ce480..a091dd0 100644
--- a/desk/sur/nostrill.hoon
+++ b/desk/sur/nostrill.hoon
@@ -12,9 +12,9 @@
:: nostr feed from relays
=nostr-feed
:: profiles
- profiles=(map @ux user-meta:nostr)
- following=(map @ux =feed:trill)
- follow-graph=(map @ux (set follow))
+ profiles=(map user user-meta:nostr)
+ following=(map user =feed:trill)
+ follow-graph=(map user (set user))
:: TODO global feed somehow?
==
@@ -29,6 +29,7 @@ $: pub=(unit @ux)
relay=(unit @t)
pr=(unit user-meta:nostr)
==
++$ user $%([%urbit p=@p] [%nostr p=@ux])
+$ follow [pubkey=@ux name=@t relay=(unit @t)]
++ ui
@@ -52,8 +53,8 @@ $: pub=(unit @ux)
[%del pubkey=@ux]
==
+$ fols-poke
- $% [%add pubkey=@ux]
- [%del pubkey=@ux]
+ $% [%add =user]
+ [%del =user]
==
+$ prof-poke
$% [%add meta=user-meta:nostr]
diff --git a/desk/sur/nostrill/comms.hoon b/desk/sur/nostrill/comms.hoon
index d3dc8e1..4930235 100644
--- a/desk/sur/nostrill/comms.hoon
+++ b/desk/sur/nostrill/comms.hoon
@@ -8,15 +8,13 @@
+$ req
$% [%feed ~]
[%thread id=@da]
- [%prof ~]
==
+$ res
$% [%ok p=res-data]
[%ng msg=@t]
==
+$ res-data
- $% [%feed =fc:feed]
+ $% [%feed =fc:feed profile=(unit user-meta:nsur)]
[%thread p=full-node:post]
- [%prof p=user-meta:nsur]
==
--