Add td_api::toggleChatFolderTags.

This commit is contained in:
levlam 2024-03-01 19:28:32 +03:00
parent 3221d42d7b
commit f726ca930b
6 changed files with 36 additions and 0 deletions

View File

@ -8262,6 +8262,9 @@ getChatFolderChatCount folder:chatFolder = Count;
//@description Changes the order of chat folders @chat_folder_ids Identifiers of chat folders in the new correct order @main_chat_list_position Position of the main chat list among chat folders, 0-based. Can be non-zero only for Premium users
reorderChatFolders chat_folder_ids:vector<int32> main_chat_list_position:int32 = Ok;
//@description Toggles whether chat folder tags are enabled @are_tags_enabled Pass true to enable folder tags; pass false to disable them
toggleChatFolderTags are_tags_enabled:Bool = Ok;
//@description Returns recommended chat folders for the current user
getRecommendedChatFolders = RecommendedChatFolders;

View File

@ -1843,6 +1843,25 @@ void DialogFilterManager::on_reorder_dialog_filters(vector<DialogFilterId> dialo
synchronize_dialog_filters();
}
void DialogFilterManager::toggle_dialog_filter_tags(bool are_tags_enabled, Promise<Unit> &&promise) {
if (!td_->option_manager_->get_option_boolean("is_premium")) {
if (!are_tags_enabled) {
return promise.set_value(Unit());
}
return promise.set_error(Status::Error(400, "Method not available"));
}
if (are_tags_enabled_ != are_tags_enabled) {
are_tags_enabled = are_tags_enabled;
save_dialog_filters();
send_update_chat_folders();
synchronize_dialog_filters();
}
promise.set_value(Unit());
}
void DialogFilterManager::toggle_are_tags_enabled_on_server(bool are_tags_enabled) {
CHECK(!td_->auth_manager_->is_bot());
are_dialog_filters_being_synchronized_ = true;

View File

@ -81,6 +81,8 @@ class DialogFilterManager final : public Actor {
void reorder_dialog_filters(vector<DialogFilterId> dialog_filter_ids, int32 main_dialog_list_position,
Promise<Unit> &&promise);
void toggle_dialog_filter_tags(bool are_tags_enabled, Promise<Unit> &&promise);
void get_dialogs_for_dialog_filter_invite_link(DialogFilterId dialog_filter_id,
Promise<td_api::object_ptr<td_api::chats>> promise);

View File

@ -6468,6 +6468,12 @@ void Td::on_request(uint64 id, const td_api::reorderChatFolders &request) {
request.main_chat_list_position_, std::move(promise));
}
void Td::on_request(uint64 id, const td_api::toggleChatFolderTags &request) {
CHECK_IS_USER();
CREATE_OK_REQUEST_PROMISE();
dialog_filter_manager_->toggle_dialog_filter_tags(request.are_tags_enabled_, std::move(promise));
}
void Td::on_request(uint64 id, const td_api::getChatsForChatFolderInviteLink &request) {
CHECK_IS_USER();
CREATE_REQUEST_PROMISE();

View File

@ -1046,6 +1046,8 @@ class Td final : public Actor {
void on_request(uint64 id, const td_api::reorderChatFolders &request);
void on_request(uint64 id, const td_api::toggleChatFolderTags &request);
void on_request(uint64 id, const td_api::getChatsForChatFolderInviteLink &request);
void on_request(uint64 id, td_api::createChatFolderInviteLink &request);

View File

@ -5430,6 +5430,10 @@ class CliClient final : public Actor {
get_args(args, main_chat_list_position, chat_folder_ids);
send_request(td_api::make_object<td_api::reorderChatFolders>(as_chat_folder_ids(chat_folder_ids),
main_chat_list_position));
} else if (op == "tcft") {
bool are_tags_enabled;
get_args(args, are_tags_enabled);
send_request(td_api::make_object<td_api::toggleChatFolderTags>(are_tags_enabled));
} else if (op == "gcfcfil") {
ChatFolderId chat_folder_id;
get_args(args, chat_folder_id);