Add td_api::toggleGeneralForumTopicIsHidden.
This commit is contained in:
parent
4d82036ac4
commit
38d3ecbd26
@ -5336,6 +5336,11 @@ editForumTopic chat_id:int53 message_thread_id:int53 name:string edit_icon_custo
|
||||
//@is_closed Pass true to close the topic; pass false to reopen it
|
||||
toggleForumTopicIsClosed chat_id:int53 message_thread_id:int53 is_closed:Bool = Ok;
|
||||
|
||||
//@description Toggles whether a General topic is hidden in a forum supergroup chat; requires can_manage_topics administrator rights in the supergroup
|
||||
//@chat_id Identifier of the chat
|
||||
//@is_hidden Pass true to hide and close the General topic; pass false to unhide it
|
||||
toggleGeneralForumTopicIsHidden chat_id:int53 is_hidden:Bool = Ok;
|
||||
|
||||
//@description Deletes all messages in a forum topic; requires can_delete_messages administrator rights in the supergroup unless the user is creator of the topic, the topic has no messages from other users and has at most 11 messages
|
||||
//@chat_id Identifier of the chat
|
||||
//@message_thread_id Message thread identifier of the forum topic
|
||||
|
@ -138,7 +138,7 @@ class EditForumTopicQuery final : public Td::ResultHandler {
|
||||
}
|
||||
send_query(G()->net_query_creator().create(
|
||||
telegram_api::channels_editForumTopic(flags, std::move(input_channel),
|
||||
top_thread_message_id.get_server_message_id().get(), title,
|
||||
top_thread_message_id_.get_server_message_id().get(), title,
|
||||
icon_custom_emoji_id.get(), false, false),
|
||||
{{channel_id}}));
|
||||
}
|
||||
@ -153,11 +153,26 @@ class EditForumTopicQuery final : public Td::ResultHandler {
|
||||
int32 flags = telegram_api::channels_editForumTopic::CLOSED_MASK;
|
||||
send_query(G()->net_query_creator().create(
|
||||
telegram_api::channels_editForumTopic(flags, std::move(input_channel),
|
||||
top_thread_message_id.get_server_message_id().get(), string(), 0,
|
||||
top_thread_message_id_.get_server_message_id().get(), string(), 0,
|
||||
is_closed, false),
|
||||
{{channel_id}}));
|
||||
}
|
||||
|
||||
void send(ChannelId channel_id, bool is_hidden) {
|
||||
channel_id_ = channel_id;
|
||||
top_thread_message_id_ = MessageId(ServerMessageId(1));
|
||||
|
||||
auto input_channel = td_->contacts_manager_->get_input_channel(channel_id);
|
||||
CHECK(input_channel != nullptr);
|
||||
|
||||
int32 flags = telegram_api::channels_editForumTopic::HIDDEN_MASK;
|
||||
send_query(G()->net_query_creator().create(
|
||||
telegram_api::channels_editForumTopic(flags, std::move(input_channel),
|
||||
top_thread_message_id_.get_server_message_id().get(), string(), 0, false,
|
||||
is_hidden),
|
||||
{{channel_id}}));
|
||||
}
|
||||
|
||||
void on_result(BufferSlice packet) final {
|
||||
auto result_ptr = fetch_result<telegram_api::channels_editForumTopic>(packet);
|
||||
if (result_ptr.is_error()) {
|
||||
@ -310,6 +325,17 @@ void ForumTopicManager::toggle_forum_topic_is_closed(DialogId dialog_id, Message
|
||||
td_->create_handler<EditForumTopicQuery>(std::move(promise))->send(channel_id, top_thread_message_id, is_closed);
|
||||
}
|
||||
|
||||
void ForumTopicManager::toggle_forum_topic_is_hidden(DialogId dialog_id, bool is_hidden, Promise<Unit> &&promise) {
|
||||
TRY_STATUS_PROMISE(promise, is_forum(dialog_id));
|
||||
auto channel_id = dialog_id.get_channel_id();
|
||||
|
||||
if (!td_->contacts_manager_->get_channel_permissions(channel_id).can_edit_topics()) {
|
||||
return promise.set_error(Status::Error(400, "Not enough rights to close or open the topic"));
|
||||
}
|
||||
|
||||
td_->create_handler<EditForumTopicQuery>(std::move(promise))->send(channel_id, is_hidden);
|
||||
}
|
||||
|
||||
void ForumTopicManager::delete_forum_topic(DialogId dialog_id, MessageId top_thread_message_id,
|
||||
Promise<Unit> &&promise) {
|
||||
TRY_STATUS_PROMISE(promise, is_forum(dialog_id));
|
||||
|
@ -46,6 +46,8 @@ class ForumTopicManager final : public Actor {
|
||||
void toggle_forum_topic_is_closed(DialogId dialog_id, MessageId top_thread_message_id, bool is_closed,
|
||||
Promise<Unit> &&promise);
|
||||
|
||||
void toggle_forum_topic_is_hidden(DialogId dialog_id, bool is_hidden, Promise<Unit> &&promise);
|
||||
|
||||
void delete_forum_topic(DialogId dialog_id, MessageId top_thread_message_id, Promise<Unit> &&promise);
|
||||
|
||||
void delete_all_dialog_topics(DialogId dialog_id);
|
||||
|
@ -5555,6 +5555,12 @@ void Td::on_request(uint64 id, const td_api::toggleForumTopicIsClosed &request)
|
||||
request.is_closed_, std::move(promise));
|
||||
}
|
||||
|
||||
void Td::on_request(uint64 id, const td_api::toggleGeneralForumTopicIsHidden &request) {
|
||||
CREATE_OK_REQUEST_PROMISE();
|
||||
forum_topic_manager_->toggle_forum_topic_is_hidden(DialogId(request.chat_id_), request.is_hidden_,
|
||||
std::move(promise));
|
||||
}
|
||||
|
||||
void Td::on_request(uint64 id, const td_api::deleteForumTopic &request) {
|
||||
CREATE_OK_REQUEST_PROMISE();
|
||||
forum_topic_manager_->delete_forum_topic(DialogId(request.chat_id_), MessageId(request.message_thread_id_),
|
||||
|
@ -746,6 +746,8 @@ class Td final : public Actor {
|
||||
|
||||
void on_request(uint64 id, const td_api::toggleForumTopicIsClosed &request);
|
||||
|
||||
void on_request(uint64 id, const td_api::toggleGeneralForumTopicIsHidden &request);
|
||||
|
||||
void on_request(uint64 id, const td_api::deleteForumTopic &request);
|
||||
|
||||
void on_request(uint64 id, td_api::setGameScore &request);
|
||||
|
@ -3884,6 +3884,11 @@ class CliClient final : public Actor {
|
||||
bool is_closed;
|
||||
get_args(args, chat_id, message_thread_id, is_closed);
|
||||
send_request(td_api::make_object<td_api::toggleForumTopicIsClosed>(chat_id, message_thread_id, is_closed));
|
||||
} else if (op == "tgftih") {
|
||||
ChatId chat_id;
|
||||
bool is_hidden;
|
||||
get_args(args, chat_id, is_hidden);
|
||||
send_request(td_api::make_object<td_api::toggleGeneralForumTopicIsHidden>(chat_id, is_hidden));
|
||||
} else if (op == "dft") {
|
||||
ChatId chat_id;
|
||||
MessageThreadId message_thread_id;
|
||||
|
Loading…
Reference in New Issue
Block a user