Add td_api::toggleSupergroupIsBroadcastGroup.

This commit is contained in:
levlam 2021-02-17 01:06:35 +03:00
parent 498476a95d
commit 9b62afbea2
7 changed files with 71 additions and 0 deletions

View File

@ -4779,6 +4779,9 @@ toggleSupergroupSignMessages supergroup_id:int32 sign_messages: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:int32 is_all_history_available:Bool = Ok; toggleSupergroupIsAllHistoryAvailable supergroup_id:int32 is_all_history_available:Bool = Ok;
//@description Upgrades supergroup to a broadcast group; requires owner privileges in the supergroup @supergroup_id Identifier of the supergroup
toggleSupergroupIsBroadcastGroup supergroup_id:int32 = Ok;
//@description Reports some messages from a user in a supergroup as spam; requires administrator rights in the supergroup @supergroup_id Supergroup identifier @user_id User identifier @message_ids Identifiers of messages sent in the supergroup by the user. This list must be non-empty //@description Reports some messages from a user in a supergroup as spam; requires administrator rights in the supergroup @supergroup_id Supergroup identifier @user_id User identifier @message_ids Identifiers of messages sent in the supergroup by the user. This list must be non-empty
reportSupergroupSpam supergroup_id:int32 user_id:int32 message_ids:vector<int53> = Ok; reportSupergroupSpam supergroup_id:int32 user_id:int32 message_ids:vector<int53> = Ok;

Binary file not shown.

View File

@ -1208,6 +1208,45 @@ class TogglePrehistoryHiddenQuery : public Td::ResultHandler {
} }
}; };
class ConvertToGigagroupQuery : public Td::ResultHandler {
Promise<Unit> promise_;
ChannelId channel_id_;
public:
explicit ConvertToGigagroupQuery(Promise<Unit> &&promise) : promise_(std::move(promise)) {
}
void send(ChannelId channel_id) {
channel_id_ = channel_id;
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_convertToGigagroup(std::move(input_channel))));
}
void on_result(uint64 id, BufferSlice packet) override {
auto result_ptr = fetch_result<telegram_api::channels_convertToGigagroup>(packet);
if (result_ptr.is_error()) {
return on_error(id, result_ptr.move_as_error());
}
auto ptr = result_ptr.move_as_ok();
LOG(INFO) << "Receive result for ConvertToGigagroupQuery: " << to_string(ptr);
td->updates_manager_->on_get_updates(std::move(ptr), std::move(promise_));
}
void on_error(uint64 id, Status status) override {
if (status.message() == "CHAT_NOT_MODIFIED") {
promise_.set_value(Unit());
return;
} else {
td->contacts_manager_->on_get_channel_error(channel_id_, status, "ConvertToGigagroupQuery");
}
promise_.set_error(std::move(status));
}
};
class EditChatAboutQuery : public Td::ResultHandler { class EditChatAboutQuery : public Td::ResultHandler {
Promise<Unit> promise_; Promise<Unit> promise_;
DialogId dialog_id_; DialogId dialog_id_;
@ -6159,6 +6198,21 @@ 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);
} }
void ContactsManager::convert_channel_to_gigagroup(ChannelId channel_id, Promise<Unit> &&promise) {
auto c = get_channel(channel_id);
if (c == nullptr) {
return promise.set_error(Status::Error(6, "Supergroup not found"));
}
if (!get_channel_permissions(c).is_creator()) {
return promise.set_error(Status::Error(6, "Not enough rights to convert group to broadcast group"));
}
if (get_channel_type(c) != ChannelType::Megagroup) {
return promise.set_error(Status::Error(6, "Chat must be a supergroup"));
}
td_->create_handler<ConvertToGigagroupQuery>(std::move(promise))->send(channel_id);
}
void ContactsManager::set_channel_description(ChannelId channel_id, const string &description, void ContactsManager::set_channel_description(ChannelId channel_id, const string &description,
Promise<Unit> &&promise) { Promise<Unit> &&promise) {
auto new_description = strip_empty_characters(description, MAX_DESCRIPTION_LENGTH); auto new_description = strip_empty_characters(description, MAX_DESCRIPTION_LENGTH);

View File

@ -352,6 +352,8 @@ class ContactsManager : 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 convert_channel_to_gigagroup(ChannelId channel_id, Promise<Unit> &&promise);
void set_channel_description(ChannelId channel_id, const string &description, Promise<Unit> &&promise); void set_channel_description(ChannelId channel_id, const string &description, Promise<Unit> &&promise);
void set_channel_discussion_group(DialogId dialog_id, DialogId discussion_dialog_id, Promise<Unit> &&promise); void set_channel_discussion_group(DialogId dialog_id, DialogId discussion_dialog_id, Promise<Unit> &&promise);

View File

@ -6733,6 +6733,12 @@ 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::toggleSupergroupIsBroadcastGroup &request) {
CHECK_IS_USER();
CREATE_OK_REQUEST_PROMISE();
contacts_manager_->convert_channel_to_gigagroup(ChannelId(request.supergroup_id_), std::move(promise));
}
void Td::on_request(uint64 id, const td_api::reportSupergroupSpam &request) { void Td::on_request(uint64 id, const td_api::reportSupergroupSpam &request) {
CHECK_IS_USER(); CHECK_IS_USER();
CREATE_OK_REQUEST_PROMISE(); CREATE_OK_REQUEST_PROMISE();

View File

@ -892,6 +892,8 @@ class Td final : public NetQueryCallback {
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::toggleSupergroupIsBroadcastGroup &request);
void on_request(uint64 id, const td_api::reportSupergroupSpam &request); void on_request(uint64 id, const td_api::reportSupergroupSpam &request);
void on_request(uint64 id, td_api::getSupergroupMembers &request); void on_request(uint64 id, td_api::getSupergroupMembers &request);

View File

@ -3728,6 +3728,10 @@ 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 == "ToggleSupergroupIsBroadcastGroup") {
string supergroup_id;
get_args(args, supergroup_id);
send_request(td_api::make_object<td_api::toggleSupergroupIsBroadcastGroup>(as_supergroup_id(supergroup_id)));
} else if (op == "tsgsm") { } else if (op == "tsgsm") {
string supergroup_id; string supergroup_id;
bool sign_messages; bool sign_messages;