sendFileMessage method

Future<void> sendFileMessage({
  1. required String recipientPubKey,
  2. required Nip17FileMetadata metadata,
  3. List<List<String>> additionalTags = const [],
  4. Iterable<String>? recipientDmRelayDiscoveryRelays,
})

Sends an already-uploaded encrypted file as a NIP-17 kind-15 message.

The URL, hashes, MIME type, key and nonce are placed only in the encrypted rumor. Uploading the ciphertext is deliberately separate so applications can choose the appropriate standard Blossom kind-10063 server list.

Implementation

Future<void> sendFileMessage({
  required String recipientPubKey,
  required Nip17FileMetadata metadata,
  List<List<String>> additionalTags = const [],
  Iterable<String>? recipientDmRelayDiscoveryRelays,
}) async {
  final senderPubKey = _requireLoggedPubKey();
  final rumor = await _giftWrap.createRumor(
    content: metadata.url.toString(),
    kind: kFileMessageKind,
    tags: [
      ['p', recipientPubKey],
      ...metadata.toTags(),
      ...additionalTags,
    ],
  );

  await _sendRumor(
    rumor: rumor,
    recipientPubKey: recipientPubKey,
    senderPubKey: senderPubKey,
    recipientDmRelayDiscoveryRelays: recipientDmRelayDiscoveryRelays,
  );
}