block method

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

Implementation

Future<User?> block({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) {
    user.profile?.blockedUsersList = [];
  }

  user.profile?.blockedUsersList =
      <String>{...user.profile!.blockedUsersList!, ...users}.toList();

  if (_decryptedPgpPvtKey == null) {
    throw Exception(PushAPI.ensureSignerMessage());
  }

  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),
  );
}