Add toggleForumTopicIsClosed.
This commit is contained in:
parent
0a0710c3eb
commit
99e6629c79
@ -5307,6 +5307,12 @@ createForumTopic chat_id:int53 title:string icon:forumTopicIcon = ForumTopicInfo
|
||||
//@icon_custom_emoji_id Identifier of the new custom emoji for topic icon. Telegram Premium users can use any custom emoji, other users can use only a custom emoji returned by getForumTopicDefaultIcons
|
||||
editForumTopic chat_id:int53 message_thread_id:int53 title:string icon_custom_emoji_id:int64 = Ok;
|
||||
|
||||
//@description Toggles is_closed state of a topic in a forum supergroup chat; requires can_manage_topics administrator rights in the supergroup
|
||||
//@chat_id Identifier of the chat
|
||||
//@message_thread_id Message thread identifier of the forum topic
|
||||
//@is_closed Pass true to close the topic; pass false to open it
|
||||
toggleForumTopicIsClosed chat_id:int53 message_thread_id:int53 is_closed:Bool = Ok;
|
||||
|
||||
|
||||
//@description Returns information about a emoji reaction. Returns a 404 error if the reaction is not found @emoji Text representation of the reaction
|
||||
getEmojiReaction emoji:string = EmojiReaction;
|
||||
|
@ -131,6 +131,21 @@ class EditForumTopicQuery final : public Td::ResultHandler {
|
||||
{{channel_id}}));
|
||||
}
|
||||
|
||||
void send(ChannelId channel_id, MessageId top_thread_message_id, bool is_closed) {
|
||||
channel_id_ = channel_id;
|
||||
top_thread_message_id_ = top_thread_message_id;
|
||||
|
||||
auto input_channel = td_->contacts_manager_->get_input_channel(channel_id);
|
||||
CHECK(input_channel != nullptr);
|
||||
|
||||
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,
|
||||
is_closed),
|
||||
{{channel_id}}));
|
||||
}
|
||||
|
||||
void on_result(BufferSlice packet) final {
|
||||
auto result_ptr = fetch_result<telegram_api::channels_editForumTopic>(packet);
|
||||
if (result_ptr.is_error()) {
|
||||
@ -233,6 +248,22 @@ void ForumTopicManager::edit_forum_topic(DialogId dialog_id, MessageId top_threa
|
||||
->send(channel_id, top_thread_message_id, new_title, icon_custom_emoji_id);
|
||||
}
|
||||
|
||||
void ForumTopicManager::toggle_forum_topic_is_closed(DialogId dialog_id, MessageId top_thread_message_id,
|
||||
bool is_closed, Promise<Unit> &&promise) {
|
||||
TRY_STATUS_PROMISE(promise, is_forum(dialog_id));
|
||||
auto channel_id = dialog_id.get_channel_id();
|
||||
|
||||
if (!top_thread_message_id.is_valid() || !top_thread_message_id.is_server()) {
|
||||
return promise.set_error(Status::Error(400, "Invalid message thread identifier specified"));
|
||||
}
|
||||
|
||||
if (!td_->contacts_manager_->get_channel_permissions(channel_id).can_edit_topics()) {
|
||||
return promise.set_error(Status::Error(400, "Not enough rights to edit a topic"));
|
||||
}
|
||||
|
||||
td_->create_handler<EditForumTopicQuery>(std::move(promise))->send(channel_id, top_thread_message_id, is_closed);
|
||||
}
|
||||
|
||||
Status ForumTopicManager::is_forum(DialogId dialog_id) {
|
||||
if (!td_->messages_manager_->have_dialog_force(dialog_id, "ForumTopicManager::is_forum")) {
|
||||
return Status::Error(400, "Chat not found");
|
||||
|
@ -39,6 +39,9 @@ class ForumTopicManager final : public Actor {
|
||||
void edit_forum_topic(DialogId dialog_id, MessageId top_thread_message_id, string &&title,
|
||||
CustomEmojiId icon_custom_emoji_id, Promise<Unit> &&promise);
|
||||
|
||||
void toggle_forum_topic_is_closed(DialogId dialog_id, MessageId top_thread_message_id, bool is_closed,
|
||||
Promise<Unit> &&promise);
|
||||
|
||||
private:
|
||||
static constexpr size_t MAX_FORUM_TOPIC_TITLE_LENGTH = 128; // server side limit for forum topic title
|
||||
|
||||
|
@ -5532,6 +5532,13 @@ void Td::on_request(uint64 id, td_api::editForumTopic &request) {
|
||||
std::move(promise));
|
||||
}
|
||||
|
||||
void Td::on_request(uint64 id, const td_api::toggleForumTopicIsClosed &request) {
|
||||
CHECK_IS_USER();
|
||||
CREATE_OK_REQUEST_PROMISE();
|
||||
forum_topic_manager_->toggle_forum_topic_is_closed(DialogId(request.chat_id_), MessageId(request.message_thread_id_),
|
||||
request.is_closed_, std::move(promise));
|
||||
}
|
||||
|
||||
void Td::on_request(uint64 id, td_api::setGameScore &request) {
|
||||
CHECK_IS_BOT();
|
||||
CREATE_REQUEST_PROMISE();
|
||||
|
@ -736,6 +736,8 @@ class Td final : public Actor {
|
||||
|
||||
void on_request(uint64 id, td_api::editForumTopic &request);
|
||||
|
||||
void on_request(uint64 id, const td_api::toggleForumTopicIsClosed &request);
|
||||
|
||||
void on_request(uint64 id, td_api::setGameScore &request);
|
||||
|
||||
void on_request(uint64 id, td_api::setInlineGameScore &request);
|
||||
|
@ -3871,6 +3871,12 @@ class CliClient final : public Actor {
|
||||
get_args(args, chat_id, message_thread_id, title, icon_custom_emoji_id);
|
||||
send_request(
|
||||
td_api::make_object<td_api::editForumTopic>(chat_id, message_thread_id, title, icon_custom_emoji_id));
|
||||
} else if (op == "tftic") {
|
||||
ChatId chat_id;
|
||||
MessageThreadId message_thread_id;
|
||||
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 == "gallm") {
|
||||
send_request(td_api::make_object<td_api::getActiveLiveLocationMessages>());
|
||||
} else if (op == "sbsm") {
|
||||
|
Loading…
Reference in New Issue
Block a user