mirror of
https://github.com/nbd-wtf/go-nostr.git
synced 2025-04-09 04:18:02 +02:00
sdk: return store event along with ProfileMetadata.
This commit is contained in:
parent
711b0844b1
commit
5847335506
@ -11,6 +11,7 @@ import (
|
||||
|
||||
type ProfileMetadata struct {
|
||||
pubkey string
|
||||
event *nostr.Event
|
||||
|
||||
Name string `json:"name,omitempty"`
|
||||
DisplayName string `json:"display_name,omitempty"`
|
||||
@ -47,6 +48,7 @@ func FetchProfileMetadata(ctx context.Context, pool *nostr.SimplePool, pubkey st
|
||||
for ie := range ch {
|
||||
if m, err := ParseMetadata(ie.Event); err == nil {
|
||||
m.pubkey = pubkey
|
||||
m.event = ie.Event
|
||||
return *m
|
||||
}
|
||||
}
|
||||
|
@ -46,9 +46,14 @@ func (sys System) FetchProfileMetadata(ctx context.Context, pubkey string) Profi
|
||||
return v
|
||||
}
|
||||
|
||||
ctx, cancel := context.WithTimeout(ctx, time.Second*5)
|
||||
defer cancel()
|
||||
res := FetchProfileMetadata(ctx, sys.Pool, pubkey, sys.MetadataRelays...)
|
||||
ctxRelays, cancel := context.WithTimeout(ctx, time.Second*2)
|
||||
relays := sys.FetchOutboxRelays(ctxRelays, pubkey)
|
||||
cancel()
|
||||
|
||||
ctx, cancel = context.WithTimeout(ctx, time.Second*3)
|
||||
res := FetchProfileMetadata(ctx, sys.Pool, pubkey, append(relays, sys.MetadataRelays...)...)
|
||||
cancel()
|
||||
|
||||
sys.MetadataCache.SetWithTTL(pubkey, res, time.Hour*6)
|
||||
return res
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user