Add chatFilter.is_shareable.
This commit is contained in:
parent
d1c9cacf85
commit
761bc9c992
@ -1295,6 +1295,7 @@ chatTypeSecret secret_chat_id:int32 user_id:int53 = ChatType;
|
|||||||
//@icon_name The chosen icon name for short filter representation. If non-empty, must be one of "All", "Unread", "Unmuted", "Bots", "Channels", "Groups", "Private", "Custom", "Setup", "Cat", "Crown",
|
//@icon_name The chosen icon name for short filter representation. If non-empty, must be one of "All", "Unread", "Unmuted", "Bots", "Channels", "Groups", "Private", "Custom", "Setup", "Cat", "Crown",
|
||||||
//-"Favorite", "Flower", "Game", "Home", "Love", "Mask", "Party", "Sport", "Study", "Trade", "Travel", "Work", "Airplane", "Book", "Light", "Like", "Money", "Note", "Palette".
|
//-"Favorite", "Flower", "Game", "Home", "Love", "Mask", "Party", "Sport", "Study", "Trade", "Travel", "Work", "Airplane", "Book", "Light", "Like", "Money", "Note", "Palette".
|
||||||
//-If empty, use getChatFilterDefaultIconName to get default icon name for the filter
|
//-If empty, use getChatFilterDefaultIconName to get default icon name for the filter
|
||||||
|
//@is_shareable True if at least one link has been created for the filter
|
||||||
//@pinned_chat_ids The chat identifiers of pinned chats in the filtered chat list. There can be up to getOption("chat_filter_chosen_chat_count_max") pinned and always included non-secret chats and the same number of secret chats, but the limit can be increased with Telegram Premium
|
//@pinned_chat_ids The chat identifiers of pinned chats in the filtered chat list. There can be up to getOption("chat_filter_chosen_chat_count_max") pinned and always included non-secret chats and the same number of secret chats, but the limit can be increased with Telegram Premium
|
||||||
//@included_chat_ids The chat identifiers of always included chats in the filtered chat list. There can be up to getOption("chat_filter_chosen_chat_count_max") pinned and always included non-secret chats and the same number of secret chats, but the limit can be increased with Telegram Premium
|
//@included_chat_ids The chat identifiers of always included chats in the filtered chat list. There can be up to getOption("chat_filter_chosen_chat_count_max") pinned and always included non-secret chats and the same number of secret chats, but the limit can be increased with Telegram Premium
|
||||||
//@excluded_chat_ids The chat identifiers of always excluded chats in the filtered chat list. There can be up to getOption("chat_filter_chosen_chat_count_max") always excluded non-secret chats and the same number of secret chats, but the limit can be increased with Telegram Premium
|
//@excluded_chat_ids The chat identifiers of always excluded chats in the filtered chat list. There can be up to getOption("chat_filter_chosen_chat_count_max") always excluded non-secret chats and the same number of secret chats, but the limit can be increased with Telegram Premium
|
||||||
@ -1306,7 +1307,7 @@ chatTypeSecret secret_chat_id:int32 user_id:int53 = ChatType;
|
|||||||
//@include_bots True, if bots need to be included
|
//@include_bots True, if bots need to be included
|
||||||
//@include_groups True, if basic groups and supergroups need to be included
|
//@include_groups True, if basic groups and supergroups need to be included
|
||||||
//@include_channels True, if channels need to be included
|
//@include_channels True, if channels need to be included
|
||||||
chatFilter title:string icon_name:string pinned_chat_ids:vector<int53> included_chat_ids:vector<int53> excluded_chat_ids:vector<int53> exclude_muted:Bool exclude_read:Bool exclude_archived:Bool include_contacts:Bool include_non_contacts:Bool include_bots:Bool include_groups:Bool include_channels:Bool = ChatFilter;
|
chatFilter title:string icon_name:string is_shareable:Bool pinned_chat_ids:vector<int53> included_chat_ids:vector<int53> excluded_chat_ids:vector<int53> exclude_muted:Bool exclude_read:Bool exclude_archived:Bool include_contacts:Bool include_non_contacts:Bool include_bots:Bool include_groups:Bool include_channels:Bool = ChatFilter;
|
||||||
|
|
||||||
//@description Contains basic information about a chat filter
|
//@description Contains basic information about a chat filter
|
||||||
//@id Unique chat filter identifier
|
//@id Unique chat filter identifier
|
||||||
|
@ -135,7 +135,7 @@ Result<unique_ptr<DialogFilter>> DialogFilter::create_dialog_filter(Td *td, Dial
|
|||||||
dialog_filter->include_bots_ = filter->include_bots_;
|
dialog_filter->include_bots_ = filter->include_bots_;
|
||||||
dialog_filter->include_groups_ = filter->include_groups_;
|
dialog_filter->include_groups_ = filter->include_groups_;
|
||||||
dialog_filter->include_channels_ = filter->include_channels_;
|
dialog_filter->include_channels_ = filter->include_channels_;
|
||||||
dialog_filter->is_shareable_ = false;
|
dialog_filter->is_shareable_ = filter->is_shareable_;
|
||||||
|
|
||||||
TRY_STATUS(dialog_filter->check_limits());
|
TRY_STATUS(dialog_filter->check_limits());
|
||||||
dialog_filter->sort_input_dialog_ids(td, "create_dialog_filter");
|
dialog_filter->sort_input_dialog_ids(td, "create_dialog_filter");
|
||||||
@ -280,11 +280,11 @@ Status DialogFilter::check_limits() const {
|
|||||||
}
|
}
|
||||||
if (is_shareable_) {
|
if (is_shareable_) {
|
||||||
if (!excluded_dialog_ids_.empty()) {
|
if (!excluded_dialog_ids_.empty()) {
|
||||||
return Status::Error(400, "The folder can't have excluded chats");
|
return Status::Error(400, "Shareable folders can't have excluded chats");
|
||||||
}
|
}
|
||||||
if (include_contacts_ || include_non_contacts_ || include_bots_ || include_groups_ || include_channels_ ||
|
if (include_contacts_ || include_non_contacts_ || include_bots_ || include_groups_ || include_channels_ ||
|
||||||
exclude_archived_ || exclude_read_ || exclude_muted_) {
|
exclude_archived_ || exclude_read_ || exclude_muted_) {
|
||||||
return Status::Error(400, "The folder can't have chat filters");
|
return Status::Error(400, "Shareable folders can't have chat filters");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -450,7 +450,7 @@ td_api::object_ptr<td_api::chatFilter> DialogFilter::get_chat_filter_object(
|
|||||||
};
|
};
|
||||||
|
|
||||||
return td_api::make_object<td_api::chatFilter>(
|
return td_api::make_object<td_api::chatFilter>(
|
||||||
title_, get_icon_name(), get_chat_ids(pinned_dialog_ids_), get_chat_ids(included_dialog_ids_),
|
title_, get_icon_name(), is_shareable_, get_chat_ids(pinned_dialog_ids_), get_chat_ids(included_dialog_ids_),
|
||||||
get_chat_ids(excluded_dialog_ids_), exclude_muted_, exclude_read_, exclude_archived_, include_contacts_,
|
get_chat_ids(excluded_dialog_ids_), exclude_muted_, exclude_read_, exclude_archived_, include_contacts_,
|
||||||
include_non_contacts_, include_bots_, include_groups_, include_channels_);
|
include_non_contacts_, include_bots_, include_groups_, include_channels_);
|
||||||
}
|
}
|
||||||
|
@ -1195,6 +1195,9 @@ void DialogFilterManager::create_dialog_filter(td_api::object_ptr<td_api::chatFi
|
|||||||
|
|
||||||
TRY_RESULT_PROMISE(promise, dialog_filter,
|
TRY_RESULT_PROMISE(promise, dialog_filter,
|
||||||
DialogFilter::create_dialog_filter(td_, dialog_filter_id, std::move(filter)));
|
DialogFilter::create_dialog_filter(td_, dialog_filter_id, std::move(filter)));
|
||||||
|
if (dialog_filter->is_shareable()) {
|
||||||
|
return promise.set_error(Status::Error(400, "Can't create shareable folder"));
|
||||||
|
}
|
||||||
auto chat_filter_info = dialog_filter->get_chat_filter_info_object();
|
auto chat_filter_info = dialog_filter->get_chat_filter_info_object();
|
||||||
|
|
||||||
bool at_beginning = is_recommended_dialog_filter(dialog_filter.get());
|
bool at_beginning = is_recommended_dialog_filter(dialog_filter.get());
|
||||||
@ -1215,12 +1218,15 @@ void DialogFilterManager::edit_dialog_filter(DialogFilterId dialog_filter_id,
|
|||||||
CHECK(!td_->auth_manager_->is_bot());
|
CHECK(!td_->auth_manager_->is_bot());
|
||||||
auto old_dialog_filter = get_dialog_filter(dialog_filter_id);
|
auto old_dialog_filter = get_dialog_filter(dialog_filter_id);
|
||||||
if (old_dialog_filter == nullptr) {
|
if (old_dialog_filter == nullptr) {
|
||||||
return promise.set_error(Status::Error(400, "Chat filter not found"));
|
return promise.set_error(Status::Error(400, "Chat folder not found"));
|
||||||
}
|
}
|
||||||
CHECK(is_update_chat_filters_sent_);
|
CHECK(is_update_chat_filters_sent_);
|
||||||
|
|
||||||
TRY_RESULT_PROMISE(promise, new_dialog_filter,
|
TRY_RESULT_PROMISE(promise, new_dialog_filter,
|
||||||
DialogFilter::create_dialog_filter(td_, dialog_filter_id, std::move(filter)));
|
DialogFilter::create_dialog_filter(td_, dialog_filter_id, std::move(filter)));
|
||||||
|
if (new_dialog_filter->is_shareable() != old_dialog_filter->is_shareable()) {
|
||||||
|
return promise.set_error(Status::Error(400, "Can't convert a shareable folder to a non-shareable"));
|
||||||
|
}
|
||||||
auto chat_filter_info = new_dialog_filter->get_chat_filter_info_object();
|
auto chat_filter_info = new_dialog_filter->get_chat_filter_info_object();
|
||||||
|
|
||||||
if (*new_dialog_filter == *old_dialog_filter) {
|
if (*new_dialog_filter == *old_dialog_filter) {
|
||||||
@ -1347,7 +1353,7 @@ void DialogFilterManager::reorder_dialog_filters(vector<DialogFilterId> dialog_f
|
|||||||
for (auto dialog_filter_id : dialog_filter_ids) {
|
for (auto dialog_filter_id : dialog_filter_ids) {
|
||||||
auto dialog_filter = get_dialog_filter(dialog_filter_id);
|
auto dialog_filter = get_dialog_filter(dialog_filter_id);
|
||||||
if (dialog_filter == nullptr) {
|
if (dialog_filter == nullptr) {
|
||||||
return promise.set_error(Status::Error(400, "Chat filter not found"));
|
return promise.set_error(Status::Error(400, "Chat folder not found"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
std::unordered_set<DialogFilterId, DialogFilterIdHash> new_dialog_filter_ids_set(dialog_filter_ids.begin(),
|
std::unordered_set<DialogFilterId, DialogFilterIdHash> new_dialog_filter_ids_set(dialog_filter_ids.begin(),
|
||||||
@ -1490,7 +1496,7 @@ void DialogFilterManager::create_dialog_filter_invite_link(
|
|||||||
Promise<td_api::object_ptr<td_api::chatFilterInviteLink>> promise) {
|
Promise<td_api::object_ptr<td_api::chatFilterInviteLink>> promise) {
|
||||||
auto dialog_filter = get_dialog_filter(dialog_filter_id);
|
auto dialog_filter = get_dialog_filter(dialog_filter_id);
|
||||||
if (dialog_filter == nullptr) {
|
if (dialog_filter == nullptr) {
|
||||||
return promise.set_error(Status::Error(400, "Chat filter not found"));
|
return promise.set_error(Status::Error(400, "Chat folder not found"));
|
||||||
}
|
}
|
||||||
vector<tl_object_ptr<telegram_api::InputPeer>> input_peers;
|
vector<tl_object_ptr<telegram_api::InputPeer>> input_peers;
|
||||||
input_peers.reserve(dialog_ids.size());
|
input_peers.reserve(dialog_ids.size());
|
||||||
@ -1512,7 +1518,7 @@ void DialogFilterManager::get_dialog_filter_invite_links(
|
|||||||
DialogFilterId dialog_filter_id, Promise<td_api::object_ptr<td_api::chatFilterInviteLinks>> promise) {
|
DialogFilterId dialog_filter_id, Promise<td_api::object_ptr<td_api::chatFilterInviteLinks>> promise) {
|
||||||
auto dialog_filter = get_dialog_filter(dialog_filter_id);
|
auto dialog_filter = get_dialog_filter(dialog_filter_id);
|
||||||
if (dialog_filter == nullptr) {
|
if (dialog_filter == nullptr) {
|
||||||
return promise.set_error(Status::Error(400, "Chat filter not found"));
|
return promise.set_error(Status::Error(400, "Chat folder not found"));
|
||||||
}
|
}
|
||||||
if (!dialog_filter->is_shareable()) {
|
if (!dialog_filter->is_shareable()) {
|
||||||
return promise.set_value(td_api::make_object<td_api::chatFilterInviteLinks>());
|
return promise.set_value(td_api::make_object<td_api::chatFilterInviteLinks>());
|
||||||
|
@ -1533,9 +1533,10 @@ class CliClient final : public Actor {
|
|||||||
string included_chat_ids;
|
string included_chat_ids;
|
||||||
string excluded_chat_ids;
|
string excluded_chat_ids;
|
||||||
get_args(filter, title, icon_name, pinned_chat_ids, included_chat_ids, excluded_chat_ids);
|
get_args(filter, title, icon_name, pinned_chat_ids, included_chat_ids, excluded_chat_ids);
|
||||||
return td_api::make_object<td_api::chatFilter>(
|
return td_api::make_object<td_api::chatFilter>(title, icon_name, false, as_chat_ids(pinned_chat_ids),
|
||||||
title, icon_name, as_chat_ids(pinned_chat_ids), as_chat_ids(included_chat_ids), as_chat_ids(excluded_chat_ids),
|
as_chat_ids(included_chat_ids), as_chat_ids(excluded_chat_ids),
|
||||||
rand_bool(), rand_bool(), rand_bool(), rand_bool(), rand_bool(), rand_bool(), rand_bool(), rand_bool());
|
rand_bool(), rand_bool(), rand_bool(), rand_bool(), rand_bool(),
|
||||||
|
rand_bool(), rand_bool(), rand_bool());
|
||||||
}
|
}
|
||||||
|
|
||||||
static td_api::object_ptr<td_api::chatAdministratorRights> as_chat_administrator_rights(
|
static td_api::object_ptr<td_api::chatAdministratorRights> as_chat_administrator_rights(
|
||||||
|
Loading…
Reference in New Issue
Block a user