broadcastDeletion method
request a deletion of an event
eventId event you want to delete
eventIds events you want to delete
customRelays relay URls to send the deletion request to specific relays
customSigner if you want to use a different signer than the default specified in NdkConfig
Implementation
NdkBroadcastResponse broadcastDeletion({
String? eventId,
List<String>? eventIds,
Iterable<String>? customRelays,
EventSigner? customSigner,
String reason = "delete",
}) {
final EventSigner mySigner = _checkSinger(customSigner: customSigner);
List<String> idsToDelete = [];
if (eventId != null) {
idsToDelete.add(eventId);
}
if (eventIds != null) {
idsToDelete.addAll(eventIds);
}
if (idsToDelete.isEmpty) {
throw ArgumentError(
"At least one eventId must be provided for deletion.");
}
Nip01Event event = Nip01Event(
pubKey: mySigner.getPublicKey(),
kind: Deletion.kKind,
tags: idsToDelete.map((e) => ["e", e]).toList(),
content: reason,
createdAt: DateTime.now().millisecondsSinceEpoch ~/ 1000);
// TODO not bulletproof, think of better way
for (final id in idsToDelete) {
_cacheManager.removeEvent(id);
}
return broadcast(
nostrEvent: event,
specificRelays: customRelays,
customSigner: mySigner,
);
}