mirror of
https://github.com/nbd-wtf/go-nostr.git
synced 2025-08-08 12:11:42 +02:00
nip22: prevent panic, return nil if not found according to nip10.go
This commit is contained in:
@@ -4,21 +4,24 @@ import "github.com/nbd-wtf/go-nostr"
|
||||
|
||||
func GetThreadRoot(tags nostr.Tags) *nostr.Tag {
|
||||
for _, tag := range tags {
|
||||
if len(tag) < 2 {
|
||||
continue
|
||||
}
|
||||
if tag[0] == "E" || tag[0] == "A" || tag[0] == "I" {
|
||||
return &tag
|
||||
}
|
||||
}
|
||||
empty := nostr.Tag{}
|
||||
return &empty
|
||||
return nil
|
||||
}
|
||||
|
||||
func GetImmediateReply(tags nostr.Tags) *nostr.Tag {
|
||||
for _, tag := range tags {
|
||||
if len(tag) < 2 {
|
||||
continue
|
||||
}
|
||||
if tag[0] == "e" || tag[0] == "a" || tag[0] == "i" {
|
||||
return &tag
|
||||
}
|
||||
}
|
||||
|
||||
empty := nostr.Tag{}
|
||||
return &empty
|
||||
return nil
|
||||
}
|
||||
|
Reference in New Issue
Block a user