summaryrefslogtreecommitdiff
path: root/desk/lib/json
diff options
context:
space:
mode:
Diffstat (limited to 'desk/lib/json')
-rw-r--r--desk/lib/json/nostr.hoon16
-rw-r--r--desk/lib/json/nostrill.hoon53
2 files changed, 52 insertions, 17 deletions
diff --git a/desk/lib/json/nostr.hoon b/desk/lib/json/nostr.hoon
index 9c36eb0..6f93c1c 100644
--- a/desk/lib/json/nostr.hoon
+++ b/desk/lib/json/nostr.hoon
@@ -38,9 +38,11 @@
::
++ raw-event |= raw-event:sur
:: WTF nostr doesn't want the prefix on the pubkey
- =/ pubkeyt (scow:sr %ux pubkey)
+ =/ scw scow:sr
+ =/ pubkeyt (scw(min-chars 64) %ux pubkey)
?~ pubkeyt !!
- =/ pubkeyj [%s (crip t.pubkeyt)]
+ :: =/ pubkeyj [%s (crip t.pubkeyt)]
+ =/ pubkeyj [%s (crip pubkeyt)]
:- %a :~
[%n '0']
pubkeyj
@@ -51,13 +53,13 @@
==
++ event
|= e=event:sur ^- json
- =/ pubkeyt (scow:sr %ux pubkey.e)
- ?~ pubkeyt !!
- =/ pubkeyj [%s (crip t.pubkeyt)]
+ :: =/ pubkeyt (scow:sr %ux pubkey.e)
+ :: ?~ pubkeyt !!
+ :: =/ pubkeyj [%s (crip t.pubkeyt)]
%: pairs
id+(hex:en:common id.e)
- :: pubkey+(hex:en:common pubkey.e)
- pubkey+pubkeyj
+ pubkey+(hex:en:common pubkey.e)
+ :: pubkey+pubkeyj
sig+(hex:en:common sig.e)
['created_at' (numb created-at.e)]
kind+(numb kind.e)
diff --git a/desk/lib/json/nostrill.hoon b/desk/lib/json/nostrill.hoon
index 43f7708..bd34acc 100644
--- a/desk/lib/json/nostrill.hoon
+++ b/desk/lib/json/nostrill.hoon
@@ -6,6 +6,7 @@
|%
:: UI comms
++ state |= state-0:sur ^- json
+ %+ frond %state
%: pairs
relays+(en-relays relays)
key+(hex:en:common pub.i.keys)
@@ -38,27 +39,60 @@
++ en-profiles |= m=(map @ux user-meta:nsur)
%- pairs
%+ turn ~(tap by m) |= [key=@ux p=user-meta:nsur]
- :- (crip (scow:sr %ux key)) (user-meta:en:nostr p)
+ =/ jkey (hex:en:common key)
+ ?> ?=(%s -.jkey)
+ :- +.jkey (user-meta:en:nostr p)
++ enfollowing
|= m=(map @ux feed:feed)
^- json
%- pairs %+ turn ~(tap by m) |= [key=@ux f=feed:feed]
- :- (crip (scow:sr %ux key)) (feed:en:trill f)
+ =/ jkey (hex:en:common key)
+ ?> ?=(%s -.jkey)
+ :- +.jkey (feed:en:trill f)
++ engraph
|= m=(map @ux (set follow:sur))
^- json
%- pairs %+ turn ~(tap by m) |= [key=@ux s=(set follow:sur)]
- :- (crip (scow:sr %ux key))
- :- %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
- ==
+ =/ jkey (hex:en:common 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
+ ==
+
+ :: ui facts
+ ++ fact |= f=fact:ui:sur ^- json
+ %+ frond %fact
+ %+ frond -.f
+ ?- -.f
+ %post (postfact +.f)
+ %enga (enga +.f)
+ ==
+ ++ postfact |= pf=post-fact:ui:sur ^- json
+ %+ frond -.pf
+ (post-wrapper +.pf)
+ ++ enga |= [pw=post-wrapper:sur reaction=*]
+ ^- json
+ ~
+ ++ post-wrapper |= p=post-wrapper:sur
+ %- pairs
+ :~ post+(poast:en:trill post.p)
+ ['nostrMeta' (nostr-meta nostr-meta.p)]
+ ==
+ ++ nostr-meta |= p=nostr-meta:sur
+ =| l=(list [@t json])
+ =. l ?~ pub.p l :_ l ['pubkey' (hex:en:common u.pub.p)]
+ =. l ?~ ev-id.p l :_ l ['eventId' (hex:en:common u.ev-id.p)]
+ =. l ?~ relay.p l :_ l ['relay' %s u.relay.p]
+ =. l ?~ pr.p l :_ l ['profile' (user-meta:en:nostr u.pr.p)]
+ %- pairs l
--
++ de
=, dejs-soft:format
@@ -94,7 +128,6 @@
==
++ de-post
%- ot :~
- pubkey+hex:de:common
content+so
==
++ de-rt