mirror of
https://github.com/nbd-wtf/go-nostr.git
synced 2025-11-19 10:36:42 +01:00
Pointer cannot hold a pointer so it can't be a hidden nil.
This commit is contained in:
@@ -2,17 +2,17 @@ package nip10
|
|||||||
|
|
||||||
import "github.com/nbd-wtf/go-nostr"
|
import "github.com/nbd-wtf/go-nostr"
|
||||||
|
|
||||||
func GetThreadRoot(tags nostr.Tags) *nostr.EventPointer {
|
func GetThreadRoot(tags nostr.Tags) nostr.Pointer {
|
||||||
for _, tag := range tags {
|
for _, tag := range tags {
|
||||||
if len(tag) >= 4 && tag[0] == "e" && tag[3] == "root" {
|
if len(tag) >= 4 && tag[0] == "e" && tag[3] == "root" {
|
||||||
p, _ := nostr.EventPointerFromTag(tag)
|
p, _ := nostr.EventPointerFromTag(tag)
|
||||||
return &p
|
return p
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
firstE := tags.Find("e")
|
firstE := tags.Find("e")
|
||||||
if firstE != nil {
|
if firstE != nil {
|
||||||
return &nostr.EventPointer{
|
return nostr.EventPointer{
|
||||||
ID: firstE[1],
|
ID: firstE[1],
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -20,7 +20,7 @@ func GetThreadRoot(tags nostr.Tags) *nostr.EventPointer {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func GetImmediateParent(tags nostr.Tags) *nostr.EventPointer {
|
func GetImmediateParent(tags nostr.Tags) nostr.Pointer {
|
||||||
var parent nostr.Tag
|
var parent nostr.Tag
|
||||||
var lastE nostr.Tag
|
var lastE nostr.Tag
|
||||||
|
|
||||||
@@ -57,13 +57,13 @@ func GetImmediateParent(tags nostr.Tags) *nostr.EventPointer {
|
|||||||
// that means this event is a direct reply to the parent
|
// that means this event is a direct reply to the parent
|
||||||
if parent != nil {
|
if parent != nil {
|
||||||
p, _ := nostr.EventPointerFromTag(parent)
|
p, _ := nostr.EventPointerFromTag(parent)
|
||||||
return &p
|
return p
|
||||||
}
|
}
|
||||||
|
|
||||||
if lastE != nil {
|
if lastE != nil {
|
||||||
// if we reached this point and we have at least one "e" we'll use that (the last)
|
// 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)
|
// (we don't bother looking for relay or author hints because these clients don't add these anyway)
|
||||||
return &nostr.EventPointer{
|
return nostr.EventPointer{
|
||||||
ID: lastE[1],
|
ID: lastE[1],
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,26 +16,12 @@ func EncodePointer(pointer nostr.Pointer) string {
|
|||||||
res, _ := EncodeProfile(v.PublicKey, v.Relays)
|
res, _ := EncodeProfile(v.PublicKey, v.Relays)
|
||||||
return res
|
return res
|
||||||
}
|
}
|
||||||
case *nostr.ProfilePointer:
|
|
||||||
if v.Relays == nil {
|
|
||||||
res, _ := EncodePublicKey(v.PublicKey)
|
|
||||||
return res
|
|
||||||
} else {
|
|
||||||
res, _ := EncodeProfile(v.PublicKey, v.Relays)
|
|
||||||
return res
|
|
||||||
}
|
|
||||||
case nostr.EventPointer:
|
case nostr.EventPointer:
|
||||||
res, _ := EncodeEvent(v.ID, v.Relays, v.Author)
|
res, _ := EncodeEvent(v.ID, v.Relays, v.Author)
|
||||||
return res
|
return res
|
||||||
case *nostr.EventPointer:
|
|
||||||
res, _ := EncodeEvent(v.ID, v.Relays, v.Author)
|
|
||||||
return res
|
|
||||||
case nostr.EntityPointer:
|
case nostr.EntityPointer:
|
||||||
res, _ := EncodeEntity(v.PublicKey, v.Kind, v.Identifier, v.Relays)
|
res, _ := EncodeEntity(v.PublicKey, v.Kind, v.Identifier, v.Relays)
|
||||||
return res
|
return res
|
||||||
case *nostr.EntityPointer:
|
|
||||||
res, _ := EncodeEntity(v.PublicKey, v.Kind, v.Identifier, v.Relays)
|
|
||||||
return res
|
|
||||||
}
|
}
|
||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user