Add toggleSupergroupHasHiddenMembers.
This commit is contained in:
parent
8bfc68b3f8
commit
6cb9371061
@ -7307,6 +7307,9 @@ toggleSupergroupJoinByRequest supergroup_id:int53 join_by_request:Bool = Ok;
|
|||||||
//@description Toggles whether the message history of a supergroup is available to new members; requires can_change_info administrator right @supergroup_id The identifier of the supergroup @is_all_history_available The new value of is_all_history_available
|
//@description Toggles whether the message history of a supergroup is available to new members; requires can_change_info administrator right @supergroup_id The identifier of the supergroup @is_all_history_available The new value of is_all_history_available
|
||||||
toggleSupergroupIsAllHistoryAvailable supergroup_id:int53 is_all_history_available:Bool = Ok;
|
toggleSupergroupIsAllHistoryAvailable supergroup_id:int53 is_all_history_available:Bool = Ok;
|
||||||
|
|
||||||
|
//@description Toggles whether non-administrators can receive only administrators and bots using getSupergroupMembers or searchChatMembers. Can be called only if supergroupFullInfo.can_hide_members == true @supergroup_id Identifier of the supergroup @has_hidden_members New value of has_hidden_members
|
||||||
|
toggleSupergroupHasHiddenMembers supergroup_id:int53 has_hidden_members:Bool = Ok;
|
||||||
|
|
||||||
//@description Toggles whether aggressive anti-spam checks are enabled in the supergroup. Can be called only if supergroupFullInfo.can_toggle_aggressive_anti_spam == true
|
//@description Toggles whether aggressive anti-spam checks are enabled in the supergroup. Can be called only if supergroupFullInfo.can_toggle_aggressive_anti_spam == true
|
||||||
//@supergroup_id The identifier of the supergroup, which isn't a broadcast group
|
//@supergroup_id The identifier of the supergroup, which isn't a broadcast group
|
||||||
//@is_aggressive_anti_spam_enabled The new value of is_aggressive_anti_spam_enabled
|
//@is_aggressive_anti_spam_enabled The new value of is_aggressive_anti_spam_enabled
|
||||||
|
@ -1295,6 +1295,58 @@ class TogglePrehistoryHiddenQuery final : public Td::ResultHandler {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
class ToggleParticipantsHiddenQuery final : public Td::ResultHandler {
|
||||||
|
Promise<Unit> promise_;
|
||||||
|
ChannelId channel_id_;
|
||||||
|
bool has_hidden_participants_;
|
||||||
|
|
||||||
|
public:
|
||||||
|
explicit ToggleParticipantsHiddenQuery(Promise<Unit> &&promise) : promise_(std::move(promise)) {
|
||||||
|
}
|
||||||
|
|
||||||
|
void send(ChannelId channel_id, bool has_hidden_participants) {
|
||||||
|
channel_id_ = channel_id;
|
||||||
|
has_hidden_participants_ = has_hidden_participants;
|
||||||
|
|
||||||
|
auto input_channel = td_->contacts_manager_->get_input_channel(channel_id);
|
||||||
|
CHECK(input_channel != nullptr);
|
||||||
|
send_query(G()->net_query_creator().create(
|
||||||
|
telegram_api::channels_toggleParticipantsHidden(std::move(input_channel), has_hidden_participants),
|
||||||
|
{{channel_id}}));
|
||||||
|
}
|
||||||
|
|
||||||
|
void on_result(BufferSlice packet) final {
|
||||||
|
auto result_ptr = fetch_result<telegram_api::channels_toggleParticipantsHidden>(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 ToggleParticipantsHiddenQuery: " << to_string(ptr);
|
||||||
|
|
||||||
|
td_->updates_manager_->on_get_updates(
|
||||||
|
std::move(ptr),
|
||||||
|
PromiseCreator::lambda([actor_id = G()->contacts_manager(), promise = std::move(promise_),
|
||||||
|
channel_id = channel_id_,
|
||||||
|
has_hidden_participants = has_hidden_participants_](Unit result) mutable {
|
||||||
|
send_closure(actor_id, &ContactsManager::on_update_channel_has_hidden_participants, channel_id,
|
||||||
|
has_hidden_participants, std::move(promise));
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
|
||||||
|
void on_error(Status status) final {
|
||||||
|
if (status.message() == "CHAT_NOT_MODIFIED") {
|
||||||
|
if (!td_->auth_manager_->is_bot()) {
|
||||||
|
promise_.set_value(Unit());
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
td_->contacts_manager_->on_get_channel_error(channel_id_, status, "ToggleParticipantsHiddenQuery");
|
||||||
|
}
|
||||||
|
promise_.set_error(std::move(status));
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
class ToggleAntiSpamQuery final : public Td::ResultHandler {
|
class ToggleAntiSpamQuery final : public Td::ResultHandler {
|
||||||
Promise<Unit> promise_;
|
Promise<Unit> promise_;
|
||||||
ChannelId channel_id_;
|
ChannelId channel_id_;
|
||||||
@ -7508,6 +7560,14 @@ Status ContactsManager::can_hide_channel_participants(ChannelId channel_id, cons
|
|||||||
return Status::OK();
|
return Status::OK();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ContactsManager::toggle_channel_has_hidden_participants(ChannelId channel_id, bool has_hidden_participants,
|
||||||
|
Promise<Unit> &&promise) {
|
||||||
|
auto channel_full = get_channel_full_force(channel_id, true, "toggle_channel_has_hidden_participants");
|
||||||
|
TRY_STATUS_PROMISE(promise, can_hide_channel_participants(channel_id, channel_full));
|
||||||
|
|
||||||
|
td_->create_handler<ToggleParticipantsHiddenQuery>(std::move(promise))->send(channel_id, has_hidden_participants);
|
||||||
|
}
|
||||||
|
|
||||||
Status ContactsManager::can_toggle_chat_aggressive_anti_spam(ChatId chat_id) const {
|
Status ContactsManager::can_toggle_chat_aggressive_anti_spam(ChatId chat_id) const {
|
||||||
auto c = get_chat(chat_id);
|
auto c = get_chat(chat_id);
|
||||||
if (c == nullptr) {
|
if (c == nullptr) {
|
||||||
@ -15308,6 +15368,19 @@ void ContactsManager::on_update_channel_is_all_history_available(ChannelId chann
|
|||||||
promise.set_value(Unit());
|
promise.set_value(Unit());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ContactsManager::on_update_channel_has_hidden_participants(ChannelId channel_id, bool has_hidden_participants,
|
||||||
|
Promise<Unit> &&promise) {
|
||||||
|
TRY_STATUS_PROMISE(promise, G()->close_status());
|
||||||
|
CHECK(channel_id.is_valid());
|
||||||
|
auto channel_full = get_channel_full_force(channel_id, true, "on_update_channel_has_hidden_participants");
|
||||||
|
if (channel_full != nullptr && channel_full->has_hidden_participants != has_hidden_participants) {
|
||||||
|
channel_full->has_hidden_participants = has_hidden_participants;
|
||||||
|
channel_full->is_changed = true;
|
||||||
|
update_channel_full(channel_full, channel_id, "on_update_channel_has_hidden_participants");
|
||||||
|
}
|
||||||
|
promise.set_value(Unit());
|
||||||
|
}
|
||||||
|
|
||||||
void ContactsManager::on_update_channel_is_aggressive_anti_spam_enabled(ChannelId channel_id,
|
void ContactsManager::on_update_channel_is_aggressive_anti_spam_enabled(ChannelId channel_id,
|
||||||
bool is_aggressive_anti_spam_enabled,
|
bool is_aggressive_anti_spam_enabled,
|
||||||
Promise<Unit> &&promise) {
|
Promise<Unit> &&promise) {
|
||||||
|
@ -213,6 +213,8 @@ class ContactsManager final : public Actor {
|
|||||||
void on_update_channel_slow_mode_next_send_date(ChannelId channel_id, int32 slow_mode_next_send_date);
|
void on_update_channel_slow_mode_next_send_date(ChannelId channel_id, int32 slow_mode_next_send_date);
|
||||||
void on_update_channel_is_all_history_available(ChannelId channel_id, bool is_all_history_available,
|
void on_update_channel_is_all_history_available(ChannelId channel_id, bool is_all_history_available,
|
||||||
Promise<Unit> &&promise);
|
Promise<Unit> &&promise);
|
||||||
|
void on_update_channel_has_hidden_participants(ChannelId channel_id, bool has_hidden_participants,
|
||||||
|
Promise<Unit> &&promise);
|
||||||
void on_update_channel_is_aggressive_anti_spam_enabled(ChannelId channel_id, bool is_aggressive_anti_spam_enabled,
|
void on_update_channel_is_aggressive_anti_spam_enabled(ChannelId channel_id, bool is_aggressive_anti_spam_enabled,
|
||||||
Promise<Unit> &&promise);
|
Promise<Unit> &&promise);
|
||||||
void on_update_channel_default_permissions(ChannelId channel_id, RestrictedRights default_permissions);
|
void on_update_channel_default_permissions(ChannelId channel_id, RestrictedRights default_permissions);
|
||||||
@ -405,6 +407,9 @@ class ContactsManager final : public Actor {
|
|||||||
void toggle_channel_is_all_history_available(ChannelId channel_id, bool is_all_history_available,
|
void toggle_channel_is_all_history_available(ChannelId channel_id, bool is_all_history_available,
|
||||||
Promise<Unit> &&promise);
|
Promise<Unit> &&promise);
|
||||||
|
|
||||||
|
void toggle_channel_has_hidden_participants(ChannelId channel_id, bool has_hidden_participants,
|
||||||
|
Promise<Unit> &&promise);
|
||||||
|
|
||||||
void toggle_channel_is_aggressive_anti_spam_enabled(ChannelId channel_id, bool is_aggressive_anti_spam_enabled,
|
void toggle_channel_is_aggressive_anti_spam_enabled(ChannelId channel_id, bool is_aggressive_anti_spam_enabled,
|
||||||
Promise<Unit> &&promise);
|
Promise<Unit> &&promise);
|
||||||
|
|
||||||
|
@ -7054,6 +7054,13 @@ void Td::on_request(uint64 id, const td_api::toggleSupergroupIsAllHistoryAvailab
|
|||||||
request.is_all_history_available_, std::move(promise));
|
request.is_all_history_available_, std::move(promise));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Td::on_request(uint64 id, const td_api::toggleSupergroupHasHiddenMembers &request) {
|
||||||
|
CHECK_IS_USER();
|
||||||
|
CREATE_OK_REQUEST_PROMISE();
|
||||||
|
contacts_manager_->toggle_channel_has_hidden_participants(ChannelId(request.supergroup_id_),
|
||||||
|
request.has_hidden_members_, std::move(promise));
|
||||||
|
}
|
||||||
|
|
||||||
void Td::on_request(uint64 id, const td_api::toggleSupergroupIsAggressiveAntiSpamEnabled &request) {
|
void Td::on_request(uint64 id, const td_api::toggleSupergroupIsAggressiveAntiSpamEnabled &request) {
|
||||||
CHECK_IS_USER();
|
CHECK_IS_USER();
|
||||||
CREATE_OK_REQUEST_PROMISE();
|
CREATE_OK_REQUEST_PROMISE();
|
||||||
|
@ -1122,6 +1122,8 @@ class Td final : public Actor {
|
|||||||
|
|
||||||
void on_request(uint64 id, const td_api::toggleSupergroupIsAllHistoryAvailable &request);
|
void on_request(uint64 id, const td_api::toggleSupergroupIsAllHistoryAvailable &request);
|
||||||
|
|
||||||
|
void on_request(uint64 id, const td_api::toggleSupergroupHasHiddenMembers &request);
|
||||||
|
|
||||||
void on_request(uint64 id, const td_api::toggleSupergroupIsAggressiveAntiSpamEnabled &request);
|
void on_request(uint64 id, const td_api::toggleSupergroupIsAggressiveAntiSpamEnabled &request);
|
||||||
|
|
||||||
void on_request(uint64 id, const td_api::toggleSupergroupIsForum &request);
|
void on_request(uint64 id, const td_api::toggleSupergroupIsForum &request);
|
||||||
|
@ -4671,6 +4671,12 @@ class CliClient final : public Actor {
|
|||||||
get_args(args, supergroup_id, is_all_history_available);
|
get_args(args, supergroup_id, is_all_history_available);
|
||||||
send_request(td_api::make_object<td_api::toggleSupergroupIsAllHistoryAvailable>(as_supergroup_id(supergroup_id),
|
send_request(td_api::make_object<td_api::toggleSupergroupIsAllHistoryAvailable>(as_supergroup_id(supergroup_id),
|
||||||
is_all_history_available));
|
is_all_history_available));
|
||||||
|
} else if (op == "tsghhm") {
|
||||||
|
string supergroup_id;
|
||||||
|
bool has_hidden_members;
|
||||||
|
get_args(args, supergroup_id, has_hidden_members);
|
||||||
|
send_request(td_api::make_object<td_api::toggleSupergroupHasHiddenMembers>(as_supergroup_id(supergroup_id),
|
||||||
|
has_hidden_members));
|
||||||
} else if (op == "tsgas") {
|
} else if (op == "tsgas") {
|
||||||
string supergroup_id;
|
string supergroup_id;
|
||||||
bool is_aggressive_anti_spam_enabled;
|
bool is_aggressive_anti_spam_enabled;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user