mirror of
https://github.com/nbd-wtf/go-nostr.git
synced 2025-07-01 11:02:47 +02:00
fix OKEnvelope always requiring the 4th field.
This commit is contained in:
22
relay.go
22
relay.go
@ -51,7 +51,7 @@ type Relay struct {
|
||||
|
||||
challenges chan string // NIP-42 challenges
|
||||
notices chan string // NIP-01 NOTICEs
|
||||
okCallbacks *xsync.MapOf[string, func(bool, *string)]
|
||||
okCallbacks *xsync.MapOf[string, func(bool, string)]
|
||||
writeQueue chan writeRequest
|
||||
subscriptionChannelCloseQueue chan *Subscription
|
||||
|
||||
@ -73,7 +73,7 @@ func NewRelay(ctx context.Context, url string, opts ...RelayOption) *Relay {
|
||||
connectionContext: ctx,
|
||||
connectionContextCancel: cancel,
|
||||
Subscriptions: xsync.NewMapOf[*Subscription](),
|
||||
okCallbacks: xsync.NewMapOf[func(bool, *string)](),
|
||||
okCallbacks: xsync.NewMapOf[func(bool, string)](),
|
||||
writeQueue: make(chan writeRequest),
|
||||
subscriptionChannelCloseQueue: make(chan *Subscription),
|
||||
}
|
||||
@ -346,22 +346,17 @@ func (r *Relay) Publish(ctx context.Context, event Event) (Status, error) {
|
||||
defer cancel()
|
||||
|
||||
// listen for an OK callback
|
||||
okCallback := func(ok bool, msg *string) {
|
||||
r.okCallbacks.Store(event.ID, func(ok bool, reason string) {
|
||||
mu.Lock()
|
||||
defer mu.Unlock()
|
||||
if ok {
|
||||
status = PublishStatusSucceeded
|
||||
} else {
|
||||
status = PublishStatusFailed
|
||||
reason := ""
|
||||
if msg != nil {
|
||||
reason = *msg
|
||||
}
|
||||
err = fmt.Errorf("msg: %s", reason)
|
||||
}
|
||||
cancel()
|
||||
}
|
||||
r.okCallbacks.Store(event.ID, okCallback)
|
||||
})
|
||||
defer r.okCallbacks.Delete(event.ID)
|
||||
|
||||
// publish event
|
||||
@ -410,22 +405,17 @@ func (r *Relay) Auth(ctx context.Context, event Event) (Status, error) {
|
||||
defer cancel()
|
||||
|
||||
// listen for an OK callback
|
||||
okCallback := func(ok bool, msg *string) {
|
||||
r.okCallbacks.Store(event.ID, func(ok bool, reason string) {
|
||||
mu.Lock()
|
||||
if ok {
|
||||
status = PublishStatusSucceeded
|
||||
} else {
|
||||
status = PublishStatusFailed
|
||||
reason := ""
|
||||
if msg != nil {
|
||||
reason = *msg
|
||||
}
|
||||
err = fmt.Errorf("msg: %s", reason)
|
||||
}
|
||||
mu.Unlock()
|
||||
cancel()
|
||||
}
|
||||
r.okCallbacks.Store(event.ID, okCallback)
|
||||
})
|
||||
defer r.okCallbacks.Delete(event.ID)
|
||||
|
||||
// send AUTH
|
||||
|
Reference in New Issue
Block a user