getRecipientList function

Future<List<String>> getRecipientList()

Retrieve the list of recipients that have access to any file in the user's POD.

Implementation

Future<List<String>> getRecipientList() async {
  // Initialise the resource list and data
  final List<String> fileList;
  final Map<String, dynamic> dataMapWithPermissions;

  try {
    // Get list of file urls
    fileList = await getResources();

    if (fileList.isNotEmpty) {
      // Retrieve ACLs for each file
      dataMapWithPermissions = await readPermissionFileList(
        fileList: fileList,
        isFileUrl: false,
      );

      // Extract recipient webIDs to list
      final uniqRecipWebIdList = extractRecipWebIdList(
        dataMapWithPermissions,
        fileList: fileList,
      );

      return uniqRecipWebIdList;
    } else {
      // No files found in user's POD, therefore no recipients
      // of the user's files.
      return [];
    }
  } on Object catch (e) {
    debugPrint(e.toString());
    rethrow;
  }
}