From aa6be7d9bf9dd6ede31f5c961c6b8d79c1972955 Mon Sep 17 00:00:00 2001 From: levlam Date: Fri, 26 Jan 2024 14:06:27 +0300 Subject: [PATCH] Add canSendMessageToUser.only_local. --- td/generate/scheme/td_api.tl | 6 ++++-- td/telegram/ContactsManager.cpp | 1 - td/telegram/Td.cpp | 2 +- td/telegram/cli.cpp | 4 ++-- 4 files changed, 7 insertions(+), 6 deletions(-) diff --git a/td/generate/scheme/td_api.tl b/td/generate/scheme/td_api.tl index 2bab566cf..999fef21d 100644 --- a/td/generate/scheme/td_api.tl +++ b/td/generate/scheme/td_api.tl @@ -9538,8 +9538,10 @@ setNewChatPrivacySettings settings:newChatPrivacySettings = Ok; getNewChatPrivacySettings = NewChatPrivacySettings; -//@description Check whether the current user can message another user or try to create a chat with them @user_id Identifier of the other user -canSendMessageToUser user_id:int53 = CanSendMessageToUserResult; +//@description Check whether the current user can message another user or try to create a chat with them +//@user_id Identifier of the other user +//@only_local Pass true to get only locally available information without sending network requests +canSendMessageToUser user_id:int53 only_local:Bool = CanSendMessageToUserResult; //@description Returns the value of an option by its name. (Check the list of available options on https://core.telegram.org/tdlib/options.) Can be called before authorization. Can be called synchronously for options "version" and "commit_hash" diff --git a/td/telegram/ContactsManager.cpp b/td/telegram/ContactsManager.cpp index b5781ae63..b53e6a57f 100644 --- a/td/telegram/ContactsManager.cpp +++ b/td/telegram/ContactsManager.cpp @@ -5561,7 +5561,6 @@ void ContactsManager::can_send_message_to_user( } if (force) { - LOG(ERROR) << "Can't check " << user_id << " message privacy settings"; return promise.set_value(td_api::make_object()); } diff --git a/td/telegram/Td.cpp b/td/telegram/Td.cpp index acd0fbbc1..e86772c81 100644 --- a/td/telegram/Td.cpp +++ b/td/telegram/Td.cpp @@ -6531,7 +6531,7 @@ void Td::on_request(uint64 id, td_api::setNewChatPrivacySettings &request) { void Td::on_request(uint64 id, const td_api::canSendMessageToUser &request) { CHECK_IS_USER(); CREATE_REQUEST_PROMISE(); - contacts_manager_->can_send_message_to_user(UserId(request.user_id_), false, std::move(promise)); + contacts_manager_->can_send_message_to_user(UserId(request.user_id_), request.only_local_, std::move(promise)); } void Td::on_request(uint64 id, td_api::setChatTitle &request) { diff --git a/td/telegram/cli.cpp b/td/telegram/cli.cpp index 80167349f..f6b5823fe 100644 --- a/td/telegram/cli.cpp +++ b/td/telegram/cli.cpp @@ -5449,10 +5449,10 @@ class CliClient final : public Actor { get_args(args, allow_new_chats_from_unknown_users); auto settings = td_api::make_object(allow_new_chats_from_unknown_users); send_request(td_api::make_object(std::move(settings))); - } else if (op == "csmtu") { + } else if (op == "csmtu" || op == "csmtul") { UserId user_id; get_args(args, user_id); - send_request(td_api::make_object(user_id)); + send_request(td_api::make_object(user_id, op == "csmtul")); } else if (op == "sct") { ChatId chat_id; string title;