Add getChatInviteLinkMembers.only_with_expired_subscription.

This commit is contained in:
levlam 2024-08-12 19:19:36 +03:00
parent e579dd6823
commit c51648459e
5 changed files with 17 additions and 11 deletions

View File

@ -10154,9 +10154,10 @@ getChatInviteLinks chat_id:int53 creator_user_id:int53 is_revoked:Bool offset_da
//@description Returns chat members joined a chat via an invite link. Requires administrator privileges and can_invite_users right in the chat for own links and owner privileges for other links
//@chat_id Chat identifier
//@invite_link Invite link for which to return chat members
//@only_with_expired_subscription True, if the link is a subscription link and only members with expired subscription must be returned
//@offset_member A chat member from which to return next chat members; pass null to get results from the beginning
//@limit The maximum number of chat members to return; up to 100
getChatInviteLinkMembers chat_id:int53 invite_link:string offset_member:chatInviteLinkMember limit:int32 = ChatInviteLinkMembers;
getChatInviteLinkMembers chat_id:int53 invite_link:string only_with_expired_subscription:Bool offset_member:chatInviteLinkMember limit:int32 = ChatInviteLinkMembers;
//@description Revokes invite link for a chat. Available for basic groups, supergroups, and channels. Requires administrator privileges and can_invite_users right in the chat for own links and owner privileges for other links.
//-If a primary link is revoked, then additionally to the revoked link returns new primary link

View File

@ -391,7 +391,8 @@ class GetChatInviteImportersQuery final : public Td::ResultHandler {
: promise_(std::move(promise)) {
}
void send(DialogId dialog_id, const string &invite_link, int32 offset_date, UserId offset_user_id, int32 limit) {
void send(DialogId dialog_id, const string &invite_link, bool subscription_expired, int32 offset_date,
UserId offset_user_id, int32 limit) {
dialog_id_ = dialog_id;
auto input_peer = td_->dialog_manager_->get_input_peer(dialog_id, AccessRights::Write);
CHECK(input_peer != nullptr);
@ -402,6 +403,9 @@ class GetChatInviteImportersQuery final : public Td::ResultHandler {
}
int32 flags = telegram_api::messages_getChatInviteImporters::LINK_MASK;
if (subscription_expired) {
flags |= telegram_api::messages_getChatInviteImporters::SUBSCRIPTION_EXPIRED_MASK;
}
send_query(G()->net_query_creator().create(telegram_api::messages_getChatInviteImporters(
flags, false /*ignored*/, false /*ignored*/, std::move(input_peer), invite_link, string(), offset_date,
r_input_user.move_as_ok(), limit)));
@ -1060,8 +1064,9 @@ void DialogInviteLinkManager::get_dialog_invite_links(DialogId dialog_id, UserId
}
void DialogInviteLinkManager::get_dialog_invite_link_users(
DialogId dialog_id, const string &invite_link, td_api::object_ptr<td_api::chatInviteLinkMember> offset_member,
int32 limit, Promise<td_api::object_ptr<td_api::chatInviteLinkMembers>> &&promise) {
DialogId dialog_id, const string &invite_link, bool subscription_expired,
td_api::object_ptr<td_api::chatInviteLinkMember> offset_member, int32 limit,
Promise<td_api::object_ptr<td_api::chatInviteLinkMembers>> &&promise) {
TRY_STATUS_PROMISE(promise, can_manage_dialog_invite_links(dialog_id));
if (limit <= 0) {
@ -1080,7 +1085,7 @@ void DialogInviteLinkManager::get_dialog_invite_link_users(
}
td_->create_handler<GetChatInviteImportersQuery>(std::move(promise))
->send(dialog_id, invite_link, offset_date, offset_user_id, limit);
->send(dialog_id, invite_link, subscription_expired, offset_date, offset_user_id, limit);
}
void DialogInviteLinkManager::revoke_dialog_invite_link(

View File

@ -73,7 +73,7 @@ class DialogInviteLinkManager final : public Actor {
const string &offset_invite_link, int32 limit,
Promise<td_api::object_ptr<td_api::chatInviteLinks>> &&promise);
void get_dialog_invite_link_users(DialogId dialog_id, const string &invite_link,
void get_dialog_invite_link_users(DialogId dialog_id, const string &invite_link, bool subscription_expired,
td_api::object_ptr<td_api::chatInviteLinkMember> offset_member, int32 limit,
Promise<td_api::object_ptr<td_api::chatInviteLinkMembers>> &&promise);

View File

@ -6827,9 +6827,9 @@ void Td::on_request(uint64 id, td_api::getChatInviteLinkMembers &request) {
CHECK_IS_USER();
CLEAN_INPUT_STRING(request.invite_link_);
CREATE_REQUEST_PROMISE();
dialog_invite_link_manager_->get_dialog_invite_link_users(DialogId(request.chat_id_), request.invite_link_,
std::move(request.offset_member_), request.limit_,
std::move(promise));
dialog_invite_link_manager_->get_dialog_invite_link_users(
DialogId(request.chat_id_), request.invite_link_, request.only_with_expired_subscription_,
std::move(request.offset_member_), request.limit_, std::move(promise));
}
void Td::on_request(uint64 id, td_api::getChatJoinRequests &request) {

View File

@ -4413,7 +4413,7 @@ class CliClient final : public Actor {
get_args(args, chat_id, creator_user_id, offset_date, offset_invite_link, limit);
send_request(td_api::make_object<td_api::getChatInviteLinks>(chat_id, creator_user_id, op == "gcilr", offset_date,
offset_invite_link, as_limit(limit)));
} else if (op == "gcilm") {
} else if (op == "gcilm" || op == "gcilme") {
ChatId chat_id;
string invite_link;
UserId offset_user_id;
@ -4421,7 +4421,7 @@ class CliClient final : public Actor {
string limit;
get_args(args, chat_id, invite_link, offset_user_id, offset_date, limit);
send_request(td_api::make_object<td_api::getChatInviteLinkMembers>(
chat_id, invite_link,
chat_id, invite_link, op == "gcilme",
td_api::make_object<td_api::chatInviteLinkMember>(offset_user_id, offset_date, false, 0), as_limit(limit)));
} else if (op == "gcjr") {
ChatId chat_id;