mirror of
https://github.com/nbd-wtf/go-nostr.git
synced 2025-03-17 13:22:56 +01:00
try to prevent pointer to pointer bug.
This commit is contained in:
parent
769887fac1
commit
74e121075e
@ -16,12 +16,26 @@ 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 ""
|
||||||
}
|
}
|
||||||
|
@ -31,7 +31,7 @@ func ParseReferences(evt nostr.Event) iter.Seq[Reference] {
|
|||||||
if prefix, data, err := nip19.Decode(nip19code); err == nil {
|
if prefix, data, err := nip19.Decode(nip19code); err == nil {
|
||||||
switch prefix {
|
switch prefix {
|
||||||
case "npub":
|
case "npub":
|
||||||
pointer := &nostr.ProfilePointer{
|
pointer := nostr.ProfilePointer{
|
||||||
PublicKey: data.(string), Relays: []string{},
|
PublicKey: data.(string), Relays: []string{},
|
||||||
}
|
}
|
||||||
tag := evt.Tags.FindWithValue("p", pointer.PublicKey)
|
tag := evt.Tags.FindWithValue("p", pointer.PublicKey)
|
||||||
@ -52,7 +52,7 @@ func ParseReferences(evt nostr.Event) iter.Seq[Reference] {
|
|||||||
}
|
}
|
||||||
case "note":
|
case "note":
|
||||||
// we don't even bother here because people using note1 codes aren't including relay hints anyway
|
// we don't even bother here because people using note1 codes aren't including relay hints anyway
|
||||||
reference.Pointer = &nostr.EventPointer{ID: data.(string), Relays: nil}
|
reference.Pointer = nostr.EventPointer{ID: data.(string), Relays: nil}
|
||||||
case "nevent":
|
case "nevent":
|
||||||
pointer := data.(nostr.EventPointer)
|
pointer := data.(nostr.EventPointer)
|
||||||
tag := evt.Tags.FindWithValue("e", pointer.ID)
|
tag := evt.Tags.FindWithValue("e", pointer.ID)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user