Pointer cannot hold a pointer so it can't be a hidden nil.
This commit is contained in:
@@ -2,24 +2,24 @@ package nip10
|
||||
|
||||
import "fiatjaf.com/nostr"
|
||||
|
||||
func GetThreadRoot(tags nostr.Tags) *nostr.EventPointer {
|
||||
func GetThreadRoot(tags nostr.Tags) nostr.Pointer {
|
||||
for _, tag := range tags {
|
||||
if len(tag) >= 4 && tag[0] == "e" && tag[3] == "root" {
|
||||
p, _ := nostr.EventPointerFromTag(tag)
|
||||
return &p
|
||||
return p
|
||||
}
|
||||
}
|
||||
|
||||
firstE := tags.Find("e")
|
||||
if firstE != nil {
|
||||
p, _ := nostr.EventPointerFromTag(firstE)
|
||||
return &p
|
||||
return p
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func GetImmediateParent(tags nostr.Tags) *nostr.EventPointer {
|
||||
func GetImmediateParent(tags nostr.Tags) nostr.Pointer {
|
||||
var parent nostr.Tag
|
||||
var lastE nostr.Tag
|
||||
|
||||
@@ -56,14 +56,14 @@ func GetImmediateParent(tags nostr.Tags) *nostr.EventPointer {
|
||||
// that means this event is a direct reply to the parent
|
||||
if parent != nil {
|
||||
p, _ := nostr.EventPointerFromTag(parent)
|
||||
return &p
|
||||
return p
|
||||
}
|
||||
|
||||
if lastE != nil {
|
||||
// if we reached this point and we have at least one "e" we'll use that (the last)
|
||||
// (we don't bother looking for relay or author hints because these clients don't add these anyway)
|
||||
p, _ := nostr.EventPointerFromTag(lastE)
|
||||
return &p
|
||||
return p
|
||||
}
|
||||
|
||||
return nil
|
||||
|
||||
@@ -14,20 +14,10 @@ func EncodePointer(pointer nostr.Pointer) string {
|
||||
} else {
|
||||
return EncodeNprofile(v.PublicKey, v.Relays)
|
||||
}
|
||||
case *nostr.ProfilePointer:
|
||||
if v.Relays == nil {
|
||||
return EncodeNpub(v.PublicKey)
|
||||
} else {
|
||||
return EncodeNprofile(v.PublicKey, v.Relays)
|
||||
}
|
||||
case nostr.EventPointer:
|
||||
return EncodeNevent(v.ID, v.Relays, v.Author)
|
||||
case *nostr.EventPointer:
|
||||
return EncodeNevent(v.ID, v.Relays, v.Author)
|
||||
case nostr.EntityPointer:
|
||||
return EncodeNaddr(v.PublicKey, v.Kind, v.Identifier, v.Relays)
|
||||
case *nostr.EntityPointer:
|
||||
return EncodeNaddr(v.PublicKey, v.Kind, v.Identifier, v.Relays)
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user