breaking pointer mess

- ExternalPointer (?)
- nip27, nip22 and nip10 functions to return pointers
- get rid of sdk/thread helpers that were just a thin layer over nip10 and nip22
This commit is contained in:
fiatjaf
2025-03-10 02:35:02 -03:00
parent f575f63f6c
commit 7e04bbb4b8
8 changed files with 119 additions and 79 deletions

View File

@@ -2,25 +2,41 @@ package nip22
import "github.com/nbd-wtf/go-nostr"
func GetThreadRoot(tags nostr.Tags) *nostr.Tag {
func GetThreadRoot(tags nostr.Tags) nostr.Pointer {
for _, tag := range tags {
if len(tag) < 2 {
continue
}
if tag[0] == "E" || tag[0] == "A" || tag[0] == "I" {
return &tag
switch tag[0] {
case "E":
ep, _ := nostr.EventPointerFromTag(tag)
return ep
case "A":
ep, _ := nostr.EntityPointerFromTag(tag)
return ep
case "I":
ep, _ := nostr.ExternalPointerFromTag(tag)
return ep
}
}
return nil
}
func GetImmediateReply(tags nostr.Tags) *nostr.Tag {
func GetImmediateParent(tags nostr.Tags) nostr.Pointer {
for _, tag := range tags {
if len(tag) < 2 {
continue
}
if tag[0] == "e" || tag[0] == "a" || tag[0] == "i" {
return &tag
switch tag[0] {
case "e":
ep, _ := nostr.EventPointerFromTag(tag)
return ep
case "a":
ep, _ := nostr.EntityPointerFromTag(tag)
return ep
case "i":
ep, _ := nostr.ExternalPointerFromTag(tag)
return ep
}
}
return nil