Add td_api::editChatSubscriptionInviteLink.

This commit is contained in:
levlam 2024-08-14 00:15:49 +03:00
parent 8cefcc6ac7
commit 190aeb0849
6 changed files with 33 additions and 8 deletions

View File

@ -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 //@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; 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 //@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 //@chat_id Chat identifier
//@invite_link Invite link to get //@invite_link Invite link to get

View File

@ -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, 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; dialog_id_ = dialog_id;
auto input_peer = td_->dialog_manager_->get_input_peer(dialog_id, AccessRights::Write); auto input_peer = td_->dialog_manager_->get_input_peer(dialog_id, AccessRights::Write);
CHECK(input_peer != nullptr); CHECK(input_peer != nullptr);
int32 flags = telegram_api::messages_editExportedChatInvite::EXPIRE_DATE_MASK | int32 flags = telegram_api::messages_editExportedChatInvite::TITLE_MASK;
telegram_api::messages_editExportedChatInvite::USAGE_LIMIT_MASK | if (!is_subscription) {
telegram_api::messages_editExportedChatInvite::REQUEST_NEEDED_MASK | flags |= telegram_api::messages_editExportedChatInvite::EXPIRE_DATE_MASK |
telegram_api::messages_editExportedChatInvite::TITLE_MASK; telegram_api::messages_editExportedChatInvite::USAGE_LIMIT_MASK |
telegram_api::messages_editExportedChatInvite::REQUEST_NEEDED_MASK;
}
send_query(G()->net_query_creator().create( send_query(G()->net_query_creator().create(
telegram_api::messages_editExportedChatInvite(flags, false /*ignored*/, std::move(input_peer), invite_link, telegram_api::messages_editExportedChatInvite(flags, false /*ignored*/, std::move(input_peer), invite_link,
expire_date, usage_limit, creates_join_request, title))); 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, 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, int32 expire_date, int32 usage_limit, bool creates_join_request,
bool is_subscription,
Promise<td_api::object_ptr<td_api::chatInviteLink>> &&promise) { Promise<td_api::object_ptr<td_api::chatInviteLink>> &&promise) {
TRY_STATUS_PROMISE(promise, can_manage_dialog_invite_links(dialog_id)); TRY_STATUS_PROMISE(promise, can_manage_dialog_invite_links(dialog_id));
if (creates_join_request && usage_limit > 0) { 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); auto new_title = clean_name(std::move(title), MAX_INVITE_LINK_TITLE_LENGTH);
td_->create_handler<EditChatInviteLinkQuery>(std::move(promise)) td_->create_handler<EditChatInviteLinkQuery>(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, void DialogInviteLinkManager::get_dialog_invite_link(DialogId dialog_id, const string &invite_link,

View File

@ -61,7 +61,7 @@ class DialogInviteLinkManager final : public Actor {
Promise<td_api::object_ptr<td_api::chatInviteLink>> &&promise); Promise<td_api::object_ptr<td_api::chatInviteLink>> &&promise);
void edit_dialog_invite_link(DialogId dialog_id, const string &link, string title, int32 expire_date, 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<td_api::object_ptr<td_api::chatInviteLink>> &&promise); Promise<td_api::object_ptr<td_api::chatInviteLink>> &&promise);
void get_dialog_invite_link(DialogId dialog_id, const string &invite_link, void get_dialog_invite_link(DialogId dialog_id, const string &invite_link,

View File

@ -6804,7 +6804,15 @@ void Td::on_request(uint64 id, td_api::editChatInviteLink &request) {
CREATE_REQUEST_PROMISE(); CREATE_REQUEST_PROMISE();
dialog_invite_link_manager_->edit_dialog_invite_link( dialog_invite_link_manager_->edit_dialog_invite_link(
DialogId(request.chat_id_), request.invite_link_, std::move(request.name_), request.expiration_date_, 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) { void Td::on_request(uint64 id, td_api::getChatInviteLink &request) {

View File

@ -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::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, td_api::getChatInviteLink &request);
void on_request(uint64 id, const td_api::getChatInviteLinkCounts &request); void on_request(uint64 id, const td_api::getChatInviteLinkCounts &request);

View File

@ -4397,6 +4397,12 @@ class CliClient final : public Actor {
get_args(args, chat_id, invite_link, name, expiration_date, member_limit, creates_join_request); get_args(args, chat_id, invite_link, name, expiration_date, member_limit, creates_join_request);
send_request(td_api::make_object<td_api::editChatInviteLink>(chat_id, invite_link, name, expiration_date, send_request(td_api::make_object<td_api::editChatInviteLink>(chat_id, invite_link, name, expiration_date,
member_limit, creates_join_request)); 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<td_api::editChatSubscriptionInviteLink>(chat_id, invite_link, name));
} else if (op == "rcil") { } else if (op == "rcil") {
ChatId chat_id; ChatId chat_id;
string invite_link; string invite_link;