mirror of
https://github.com/nbd-wtf/go-nostr.git
synced 2025-07-03 03:55:51 +02:00
tag helpers in a separate file and nip10 helpers.
This commit is contained in:
24
nip10/nip10.go
Normal file
24
nip10/nip10.go
Normal file
@ -0,0 +1,24 @@
|
||||
package nip10
|
||||
|
||||
import "github.com/nbd-wtf/go-nostr"
|
||||
|
||||
func GetThreadRoot(tags nostr.Tags) *nostr.Tag {
|
||||
for _, tag := range tags {
|
||||
if len(tag) >= 4 && tag[0] == "e" && tag[3] == "root" {
|
||||
return &tag
|
||||
}
|
||||
}
|
||||
|
||||
return tags.GetFirst([]string{"e", ""})
|
||||
}
|
||||
|
||||
func GetImmediateReply(tags nostr.Tags) *nostr.Tag {
|
||||
for i := len(tags) - 1; i >= 0; i-- {
|
||||
tag := tags[i]
|
||||
if len(tag) >= 4 && tag[0] == "e" && tag[3] == "reply" {
|
||||
return &tag
|
||||
}
|
||||
}
|
||||
|
||||
return tags.GetLast([]string{"e", ""})
|
||||
}
|
Reference in New Issue
Block a user