mirror of
https://github.com/fiatjaf/nak.git
synced 2024-11-22 00:09:08 -05:00
fix event publishing flow: no need to reconnect and AUTH messages make sense.
This commit is contained in:
parent
30dbe2c1c0
commit
ed3156ae10
8
event.go
8
event.go
|
@ -217,11 +217,8 @@ example:
|
|||
if len(relays) > 0 {
|
||||
os.Stdout.Sync()
|
||||
for _, relay := range relays {
|
||||
log("publishing to %s... ", relay.URL)
|
||||
if relay, err := nostr.RelayConnect(c.Context, relay.URL); err != nil {
|
||||
log("failed to connect: %s\n", err)
|
||||
} else {
|
||||
publish:
|
||||
log("publishing to %s... ", relay.URL)
|
||||
ctx, cancel := context.WithTimeout(c.Context, 10*time.Second)
|
||||
defer cancel()
|
||||
|
||||
|
@ -233,7 +230,7 @@ example:
|
|||
}
|
||||
|
||||
// error publishing
|
||||
if isAuthRequired(err.Error()) && sec != "" && doAuth {
|
||||
if strings.HasPrefix(err.Error(), "msg: auth-required:") && sec != "" && doAuth {
|
||||
// if the relay is requesting auth and we can auth, let's do it
|
||||
log("performing auth... ")
|
||||
st, err := relay.Auth(c.Context, func(evt *nostr.Event) error { return evt.Sign(sec) })
|
||||
|
@ -253,7 +250,6 @@ example:
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
exitIfLineProcessingError(c)
|
||||
return nil
|
||||
|
|
Loading…
Reference in New Issue
Block a user