support handling CLOSED messages from relay client.

This commit is contained in:
fiatjaf
2023-11-28 18:54:24 -03:00
parent fa20f84ec7
commit 7449f254db
3 changed files with 17 additions and 1 deletions

View File

@@ -300,6 +300,10 @@ func (r *Relay) Connect(ctx context.Context) error {
if subscription, ok := r.Subscriptions.Load(string(*env)); ok {
subscription.dispatchEose()
}
case *ClosedEnvelope:
if subscription, ok := r.Subscriptions.Load(string(env.SubscriptionID)); ok {
subscription.dispatchClosed(env.Reason)
}
case *CountEnvelope:
if subscription, ok := r.Subscriptions.Load(string(env.SubscriptionID)); ok && env.Count != nil && subscription.countResult != nil {
subscription.countResult <- *env.Count
@@ -478,6 +482,7 @@ func (r *Relay) PrepareSubscription(ctx context.Context, filters Filters, opts .
counter: int(current),
Events: make(chan *Event),
EndOfStoredEvents: make(chan struct{}),
ClosedReason: make(chan string, 1),
Filters: filters,
}