unblock method

Future<User?> unblock({
  1. required List<String> users,
})

Implementation

Future<User?> unblock({required List<String> users}) async {
  if (!_hasSigner || _decryptedPgpPvtKey == null) {
    throw Exception(PushAPI.ensureSignerMessage());
  }

  final user = await PUSH_USER.getUser(address: _account);

  for (var element in users) {
    if (!isValidETHAddress(element)) {
      throw Exception('Invalid address in the users: $element');
    }
  }

  if (user!.profile!.blockedUsersList == null) {
    return user;
  }

  final userDIDs =
      await Future.wait(users.map((e) async => await getUserDID(address: e)));

  user.profile!.blockedUsersList = user.profile!.blockedUsersList!
      .where((element) => !userDIDs.contains(element))
      .toList();

  return PUSH_USER.profileUpdate(
    pgpPrivateKey: _decryptedPgpPvtKey!,
    account: _account,
    profile: Profile(
        name: user.profile!.name,
        desc: user.profile!.desc,
        picture: user.profile!.picture,
        blockedUsersList: user.profile?.blockedUsersList),
  );
}