deleteBlob method

Future<List<BlobDeleteResult>> deleteBlob({
  1. required String sha256,
  2. List<String>? serverUrls,
})

delete a blob if serverUrls is null, the userServerList is fetched from nostr.
if the pukey has no UserServerList (kind: 10063), throws an error
the current signer is used to sign the request

Implementation

Future<List<BlobDeleteResult>> deleteBlob({
  required String sha256,
  List<String>? serverUrls,
}) async {
  final now = DateTime.now().millisecondsSinceEpoch ~/ 1000;

  _checkSigner();

  final Nip01Event myAuthorization = Nip01Event(
    content: "delete",
    pubKey: _signer.getPublicKey(),
    kind: kBlossom,
    createdAt: now,
    tags: [
      ["t", "delete"],
      ["x", sha256],
      ["expiration", "${now + BLOSSOM_AUTH_EXPIRATION.inMilliseconds}"],
    ],
  );

  await _signer.sign(myAuthorization);

  /// fetch user server list from nostr
  serverUrls ??= await _userServerList
      .getUserServerList(pubkeys: [_signer.getPublicKey()]);

  if (serverUrls == null) {
    throw Exception("User has no server list");
  }
  return _blossomImpl.deleteBlob(
    sha256: sha256,
    authorization: myAuthorization,
    serverUrls: serverUrls,
  );
}