Support deletion of all revoked invite links created by other administrator.
This commit is contained in:
parent
4d8fad1e81
commit
342b4e45ca
@ -4465,8 +4465,10 @@ revokeChatInviteLink chat_id:int53 invite_link:string = ChatInviteLink;
|
|||||||
//@description Deletes revoked chat invite links. 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 to revoke
|
//@description Deletes revoked chat invite links. 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 to revoke
|
||||||
deleteRevokedChatInviteLink chat_id:int53 invite_link:string = Ok;
|
deleteRevokedChatInviteLink chat_id:int53 invite_link:string = Ok;
|
||||||
|
|
||||||
//@description Deletes all revoked chat invite links. Requires administrator privileges and can_invite_users right in the chat for own links and owner privileges for other links @chat_id Chat identifier
|
//@description Deletes all revoked chat invite links created by a given chat administrator. Requires administrator privileges and can_invite_users right in the chat for own links and owner privileges for other links
|
||||||
deleteAllRevokedChatInviteLinks chat_id:int53 = Ok;
|
//@chat_id Chat identifier
|
||||||
|
//@administrator_user_id User identifier of a chat administrator, which links will be deleted. Must be an identifier of the current user for non-owner
|
||||||
|
deleteAllRevokedChatInviteLinks chat_id:int53 administrator_user_id:int32 = Ok;
|
||||||
|
|
||||||
//@description Checks the validity of an invite link for a chat and returns information about the corresponding chat @invite_link Invite link to be checked; must have URL "t.me", "telegram.me", or "telegram.dog" and query beginning with "/joinchat/" or "/+"
|
//@description Checks the validity of an invite link for a chat and returns information about the corresponding chat @invite_link Invite link to be checked; must have URL "t.me", "telegram.me", or "telegram.dog" and query beginning with "/joinchat/" or "/+"
|
||||||
checkChatInviteLink invite_link:string = ChatInviteLinkInfo;
|
checkChatInviteLink invite_link:string = ChatInviteLinkInfo;
|
||||||
|
Binary file not shown.
@ -1895,15 +1895,18 @@ class DeleteRevokedExportedChatInvitesQuery : public Td::ResultHandler {
|
|||||||
explicit DeleteRevokedExportedChatInvitesQuery(Promise<Unit> &&promise) : promise_(std::move(promise)) {
|
explicit DeleteRevokedExportedChatInvitesQuery(Promise<Unit> &&promise) : promise_(std::move(promise)) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void send(DialogId dialog_id) {
|
void send(DialogId dialog_id, UserId administrator_user_id) {
|
||||||
dialog_id_ = dialog_id;
|
dialog_id_ = dialog_id;
|
||||||
auto input_peer = td->messages_manager_->get_input_peer(dialog_id, AccessRights::Write);
|
auto input_peer = td->messages_manager_->get_input_peer(dialog_id, AccessRights::Write);
|
||||||
if (input_peer == nullptr) {
|
if (input_peer == nullptr) {
|
||||||
return on_error(0, Status::Error(400, "Can't access the chat"));
|
return on_error(0, Status::Error(400, "Can't access the chat"));
|
||||||
}
|
}
|
||||||
|
|
||||||
send_query(G()->net_query_creator().create(telegram_api::messages_deleteRevokedExportedChatInvites(
|
auto input_user = td->contacts_manager_->get_input_user(administrator_user_id);
|
||||||
std::move(input_peer), make_tl_object<telegram_api::inputUserSelf>())));
|
CHECK(input_user != nullptr);
|
||||||
|
|
||||||
|
send_query(G()->net_query_creator().create(
|
||||||
|
telegram_api::messages_deleteRevokedExportedChatInvites(std::move(input_peer), std::move(input_user))));
|
||||||
}
|
}
|
||||||
|
|
||||||
void on_result(uint64 id, BufferSlice packet) override {
|
void on_result(uint64 id, BufferSlice packet) override {
|
||||||
@ -6993,10 +6996,16 @@ void ContactsManager::delete_revoked_dialog_invite_link(DialogId dialog_id, cons
|
|||||||
td_->create_handler<DeleteExportedChatInviteQuery>(std::move(promise))->send(dialog_id, invite_link);
|
td_->create_handler<DeleteExportedChatInviteQuery>(std::move(promise))->send(dialog_id, invite_link);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ContactsManager::delete_all_revoked_dialog_invite_links(DialogId dialog_id, Promise<Unit> &&promise) {
|
void ContactsManager::delete_all_revoked_dialog_invite_links(DialogId dialog_id, UserId administrator_user_id,
|
||||||
TRY_STATUS_PROMISE(promise, can_manage_dialog_invite_links(dialog_id));
|
Promise<Unit> &&promise) {
|
||||||
|
TRY_STATUS_PROMISE(promise, can_manage_dialog_invite_links(dialog_id, administrator_user_id != get_my_id()));
|
||||||
|
|
||||||
td_->create_handler<DeleteRevokedExportedChatInvitesQuery>(std::move(promise))->send(dialog_id);
|
if (!have_input_user(administrator_user_id)) {
|
||||||
|
return promise.set_error(Status::Error(400, "Administrator user not found"));
|
||||||
|
}
|
||||||
|
|
||||||
|
td_->create_handler<DeleteRevokedExportedChatInvitesQuery>(std::move(promise))
|
||||||
|
->send(dialog_id, administrator_user_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ContactsManager::check_dialog_invite_link(const string &invite_link, Promise<Unit> &&promise) const {
|
void ContactsManager::check_dialog_invite_link(const string &invite_link, Promise<Unit> &&promise) const {
|
||||||
|
@ -402,7 +402,8 @@ class ContactsManager : public Actor {
|
|||||||
|
|
||||||
void delete_revoked_dialog_invite_link(DialogId dialog_id, const string &invite_link, Promise<Unit> &&promise);
|
void delete_revoked_dialog_invite_link(DialogId dialog_id, const string &invite_link, Promise<Unit> &&promise);
|
||||||
|
|
||||||
void delete_all_revoked_dialog_invite_links(DialogId dialog_id, Promise<Unit> &&promise);
|
void delete_all_revoked_dialog_invite_links(DialogId dialog_id, UserId administrator_user_id,
|
||||||
|
Promise<Unit> &&promise);
|
||||||
|
|
||||||
void check_dialog_invite_link(const string &invite_link, Promise<Unit> &&promise) const;
|
void check_dialog_invite_link(const string &invite_link, Promise<Unit> &&promise) const;
|
||||||
|
|
||||||
|
@ -6377,7 +6377,8 @@ void Td::on_request(uint64 id, td_api::deleteRevokedChatInviteLink &request) {
|
|||||||
|
|
||||||
void Td::on_request(uint64 id, const td_api::deleteAllRevokedChatInviteLinks &request) {
|
void Td::on_request(uint64 id, const td_api::deleteAllRevokedChatInviteLinks &request) {
|
||||||
CREATE_OK_REQUEST_PROMISE();
|
CREATE_OK_REQUEST_PROMISE();
|
||||||
contacts_manager_->delete_all_revoked_dialog_invite_links(DialogId(request.chat_id_), std::move(promise));
|
contacts_manager_->delete_all_revoked_dialog_invite_links(DialogId(request.chat_id_),
|
||||||
|
UserId(request.administrator_user_id_), std::move(promise));
|
||||||
}
|
}
|
||||||
|
|
||||||
void Td::on_request(uint64 id, td_api::checkChatInviteLink &request) {
|
void Td::on_request(uint64 id, td_api::checkChatInviteLink &request) {
|
||||||
|
@ -2744,8 +2744,10 @@ class CliClient final : public Actor {
|
|||||||
get_args(args, chat_id, invite_link);
|
get_args(args, chat_id, invite_link);
|
||||||
send_request(td_api::make_object<td_api::deleteRevokedChatInviteLink>(as_chat_id(chat_id), invite_link));
|
send_request(td_api::make_object<td_api::deleteRevokedChatInviteLink>(as_chat_id(chat_id), invite_link));
|
||||||
} else if (op == "darcil") {
|
} else if (op == "darcil") {
|
||||||
string chat_id = args;
|
string chat_id;
|
||||||
send_request(td_api::make_object<td_api::deleteAllRevokedChatInviteLinks>(as_chat_id(chat_id)));
|
string administrator_user_id;
|
||||||
|
get_args(args, chat_id, administrator_user_id);
|
||||||
|
send_request(td_api::make_object<td_api::deleteAllRevokedChatInviteLinks>(as_chat_id(chat_id), as_user_id(administrator_user_id)));
|
||||||
} else if (op == "ccil") {
|
} else if (op == "ccil") {
|
||||||
send_request(td_api::make_object<td_api::checkChatInviteLink>(args));
|
send_request(td_api::make_object<td_api::checkChatInviteLink>(args));
|
||||||
} else if (op == "jcbil") {
|
} else if (op == "jcbil") {
|
||||||
|
Loading…
Reference in New Issue
Block a user