fix: send filters to new clients

This commit is contained in:
Kieran 2024-01-10 15:09:57 +00:00
parent 365f50694c
commit e9458b82f4
No known key found for this signature in database
GPG Key ID: DE71CEB3925BE941

View File

@ -42,7 +42,7 @@ public class NostrListener : IDisposable
_ = nostrWebsocketClient.Communicator.Stop(WebSocketCloseStatus.NormalClosure, string.Empty);
}
}
private void AddCommunicators(List<Uri> relays)
{
var missing = relays.Where(a => _client.FindClient(ClientName(a)) == null);
@ -51,6 +51,14 @@ public class NostrListener : IDisposable
{
_client.RegisterCommunicator(comm);
comm.Start();
var client = _client.FindClient(comm.Name);
if (client != default)
{
foreach (var (k, v) in _subscriptionToFilter)
{
client.Send(new NostrRequest(k, v));
}
}
}
}
@ -122,7 +130,7 @@ public class NostrListener : IDisposable
var relays = await db.Relays.Select(a => a.Url).ToListAsync(cancellationToken: stoppingToken);
_nostrListener.AddCommunicators(relays);
await Task.Delay(TimeSpan.FromMinutes(10), stoppingToken);
}
}