From c47a6ba4f5ea2e112e7c8d4c320f3ad49f805366 Mon Sep 17 00:00:00 2001 From: Daniele Tonon Date: Sun, 4 Jun 2023 16:54:49 +0200 Subject: [PATCH] Manage not NIP-27 contents --- render.go | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/render.go b/render.go index b41fb68..be393a0 100644 --- a/render.go +++ b/render.go @@ -207,6 +207,20 @@ func render(w http.ResponseWriter, r *http.Request) { description = prettyJsonOrRaw(event.Content) } + // Manage not NIP-27 content replacing #[..] note/npub occurrences + for index, value := range event.Tags { + placeholderTag := "#[" + fmt.Sprintf("%d", index) + "]" + nreplace := "" + if value[0] == "p" { + nreplace, _ = nip19.EncodePublicKey(value[1]) + } else if value[0] == "e" { + nreplace, _ = nip19.EncodeNote(value[1]) + } else { + continue + } + content = strings.ReplaceAll(content, placeholderTag, "nostr:"+nreplace) + } + eventJSON, _ := json.MarshalIndent(event, "", " ") params := map[string]any{