mirror of
https://github.com/nbd-wtf/go-nostr.git
synced 2025-03-18 05:42:20 +01:00
nip17: fix nil pointer
Fixes a nil pointer when the Publish succeeds. In that case the err is nil, and calling .Error() on nil causes a nil pointer exception. Reproduced at: https://play.golang.com/p/ps8d82Qt9kO
This commit is contained in:
parent
defc349e57
commit
967a08fb65
@ -55,7 +55,7 @@ func PublishMessage(
|
||||
}
|
||||
|
||||
err = r.Publish(ctx, event)
|
||||
if strings.HasPrefix(err.Error(), "auth-required:") {
|
||||
if err != nil && strings.HasPrefix(err.Error(), "auth-required:") {
|
||||
authErr := r.Auth(ctx, func(ae *nostr.Event) error { return kr.SignEvent(ctx, ae) })
|
||||
if authErr == nil {
|
||||
err = r.Publish(ctx, event)
|
||||
|
Loading…
x
Reference in New Issue
Block a user