Add support for summary field and cut description if too long

This commit is contained in:
Daniele Tonon
2023-06-06 09:54:51 +02:00
parent d1fd67a572
commit 9a7c47a2aa

View File

@@ -149,10 +149,13 @@ func render(w http.ResponseWriter, r *http.Request) {
} }
var subject string var subject string
var summary string
for _, tag := range event.Tags { for _, tag := range event.Tags {
if tag[0] == "subject" || tag[0] == "title" { if tag[0] == "subject" || tag[0] == "title" {
subject = tag[1] subject = tag[1]
break }
if tag[0] == "summary" {
summary = tag[1]
} }
} }
@@ -203,8 +206,13 @@ func render(w http.ResponseWriter, r *http.Request) {
} else { } else {
description = seenOnRelays description = seenOnRelays
} }
} else if summary != "" {
description = summary
} else { } else {
description = prettyJsonOrRaw(event.Content) description = prettyJsonOrRaw(event.Content)
if len(description) > 240 {
description = description[:240]
}
} }
// Manage not NIP-27 content replacing #[..] note/npub occurrences // Manage not NIP-27 content replacing #[..] note/npub occurrences