blockedChatMembers method

Future<Map> blockedChatMembers({
  1. required dynamic chat_id,
  2. bool is_delete_chat_history = false,
  3. bool remove_from_chat_list = false,
  4. bool revoke = false,
  5. bool is_blocked = true,
  6. required int clientId,
  7. bool isVoid = false,
  8. Duration? delayDuration,
  9. Duration? delayLoop,
  10. Duration? invokeTimeOut,
  11. String? extra,
  12. dynamic onProcces(
    1. Map data,
    2. int client_id
    )?,
  13. bool? isUseCache,
  14. Duration? durationCacheExpire,
})

delete chat history

Implementation

Future<Map> blockedChatMembers({
  required chat_id,
  bool is_delete_chat_history = false,
  bool remove_from_chat_list = false,
  bool revoke = false,
  bool is_blocked = true,
  required int clientId,
  bool isVoid = false,
  Duration? delayDuration,
  Duration? delayLoop,
  Duration? invokeTimeOut,
  String? extra,
  dynamic Function(Map data, int client_id)? onProcces,
  bool? isUseCache,
  Duration? durationCacheExpire,
}) async {
  delayLoop ??= Duration(milliseconds: 500);
  Map members = await getAllMembers(
    chat_id: chat_id,
    clientId: clientId,
    onProcces: onProcces,
    isUseCache: isUseCache,
    durationCacheExpire: durationCacheExpire,
  );
  late Map jsonRespond = {
    "@type": "users",
    "users": [],
  };
  if (members["user_ids"] is List) {
    late List<Map> users = [];
    List<int> member_user_ids = (members["user_ids"] as List).cast<int>();
    for (var i = 0; i < member_user_ids.length; i++) {
      int user_id = member_user_ids[i];
      await Future.delayed(delayLoop);
      try {
        Map toggle_message_sender_is_blocked =
            await toggleMessageSenderIsBlocked(
          user_id: user_id,
          is_blocked: is_blocked,
          clientId: clientId,
          isVoid: isVoid,
          isUseCache: isUseCache,
          durationCacheExpire: durationCacheExpire,
        );
        toggle_message_sender_is_blocked["user_id"] = user_id;
        users.add(toggle_message_sender_is_blocked);
        if (is_delete_chat_history) {
          await Future.delayed(delayLoop);
          try {
            await deleteChatHistory(
              chat_id: user_id,
              remove_from_chat_list: remove_from_chat_list,
              revoke: revoke,
              clientId: clientId,
              isVoid: isVoid,
              isUseCache: isUseCache,
              durationCacheExpire: durationCacheExpire,
            );
          } catch (e) {}
        }
      } catch (e) {
        users.add({"@type": "error", "user_id": user_id});
      }
    }
    try {
      jsonRespond["users"] = users;
    } catch (e) {}
  }
  return jsonRespond;
}