From 9a7c47a2aa81b8929e03f857980d6534d40a1197 Mon Sep 17 00:00:00 2001 From: Daniele Tonon Date: Tue, 6 Jun 2023 09:54:51 +0200 Subject: [PATCH] Add support for summary field and cut description if too long --- render.go | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/render.go b/render.go index be393a0..68fd6cf 100644 --- a/render.go +++ b/render.go @@ -149,10 +149,13 @@ func render(w http.ResponseWriter, r *http.Request) { } var subject string + var summary string for _, tag := range event.Tags { if tag[0] == "subject" || tag[0] == "title" { subject = tag[1] - break + } + if tag[0] == "summary" { + summary = tag[1] } } @@ -203,8 +206,13 @@ func render(w http.ResponseWriter, r *http.Request) { } else { description = seenOnRelays } + } else if summary != "" { + description = summary } else { description = prettyJsonOrRaw(event.Content) + if len(description) > 240 { + description = description[:240] + } } // Manage not NIP-27 content replacing #[..] note/npub occurrences