listBlobs method

Future<List<BlobDescriptor>> listBlobs({
  1. required String pubkey,
  2. List<String>? serverUrls,
  3. bool useAuth = true,
  4. DateTime? since,
  5. DateTime? until,
})

list the pubkey blobs
if serverUrls is null, the userServerList is fetched from nostr.
if the pukey has no UserServerList (kind: 10063), throws an error

Implementation

Future<List<BlobDescriptor>> listBlobs({
  required String pubkey,
  List<String>? serverUrls,
  bool useAuth = true,
  DateTime? since,
  DateTime? until,
}) async {
  Nip01Event? myAuthorization;

  if (useAuth) {
    _checkSigner();

    final now = DateTime.now().millisecondsSinceEpoch ~/ 1000;
    myAuthorization = Nip01Event(
      content: "List Blobs",
      pubKey: _signer.getPublicKey(),
      kind: kBlossom,
      createdAt: now,
      tags: [
        ["t", "list"],
        ["expiration", "${now + BLOSSOM_AUTH_EXPIRATION.inMilliseconds}"],
      ],
    );

    await _signer.sign(myAuthorization);
  }

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

  if (serverUrls == null) {
    throw Exception("User has no server list: $pubkey");
  }

  return _blossomImpl.listBlobs(
    pubkey: pubkey,
    since: since,
    until: until,
    serverUrls: serverUrls,
    authorization: myAuthorization,
  );
}