mirror of
https://github.com/aljazceru/njump.git
synced 2026-01-31 11:44:34 +01:00
fix getParentNevent()
this would panic if we didn\'t have any relays in data.relays for the child. but also I think it wasn't a good idea to give spurious hints in the nevent. either we have good hints or we don't.
This commit is contained in:
2
data.go
2
data.go
@@ -211,7 +211,7 @@ func grabData(ctx context.Context, code string, isProfileSitemap bool) (*Data, e
|
||||
case 1, 7, 30023, 30024:
|
||||
data.templateId = Note
|
||||
data.content = event.Content
|
||||
if parentNevent := getParentNevent(event, data.relays[0]); parentNevent != "" {
|
||||
if parentNevent := getParentNevent(event); parentNevent != "" {
|
||||
data.parentLink = template.HTML(replaceNostrURLsWithTags(nostrNoteNeventMatcher, "nostr:"+parentNevent))
|
||||
}
|
||||
case 6:
|
||||
|
||||
12
utils.go
12
utils.go
@@ -175,19 +175,15 @@ func getPreviewStyle(r *http.Request) Style {
|
||||
}
|
||||
}
|
||||
|
||||
func getParentNevent(event *nostr.Event, fallbackRelay string) string {
|
||||
func getParentNevent(event *nostr.Event) string {
|
||||
parentNevent := ""
|
||||
replyTag := nip10.GetImmediateReply(event.Tags)
|
||||
if replyTag != nil {
|
||||
relay := ""
|
||||
var relays []string
|
||||
if (len(*replyTag) > 2) && ((*replyTag)[2] != "") {
|
||||
relay = (*replyTag)[2]
|
||||
} else if fallbackRelay != "" {
|
||||
relay = fallbackRelay
|
||||
} else {
|
||||
relay = getRandomRelay()
|
||||
relays = []string{(*replyTag)[2]}
|
||||
}
|
||||
parentNevent, _ = nip19.EncodeEvent((*replyTag)[1], []string{relay}, "")
|
||||
parentNevent, _ = nip19.EncodeEvent((*replyTag)[1], relays, "")
|
||||
}
|
||||
return parentNevent
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user