Add td_api::getChatFolderNewChats.
This commit is contained in:
parent
19e15f283c
commit
e6cc743c33
@ -6847,6 +6847,9 @@ checkChatFolderInviteLink invite_link:string = ChatFolderInviteLinkInfo;
|
||||
//@description Adds a chat folder by an invite link @invite_link Invite link for the chat folder @chat_ids Identifiers of the chats added to the chat folder. The chats are automatically joined if they aren't joined yet
|
||||
addChatFolderByInviteLink invite_link:string chat_ids:vector<int53> = Ok;
|
||||
|
||||
//@description Returns new chats added to a shareable chat folder by its owner. The method should be called at most once an hour for the given chat folder @chat_folder_id Chat folder identifier
|
||||
getChatFolderNewChats chat_folder_id:int32 = Chats;
|
||||
|
||||
|
||||
//@description Changes the chat title. Supported only for basic groups, supergroups and channels. Requires can_change_info administrator right
|
||||
//@chat_id Chat identifier
|
||||
|
@ -369,6 +369,38 @@ class JoinChatlistInviteQuery final : public Td::ResultHandler {
|
||||
}
|
||||
};
|
||||
|
||||
class GetChatlistUpdatesQuery final : public Td::ResultHandler {
|
||||
Promise<td_api::object_ptr<td_api::chats>> promise_;
|
||||
|
||||
public:
|
||||
explicit GetChatlistUpdatesQuery(Promise<td_api::object_ptr<td_api::chats>> &&promise)
|
||||
: promise_(std::move(promise)) {
|
||||
}
|
||||
|
||||
void send(DialogFilterId dialog_filter_id) {
|
||||
send_query(G()->net_query_creator().create(
|
||||
telegram_api::chatlists_getChatlistUpdates(dialog_filter_id.get_input_chatlist())));
|
||||
}
|
||||
|
||||
void on_result(BufferSlice packet) final {
|
||||
auto result_ptr = fetch_result<telegram_api::chatlists_getChatlistUpdates>(packet);
|
||||
if (result_ptr.is_error()) {
|
||||
return on_error(result_ptr.move_as_error());
|
||||
}
|
||||
|
||||
auto ptr = result_ptr.move_as_ok();
|
||||
LOG(INFO) << "Receive result for GetChatlistUpdatesQuery: " << to_string(ptr);
|
||||
td_->contacts_manager_->on_get_users(std::move(ptr->users_), "GetChatlistUpdatesQuery");
|
||||
td_->contacts_manager_->on_get_chats(std::move(ptr->chats_), "GetChatlistUpdatesQuery");
|
||||
auto missing_dialog_ids = td_->messages_manager_->get_peers_dialog_ids(std::move(ptr->missing_peers_));
|
||||
promise_.set_value(MessagesManager::get_chats_object(-1, missing_dialog_ids));
|
||||
}
|
||||
|
||||
void on_error(Status status) final {
|
||||
promise_.set_error(std::move(status));
|
||||
}
|
||||
};
|
||||
|
||||
class GetDialogsQuery final : public Td::ResultHandler {
|
||||
Promise<Unit> promise_;
|
||||
bool is_single_ = false;
|
||||
@ -1892,6 +1924,18 @@ void DialogFilterManager::add_dialog_filter_by_invite_link(const string &invite_
|
||||
td_->create_handler<JoinChatlistInviteQuery>(std::move(promise))->send(invite_link, std::move(dialog_ids));
|
||||
}
|
||||
|
||||
void DialogFilterManager::get_dialog_filter_new_chats(DialogFilterId dialog_filter_id,
|
||||
Promise<td_api::object_ptr<td_api::chats>> promise) {
|
||||
auto dialog_filter = get_dialog_filter(dialog_filter_id);
|
||||
if (dialog_filter == nullptr) {
|
||||
return promise.set_error(Status::Error(400, "Chat folder not found"));
|
||||
}
|
||||
if (!dialog_filter->is_shareable()) {
|
||||
return promise.set_value(td_api::make_object<td_api::chats>());
|
||||
}
|
||||
td_->create_handler<GetChatlistUpdatesQuery>(std::move(promise))->send(dialog_filter_id);
|
||||
}
|
||||
|
||||
void DialogFilterManager::set_dialog_filter_has_my_invite_links(DialogFilterId dialog_filter_id,
|
||||
bool has_my_invite_links) {
|
||||
auto dialog_filter = get_dialog_filter(dialog_filter_id);
|
||||
|
@ -99,6 +99,8 @@ class DialogFilterManager final : public Actor {
|
||||
void add_dialog_filter_by_invite_link(const string &invite_link, vector<DialogId> dialog_ids,
|
||||
Promise<Unit> &&promise);
|
||||
|
||||
void get_dialog_filter_new_chats(DialogFilterId dialog_filter_id, Promise<td_api::object_ptr<td_api::chats>> promise);
|
||||
|
||||
void on_get_dialog_filter(telegram_api::object_ptr<telegram_api::DialogFilter> filter);
|
||||
|
||||
void get_recommended_dialog_filters(Promise<td_api::object_ptr<td_api::recommendedChatFolders>> &&promise);
|
||||
|
@ -6208,6 +6208,12 @@ void Td::on_request(uint64 id, td_api::addChatFolderByInviteLink &request) {
|
||||
std::move(request.invite_link_), DialogId::get_dialog_ids(request.chat_ids_), std::move(promise));
|
||||
}
|
||||
|
||||
void Td::on_request(uint64 id, const td_api::getChatFolderNewChats &request) {
|
||||
CHECK_IS_USER();
|
||||
CREATE_REQUEST_PROMISE();
|
||||
dialog_filter_manager_->get_dialog_filter_new_chats(DialogFilterId(request.chat_folder_id_), std::move(promise));
|
||||
}
|
||||
|
||||
void Td::on_request(uint64 id, td_api::setChatTitle &request) {
|
||||
CLEAN_INPUT_STRING(request.title_);
|
||||
CREATE_OK_REQUEST_PROMISE();
|
||||
|
@ -939,6 +939,8 @@ class Td final : public Actor {
|
||||
|
||||
void on_request(uint64 id, td_api::addChatFolderByInviteLink &request);
|
||||
|
||||
void on_request(uint64 id, const td_api::getChatFolderNewChats &request);
|
||||
|
||||
void on_request(uint64 id, td_api::setChatTitle &request);
|
||||
|
||||
void on_request(uint64 id, const td_api::setChatPhoto &request);
|
||||
|
@ -4622,6 +4622,10 @@ class CliClient final : public Actor {
|
||||
string chat_ids;
|
||||
get_args(args, invite_link, chat_ids);
|
||||
send_request(td_api::make_object<td_api::addChatFolderByInviteLink>(invite_link, as_chat_ids(chat_ids)));
|
||||
} else if (op == "gcfnc") {
|
||||
ChatFolderId chat_folder_id;
|
||||
get_args(args, chat_folder_id);
|
||||
send_request(td_api::make_object<td_api::getChatFolderNewChats>(chat_folder_id));
|
||||
} else if (op == "grcf") {
|
||||
send_request(td_api::make_object<td_api::getRecommendedChatFolders>());
|
||||
} else if (op == "gcfdin") {
|
||||
|
Loading…
x
Reference in New Issue
Block a user