Allow to change topic name and icon separately.
This commit is contained in:
parent
7c4ec3cffa
commit
aef203ed05
@ -5324,9 +5324,10 @@ createForumTopic chat_id:int53 name:string icon:forumTopicIcon = ForumTopicInfo;
|
|||||||
//@description Edits title and icon of a topic in a forum supergroup chat; requires can_manage_topics administrator rights in the supergroup unless the user is creator of the topic
|
//@description Edits title and icon of a topic in a forum supergroup chat; requires can_manage_topics administrator rights in the supergroup unless the user is creator of the topic
|
||||||
//@chat_id Identifier of the chat
|
//@chat_id Identifier of the chat
|
||||||
//@message_thread_id Message thread identifier of the forum topic
|
//@message_thread_id Message thread identifier of the forum topic
|
||||||
//@name New name of the topic; 1-128 characters
|
//@name New name of the topic; 0-128 characters. If empty, the previous topic name is kept
|
||||||
//@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
|
//@edit_icon_custom_emoji Pass true to edit the icon of the topic
|
||||||
editForumTopic chat_id:int53 message_thread_id:int53 name:string icon_custom_emoji_id:int64 = Ok;
|
//@icon_custom_emoji_id Identifier of the new custom emoji for topic icon; pass 0 to remove the custom emoji. Ignored if edit_icon_custom_emoji is false. 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 name:string edit_icon_custom_emoji:Bool icon_custom_emoji_id:int64 = Ok;
|
||||||
|
|
||||||
//@description Toggles whether a topic is closed in a forum supergroup chat; requires can_manage_topics administrator rights in the supergroup unless the user is creator of the topic
|
//@description Toggles whether a topic is closed in a forum supergroup chat; requires can_manage_topics administrator rights in the supergroup unless the user is creator of the topic
|
||||||
//@chat_id Identifier of the chat
|
//@chat_id Identifier of the chat
|
||||||
|
@ -121,16 +121,21 @@ class EditForumTopicQuery final : public Td::ResultHandler {
|
|||||||
explicit EditForumTopicQuery(Promise<Unit> &&promise) : promise_(std::move(promise)) {
|
explicit EditForumTopicQuery(Promise<Unit> &&promise) : promise_(std::move(promise)) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void send(ChannelId channel_id, MessageId top_thread_message_id, const string &title,
|
void send(ChannelId channel_id, MessageId top_thread_message_id, bool edit_title, const string &title,
|
||||||
CustomEmojiId icon_custom_emoji_id) {
|
bool edit_custom_emoji_id, CustomEmojiId icon_custom_emoji_id) {
|
||||||
channel_id_ = channel_id;
|
channel_id_ = channel_id;
|
||||||
top_thread_message_id_ = top_thread_message_id;
|
top_thread_message_id_ = top_thread_message_id;
|
||||||
|
|
||||||
auto input_channel = td_->contacts_manager_->get_input_channel(channel_id);
|
auto input_channel = td_->contacts_manager_->get_input_channel(channel_id);
|
||||||
CHECK(input_channel != nullptr);
|
CHECK(input_channel != nullptr);
|
||||||
|
|
||||||
int32 flags =
|
int32 flags = 0;
|
||||||
telegram_api::channels_editForumTopic::TITLE_MASK | telegram_api::channels_editForumTopic::ICON_EMOJI_ID_MASK;
|
if (edit_title) {
|
||||||
|
flags |= telegram_api::channels_editForumTopic::TITLE_MASK;
|
||||||
|
}
|
||||||
|
if (edit_custom_emoji_id) {
|
||||||
|
flags |= telegram_api::channels_editForumTopic::ICON_EMOJI_ID_MASK;
|
||||||
|
}
|
||||||
send_query(G()->net_query_creator().create(
|
send_query(G()->net_query_creator().create(
|
||||||
telegram_api::channels_editForumTopic(flags, std::move(input_channel),
|
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,
|
||||||
@ -257,7 +262,8 @@ void ForumTopicManager::on_forum_topic_created(DialogId dialog_id, unique_ptr<Fo
|
|||||||
}
|
}
|
||||||
|
|
||||||
void ForumTopicManager::edit_forum_topic(DialogId dialog_id, MessageId top_thread_message_id, string &&title,
|
void ForumTopicManager::edit_forum_topic(DialogId dialog_id, MessageId top_thread_message_id, string &&title,
|
||||||
CustomEmojiId icon_custom_emoji_id, Promise<Unit> &&promise) {
|
bool edit_icon_custom_emoji, CustomEmojiId icon_custom_emoji_id,
|
||||||
|
Promise<Unit> &&promise) {
|
||||||
TRY_STATUS_PROMISE(promise, is_forum(dialog_id));
|
TRY_STATUS_PROMISE(promise, is_forum(dialog_id));
|
||||||
auto channel_id = dialog_id.get_channel_id();
|
auto channel_id = dialog_id.get_channel_id();
|
||||||
|
|
||||||
@ -272,13 +278,14 @@ void ForumTopicManager::edit_forum_topic(DialogId dialog_id, MessageId top_threa
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool edit_title = !title.empty();
|
||||||
auto new_title = clean_name(std::move(title), MAX_FORUM_TOPIC_TITLE_LENGTH);
|
auto new_title = clean_name(std::move(title), MAX_FORUM_TOPIC_TITLE_LENGTH);
|
||||||
if (new_title.empty()) {
|
if (edit_title && new_title.empty()) {
|
||||||
return promise.set_error(Status::Error(400, "Title must be non-empty"));
|
return promise.set_error(Status::Error(400, "Title must be non-empty"));
|
||||||
}
|
}
|
||||||
|
|
||||||
td_->create_handler<EditForumTopicQuery>(std::move(promise))
|
td_->create_handler<EditForumTopicQuery>(std::move(promise))
|
||||||
->send(channel_id, top_thread_message_id, new_title, icon_custom_emoji_id);
|
->send(channel_id, top_thread_message_id, edit_title, new_title, edit_icon_custom_emoji, icon_custom_emoji_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ForumTopicManager::toggle_forum_topic_is_closed(DialogId dialog_id, MessageId top_thread_message_id,
|
void ForumTopicManager::toggle_forum_topic_is_closed(DialogId dialog_id, MessageId top_thread_message_id,
|
||||||
|
@ -41,7 +41,7 @@ class ForumTopicManager final : public Actor {
|
|||||||
Promise<td_api::object_ptr<td_api::forumTopicInfo>> &&promise);
|
Promise<td_api::object_ptr<td_api::forumTopicInfo>> &&promise);
|
||||||
|
|
||||||
void edit_forum_topic(DialogId dialog_id, MessageId top_thread_message_id, string &&title,
|
void edit_forum_topic(DialogId dialog_id, MessageId top_thread_message_id, string &&title,
|
||||||
CustomEmojiId icon_custom_emoji_id, Promise<Unit> &&promise);
|
bool edit_icon_custom_emoji, 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,
|
void toggle_forum_topic_is_closed(DialogId dialog_id, MessageId top_thread_message_id, bool is_closed,
|
||||||
Promise<Unit> &&promise);
|
Promise<Unit> &&promise);
|
||||||
|
@ -5545,8 +5545,8 @@ void Td::on_request(uint64 id, td_api::editForumTopic &request) {
|
|||||||
CLEAN_INPUT_STRING(request.name_);
|
CLEAN_INPUT_STRING(request.name_);
|
||||||
CREATE_OK_REQUEST_PROMISE();
|
CREATE_OK_REQUEST_PROMISE();
|
||||||
forum_topic_manager_->edit_forum_topic(DialogId(request.chat_id_), MessageId(request.message_thread_id_),
|
forum_topic_manager_->edit_forum_topic(DialogId(request.chat_id_), MessageId(request.message_thread_id_),
|
||||||
std::move(request.name_), CustomEmojiId(request.icon_custom_emoji_id_),
|
std::move(request.name_), request.edit_icon_custom_emoji_,
|
||||||
std::move(promise));
|
CustomEmojiId(request.icon_custom_emoji_id_), std::move(promise));
|
||||||
}
|
}
|
||||||
|
|
||||||
void Td::on_request(uint64 id, const td_api::toggleForumTopicIsClosed &request) {
|
void Td::on_request(uint64 id, const td_api::toggleForumTopicIsClosed &request) {
|
||||||
|
@ -3873,9 +3873,11 @@ class CliClient final : public Actor {
|
|||||||
ChatId chat_id;
|
ChatId chat_id;
|
||||||
MessageThreadId message_thread_id;
|
MessageThreadId message_thread_id;
|
||||||
string name;
|
string name;
|
||||||
|
bool edit_icon_custom_emoji;
|
||||||
int64 icon_custom_emoji_id;
|
int64 icon_custom_emoji_id;
|
||||||
get_args(args, chat_id, message_thread_id, name, icon_custom_emoji_id);
|
get_args(args, chat_id, message_thread_id, name, edit_icon_custom_emoji, icon_custom_emoji_id);
|
||||||
send_request(td_api::make_object<td_api::editForumTopic>(chat_id, message_thread_id, name, icon_custom_emoji_id));
|
send_request(td_api::make_object<td_api::editForumTopic>(chat_id, message_thread_id, name, edit_icon_custom_emoji,
|
||||||
|
icon_custom_emoji_id));
|
||||||
} else if (op == "tftic") {
|
} else if (op == "tftic") {
|
||||||
ChatId chat_id;
|
ChatId chat_id;
|
||||||
MessageThreadId message_thread_id;
|
MessageThreadId message_thread_id;
|
||||||
|
Loading…
Reference in New Issue
Block a user