mirror of https://github.com/fiatjaf/nak.git
event: renew relay connection before publishing if necessary.
This commit is contained in:
parent
9251702460
commit
ecb7f8f195
9
event.go
9
event.go
|
@ -403,13 +403,20 @@ func publishFlow(ctx context.Context, c *cli.Command, kr nostr.Signer, evt nostr
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// normal dumb flow
|
// normal dumb flow
|
||||||
for _, relay := range relays {
|
for i, relay := range relays {
|
||||||
publish:
|
publish:
|
||||||
cleanUrl, _ := strings.CutPrefix(relay.URL, "wss://")
|
cleanUrl, _ := strings.CutPrefix(relay.URL, "wss://")
|
||||||
log("publishing to %s... ", color.CyanString(cleanUrl))
|
log("publishing to %s... ", color.CyanString(cleanUrl))
|
||||||
ctx, cancel := context.WithTimeout(ctx, 10*time.Second)
|
ctx, cancel := context.WithTimeout(ctx, 10*time.Second)
|
||||||
defer cancel()
|
defer cancel()
|
||||||
|
|
||||||
|
if !relay.IsConnected() {
|
||||||
|
if new_, err := sys.Pool.EnsureRelay(relay.URL); err == nil {
|
||||||
|
relays[i] = new_
|
||||||
|
relay = new_
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
err := relay.Publish(ctx, evt)
|
err := relay.Publish(ctx, evt)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
// published fine
|
// published fine
|
||||||
|
|
Loading…
Reference in New Issue