a bunch of [32]byte conversions. still more needed.
This commit is contained in:
@@ -5,39 +5,39 @@ import (
|
||||
"net/url"
|
||||
"strings"
|
||||
|
||||
"github.com/nbd-wtf/go-nostr"
|
||||
cache_memory "github.com/nbd-wtf/go-nostr/sdk/cache/memory"
|
||||
"fiatjaf.com/nostr"
|
||||
cache_memory "fiatjaf.com/nostr/sdk/cache/memory"
|
||||
)
|
||||
|
||||
type ProfileRef struct {
|
||||
Pubkey string
|
||||
Pubkey nostr.PubKey
|
||||
Relay string
|
||||
Petname string
|
||||
}
|
||||
|
||||
func (f ProfileRef) Value() string { return f.Pubkey }
|
||||
func (f ProfileRef) Value() nostr.PubKey { return f.Pubkey }
|
||||
|
||||
func (sys *System) FetchFollowList(ctx context.Context, pubkey string) GenericList[ProfileRef] {
|
||||
func (sys *System) FetchFollowList(ctx context.Context, pubkey nostr.PubKey) GenericList[ProfileRef] {
|
||||
if sys.FollowListCache == nil {
|
||||
sys.FollowListCache = cache_memory.New32[GenericList[ProfileRef]](1000)
|
||||
sys.FollowListCache = cache_memory.New[GenericList[ProfileRef]](1000)
|
||||
}
|
||||
|
||||
fl, _ := fetchGenericList(sys, ctx, pubkey, 3, kind_3, parseProfileRef, sys.FollowListCache)
|
||||
return fl
|
||||
}
|
||||
|
||||
func (sys *System) FetchMuteList(ctx context.Context, pubkey string) GenericList[ProfileRef] {
|
||||
func (sys *System) FetchMuteList(ctx context.Context, pubkey nostr.PubKey) GenericList[ProfileRef] {
|
||||
if sys.MuteListCache == nil {
|
||||
sys.MuteListCache = cache_memory.New32[GenericList[ProfileRef]](1000)
|
||||
sys.MuteListCache = cache_memory.New[GenericList[ProfileRef]](1000)
|
||||
}
|
||||
|
||||
ml, _ := fetchGenericList(sys, ctx, pubkey, 10000, kind_10000, parseProfileRef, sys.MuteListCache)
|
||||
return ml
|
||||
}
|
||||
|
||||
func (sys *System) FetchFollowSets(ctx context.Context, pubkey string) GenericSets[ProfileRef] {
|
||||
func (sys *System) FetchFollowSets(ctx context.Context, pubkey nostr.PubKey) GenericSets[ProfileRef] {
|
||||
if sys.FollowSetsCache == nil {
|
||||
sys.FollowSetsCache = cache_memory.New32[GenericSets[ProfileRef]](1000)
|
||||
sys.FollowSetsCache = cache_memory.New[GenericSets[ProfileRef]](1000)
|
||||
}
|
||||
|
||||
ml, _ := fetchGenericSets(sys, ctx, pubkey, 30000, kind_30000, parseProfileRef, sys.FollowSetsCache)
|
||||
@@ -52,11 +52,13 @@ func parseProfileRef(tag nostr.Tag) (fw ProfileRef, ok bool) {
|
||||
return fw, false
|
||||
}
|
||||
|
||||
fw.Pubkey = tag[1]
|
||||
if !nostr.IsValidPublicKey(fw.Pubkey) {
|
||||
pubkey, err := nostr.PubKeyFromHex(fw.Pubkey)
|
||||
if err != nil {
|
||||
return fw, false
|
||||
}
|
||||
|
||||
fw.Pubkey = pubkey
|
||||
|
||||
if len(tag) > 2 {
|
||||
if _, err := url.Parse(tag[2]); err == nil {
|
||||
fw.Relay = nostr.NormalizeURL(tag[2])
|
||||
|
||||
Reference in New Issue
Block a user