From 8ced3a1e603e7ff5a51b11f8262e189953d55046 Mon Sep 17 00:00:00 2001 From: levlam Date: Thu, 2 May 2024 17:10:28 +0300 Subject: [PATCH] Reget inaccessible users. --- telegram-bot-api/Client.cpp | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/telegram-bot-api/Client.cpp b/telegram-bot-api/Client.cpp index 4f12f8e..1492853 100644 --- a/telegram-bot-api/Client.cpp +++ b/telegram-bot-api/Client.cpp @@ -5837,7 +5837,7 @@ void Client::check_user_read_access(const UserInfo *user_info, PromisedQueryPtr template void Client::check_user(int64 user_id, PromisedQueryPtr query, OnSuccess on_success) { const UserInfo *user_info = get_user_info(user_id); - if (user_info != nullptr) { + if (user_info != nullptr && user_info->have_access) { return check_user_read_access(user_info, std::move(query), std::move(on_success)); } send_request(make_object(user_id), @@ -5847,7 +5847,7 @@ void Client::check_user(int64 user_id, PromisedQueryPtr query, OnSuccess on_succ template void Client::check_user_no_fail(int64 user_id, PromisedQueryPtr query, OnSuccess on_success) { const UserInfo *user_info = get_user_info(user_id); - if (user_info != nullptr) { + if (user_info != nullptr && user_info->have_access) { on_success(std::move(query)); return; } @@ -5943,6 +5943,12 @@ void Client::check_chat(td::Slice chat_id_str, AccessRights access_rights, Promi auto chat_id = td::to_integer(chat_id_str); auto chat_info = get_chat(chat_id); + if (chat_info != nullptr && chat_info->type == ChatInfo::Type::Private) { + const UserInfo *user_info = get_user_info(chat_info->user_id); + if (user_info == nullptr || !user_info->have_access) { + chat_info = nullptr; + } + } if (chat_info != nullptr) { return check_chat_access(chat_id, access_rights, chat_info, std::move(query), std::move(on_success)); } @@ -5964,6 +5970,12 @@ void Client::check_chat_no_fail(td::Slice chat_id_str, PromisedQueryPtr query, O auto chat_id = r_chat_id.move_as_ok(); auto chat_info = get_chat(chat_id); + if (chat_info != nullptr && chat_info->type == ChatInfo::Type::Private) { + const UserInfo *user_info = get_user_info(chat_info->user_id); + if (user_info == nullptr || !user_info->have_access) { + chat_info = nullptr; + } + } if (chat_info != nullptr) { return on_success(chat_id, std::move(query)); }