diff --git a/CMakeLists.txt b/CMakeLists.txt index aa2c6147..4f2703a5 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,6 +1,6 @@ cmake_minimum_required(VERSION 3.0.2 FATAL_ERROR) -project(TDLib VERSION 1.0.4 LANGUAGES CXX C) +project(TDLib VERSION 1.0.5 LANGUAGES CXX C) option(TD_ENABLE_JNI "Use \"ON\" to enable JNI-compatible TDLib API.") diff --git a/README.md b/README.md index fca3420b..87e19cc2 100644 --- a/README.md +++ b/README.md @@ -81,7 +81,7 @@ target_link_library(YourLibrary Td::TdJson) Or you could install `TDLib` and then reference it in your CMakeLists.txt like this: ``` -find_package(Td 1.0.4) +find_package(Td 1.0.5) target_link_library(YourLibrary Td::TdJson) ``` See [example/cpp/CMakeLists.txt](https://github.com/tdlib/td/tree/master/example/cpp/CMakeLists.txt). diff --git a/example/cpp/CMakeLists.txt b/example/cpp/CMakeLists.txt index 651aa620..e5bf1d5c 100644 --- a/example/cpp/CMakeLists.txt +++ b/example/cpp/CMakeLists.txt @@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 3.1 FATAL_ERROR) project(TdExample VERSION 1.0 LANGUAGES CXX) -find_package(Td 1.0.4 REQUIRED) +find_package(Td 1.0.5 REQUIRED) add_executable(tdjson_example tdjson_example.cpp) target_link_libraries(tdjson_example PRIVATE Td::TdJson) diff --git a/td/generate/scheme/td_api.tl b/td/generate/scheme/td_api.tl index a0a26229..8b432598 100644 --- a/td/generate/scheme/td_api.tl +++ b/td/generate/scheme/td_api.tl @@ -2263,16 +2263,16 @@ openMessageContent chat_id:int53 message_id:int53 = Ok; readAllChatMentions chat_id:int53 = Ok; -//@description Returns an existing chat corresponding to a given user @user_id User identifier -createPrivateChat user_id:int32 = Chat; +//@description Returns an existing chat corresponding to a given user @user_id User identifier @force If true, the chat will be created without network request. In this case all information about the chat except its type, title and photo can be incorrect +createPrivateChat user_id:int32 force:Bool = Chat; -//@description Returns an existing chat corresponding to a known basic group @basic_group_id Basic group identifier -createBasicGroupChat basic_group_id:int32 = Chat; +//@description Returns an existing chat corresponding to a known basic group @basic_group_id Basic group identifier @force If true, the chat will be created without network request. In this case all information about the chat except its type, title and photo can be incorrect +createBasicGroupChat basic_group_id:int32 force:Bool = Chat; -//@description Returns an existing chat corresponding to a known supergroup or channel @supergroup_id Supergroup or channel identifier -createSupergroupChat supergroup_id:int32 = Chat; +//@description Returns an existing chat corresponding to a known supergroup or channel @supergroup_id Supergroup or channel identifier @force If true, the chat will be created without network request. In this case all information about the chat except its type, title and photo can be incorrect +createSupergroupChat supergroup_id:int32 force:Bool = Chat; -//@description Returns an existing chat corresponding to a known secret chat @secret_chat_id Secret Chat identifier +//@description Returns an existing chat corresponding to a known secret chat @secret_chat_id Secret chat identifier createSecretChat secret_chat_id:int32 = Chat; //@description Creates a new basic group and sends a corresponding messageBasicGroupChatCreate. Returns the newly created chat @user_ids Identifiers of users to be added to the basic group @title Title of the new basic group; 1-255 characters diff --git a/td/generate/scheme/td_api.tlo b/td/generate/scheme/td_api.tlo index ab286810..53e52e8e 100644 Binary files a/td/generate/scheme/td_api.tlo and b/td/generate/scheme/td_api.tlo differ diff --git a/td/telegram/MessagesManager.cpp b/td/telegram/MessagesManager.cpp index a01aa5a8..f803d123 100644 --- a/td/telegram/MessagesManager.cpp +++ b/td/telegram/MessagesManager.cpp @@ -11366,7 +11366,7 @@ Status MessagesManager::set_dialog_client_data(DialogId dialog_id, string &&clie return Status::OK(); } -void MessagesManager::create_dialog(DialogId dialog_id, Promise &&promise) { +void MessagesManager::create_dialog(DialogId dialog_id, bool force, Promise &&promise) { if (!have_input_peer(dialog_id, AccessRights::Read)) { if (!have_dialog_info_force(dialog_id)) { return promise.set_error(Status::Error(6, "Chat info not found")); @@ -11376,7 +11376,7 @@ void MessagesManager::create_dialog(DialogId dialog_id, Promise &&promise) } } - if (td_->auth_manager_->is_bot() || dialog_id.get_type() == DialogType::SecretChat) { + if (force || td_->auth_manager_->is_bot() || dialog_id.get_type() == DialogType::SecretChat) { force_create_dialog(dialog_id, "create dialog"); } else { const Dialog *d = get_dialog_force(dialog_id); diff --git a/td/telegram/MessagesManager.h b/td/telegram/MessagesManager.h index 6f765bed..3f4ed1a0 100644 --- a/td/telegram/MessagesManager.h +++ b/td/telegram/MessagesManager.h @@ -1122,7 +1122,7 @@ class MessagesManager : public Actor { Status set_dialog_client_data(DialogId dialog_id, string &&client_data) TD_WARN_UNUSED_RESULT; - void create_dialog(DialogId dialog_id, Promise &&promise); + void create_dialog(DialogId dialog_id, bool force, Promise &&promise); DialogId create_new_group_chat(const vector &user_ids, const string &title, int64 &random_id, Promise &&promise); diff --git a/td/telegram/Td.cpp b/td/telegram/Td.cpp index ca8e03aa..9f7541e4 100644 --- a/td/telegram/Td.cpp +++ b/td/telegram/Td.cpp @@ -1667,9 +1667,10 @@ class GetWebPageInstantViewRequest : public RequestActor<> { class CreateChatRequest : public RequestActor<> { DialogId dialog_id_; + bool force_; void do_run(Promise &&promise) override { - td->messages_manager_->create_dialog(dialog_id_, std::move(promise)); + td->messages_manager_->create_dialog(dialog_id_, force_, std::move(promise)); } void do_send_result() override { @@ -1677,8 +1678,8 @@ class CreateChatRequest : public RequestActor<> { } public: - CreateChatRequest(ActorShared td, uint64 request_id, DialogId dialog_id) - : RequestActor<>(std::move(td), request_id), dialog_id_(dialog_id) { + CreateChatRequest(ActorShared td, uint64 request_id, DialogId dialog_id, bool force) + : RequestActor<>(std::move(td), request_id), dialog_id_(dialog_id), force_(force) { } }; @@ -5344,22 +5345,22 @@ void Td::on_request(uint64 id, td_api::getWebPageInstantView &request) { void Td::on_request(uint64 id, const td_api::createPrivateChat &request) { CHECK_AUTH(); - CREATE_REQUEST(CreateChatRequest, DialogId(UserId(request.user_id_))); + CREATE_REQUEST(CreateChatRequest, DialogId(UserId(request.user_id_)), request.force_); } void Td::on_request(uint64 id, const td_api::createBasicGroupChat &request) { CHECK_AUTH(); - CREATE_REQUEST(CreateChatRequest, DialogId(ChatId(request.basic_group_id_))); + CREATE_REQUEST(CreateChatRequest, DialogId(ChatId(request.basic_group_id_)), request.force_); } void Td::on_request(uint64 id, const td_api::createSupergroupChat &request) { CHECK_AUTH(); - CREATE_REQUEST(CreateChatRequest, DialogId(ChannelId(request.supergroup_id_))); + CREATE_REQUEST(CreateChatRequest, DialogId(ChannelId(request.supergroup_id_)), request.force_); } void Td::on_request(uint64 id, td_api::createSecretChat &request) { CHECK_AUTH(); - CREATE_REQUEST(CreateChatRequest, DialogId(SecretChatId(request.secret_chat_id_))); + CREATE_REQUEST(CreateChatRequest, DialogId(SecretChatId(request.secret_chat_id_)), true); } void Td::on_request(uint64 id, td_api::createNewBasicGroupChat &request) { diff --git a/td/telegram/Td.h b/td/telegram/Td.h index a97cef3a..66d94a50 100644 --- a/td/telegram/Td.h +++ b/td/telegram/Td.h @@ -187,7 +187,7 @@ class Td final : public NetQueryCallback { static td_api::object_ptr static_request(td_api::object_ptr function); private: - static constexpr const char *tdlib_version = "1.0.4"; + static constexpr const char *tdlib_version = "1.0.5"; static constexpr int32 ONLINE_TIMEOUT = 240; void send_result(uint64 id, tl_object_ptr object); diff --git a/td/telegram/cli.cpp b/td/telegram/cli.cpp index 5f352eed..ed9be04d 100644 --- a/td/telegram/cli.cpp +++ b/td/telegram/cli.cpp @@ -2429,11 +2429,23 @@ class CliClient final : public Actor { } else if (op == "gcpc") { send_request(make_tl_object()); } else if (op == "cpc") { - send_request(make_tl_object(as_user_id(args))); + string user_id; + string force; + + std::tie(user_id, force) = split(args); + send_request(make_tl_object(as_user_id(user_id), as_bool(force))); } else if (op == "cbgc") { - send_request(make_tl_object(to_integer(args))); + string basic_group_id; + string force; + + std::tie(basic_group_id, force) = split(args); + send_request(make_tl_object(to_integer(basic_group_id), as_bool(force))); } else if (op == "csgc" || op == "cchc") { - send_request(make_tl_object(to_integer(args))); + string supergroup_id; + string force; + + std::tie(supergroup_id, force) = split(args); + send_request(make_tl_object(to_integer(supergroup_id), as_bool(force))); } else if (op == "sct") { string chat_id; string title; diff --git a/test/tdclient.cpp b/test/tdclient.cpp index ca1214ba..b3bfb40b 100644 --- a/test/tdclient.cpp +++ b/test/tdclient.cpp @@ -301,7 +301,7 @@ class SetUsername : public Task { void send_self_message() { tag_ = PSTRING() << format::as_hex(Random::secure_int64()); - send_query(make_tl_object(self_id_), [this](auto res) { + send_query(make_tl_object(self_id_, false), [this](auto res) { CHECK(res->get_id() == td_api::chat::ID); auto chat = move_tl_object_as(res); this->send_query(