mirror of
https://github.com/nbd-wtf/go-nostr.git
synced 2025-08-25 21:21:57 +02:00
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:
@@ -1,23 +0,0 @@
|
||||
package sdk
|
||||
|
||||
import (
|
||||
"github.com/nbd-wtf/go-nostr"
|
||||
"github.com/nbd-wtf/go-nostr/nip10"
|
||||
"github.com/nbd-wtf/go-nostr/nip22"
|
||||
)
|
||||
|
||||
func GetThreadRoot(evt *nostr.Event) *nostr.Tag {
|
||||
if evt.Kind == nostr.KindComment {
|
||||
return nip22.GetThreadRoot(evt.Tags)
|
||||
} else {
|
||||
return nip10.GetThreadRoot(evt.Tags)
|
||||
}
|
||||
}
|
||||
|
||||
func GetImmediateReply(evt *nostr.Event) *nostr.Tag {
|
||||
if evt.Kind == nostr.KindComment {
|
||||
return nip22.GetImmediateReply(evt.Tags)
|
||||
} else {
|
||||
return nip10.GetImmediateReply(evt.Tags)
|
||||
}
|
||||
}
|
@@ -106,27 +106,36 @@ func (sys *System) trackEventHints(ie nostr.RelayEvent) {
|
||||
}
|
||||
|
||||
for ref := range nip27.ParseReferences(*ie.Event) {
|
||||
if ref.Profile != nil {
|
||||
for _, relay := range ref.Profile.Relays {
|
||||
switch pointer := ref.Pointer.(type) {
|
||||
case nostr.ProfilePointer:
|
||||
for _, relay := range pointer.Relays {
|
||||
if IsVirtualRelay(relay) {
|
||||
continue
|
||||
}
|
||||
if p, err := url.Parse(relay); err != nil || (p.Scheme != "wss" && p.Scheme != "ws") {
|
||||
continue
|
||||
}
|
||||
if nostr.IsValidPublicKey(ref.Profile.PublicKey) {
|
||||
sys.Hints.Save(ref.Profile.PublicKey, nostr.NormalizeURL(relay), hints.LastInHint, ie.CreatedAt)
|
||||
}
|
||||
sys.Hints.Save(pointer.PublicKey, nostr.NormalizeURL(relay), hints.LastInHint, ie.CreatedAt)
|
||||
}
|
||||
} else if ref.Event != nil && nostr.IsValidPublicKey(ref.Event.Author) {
|
||||
for _, relay := range ref.Event.Relays {
|
||||
case nostr.EventPointer:
|
||||
for _, relay := range pointer.Relays {
|
||||
if IsVirtualRelay(relay) {
|
||||
continue
|
||||
}
|
||||
if p, err := url.Parse(relay); err != nil || (p.Scheme != "wss" && p.Scheme != "ws") {
|
||||
continue
|
||||
}
|
||||
sys.Hints.Save(ref.Event.Author, nostr.NormalizeURL(relay), hints.LastInHint, ie.CreatedAt)
|
||||
sys.Hints.Save(pointer.Author, nostr.NormalizeURL(relay), hints.LastInHint, ie.CreatedAt)
|
||||
}
|
||||
case nostr.EntityPointer:
|
||||
for _, relay := range pointer.Relays {
|
||||
if IsVirtualRelay(relay) {
|
||||
continue
|
||||
}
|
||||
if p, err := url.Parse(relay); err != nil || (p.Scheme != "wss" && p.Scheme != "ws") {
|
||||
continue
|
||||
}
|
||||
sys.Hints.Save(pointer.PublicKey, nostr.NormalizeURL(relay), hints.LastInHint, ie.CreatedAt)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user