Add supergroupFullInfo.can_hide_members.
This commit is contained in:
parent
f4f156a5b1
commit
983cb965cf
@ -873,6 +873,7 @@ supergroup id:int53 usernames:usernames date:int32 status:ChatMemberStatus membe
|
|||||||
//@slow_mode_delay_expires_in Time left before next message can be sent in the supergroup, in seconds. An updateSupergroupFullInfo update is not triggered when value of this field changes, but both new and old values are non-zero
|
//@slow_mode_delay_expires_in Time left before next message can be sent in the supergroup, in seconds. An updateSupergroupFullInfo update is not triggered when value of this field changes, but both new and old values are non-zero
|
||||||
//@can_get_members True, if members of the chat can be retrieved via getSupergroupMembers or searchChatMembers
|
//@can_get_members True, if members of the chat can be retrieved via getSupergroupMembers or searchChatMembers
|
||||||
//@has_hidden_members True, if non-administrators can receive only administrators and bots using getSupergroupMembers or searchChatMembers
|
//@has_hidden_members True, if non-administrators can receive only administrators and bots using getSupergroupMembers or searchChatMembers
|
||||||
|
//@can_hide_members True, if non-administrators and non-bots can be hidden in responses to getSupergroupMembers and searchChatMembers for non-administrators
|
||||||
//@can_set_username True, if the chat username can be changed
|
//@can_set_username True, if the chat username can be changed
|
||||||
//@can_set_sticker_set True, if the supergroup sticker set can be changed
|
//@can_set_sticker_set True, if the supergroup sticker set can be changed
|
||||||
//@can_set_location True, if the supergroup location can be changed
|
//@can_set_location True, if the supergroup location can be changed
|
||||||
@ -887,7 +888,7 @@ supergroup id:int53 usernames:usernames date:int32 status:ChatMemberStatus membe
|
|||||||
//@bot_commands List of commands of bots in the group
|
//@bot_commands List of commands of bots in the group
|
||||||
//@upgraded_from_basic_group_id Identifier of the basic group from which supergroup was upgraded; 0 if none
|
//@upgraded_from_basic_group_id Identifier of the basic group from which supergroup was upgraded; 0 if none
|
||||||
//@upgraded_from_max_message_id Identifier of the last message in the basic group from which supergroup was upgraded; 0 if none
|
//@upgraded_from_max_message_id Identifier of the last message in the basic group from which supergroup was upgraded; 0 if none
|
||||||
supergroupFullInfo photo:chatPhoto description:string member_count:int32 administrator_count:int32 restricted_count:int32 banned_count:int32 linked_chat_id:int53 slow_mode_delay:int32 slow_mode_delay_expires_in:double can_get_members:Bool has_hidden_members:Bool can_set_username:Bool can_set_sticker_set:Bool can_set_location:Bool can_get_statistics:Bool can_toggle_aggressive_anti_spam:Bool is_all_history_available:Bool is_aggressive_anti_spam_enabled:Bool sticker_set_id:int64 location:chatLocation invite_link:chatInviteLink bot_commands:vector<botCommands> upgraded_from_basic_group_id:int53 upgraded_from_max_message_id:int53 = SupergroupFullInfo;
|
supergroupFullInfo photo:chatPhoto description:string member_count:int32 administrator_count:int32 restricted_count:int32 banned_count:int32 linked_chat_id:int53 slow_mode_delay:int32 slow_mode_delay_expires_in:double can_get_members:Bool has_hidden_members:Bool can_hide_members:Bool can_set_username:Bool can_set_sticker_set:Bool can_set_location:Bool can_get_statistics:Bool can_toggle_aggressive_anti_spam:Bool is_all_history_available:Bool is_aggressive_anti_spam_enabled:Bool sticker_set_id:int64 location:chatLocation invite_link:chatInviteLink bot_commands:vector<botCommands> upgraded_from_basic_group_id:int53 upgraded_from_max_message_id:int53 = SupergroupFullInfo;
|
||||||
|
|
||||||
|
|
||||||
//@class SecretChatState @description Describes the current secret chat state
|
//@class SecretChatState @description Describes the current secret chat state
|
||||||
|
@ -1877,6 +1877,11 @@ void ConfigManager::process_app_config(tl_object_ptr<telegram_api::JSONValue> &c
|
|||||||
}
|
}
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
if (key == "hidden_members_group_size_min") {
|
||||||
|
auto setting_value = get_json_value_int(std::move(key_value->value_), key);
|
||||||
|
G()->set_option_integer("hidden_members_group_size_min", setting_value);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
new_values.push_back(std::move(key_value));
|
new_values.push_back(std::move(key_value));
|
||||||
}
|
}
|
||||||
|
@ -7475,6 +7475,28 @@ void ContactsManager::toggle_channel_is_all_history_available(ChannelId channel_
|
|||||||
td_->create_handler<TogglePrehistoryHiddenQuery>(std::move(promise))->send(channel_id, is_all_history_available);
|
td_->create_handler<TogglePrehistoryHiddenQuery>(std::move(promise))->send(channel_id, is_all_history_available);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Status ContactsManager::can_hide_channel_participants(ChannelId channel_id, const ChannelFull *channel_full) const {
|
||||||
|
auto c = get_channel(channel_id);
|
||||||
|
if (c == nullptr) {
|
||||||
|
return Status::Error(400, "Supergroup not found");
|
||||||
|
}
|
||||||
|
if (!get_channel_permissions(c).can_restrict_members()) {
|
||||||
|
return Status::Error(400, "Not enough rights to hide group members");
|
||||||
|
}
|
||||||
|
if (get_channel_type(c) != ChannelType::Megagroup) {
|
||||||
|
return Status::Error(400, "Group members are hidden by default in channels");
|
||||||
|
}
|
||||||
|
if (channel_full != nullptr && channel_full->has_hidden_participants) {
|
||||||
|
return Status::OK();
|
||||||
|
}
|
||||||
|
if (c->participant_count > 0 &&
|
||||||
|
c->participant_count < td_->option_manager_->get_option_integer("hidden_members_group_size_min")) {
|
||||||
|
return Status::Error(400, "The supergroup is too small");
|
||||||
|
}
|
||||||
|
|
||||||
|
return Status::OK();
|
||||||
|
}
|
||||||
|
|
||||||
Status ContactsManager::can_toggle_channel_aggressive_anti_spam(ChannelId channel_id,
|
Status ContactsManager::can_toggle_channel_aggressive_anti_spam(ChannelId channel_id,
|
||||||
const ChannelFull *channel_full) const {
|
const ChannelFull *channel_full) const {
|
||||||
auto c = get_channel(channel_id);
|
auto c = get_channel(channel_id);
|
||||||
@ -16319,7 +16341,7 @@ bool ContactsManager::get_channel_has_hidden_participants(ChannelId channel_id)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return channel_full->has_hidden_participants;
|
return channel_full->has_hidden_participants || !channel_full->can_get_participants;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ContactsManager::have_channel(ChannelId channel_id) const {
|
bool ContactsManager::have_channel(ChannelId channel_id) const {
|
||||||
@ -18058,16 +18080,18 @@ tl_object_ptr<td_api::supergroupFullInfo> ContactsManager::get_supergroup_full_i
|
|||||||
auto bot_commands = transform(channel_full->bot_commands, [td = td_](const BotCommands &commands) {
|
auto bot_commands = transform(channel_full->bot_commands, [td = td_](const BotCommands &commands) {
|
||||||
return commands.get_bot_commands_object(td);
|
return commands.get_bot_commands_object(td);
|
||||||
});
|
});
|
||||||
|
bool has_hidden_participants = channel_full->has_hidden_participants || !channel_full->can_get_participants;
|
||||||
return td_api::make_object<td_api::supergroupFullInfo>(
|
return td_api::make_object<td_api::supergroupFullInfo>(
|
||||||
get_chat_photo_object(td_->file_manager_.get(), channel_full->photo), channel_full->description,
|
get_chat_photo_object(td_->file_manager_.get(), channel_full->photo), channel_full->description,
|
||||||
channel_full->participant_count, channel_full->administrator_count, channel_full->restricted_count,
|
channel_full->participant_count, channel_full->administrator_count, channel_full->restricted_count,
|
||||||
channel_full->banned_count, DialogId(channel_full->linked_channel_id).get(), channel_full->slow_mode_delay,
|
channel_full->banned_count, DialogId(channel_full->linked_channel_id).get(), channel_full->slow_mode_delay,
|
||||||
slow_mode_delay_expires_in, channel_full->can_get_participants, channel_full->has_hidden_participants,
|
slow_mode_delay_expires_in, channel_full->can_get_participants, has_hidden_participants,
|
||||||
channel_full->can_set_username, channel_full->can_set_sticker_set, channel_full->can_set_location,
|
can_hide_channel_participants(channel_id, channel_full).is_ok(), channel_full->can_set_username,
|
||||||
channel_full->can_view_statistics, can_toggle_channel_aggressive_anti_spam(channel_id, channel_full).is_ok(),
|
channel_full->can_set_sticker_set, channel_full->can_set_location, channel_full->can_view_statistics,
|
||||||
channel_full->is_all_history_available, channel_full->is_aggressive_anti_spam_enabled,
|
can_toggle_channel_aggressive_anti_spam(channel_id, channel_full).is_ok(), channel_full->is_all_history_available,
|
||||||
channel_full->sticker_set_id.get(), channel_full->location.get_chat_location_object(),
|
channel_full->is_aggressive_anti_spam_enabled, channel_full->sticker_set_id.get(),
|
||||||
channel_full->invite_link.get_chat_invite_link_object(this), std::move(bot_commands),
|
channel_full->location.get_chat_location_object(), channel_full->invite_link.get_chat_invite_link_object(this),
|
||||||
|
std::move(bot_commands),
|
||||||
get_basic_group_id_object(channel_full->migrated_from_chat_id, "get_supergroup_full_info_object"),
|
get_basic_group_id_object(channel_full->migrated_from_chat_id, "get_supergroup_full_info_object"),
|
||||||
channel_full->migrated_from_max_message_id.get());
|
channel_full->migrated_from_max_message_id.get());
|
||||||
}
|
}
|
||||||
|
@ -1680,6 +1680,8 @@ class ContactsManager final : public Actor {
|
|||||||
|
|
||||||
static tl_object_ptr<td_api::supergroup> get_supergroup_object(ChannelId channel_id, const Channel *c);
|
static tl_object_ptr<td_api::supergroup> get_supergroup_object(ChannelId channel_id, const Channel *c);
|
||||||
|
|
||||||
|
Status can_hide_channel_participants(ChannelId channel_id, const ChannelFull *channel_full) const;
|
||||||
|
|
||||||
Status can_toggle_channel_aggressive_anti_spam(ChannelId channel_id, const ChannelFull *channel_full) const;
|
Status can_toggle_channel_aggressive_anti_spam(ChannelId channel_id, const ChannelFull *channel_full) const;
|
||||||
|
|
||||||
tl_object_ptr<td_api::supergroupFullInfo> get_supergroup_full_info_object(ChannelId channel_id,
|
tl_object_ptr<td_api::supergroupFullInfo> get_supergroup_full_info_object(ChannelId channel_id,
|
||||||
|
@ -267,6 +267,8 @@ bool OptionManager::is_internal_option(Slice name) {
|
|||||||
return name == "edit_time_limit" || name == "emoji_sounds";
|
return name == "edit_time_limit" || name == "emoji_sounds";
|
||||||
case 'f':
|
case 'f':
|
||||||
return name == "fragment_prefixes";
|
return name == "fragment_prefixes";
|
||||||
|
case 'h':
|
||||||
|
return name == "hidden_members_group_size_min";
|
||||||
case 'i':
|
case 'i':
|
||||||
return name == "ignored_restriction_reasons";
|
return name == "ignored_restriction_reasons";
|
||||||
case 'l':
|
case 'l':
|
||||||
|
Loading…
Reference in New Issue
Block a user