Add td_api::processChatJoinRequests.
This commit is contained in:
parent
7c0a4117a4
commit
0b2207f180
@ -5024,6 +5024,12 @@ getChatJoinRequests chat_id:int53 invite_link:string query:string offset_request
|
|||||||
//@description Handles a pending join request in a chat @chat_id Chat identifier @user_id Identifier of the user that sent the request @approve True, if the request is approved. Otherwise the request is declived
|
//@description Handles a pending join request in a chat @chat_id Chat identifier @user_id Identifier of the user that sent the request @approve True, if the request is approved. Otherwise the request is declived
|
||||||
processChatJoinRequest chat_id:int53 user_id:int53 approve:Bool = Ok;
|
processChatJoinRequest chat_id:int53 user_id:int53 approve:Bool = Ok;
|
||||||
|
|
||||||
|
//@description Handles all pending join requests for a given link in a chat
|
||||||
|
//@chat_id Chat identifier
|
||||||
|
//@invite_link Invite link for which to process join requests. If empty, all join requests will be processed. Requires administrator privileges and can_invite_users right in the chat for own links and owner privileges for other links
|
||||||
|
//@approve True, if the requests are approved. Otherwise the requests are declived
|
||||||
|
processChatJoinRequests chat_id:int53 invite_link:string approve:Bool = Ok;
|
||||||
|
|
||||||
|
|
||||||
//@description Creates a new call @user_id Identifier of the user to be called @protocol The call protocols supported by the application @is_video True, if a video call needs to be created
|
//@description Creates a new call @user_id Identifier of the user to be called @protocol The call protocols supported by the application @is_video True, if a video call needs to be created
|
||||||
createCall user_id:int53 protocol:callProtocol is_video:Bool = CallId;
|
createCall user_id:int53 protocol:callProtocol is_video:Bool = CallId;
|
||||||
|
@ -1687,7 +1687,7 @@ class HideChatJoinRequestQuery final : public Td::ResultHandler {
|
|||||||
explicit HideChatJoinRequestQuery(Promise<Unit> &&promise) : promise_(std::move(promise)) {
|
explicit HideChatJoinRequestQuery(Promise<Unit> &&promise) : promise_(std::move(promise)) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void send(DialogId dialog_id, UserId user_id, bool is_approved) {
|
void send(DialogId dialog_id, UserId user_id, bool approve) {
|
||||||
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) {
|
||||||
@ -1700,7 +1700,7 @@ class HideChatJoinRequestQuery final : public Td::ResultHandler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
int32 flags = 0;
|
int32 flags = 0;
|
||||||
if (is_approved) {
|
if (approve) {
|
||||||
flags |= telegram_api::messages_hideChatJoinRequest::APPROVED_MASK;
|
flags |= telegram_api::messages_hideChatJoinRequest::APPROVED_MASK;
|
||||||
}
|
}
|
||||||
send_query(G()->net_query_creator().create(telegram_api::messages_hideChatJoinRequest(
|
send_query(G()->net_query_creator().create(telegram_api::messages_hideChatJoinRequest(
|
||||||
@ -1724,6 +1724,49 @@ class HideChatJoinRequestQuery final : public Td::ResultHandler {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
class HideAllChatJoinRequestsQuery final : public Td::ResultHandler {
|
||||||
|
Promise<Unit> promise_;
|
||||||
|
DialogId dialog_id_;
|
||||||
|
|
||||||
|
public:
|
||||||
|
explicit HideAllChatJoinRequestsQuery(Promise<Unit> &&promise) : promise_(std::move(promise)) {
|
||||||
|
}
|
||||||
|
|
||||||
|
void send(DialogId dialog_id, const string &invite_link, bool approve) {
|
||||||
|
dialog_id_ = dialog_id;
|
||||||
|
auto input_peer = td_->messages_manager_->get_input_peer(dialog_id, AccessRights::Write);
|
||||||
|
if (input_peer == nullptr) {
|
||||||
|
return on_error(Status::Error(400, "Can't access the chat"));
|
||||||
|
}
|
||||||
|
|
||||||
|
int32 flags = 0;
|
||||||
|
if (approve) {
|
||||||
|
flags |= telegram_api::messages_hideAllChatJoinRequests::APPROVED_MASK;
|
||||||
|
}
|
||||||
|
if (!invite_link.empty()) {
|
||||||
|
flags |= telegram_api::messages_hideAllChatJoinRequests::LINK_MASK;
|
||||||
|
}
|
||||||
|
send_query(G()->net_query_creator().create(
|
||||||
|
telegram_api::messages_hideAllChatJoinRequests(flags, false /*ignored*/, std::move(input_peer), invite_link)));
|
||||||
|
}
|
||||||
|
|
||||||
|
void on_result(BufferSlice packet) final {
|
||||||
|
auto result_ptr = fetch_result<telegram_api::messages_hideAllChatJoinRequests>(packet);
|
||||||
|
if (result_ptr.is_error()) {
|
||||||
|
return on_error(result_ptr.move_as_error());
|
||||||
|
}
|
||||||
|
|
||||||
|
auto result = result_ptr.move_as_ok();
|
||||||
|
LOG(INFO) << "Receive result for HideAllChatJoinRequestsQuery: " << to_string(result);
|
||||||
|
td_->updates_manager_->on_get_updates(std::move(result), std::move(promise_));
|
||||||
|
}
|
||||||
|
|
||||||
|
void on_error(Status status) final {
|
||||||
|
td_->messages_manager_->on_get_dialog_error(dialog_id_, status, "HideAllChatJoinRequestsQuery");
|
||||||
|
promise_.set_error(std::move(status));
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
class RevokeChatInviteLinkQuery final : public Td::ResultHandler {
|
class RevokeChatInviteLinkQuery final : public Td::ResultHandler {
|
||||||
Promise<td_api::object_ptr<td_api::chatInviteLinks>> promise_;
|
Promise<td_api::object_ptr<td_api::chatInviteLinks>> promise_;
|
||||||
DialogId dialog_id_;
|
DialogId dialog_id_;
|
||||||
@ -7278,10 +7321,16 @@ void ContactsManager::get_dialog_join_requests(DialogId dialog_id, const string
|
|||||||
->send(dialog_id, invite_link, query, offset_date, offset_user_id, limit);
|
->send(dialog_id, invite_link, query, offset_date, offset_user_id, limit);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ContactsManager::process_dialog_join_requests(DialogId dialog_id, UserId user_id, bool is_approved,
|
void ContactsManager::process_dialog_join_request(DialogId dialog_id, UserId user_id, bool approve,
|
||||||
Promise<Unit> &&promise) {
|
Promise<Unit> &&promise) {
|
||||||
TRY_STATUS_PROMISE(promise, can_manage_dialog_invite_links(dialog_id));
|
TRY_STATUS_PROMISE(promise, can_manage_dialog_invite_links(dialog_id));
|
||||||
td_->create_handler<HideChatJoinRequestQuery>(std::move(promise))->send(dialog_id, user_id, is_approved);
|
td_->create_handler<HideChatJoinRequestQuery>(std::move(promise))->send(dialog_id, user_id, approve);
|
||||||
|
}
|
||||||
|
|
||||||
|
void ContactsManager::process_dialog_join_requests(DialogId dialog_id, const string &invite_link, bool approve,
|
||||||
|
Promise<Unit> &&promise) {
|
||||||
|
TRY_STATUS_PROMISE(promise, can_manage_dialog_invite_links(dialog_id));
|
||||||
|
td_->create_handler<HideAllChatJoinRequestsQuery>(std::move(promise))->send(dialog_id, invite_link, approve);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ContactsManager::revoke_dialog_invite_link(DialogId dialog_id, const string &invite_link,
|
void ContactsManager::revoke_dialog_invite_link(DialogId dialog_id, const string &invite_link,
|
||||||
|
@ -396,7 +396,10 @@ class ContactsManager final : public Actor {
|
|||||||
td_api::object_ptr<td_api::chatJoinRequest> offset_request, int32 limit,
|
td_api::object_ptr<td_api::chatJoinRequest> offset_request, int32 limit,
|
||||||
Promise<td_api::object_ptr<td_api::chatJoinRequests>> &&promise);
|
Promise<td_api::object_ptr<td_api::chatJoinRequests>> &&promise);
|
||||||
|
|
||||||
void process_dialog_join_requests(DialogId dialog_id, UserId user_id, bool is_approved, Promise<Unit> &&promise);
|
void process_dialog_join_request(DialogId dialog_id, UserId user_id, bool approve, Promise<Unit> &&promise);
|
||||||
|
|
||||||
|
void process_dialog_join_requests(DialogId dialog_id, const string &invite_link, bool approve,
|
||||||
|
Promise<Unit> &&promise);
|
||||||
|
|
||||||
void revoke_dialog_invite_link(DialogId dialog_id, const string &link,
|
void revoke_dialog_invite_link(DialogId dialog_id, const string &link,
|
||||||
Promise<td_api::object_ptr<td_api::chatInviteLinks>> &&promise);
|
Promise<td_api::object_ptr<td_api::chatInviteLinks>> &&promise);
|
||||||
|
@ -6409,8 +6409,16 @@ void Td::on_request(uint64 id, td_api::getChatJoinRequests &request) {
|
|||||||
|
|
||||||
void Td::on_request(uint64 id, const td_api::processChatJoinRequest &request) {
|
void Td::on_request(uint64 id, const td_api::processChatJoinRequest &request) {
|
||||||
CREATE_OK_REQUEST_PROMISE();
|
CREATE_OK_REQUEST_PROMISE();
|
||||||
contacts_manager_->process_dialog_join_requests(DialogId(request.chat_id_), UserId(request.user_id_),
|
contacts_manager_->process_dialog_join_request(DialogId(request.chat_id_), UserId(request.user_id_), request.approve_,
|
||||||
request.approve_, std::move(promise));
|
std::move(promise));
|
||||||
|
}
|
||||||
|
|
||||||
|
void Td::on_request(uint64 id, td_api::processChatJoinRequests &request) {
|
||||||
|
CHECK_IS_USER();
|
||||||
|
CLEAN_INPUT_STRING(request.invite_link_);
|
||||||
|
CREATE_OK_REQUEST_PROMISE();
|
||||||
|
contacts_manager_->process_dialog_join_requests(DialogId(request.chat_id_), request.invite_link_, request.approve_,
|
||||||
|
std::move(promise));
|
||||||
}
|
}
|
||||||
|
|
||||||
void Td::on_request(uint64 id, td_api::revokeChatInviteLink &request) {
|
void Td::on_request(uint64 id, td_api::revokeChatInviteLink &request) {
|
||||||
|
@ -892,6 +892,8 @@ class Td final : public Actor {
|
|||||||
|
|
||||||
void on_request(uint64 id, const td_api::processChatJoinRequest &request);
|
void on_request(uint64 id, const td_api::processChatJoinRequest &request);
|
||||||
|
|
||||||
|
void on_request(uint64 id, td_api::processChatJoinRequests &request);
|
||||||
|
|
||||||
void on_request(uint64 id, td_api::revokeChatInviteLink &request);
|
void on_request(uint64 id, td_api::revokeChatInviteLink &request);
|
||||||
|
|
||||||
void on_request(uint64 id, td_api::deleteRevokedChatInviteLink &request);
|
void on_request(uint64 id, td_api::deleteRevokedChatInviteLink &request);
|
||||||
|
@ -3048,6 +3048,12 @@ class CliClient final : public Actor {
|
|||||||
get_args(args, chat_id, user_id, approve);
|
get_args(args, chat_id, user_id, approve);
|
||||||
send_request(
|
send_request(
|
||||||
td_api::make_object<td_api::processChatJoinRequest>(as_chat_id(chat_id), as_user_id(user_id), approve));
|
td_api::make_object<td_api::processChatJoinRequest>(as_chat_id(chat_id), as_user_id(user_id), approve));
|
||||||
|
} else if (op == "pcjrs") {
|
||||||
|
string chat_id;
|
||||||
|
string invite_link;
|
||||||
|
bool approve;
|
||||||
|
get_args(args, chat_id, invite_link, approve);
|
||||||
|
send_request(td_api::make_object<td_api::processChatJoinRequests>(as_chat_id(chat_id), invite_link, approve));
|
||||||
} else if (op == "drcil") {
|
} else if (op == "drcil") {
|
||||||
string chat_id;
|
string chat_id;
|
||||||
string invite_link;
|
string invite_link;
|
||||||
|
Loading…
Reference in New Issue
Block a user