small context tweaks.

This commit is contained in:
fiatjaf
2023-07-11 11:04:16 -03:00
parent 6f24ed761a
commit 15dc2dff45
2 changed files with 13 additions and 9 deletions

View File

@@ -132,18 +132,19 @@ func getLastNotes(ctx context.Context, code string) []*nostr.Event {
if pp == nil {
return nil
}
ctx, cancel := context.WithTimeout(ctx, time.Millisecond*1500)
defer cancel()
relays := pp.Relays
for _, relay := range sdk.FetchRelaysForPubkey(ctx, pool, pp.PublicKey, pp.Relays...) {
if relay.Outbox {
relays = append(relays, relay.URL)
{
ctx, cancel := context.WithTimeout(ctx, time.Millisecond*1500)
defer cancel()
for _, relay := range sdk.FetchRelaysForPubkey(ctx, pool, pp.PublicKey, pp.Relays...) {
if relay.Outbox {
relays = append(relays, relay.URL)
}
}
}
ctx, cancel = context.WithTimeout(ctx, time.Second*4)
ctx, cancel := context.WithTimeout(ctx, time.Second*4)
defer cancel()
relays = append(relays, getRelay())

View File

@@ -117,7 +117,10 @@ func render(w http.ResponseWriter, r *http.Request) {
} else {
typ = "other"
}
author, _ = getEvent(r.Context(), npub)
ctx, cancel := context.WithTimeout(r.Context(), time.Second*3)
author, _ = getEvent(ctx, npub)
cancel()
}
kindDescription := kindNames[event.Kind]