/- sur=nostr /+ common=json-common, sr=sortug |% ++ en =, enjs:format |% :: shim comms ++ req |= =req:shim:sur ^- json %+ frond -.req ?- -.req %get (get +.req) %post (post +.req) == ++ get |= rs=get:shim:sur :- %a %+ turn rs |= [r=@t fs=(list filter:sur)] %: pairs relay+s+r filters+a+(turn fs filter) ~ == :: ++ post |= p=post:shim:sur %: pairs event+(event event.p) relays+a+(turn relays.p cord:en:common) ~ == :: ++ raw-event |= raw-event:sur :: WTF nostr doesn't want the prefix on the pubkey =/ pubkeyt (scow:sr %ux pubkey) ?~ pubkeyt !! =/ pubkeyj [%s (crip t.pubkeyt)] :- %a :~ [%n '0'] pubkeyj (numb created-at) (numb kind) a+(turn tags tag) s+content == ++ event |= e=event:sur ^- json =/ 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 sig+(hex:en:common sig.e) ['created_at' (numb created-at.e)] kind+(numb kind.e) content+s+content.e tags+a+(turn tags.e tag) ~ == ++ tag |= t=tag:sur ^- json [%a (turn t cord:en:common)] :: :- s+key.t :: :- s+value.t :: (turn rest.t |=(tt=@t s+tt)) :: ++ filter |= f=filter:sur ^- json =| l=(list [key=@t jon=json]) =. l ?~ ids.f l :_ l ['ids' [%a (turn ids.f hex:en:common)]] =. l ?~ authors.f l :_ l ['authors' [%a (turn authors.f hex:en:common)]] =. l ?~ kinds.f l :_ l ['kinds' [%a (turn kinds.f numb)]] =. l ?~ since.f l :_ l ['since' (numb u.since.f)] =. l ?~ until.f l :_ l ['until' (numb u.until.f)] =. l ?~ limit.f l :_ l ['limit' (numb u.limit.f)] %- pairs l ++ user-meta |= meta=user-meta:sur =/ other %+ turn ~(tap by other.meta) |= [key=@t val=@t] [key %s val] %: pairs name+s+name.meta picture+s+picture.meta about+s+about.meta other == -- ++ de =, dejs-soft:format |% :: shim ++ msg %- ot :~ relay+so event+event == ++ event %- ot :~ id+hex:de:common pubkey+hex:de:common ['created_at' ni] kind+ni tags+(ar (ar so)) content+so sig+hex:de:common == ++ user-meta |= jon=json ^- (unit user-meta:sur) =/ all ((om so) jon) ?~ all ~ =/ base=(unit [name=@t about=@t picture=@t]) %. jon %- ot :~ name+so about+so picture+so == ?~ base ~ `[name.u.base about.u.base picture.u.base u.all] -- --