From e584eccc65bbb53d94fed8f658ff0dfae8b47bb9 Mon Sep 17 00:00:00 2001 From: levlam Date: Fri, 22 Jan 2021 19:23:44 +0300 Subject: [PATCH] Add createNewSupergroupChat.for_import. --- td/generate/scheme/td_api.tl | 9 +++++++-- td/generate/scheme/td_api.tlo | Bin 195484 -> 195520 bytes td/telegram/MessagesManager.cpp | 10 +++++++--- td/telegram/MessagesManager.h | 3 ++- td/telegram/Td.cpp | 9 ++++++--- td/telegram/cli.cpp | 10 ++++++---- 6 files changed, 28 insertions(+), 13 deletions(-) diff --git a/td/generate/scheme/td_api.tl b/td/generate/scheme/td_api.tl index 84eeeb526..a8133c92a 100644 --- a/td/generate/scheme/td_api.tl +++ b/td/generate/scheme/td_api.tl @@ -4192,8 +4192,13 @@ 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-128 characters createNewBasicGroupChat user_ids:vector title:string = Chat; -//@description Creates a new supergroup or channel and sends a corresponding messageSupergroupChatCreate. Returns the newly created chat @title Title of the new chat; 1-128 characters @is_channel True, if a channel chat should be created @param_description Chat description; 0-255 characters @location Chat location if a location-based supergroup is being created -createNewSupergroupChat title:string is_channel:Bool description:string location:chatLocation = Chat; +//@description Creates a new supergroup or channel and sends a corresponding messageSupergroupChatCreate. Returns the newly created chat +//@title Title of the new chat; 1-128 characters +//@is_channel True, if a channel chat needs to be created +//@param_description Chat description; 0-255 characters +//@location Chat location if a location-based supergroup is being created +//@for_import True, if the supergroup is created for importing messages using importMessage +createNewSupergroupChat title:string is_channel:Bool description:string location:chatLocation for_import:Bool = Chat; //@description Creates a new secret chat. Returns the newly created chat @user_id Identifier of the target user createNewSecretChat user_id:int32 = Chat; diff --git a/td/generate/scheme/td_api.tlo b/td/generate/scheme/td_api.tlo index 58381c582bb49e03dec3346ba7eb5f3a7ea7bd7c..a78718c4ba47e2d3c617bfe1312343eb63be0fc0 100644 GIT binary patch delta 82 zcmbR9o%_Id?uHh|Eld#}EC-i0pPL@z!KA>*I(cD*`t*h=j4YF7=EzKM;022O^-!Mv m1}MoZ{p`LbS6Y5id}eMz{&YhVCh_STT$m)bt9UY1Yyto-B_3P= delta 63 zcmX@`oqNuA?uHh|Eld#}ENj=5{huD=!KA>*GI?Qz`t*h=K!(g5nduF@jI5LYdMHnq Txyqz5J;0qwV7rGWQ^h6#BE}bI diff --git a/td/telegram/MessagesManager.cpp b/td/telegram/MessagesManager.cpp index 9163426a0..bfd0c76a1 100644 --- a/td/telegram/MessagesManager.cpp +++ b/td/telegram/MessagesManager.cpp @@ -975,7 +975,7 @@ class CreateChannelQuery : public Td::ResultHandler { } void send(const string &title, bool is_megagroup, const string &about, const DialogLocation &location, - int64 random_id) { + bool for_import, int64 random_id) { int32 flags = 0; if (is_megagroup) { flags |= telegram_api::channels_createChannel::MEGAGROUP_MASK; @@ -985,6 +985,9 @@ class CreateChannelQuery : public Td::ResultHandler { if (!location.empty()) { flags |= telegram_api::channels_createChannel::GEO_POINT_MASK; } + if (for_import) { + flags |= telegram_api::channels_createChannel::FOR_IMPORT_MASK; + } random_id_ = random_id; send_query(G()->net_query_creator().create( @@ -18979,7 +18982,7 @@ DialogId MessagesManager::create_new_group_chat(const vector &user_ids, } DialogId MessagesManager::create_new_channel_chat(const string &title, bool is_megagroup, const string &description, - const DialogLocation &location, int64 &random_id, + const DialogLocation &location, bool for_import, int64 &random_id, Promise &&promise) { LOG(INFO) << "Trying to create " << (is_megagroup ? "supergroup" : "broadcast") << " with title \"" << title << "\", description \"" << description << "\" and " << location; @@ -19014,7 +19017,8 @@ DialogId MessagesManager::create_new_channel_chat(const string &title, bool is_m created_dialogs_[random_id]; // reserve place for result td_->create_handler(std::move(promise)) - ->send(new_title, is_megagroup, strip_empty_characters(description, MAX_DESCRIPTION_LENGTH), location, random_id); + ->send(new_title, is_megagroup, strip_empty_characters(description, MAX_DESCRIPTION_LENGTH), location, for_import, + random_id); return DialogId(); } diff --git a/td/telegram/MessagesManager.h b/td/telegram/MessagesManager.h index 02549acd2..0758bf38b 100644 --- a/td/telegram/MessagesManager.h +++ b/td/telegram/MessagesManager.h @@ -637,7 +637,8 @@ class MessagesManager : public Actor { Promise &&promise); DialogId create_new_channel_chat(const string &title, bool is_megagroup, const string &description, - const DialogLocation &location, int64 &random_id, Promise &&promise); + const DialogLocation &location, bool for_import, int64 &random_id, + Promise &&promise); void create_new_secret_chat(UserId user_id, Promise &&promise); diff --git a/td/telegram/Td.cpp b/td/telegram/Td.cpp index 31e3b8d37..4797bfba1 100644 --- a/td/telegram/Td.cpp +++ b/td/telegram/Td.cpp @@ -1888,13 +1888,14 @@ class CreateNewSupergroupChatRequest : public RequestActor<> { bool is_megagroup_; string description_; DialogLocation location_; + bool for_import_; int64 random_id_; DialogId dialog_id_; void do_run(Promise &&promise) override { dialog_id_ = td->messages_manager_->create_new_channel_chat(title_, is_megagroup_, description_, location_, - random_id_, std::move(promise)); + for_import_, random_id_, std::move(promise)); } void do_send_result() override { @@ -1904,12 +1905,14 @@ class CreateNewSupergroupChatRequest : public RequestActor<> { public: CreateNewSupergroupChatRequest(ActorShared td, uint64 request_id, string title, bool is_megagroup, - string description, td_api::object_ptr &&location) + string description, td_api::object_ptr &&location, + bool for_import) : RequestActor(std::move(td), request_id) , title_(std::move(title)) , is_megagroup_(is_megagroup) , description_(std::move(description)) , location_(std::move(location)) + , for_import_(for_import) , random_id_(0) { } }; @@ -5873,7 +5876,7 @@ void Td::on_request(uint64 id, td_api::createNewSupergroupChat &request) { CLEAN_INPUT_STRING(request.title_); CLEAN_INPUT_STRING(request.description_); CREATE_REQUEST(CreateNewSupergroupChatRequest, std::move(request.title_), !request.is_channel_, - std::move(request.description_), std::move(request.location_)); + std::move(request.description_), std::move(request.location_), request.for_import_); } void Td::on_request(uint64 id, td_api::createNewSecretChat &request) { CREATE_REQUEST(CreateNewSecretChatRequest, request.user_id_); diff --git a/td/telegram/cli.cpp b/td/telegram/cli.cpp index 706e8d128..3f1f6a634 100644 --- a/td/telegram/cli.cpp +++ b/td/telegram/cli.cpp @@ -3438,13 +3438,15 @@ class CliClient final : public Actor { get_args(args, user_ids_string, title); send_request(td_api::make_object(as_user_ids(user_ids_string), title)); } else if (op == "cnchc") { - send_request(td_api::make_object(args, true, "Description", nullptr)); + send_request(td_api::make_object(args, true, "Description", nullptr, false)); } else if (op == "cnsgc") { - send_request(td_api::make_object(args, false, "Description", nullptr)); + send_request(td_api::make_object(args, false, "Description", nullptr, false)); } else if (op == "cnsgcloc") { send_request(td_api::make_object( - args, false, "Description", - td_api::make_object(as_location("40.0", "60.0"), "address"))); + args, false, "Description", td_api::make_object(as_location("40.0", "60.0"), "address"), + false)); + } else if (op == "cnsgcimport") { + send_request(td_api::make_object(args, false, "Description", nullptr, true)); } else if (op == "UpgradeBasicGroupChatToSupergroupChat") { send_request(td_api::make_object(as_chat_id(args))); } else if (op == "DeleteChat") {