summaryrefslogtreecommitdiff
path: root/desk/lib
diff options
context:
space:
mode:
Diffstat (limited to 'desk/lib')
-rw-r--r--desk/lib/mutations/nostr.hoon (renamed from desk/lib/nostrill/mutations.hoon)31
-rw-r--r--desk/lib/mutations/trill.hoon78
-rw-r--r--desk/lib/nostr/events.hoon49
-rw-r--r--desk/lib/nostr/keys.hoon (renamed from desk/lib/nostr.hoon)0
-rw-r--r--desk/lib/nostrill.hoon54
-rw-r--r--desk/lib/nostrill/comms.hoon4
-rw-r--r--desk/lib/nostrill/follows.hoon7
-rw-r--r--desk/lib/scri.hoon9
-rw-r--r--desk/lib/shim.hoon6
9 files changed, 162 insertions, 76 deletions
diff --git a/desk/lib/nostrill/mutations.hoon b/desk/lib/mutations/nostr.hoon
index 8fca2b2..2c6acd5 100644
--- a/desk/lib/nostrill/mutations.hoon
+++ b/desk/lib/mutations/nostr.hoon
@@ -1,4 +1,4 @@
-/- sur=nostrill, nsur=nostr,
+/- sur=nostrill, nsur=nostr, comms=nostrill-comms,
post=trill-post, gate=trill-gate, feed=trill-feed
/+ appjs=json-nostrill,
@@ -10,24 +10,6 @@
|_ [=state:sur =bowl:gall]
+$ card card:agent:gall
-++ debug-own-feed
- =/ postlist (tap:orm:feed feed.state)
- =/ lol
- |- ?~ postlist ~
- ~& >> poast=+.i.postlist
- $(postlist t.postlist)
- ~
-:: TODO not a mutation but fuck it
-++ get-poast |= [host=@p id=@] ^- (unit post:post)
- =/ poast ?: .=(host our.bowl)
- (get:orm:feed feed.state id)
- ~
- poast
-
-:: state
-++ add-to-feed |= p=post:post
- =. feed.state (put:orm:feed feed.state id.p p)
- state
:: events
++ process-events ^- (quip card _state)
:: =/ l events.state
@@ -247,4 +229,15 @@
=. relays.state (~(put by relays.state) relay u.rs)
`state
--
+
+++ handle-prof-fact |= pf=prof-fact:comms
+ ^- (quip card _state)
+ =/ =user:sur [%urbit src.bowl]
+ ?- -.pf
+ %prof =. profiles.state (~(put by profiles.state) user +.pf)
+ :: TODO kinda wanna send it to the UI
+ `state
+ %keys `state
+ :: TODO really need a way to keep track of everyone's pubkeys
+ ==
--
diff --git a/desk/lib/mutations/trill.hoon b/desk/lib/mutations/trill.hoon
new file mode 100644
index 0000000..ea6dadf
--- /dev/null
+++ b/desk/lib/mutations/trill.hoon
@@ -0,0 +1,78 @@
+/- sur=nostrill, nsur=nostr, comms=nostrill-comms,
+ post=trill-post, gate=trill-gate, feed=trill-feed
+
+/+ appjs=json-nostrill,
+ lib=nostrill,
+ trill=trill-post,
+ njs=json-nostr,
+ postlib=trill-post,
+ shim,
+ sr=sortug
+
+|_ [=state:sur =bowl:gall]
++$ card card:agent:gall
+++ debug-own-feed
+ =/ postlist (tap:orm:feed feed.state)
+ =/ lol
+ |- ?~ postlist ~
+ ~& >> poast=+.i.postlist
+ $(postlist t.postlist)
+ ~
+
+:: state
+++ add-to-feed |= p=post:post
+ =. feed.state (put:orm:feed feed.state id.p p)
+ state
+
+++ handle-post |= poke=post-poke:ui:sur
+ ^- (quip card _state)
+ =/ profile (~(get by profiles.state) [%urbit our.bowl])
+ =/ pubkey pub.i.keys.state
+ =/ p=post:post
+ ?- -.poke
+ %add
+ =/ sp (build-sp:trill our.bowl our.bowl content.poke ~ ~)
+ (build-post:trill now.bowl pubkey sp)
+ %quote
+ =/ sp (build-sp:trill our.bowl our.bowl content.poke ~ ~)
+ =/ quote [%ref %trill host.poke /(crip (scow:sr %ud id.poke))]
+ =. contents.sp (snoc contents.sp quote)
+ (build-post:trill now.bowl pubkey sp)
+ %reply
+ =/ sp (build-sp:trill host.poke our.bowl content.poke `id.poke `thread.poke)
+ (build-post:trill now.bowl pubkey sp)
+ %rp
+ =/ quote [%ref %trill host.poke /(crip (scow:sr %ud id.poke))]
+ =/ sp (build-sp:trill host.poke our.bowl '' ~ ~)
+ =. contents.sp ~[quote]
+ (build-post:trill now.bowl pubkey sp)
+ ==
+ =/ pw [p (some pubkey) ~ ~ profile]
+ =/ jfact=fact:ui:sur [%post %add pw]
+ =/ ui-card (update-ui:cards:lib jfact)
+ :: only update followers when we are updating our own feed
+ ?. .=(our.bowl host.p) [~[ui-card] state]
+ =. state (add-to-feed p)
+ =/ =fact:comms [%post %add p]
+ =/ fact-card (update-followers:cards:lib fact)
+ :_ state
+ :~ ui-card
+ fact-card
+ ==
+
+
+++ handle-post-fact |= pf=post-fact:comms
+ ^- (quip card _state)
+ =/ =user:sur [%urbit src.bowl]
+ =/ fed (~(get by following.state) user)
+ ?~ fed ~& "emmm not following ya" `state
+ =/ nf=feed:feed
+ ?: ?=(%del -.pf)
+ =< + (del:orm:feed u.fed id.pf)
+ ::mmm people aren't supposed to update if its not their own feeds
+ :: =/ =user:nsur [%urbit host.p.pdf]
+ (put:orm:feed u.fed id.p.pf p.pf)
+ =. following.state (~(put by following.state) user nf)
+ :: TODO update the ui with the changes
+ :_ state ~
+--
diff --git a/desk/lib/nostr/events.hoon b/desk/lib/nostr/events.hoon
new file mode 100644
index 0000000..2a3e818
--- /dev/null
+++ b/desk/lib/nostr/events.hoon
@@ -0,0 +1,49 @@
+/- sur=nostrill, nsur=nostr, post=trill-post, gate=trill-gate
+/+ js=json-nostr, sr=sortug, trill=trill-post, nostr-keys
+|%
+++ post-to-event |= [=keys:nsur eny=@ p=post:post] ^- event:nsur
+ =/ cl (latest-post-content:trill contents.p)
+ =/ string (crip (content-list-to-md:trill cl))
+ =/ ts (to-unix-secs:jikan:sr id.p)
+ =/ raw=raw-event:nsur [pub.keys ts 1 ~ string]
+ =/ event-id (hash-event:nostr-keys raw)
+ =/ signature (sign-event:nostr-keys priv.keys event-id eny)
+ ~& hash-and-signed=[event-id signature]
+ =/ =event:nsur :*
+ event-id
+ pub.keys
+ created-at.raw
+ kind.raw
+ tags.raw
+ content.raw
+ signature
+ ==
+ event
+
+++ event-to-post
+ |= [=event:nsur profile=(unit user-meta:nsur) relay=(unit @t)]
+ ^- post-wrapper:sur
+
+ =/ cl (tokenize:trill content.event)
+ =/ ts (from-unix:jikan:sr created-at.event)
+ =/ cm=content-map:post (init-content-map:trill cl ts)
+
+ :: TODO more about @ps and stuff
+ =/ p=post:post :*
+ id=ts
+ host=`@p`pubkey.event
+ author=`@p`pubkey.event
+ thread=ts
+ parent=~
+ children=~
+ contents=cm
+ read=*lock:gate
+ write=*lock:gate
+ *engagement:post
+ 0v0
+ *signature:post
+ tags=~
+ ==
+ =/ meta [(some pubkey.event) (some id.event) relay profile]
+ [p meta]
+--
diff --git a/desk/lib/nostr.hoon b/desk/lib/nostr/keys.hoon
index 90eb563..90eb563 100644
--- a/desk/lib/nostr.hoon
+++ b/desk/lib/nostr/keys.hoon
diff --git a/desk/lib/nostrill.hoon b/desk/lib/nostrill.hoon
index 6d22adc..41caff2 100644
--- a/desk/lib/nostrill.hoon
+++ b/desk/lib/nostrill.hoon
@@ -1,5 +1,5 @@
-/- post=trill-post, nsur=nostr, sur=nostrill, gate=trill-gate
-/+ trill=trill-post, nostr, sr=sortug, jsonlib=json-nostrill
+/- post=trill-post, nsur=nostr, sur=nostrill, gate=trill-gate, comms=nostrill-comms
+/+ trill=trill-post, nostr-keys, sr=sortug, jsonlib=json-nostrill
|%
::
++ default-state |= =bowl:gall ^- state:sur
@@ -9,7 +9,7 @@
:: =/ l ~['wss://relay.damus.io' 'wss://nos.lol']
=/ rl %+ turn l |= t=@t [t *relay-stats:nsur]
:: =/ l ~[['wss://relay.damus.io' ~]]
- =/ key (gen-keys:nostr eny.bowl)
+ =/ key (gen-keys:nostr-keys eny.bowl)
=/ keyl [key ~]
s(relays (malt rl), keys keyl)
@@ -29,51 +29,6 @@
$(l t.l)
::
-++ post-to-event |= [=keys:nsur eny=@ p=post:post] ^- event:nsur
- =/ cl (latest-post-content:trill contents.p)
- =/ string (crip (content-list-to-md:trill cl))
- =/ ts (to-unix-secs:jikan:sr id.p)
- =/ raw=raw-event:nsur [pub.keys ts 1 ~ string]
- =/ event-id (hash-event:nostr raw)
- =/ signature (sign-event:nostr priv.keys event-id eny)
- ~& hash-and-signed=[event-id signature]
- =/ =event:nsur :*
- event-id
- pub.keys
- created-at.raw
- kind.raw
- tags.raw
- content.raw
- signature
- ==
- event
-
-++ event-to-post
- |= [=event:nsur profile=(unit user-meta:nsur) relay=(unit @t)]
- ^- post-wrapper:sur
-
- =/ cl (tokenize:trill content.event)
- =/ ts (from-unix:jikan:sr created-at.event)
- =/ cm=content-map:post (init-content-map:trill cl ts)
-
- :: TODO more about @ps and stuff
- =/ p=post:post :*
- id=ts
- host=`@p`pubkey.event
- author=`@p`pubkey.event
- thread=ts
- parent=~
- children=~
- contents=cm
- read=*lock:gate
- write=*lock:gate
- *engagement:post
- 0v0
- *signature:post
- tags=~
- ==
- =/ meta [(some pubkey.event) (some id.event) relay profile]
- [p meta]
++ cards
|_ =bowl:gall
@@ -82,5 +37,8 @@
++ update-ui |= =fact:ui:sur ^- card:agent:gall
=/ jon (fact:en:jsonlib fact)
[%give %fact ~[/ui] %json !>(jon)]
+ :: ++ update-followers |= =fact:comms ^- card:agent:gall
+ ++ update-followers |= =fact:comms ^- card:agent:gall
+ [%give %fact ~[/follow] %noun !>(fact)]
--
--
diff --git a/desk/lib/nostrill/comms.hoon b/desk/lib/nostrill/comms.hoon
index 23e442a..5ae07a0 100644
--- a/desk/lib/nostrill/comms.hoon
+++ b/desk/lib/nostrill/comms.hoon
@@ -83,8 +83,10 @@
=/ c2 [%give %kick paths ~]
:~(c1 c2)
:: for the follow flow
- =/ cage [%noun !>(res)]
+ =/ cage [%noun !>([%init res])]
=/ c1 [%give %fact paths cage]
:~(c1)
+
+
--
diff --git a/desk/lib/nostrill/follows.hoon b/desk/lib/nostrill/follows.hoon
index 1cf8a66..9cda041 100644
--- a/desk/lib/nostrill/follows.hoon
+++ b/desk/lib/nostrill/follows.hoon
@@ -31,10 +31,7 @@
=/ c2 (urbit-leave +.user)
:~(c1 c2)
-++ handle-agent-res |= raw=*
- ~& "handling-agent-res"
- =/ =res:comms ;; res:comms raw
- ~& res=-.res
+++ handle-follow-res |= =res:comms
?- -.res
%ng :: bruh
`state
@@ -47,7 +44,7 @@
++ handle-refollow |= sip=@p
:_ state :_ ~
:: (urbit-watch sip)
- [%pass /refollow %agent [sip dap.bowl] %watch /followre]
+ [%pass /follow %agent [sip dap.bowl] %watch /follow]
++ handle-follow-ok |= [=user:sur =fc:feed profile=(unit user-meta:nsur)]
^- (quip card:agent:gall _state)
diff --git a/desk/lib/scri.hoon b/desk/lib/scri.hoon
index b590624..e76d79a 100644
--- a/desk/lib/scri.hoon
+++ b/desk/lib/scri.hoon
@@ -12,6 +12,15 @@
|_ [=state:sur =bowl:gall]
+$ card card:agent:gall
+
+++ get-poast |= [host=@p id=@] ^- (unit post:post)
+ =/ poast ?: .=(host our.bowl)
+ (get:orm:feed feed.state id)
+ ~
+ poast
+
+
+
++ thread |= [hs=@t ids=@t]
^- (unit (unit cage)) :- ~ :- ~ :- %json !>
%- beg-res:en:appjs
diff --git a/desk/lib/shim.hoon b/desk/lib/shim.hoon
index d9a5e6e..af2d142 100644
--- a/desk/lib/shim.hoon
+++ b/desk/lib/shim.hoon
@@ -1,5 +1,5 @@
/- sur=nostrill, nsur=nostr
-/+ js=json-nostr, sr=sortug, nlib=nostr, constants
+/+ js=json-nostr, sr=sortug, nostr-keys, constants
/= web /web/router
|_ [=state:sur =bowl:gall]
@@ -21,7 +21,7 @@
^- [bulk-req:shim:nsur _state]
=/ rls ~(tap by relays.state)
=| urls=(list @t)
- =/ sub-id (gen-sub-id:nlib eny.bowl)
+ =/ sub-id (gen-sub-id:nostr-keys eny.bowl)
=/ =req:shim:nsur [%req sub-id fs]
|- ?~ rls [[urls req] state]
:: build http card
@@ -120,7 +120,7 @@
:: TODO make a function to use most reliable
=/ relay (head ~(tap in relays))
~& http=relay
- =/ sub-id (gen-sub-id:nlib eny.bowl)
+ =/ sub-id (gen-sub-id:nostr-keys eny.bowl)
=/ kinds (silt ~[0])
=/ total=filter:nsur [~ `pubkeys `kinds ~ ~ ~ ~]
=/ req=http-req:shim:nsur [relay http-delay:constants sub-id ~[total]]