handleEventBroadcast method
NdkBroadcastResponse
handleEventBroadcast({
- required Nip01Event nostrEvent,
- required EventSigner? signer,
- required Stream<
List< doneStream,RelayBroadcastResponse> > - Iterable<
String> ? specificRelays,
override
broadcasts given event using inbox/outbox (gossip) if explicit relays are given they are used instead
nostrEvent
event to publish
explicitRelays
used instead of gossip if set
Implementation
@override
NdkBroadcastResponse handleEventBroadcast({
required Nip01Event nostrEvent,
required EventSigner? signer,
required Stream<List<RelayBroadcastResponse>> doneStream,
Iterable<String>? specificRelays,
}) {
Future<void> asyncStuff() async {
await relayManagerLight.seedRelaysConnected;
if (signer != null) {
await signer.sign(nostrEvent);
}
if (specificRelays != null) {
return RelayJitBroadcastSpecificRelaysStrategy.broadcast(
specificRelays: specificRelays.toList(),
relayManager: relayManagerLight,
eventToPublish: nostrEvent,
connectedRelays: relayManagerLight.connectedRelays
.whereType<RelayConnectivity<JitEngineRelayConnectivityData>>()
.toList(),
);
}
// default publish to own outbox
await RelayJitBroadcastOutboxStrategy.broadcast(
eventToPublish: nostrEvent,
connectedRelays: relayManagerLight.connectedRelays
.whereType<RelayConnectivity<JitEngineRelayConnectivityData>>()
.toList(),
cacheManager: cache,
relayManager: relayManagerLight,
);
// check if we need to publish to others inboxes
if (nostrEvent.pTags.isNotEmpty) {
await RelayJitBroadcastOtherReadStrategy.broadcast(
eventToPublish: nostrEvent,
connectedRelays: relayManagerLight.connectedRelays
.whereType<RelayConnectivity<JitEngineRelayConnectivityData>>()
.toList(),
cacheManager: cache,
relayManager: relayManagerLight,
pubkeysOfInbox: nostrEvent.pTags,
);
}
}
asyncStuff();
return NdkBroadcastResponse(
publishEvent: nostrEvent,
broadcastDoneStream: doneStream,
);
}