grantAccess method

Future<void> grantAccess({
  1. required String folderPath,
  2. required MailboxType type,
  3. required PeerId targetPeerId,
  4. required AccessMode accessMode,
})

Grant access to another peer

Implementation

Future<void> grantAccess({
  required String folderPath,
  required MailboxType type,
  required PeerId targetPeerId,
  required AccessMode accessMode,
}) async {
  _logger.fine('Granting $accessMode access to ${targetPeerId.toBase58()} for $folderPath');

  final address = MailboxAddress(
    ownerId: host.id,
    folderPath: folderPath,
    type: type,
  );

  final request = GrantAccessRequest(
    address: address,
    targetPeerId: targetPeerId,
    accessMode: accessMode,
  );

  final response = await _sendRequest(request);
  if (!response.success) {
    throw MailboxManagementError(
      response.errorMessage ?? 'Failed to grant access',
    );
  }

  _logger.info('Granted $accessMode access to ${targetPeerId.toBase58()} for ${address.fullPath}');
}