MailboxAddress.parse constructor

MailboxAddress.parse(
  1. String fullPath, {
  2. MailboxType? type,
})

Parse from full path string: "12D3KooW.../folder/path"

Implementation

factory MailboxAddress.parse(String fullPath, {MailboxType? type}) {
  final parts = fullPath.split('/');
  if (parts.length < 2) {
    throw ArgumentError('Invalid mailbox path: $fullPath');
  }

  final peerIdStr = parts[0];
  final folder = parts.sublist(1).join('/');

  return MailboxAddress(
    ownerId: PeerId.fromString(peerIdStr),
    folderPath: folder,
    type: type ?? MailboxType.private,  // Default to private if not specified
  );
}