diff --git a/td/generate/scheme/td_api.tl b/td/generate/scheme/td_api.tl index 19728606b..92a5b27ed 100644 --- a/td/generate/scheme/td_api.tl +++ b/td/generate/scheme/td_api.tl @@ -10150,6 +10150,12 @@ createChatSubscriptionInviteLink chat_id:int53 name:string subscription_pricing: //@creates_join_request Pass true if users joining the chat via the link need to be approved by chat administrators. In this case, member_limit must be 0 editChatInviteLink chat_id:int53 invite_link:string name:string expiration_date:int32 member_limit:int32 creates_join_request:Bool = ChatInviteLink; +//@description Edits a subscription invite link for a channel chat. Requires can_invite_users right in the chat for own links and owner privileges for other links +//@chat_id Chat identifier +//@invite_link Invite link to be edited +//@name Invite link name; 0-32 characters +editChatSubscriptionInviteLink chat_id:int53 invite_link:string name:string = ChatInviteLink; + //@description Returns information about an invite link. Requires administrator privileges and can_invite_users right in the chat to get own links and owner privileges to get other links //@chat_id Chat identifier //@invite_link Invite link to get diff --git a/td/telegram/DialogInviteLinkManager.cpp b/td/telegram/DialogInviteLinkManager.cpp index ba2900f22..155dad3e9 100644 --- a/td/telegram/DialogInviteLinkManager.cpp +++ b/td/telegram/DialogInviteLinkManager.cpp @@ -179,15 +179,17 @@ class EditChatInviteLinkQuery final : public Td::ResultHandler { } void send(DialogId dialog_id, const string &invite_link, const string &title, int32 expire_date, int32 usage_limit, - bool creates_join_request) { + bool creates_join_request, bool is_subscription) { dialog_id_ = dialog_id; auto input_peer = td_->dialog_manager_->get_input_peer(dialog_id, AccessRights::Write); CHECK(input_peer != nullptr); - int32 flags = telegram_api::messages_editExportedChatInvite::EXPIRE_DATE_MASK | - telegram_api::messages_editExportedChatInvite::USAGE_LIMIT_MASK | - telegram_api::messages_editExportedChatInvite::REQUEST_NEEDED_MASK | - telegram_api::messages_editExportedChatInvite::TITLE_MASK; + int32 flags = telegram_api::messages_editExportedChatInvite::TITLE_MASK; + if (!is_subscription) { + flags |= telegram_api::messages_editExportedChatInvite::EXPIRE_DATE_MASK | + telegram_api::messages_editExportedChatInvite::USAGE_LIMIT_MASK | + telegram_api::messages_editExportedChatInvite::REQUEST_NEEDED_MASK; + } send_query(G()->net_query_creator().create( telegram_api::messages_editExportedChatInvite(flags, false /*ignored*/, std::move(input_peer), invite_link, expire_date, usage_limit, creates_join_request, title))); @@ -1022,6 +1024,7 @@ void DialogInviteLinkManager::export_dialog_invite_link_impl( void DialogInviteLinkManager::edit_dialog_invite_link(DialogId dialog_id, const string &invite_link, string title, int32 expire_date, int32 usage_limit, bool creates_join_request, + bool is_subscription, Promise> &&promise) { TRY_STATUS_PROMISE(promise, can_manage_dialog_invite_links(dialog_id)); if (creates_join_request && usage_limit > 0) { @@ -1035,7 +1038,7 @@ void DialogInviteLinkManager::edit_dialog_invite_link(DialogId dialog_id, const auto new_title = clean_name(std::move(title), MAX_INVITE_LINK_TITLE_LENGTH); td_->create_handler(std::move(promise)) - ->send(dialog_id, invite_link, new_title, expire_date, usage_limit, creates_join_request); + ->send(dialog_id, invite_link, new_title, expire_date, usage_limit, creates_join_request, is_subscription); } void DialogInviteLinkManager::get_dialog_invite_link(DialogId dialog_id, const string &invite_link, diff --git a/td/telegram/DialogInviteLinkManager.h b/td/telegram/DialogInviteLinkManager.h index 0aadff7f9..5f003b856 100644 --- a/td/telegram/DialogInviteLinkManager.h +++ b/td/telegram/DialogInviteLinkManager.h @@ -61,7 +61,7 @@ class DialogInviteLinkManager final : public Actor { Promise> &&promise); void edit_dialog_invite_link(DialogId dialog_id, const string &link, string title, int32 expire_date, - int32 usage_limit, bool creates_join_request, + int32 usage_limit, bool creates_join_request, bool is_subscription, Promise> &&promise); void get_dialog_invite_link(DialogId dialog_id, const string &invite_link, diff --git a/td/telegram/Td.cpp b/td/telegram/Td.cpp index ff06ab6ff..ffbe4986b 100644 --- a/td/telegram/Td.cpp +++ b/td/telegram/Td.cpp @@ -6804,7 +6804,15 @@ void Td::on_request(uint64 id, td_api::editChatInviteLink &request) { CREATE_REQUEST_PROMISE(); dialog_invite_link_manager_->edit_dialog_invite_link( DialogId(request.chat_id_), request.invite_link_, std::move(request.name_), request.expiration_date_, - request.member_limit_, request.creates_join_request_, std::move(promise)); + request.member_limit_, request.creates_join_request_, false, std::move(promise)); +} + +void Td::on_request(uint64 id, td_api::editChatSubscriptionInviteLink &request) { + CLEAN_INPUT_STRING(request.name_); + CLEAN_INPUT_STRING(request.invite_link_); + CREATE_REQUEST_PROMISE(); + dialog_invite_link_manager_->edit_dialog_invite_link(DialogId(request.chat_id_), request.invite_link_, + std::move(request.name_), 0, 0, false, true, std::move(promise)); } void Td::on_request(uint64 id, td_api::getChatInviteLink &request) { diff --git a/td/telegram/Td.h b/td/telegram/Td.h index 1d824d3d7..8a812a8c9 100644 --- a/td/telegram/Td.h +++ b/td/telegram/Td.h @@ -1280,6 +1280,8 @@ class Td final : public Actor { void on_request(uint64 id, td_api::editChatInviteLink &request); + void on_request(uint64 id, td_api::editChatSubscriptionInviteLink &request); + void on_request(uint64 id, td_api::getChatInviteLink &request); void on_request(uint64 id, const td_api::getChatInviteLinkCounts &request); diff --git a/td/telegram/cli.cpp b/td/telegram/cli.cpp index 526750eed..1ea91980e 100644 --- a/td/telegram/cli.cpp +++ b/td/telegram/cli.cpp @@ -4397,6 +4397,12 @@ class CliClient final : public Actor { get_args(args, chat_id, invite_link, name, expiration_date, member_limit, creates_join_request); send_request(td_api::make_object(chat_id, invite_link, name, expiration_date, member_limit, creates_join_request)); + } else if (op == "ecsil") { + ChatId chat_id; + string invite_link; + string name; + get_args(args, chat_id, invite_link, name); + send_request(td_api::make_object(chat_id, invite_link, name)); } else if (op == "rcil") { ChatId chat_id; string invite_link;