aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--example/csharp/TdExample.cs2
-rw-r--r--example/java/org/drinkless/tdlib/example/Example.java2
-rw-r--r--td/generate/DoxygenTlDocumentationGenerator.php2
-rw-r--r--td/generate/scheme/td_api.tl19
-rw-r--r--td/telegram/MessageCopyOptions.h9
-rw-r--r--td/telegram/MessagesManager.cpp196
-rw-r--r--td/telegram/MessagesManager.h32
-rw-r--r--td/telegram/Requests.cpp16
-rw-r--r--td/telegram/cli.cpp22
-rw-r--r--td/tl/TlObject.h2
-rw-r--r--test/online.cpp2
-rw-r--r--test/tdclient.cpp12
12 files changed, 141 insertions, 175 deletions
diff --git a/example/csharp/TdExample.cs b/example/csharp/TdExample.cs
index a912d9808..2525bb514 100644
--- a/example/csharp/TdExample.cs
+++ b/example/csharp/TdExample.cs
@@ -210,7 +210,7 @@ namespace TdExample
TdApi.ReplyMarkup replyMarkup = new TdApi.ReplyMarkupInlineKeyboard(new TdApi.InlineKeyboardButton[][] { row, row, row });
TdApi.InputMessageContent content = new TdApi.InputMessageText(new TdApi.FormattedText(message, null), null, true);
- _client.Send(new TdApi.SendMessage(chatId, 0, null, null, replyMarkup, content), _defaultHandler);
+ _client.Send(new TdApi.SendMessage(chatId, null, null, null, replyMarkup, content), _defaultHandler);
}
static void Main()
diff --git a/example/java/org/drinkless/tdlib/example/Example.java b/example/java/org/drinkless/tdlib/example/Example.java
index 1775cf48b..ffa18deba 100644
--- a/example/java/org/drinkless/tdlib/example/Example.java
+++ b/example/java/org/drinkless/tdlib/example/Example.java
@@ -293,7 +293,7 @@ public final class Example {
TdApi.ReplyMarkup replyMarkup = new TdApi.ReplyMarkupInlineKeyboard(new TdApi.InlineKeyboardButton[][]{row, row, row});
TdApi.InputMessageContent content = new TdApi.InputMessageText(new TdApi.FormattedText(message, null), null, true);
- client.send(new TdApi.SendMessage(chatId, 0, null, null, replyMarkup, content), defaultHandler);
+ client.send(new TdApi.SendMessage(chatId, null, null, null, replyMarkup, content), defaultHandler);
}
public static void main(String[] args) throws InterruptedException {
diff --git a/td/generate/DoxygenTlDocumentationGenerator.php b/td/generate/DoxygenTlDocumentationGenerator.php
index 5fa507baf..1d21eb845 100644
--- a/td/generate/DoxygenTlDocumentationGenerator.php
+++ b/td/generate/DoxygenTlDocumentationGenerator.php
@@ -235,7 +235,7 @@ EOT
* auto get_me_request = td::td_api::make_object<td::td_api::getMe>();
* auto message_text = td::td_api::make_object<td::td_api::formattedText>("Hello, world!!!",
* td::td_api::array<td::td_api::object_ptr<td::td_api::textEntity>>());
- * auto send_message_request = td::td_api::make_object<td::td_api::sendMessage>(chat_id, 0, nullptr, nullptr, nullptr,
+ * auto send_message_request = td::td_api::make_object<td::td_api::sendMessage>(chat_id, nullptr, nullptr, nullptr, nullptr,
* td::td_api::make_object<td::td_api::inputMessageText>(std::move(message_text), nullptr, true));
* \\endcode
*
diff --git a/td/generate/scheme/td_api.tl b/td/generate/scheme/td_api.tl
index 3859e5926..5baef7f85 100644
--- a/td/generate/scheme/td_api.tl
+++ b/td/generate/scheme/td_api.tl
@@ -4940,7 +4940,6 @@ messageSelfDestructTypeImmediately = MessageSelfDestructType;
//@description Options to be used when a message is sent
-//@direct_messages_chat_topic_id Unique identifier of the topic in a channel direct messages chat administered by the current user; pass 0 if the chat isn't a channel direct messages chat administered by the current user
//@suggested_post_info Information about the suggested post; pass null if none. For messages to channel direct messages chat only. Applicable only to sendMessage and addOffer
//@disable_notification Pass true to disable notification for the message
//@from_background Pass true if the message is sent from the background
@@ -4953,7 +4952,7 @@ messageSelfDestructTypeImmediately = MessageSelfDestructType;
//@effect_id Identifier of the effect to apply to the message; pass 0 if none; applicable only to sendMessage and sendMessageAlbum in private chats
//@sending_id Non-persistent identifier, which will be returned back in messageSendingStatePending object and can be used to match sent messages and corresponding updateNewMessage updates
//@only_preview Pass true to get a fake message instead of actually sending them
-messageSendOptions direct_messages_chat_topic_id:int53 suggested_post_info:inputSuggestedPostInfo disable_notification:Bool from_background:Bool protect_content:Bool allow_paid_broadcast:Bool paid_message_star_count:int53 update_order_of_installed_sticker_sets:Bool scheduling_state:MessageSchedulingState effect_id:int64 sending_id:int32 only_preview:Bool = MessageSendOptions;
+messageSendOptions suggested_post_info:inputSuggestedPostInfo disable_notification:Bool from_background:Bool protect_content:Bool allow_paid_broadcast:Bool paid_message_star_count:int53 update_order_of_installed_sticker_sets:Bool scheduling_state:MessageSchedulingState effect_id:int64 sending_id:int32 only_preview:Bool = MessageSendOptions;
//@description Options to be used when a message content is copied without reference to the original sender. Service messages, messages with messageInvoice, messagePaidMedia, messageGiveaway, or messageGiveawayWinners content can't be copied
//@send_copy True, if content of the message needs to be copied without reference to the original sender. Always true if the message is forwarded to a secret chat or is local.
@@ -10481,21 +10480,21 @@ setChatMessageSender chat_id:int53 message_sender_id:MessageSender = Ok;
//@description Sends a message. Returns the sent message
//@chat_id Target chat
-//@message_thread_id If not 0, the message thread identifier in which the message will be sent
+//@topic_id Topic in which the message will be sent; pass null if none
//@reply_to Information about the message or story to be replied; pass null if none
//@options Options to be used to send the message; pass null to use default options
//@reply_markup Markup for replying to the message; pass null if none; for bots only
//@input_message_content The content of the message to be sent
-sendMessage chat_id:int53 message_thread_id:int53 reply_to:InputMessageReplyTo options:messageSendOptions reply_markup:ReplyMarkup input_message_content:InputMessageContent = Message;
+sendMessage chat_id:int53 topic_id:MessageTopic reply_to:InputMessageReplyTo options:messageSendOptions reply_markup:ReplyMarkup input_message_content:InputMessageContent = Message;
//@description Sends 2-10 messages grouped together into an album. Currently, only audio, document, photo and video messages can be grouped into an album.
//-Documents and audio files can be only grouped in an album with messages of the same type. Returns sent messages
//@chat_id Target chat
-//@message_thread_id If not 0, the message thread identifier in which the messages will be sent
+//@topic_id Topic in which the messages will be sent; pass null if none
//@reply_to Information about the message or story to be replied; pass null if none
//@options Options to be used to send the messages; pass null to use default options
//@input_message_contents Contents of messages to be sent. At most 10 messages can be added to an album. All messages must have the same value of show_caption_above_media
-sendMessageAlbum chat_id:int53 message_thread_id:int53 reply_to:InputMessageReplyTo options:messageSendOptions input_message_contents:vector<InputMessageContent> = Messages;
+sendMessageAlbum chat_id:int53 topic_id:MessageTopic reply_to:InputMessageReplyTo options:messageSendOptions input_message_contents:vector<InputMessageContent> = Messages;
//@description Invites a bot to a chat (if it is not yet a member) and sends it the /start command; requires can_invite_users member right. Bots can't be invited to a private chat other than the chat with the bot.
//-Bots can't be invited to channels (although they can be added as admins) and secret chats. Returns the sent message
@@ -10506,24 +10505,24 @@ sendBotStartMessage bot_user_id:int53 chat_id:int53 parameter:string = Message;
//@description Sends the result of an inline query as a message. Returns the sent message. Always clears a chat draft message
//@chat_id Target chat
-//@message_thread_id If not 0, the message thread identifier in which the message will be sent
+//@topic_id Topic in which the message will be sent; pass null if none
//@reply_to Information about the message or story to be replied; pass null if none
//@options Options to be used to send the message; pass null to use default options
//@query_id Identifier of the inline query
//@result_id Identifier of the inline query result
//@hide_via_bot Pass true to hide the bot, via which the message is sent. Can be used only for bots getOption("animation_search_bot_username"), getOption("photo_search_bot_username"), and getOption("venue_search_bot_username")
-sendInlineQueryResultMessage chat_id:int53 message_thread_id:int53 reply_to:InputMessageReplyTo options:messageSendOptions query_id:int64 result_id:string hide_via_bot:Bool = Message;
+sendInlineQueryResultMessage chat_id:int53 topic_id:MessageTopic reply_to:InputMessageReplyTo options:messageSendOptions query_id:int64 result_id:string hide_via_bot:Bool = Message;
//@description Forwards previously sent messages. Returns the forwarded messages in the same order as the message identifiers passed in message_ids. If a message can't be forwarded, null will be returned instead of the message
//@chat_id Identifier of the chat to which to forward messages
-//@message_thread_id If not 0, the message thread identifier in which the message will be sent; for forum threads only
+//@topic_id Topic in which the messages will be forwarded; message threads aren't supported; pass null if none
//@from_chat_id Identifier of the chat from which to forward messages
//@message_ids Identifiers of the messages to forward. Message identifiers must be in a strictly increasing order. At most 100 messages can be forwarded simultaneously. A message can be forwarded only if messageProperties.can_be_forwarded
//@options Options to be used to send the messages; pass null to use default options
//@send_copy Pass true to copy content of the messages without reference to the original sender. Always true if the messages are forwarded to a secret chat or are local.
//-Use messageProperties.can_be_copied and messageProperties.can_be_copied_to_secret_chat to check whether the message is suitable
//@remove_caption Pass true to remove media captions of message copies. Ignored if send_copy is false
-forwardMessages chat_id:int53 message_thread_id:int53 from_chat_id:int53 message_ids:vector<int53> options:messageSendOptions send_copy:Bool remove_caption:Bool = Messages;
+forwardMessages chat_id:int53 topic_id:MessageTopic from_chat_id:int53 message_ids:vector<int53> options:messageSendOptions send_copy:Bool remove_caption:Bool = Messages;
//@description Sends messages from a quick reply shortcut. Requires Telegram Business subscription. Can't be used to send paid messages
//@chat_id Identifier of the chat to which to send messages. The chat must be a private chat with a regular user
diff --git a/td/telegram/MessageCopyOptions.h b/td/telegram/MessageCopyOptions.h
index f295b261f..0d85dfc14 100644
--- a/td/telegram/MessageCopyOptions.h
+++ b/td/telegram/MessageCopyOptions.h
@@ -9,6 +9,7 @@
#include "td/telegram/MessageEntity.h"
#include "td/telegram/MessageId.h"
#include "td/telegram/MessageInputReplyTo.h"
+#include "td/telegram/MessageTopic.h"
#include "td/telegram/ReplyMarkup.h"
#include "td/utils/common.h"
@@ -16,6 +17,8 @@
namespace td {
+class Td;
+
struct MessageCopyOptions {
bool send_copy = false;
bool replace_caption = false;
@@ -28,7 +31,7 @@ struct MessageCopyOptions {
MessageCopyOptions(bool send_copy, bool remove_caption) : send_copy(send_copy), replace_caption(remove_caption) {
}
- bool is_supported_server_side(MessageId top_thread_message_id) const {
+ bool is_supported_server_side(const Td *td, const MessageTopic &message_topic) const {
if (!send_copy) {
return true;
}
@@ -36,8 +39,8 @@ struct MessageCopyOptions {
return false;
}
if (input_reply_to.is_valid() &&
- (top_thread_message_id == MessageId() || input_reply_to.has_quote() || input_reply_to.has_todo_item_id() ||
- input_reply_to.get_same_chat_reply_to_message_id() != top_thread_message_id)) {
+ (!message_topic.is_forum() || input_reply_to.has_quote() || input_reply_to.has_todo_item_id() ||
+ input_reply_to.get_same_chat_reply_to_message_id() != message_topic.get_implicit_reply_to_message_id(td))) {
return false;
}
return true;
diff --git a/td/telegram/MessagesManager.cpp b/td/telegram/MessagesManager.cpp
index be8bcddca..d73b1e696 100644
--- a/td/telegram/MessagesManager.cpp
+++ b/td/telegram/MessagesManager.cpp
@@ -20203,10 +20203,10 @@ int64 MessagesManager::generate_new_random_id(const Dialog *d) {
}
unique_ptr<MessagesManager::Message> MessagesManager::create_message_to_send(
- Dialog *d, MessageId top_thread_message_id, MessageInputReplyTo &&input_reply_to, const MessageSendOptions &options,
- unique_ptr<MessageContent> &&content, bool invert_media, bool suppress_reply_info,
- unique_ptr<MessageForwardInfo> forward_info, DialogId real_forward_from_dialog_id, bool is_copy,
- DialogId send_as_dialog_id) const {
+ Dialog *d, const MessageTopic &message_topic, MessageInputReplyTo &&input_reply_to,
+ const MessageSendOptions &options, unique_ptr<MessageContent> &&content, bool invert_media,
+ bool suppress_reply_info, unique_ptr<MessageForwardInfo> forward_info, DialogId real_forward_from_dialog_id,
+ bool is_copy, DialogId send_as_dialog_id) {
CHECK(d != nullptr);
CHECK(content != nullptr);
@@ -20217,48 +20217,30 @@ unique_ptr<MessagesManager::Message> MessagesManager::create_message_to_send(
auto my_id = td_->user_manager_->get_my_id();
int64 reply_to_random_id = 0;
- bool is_topic_message = false;
- auto initial_top_thread_message_id = top_thread_message_id;
+ bool is_topic_message = message_topic.is_forum(); // message_topic can't be General forum topic here
+ auto top_thread_message_id = MessageId(ServerMessageId(message_topic.get_input_top_msg_id()));
auto same_chat_reply_to_message_id = input_reply_to.get_same_chat_reply_to_message_id();
if (same_chat_reply_to_message_id.is_valid() || same_chat_reply_to_message_id.is_valid_scheduled()) {
// the message was forcely preloaded in create_message_input_reply_to
// it can be missing, only if it is unknown message from a push notification, or an unknown top thread message
const Message *reply_m = get_message(d, same_chat_reply_to_message_id);
- if (reply_m != nullptr && !same_chat_reply_to_message_id.is_scheduled()) {
- if (reply_m->top_thread_message_id.is_valid()) {
- top_thread_message_id = reply_m->top_thread_message_id;
- }
- is_topic_message = reply_m->is_topic_message;
- }
if (dialog_type == DialogType::SecretChat || same_chat_reply_to_message_id.is_yet_unsent()) {
if (reply_m != nullptr) {
reply_to_random_id = reply_m->random_id;
} else {
CHECK(dialog_type == DialogType::SecretChat);
- CHECK(top_thread_message_id == MessageId());
+ CHECK(message_topic.is_empty());
input_reply_to = MessageInputReplyTo();
}
}
}
- if (top_thread_message_id.is_valid()) {
- if (dialog_type == DialogType::User) {
- is_topic_message = true;
- } else {
- const Message *top_m = get_message(d, top_thread_message_id);
- if (top_m != nullptr) {
- is_topic_message = top_m->is_topic_message;
- } else {
- is_topic_message = true;
- }
- }
- }
auto message = make_unique<Message>();
auto *m = message.get();
bool is_channel_post = td_->dialog_manager_->is_broadcast_channel(dialog_id);
if (!is_channel_post ||
(!is_scheduled && td_->chat_manager_->get_channel_sign_messages(dialog_id.get_channel_id()))) {
- if (options.monoforum_topic_id.is_valid()) {
+ if (message_topic.is_monoforum()) {
CHECK(dialog_id.get_type() == DialogType::Channel);
auto channel_id = td_->chat_manager_->get_monoforum_channel_id(dialog_id.get_channel_id());
CHECK(channel_id.is_valid());
@@ -20312,7 +20294,7 @@ unique_ptr<MessagesManager::Message> MessagesManager::create_message_to_send(
m->input_reply_to = std::move(input_reply_to);
m->reply_to_random_id = reply_to_random_id;
m->top_thread_message_id = top_thread_message_id;
- m->initial_top_thread_message_id = initial_top_thread_message_id;
+ m->initial_top_thread_message_id = top_thread_message_id;
m->is_topic_message = is_topic_message;
m->initial_is_topic_message = is_topic_message;
m->is_channel_post = is_channel_post;
@@ -20382,24 +20364,25 @@ unique_ptr<MessagesManager::Message> MessagesManager::create_message_to_send(
}
if (dialog_id == DialogId(my_id)) {
m->saved_messages_topic_id = SavedMessagesTopicId(dialog_id, m->forward_info.get(), m->real_forward_from_dialog_id);
- } else {
- m->saved_messages_topic_id = options.monoforum_topic_id;
+ } else if (message_topic.is_monoforum()) {
+ m->saved_messages_topic_id = message_topic.get_monoforum_saved_messages_topic_id();
+ }
+ if (m->sender_dialog_id.is_valid() && m->sender_dialog_id != dialog_id) {
+ force_create_dialog(m->sender_dialog_id, "create_message_to_send");
}
-
return message;
}
MessagesManager::Message *MessagesManager::get_message_to_send(
- Dialog *d, MessageId top_thread_message_id, MessageInputReplyTo &&input_reply_to, const MessageSendOptions &options,
- unique_ptr<MessageContent> &&content, bool invert_media, bool *need_update_dialog_pos, bool suppress_reply_info,
- unique_ptr<MessageForwardInfo> forward_info, DialogId real_forward_from_dialog_id, bool is_copy,
- DialogId send_as_dialog_id) {
+ Dialog *d, const MessageTopic &message_topic, MessageInputReplyTo &&input_reply_to,
+ const MessageSendOptions &options, unique_ptr<MessageContent> &&content, bool invert_media,
+ bool *need_update_dialog_pos, bool suppress_reply_info, unique_ptr<MessageForwardInfo> forward_info,
+ DialogId real_forward_from_dialog_id, bool is_copy, DialogId send_as_dialog_id) {
d->was_opened = true;
- auto message = create_message_to_send(d, top_thread_message_id, std::move(input_reply_to), options,
- std::move(content), invert_media, suppress_reply_info, std::move(forward_info),
+ auto message = create_message_to_send(d, message_topic, std::move(input_reply_to), options, std::move(content),
+ invert_media, suppress_reply_info, std::move(forward_info),
real_forward_from_dialog_id, is_copy, send_as_dialog_id);
-
auto message_id = message->message_id;
message->random_id = generate_new_random_id(d);
@@ -20407,16 +20390,13 @@ MessagesManager::Message *MessagesManager::get_message_to_send(
CHECK(td_->dialog_manager_->have_input_peer(d->dialog_id, true, AccessRights::Read));
auto result =
add_message_to_dialog(d, std::move(message), false, true, &need_update, need_update_dialog_pos, "send message");
- LOG_CHECK(result != nullptr) << message_id << " " << debug_add_message_to_dialog_fail_reason_;
+ LOG_CHECK(result != nullptr) << message_id << ' ' << debug_add_message_to_dialog_fail_reason_;
if (result->message_id.is_scheduled()) {
send_update_chat_has_scheduled_messages(d, false);
}
if (options.update_stickersets_order && !td_->auth_manager_->is_bot()) {
move_message_content_sticker_set_to_top(td_, result->content.get());
}
- if (options.monoforum_topic_id.is_valid() && result->sender_dialog_id.is_valid()) {
- force_create_dialog(result->sender_dialog_id, "get_message_to_send");
- }
if (result->paid_message_star_count > 0) {
td_->star_manager_->add_pending_owned_star_count(-result->paid_message_star_count, false);
}
@@ -21142,7 +21122,7 @@ class MessagesManager::SendMessageLogEvent {
};
Result<td_api::object_ptr<td_api::message>> MessagesManager::send_message(
- DialogId dialog_id, const MessageId top_thread_message_id,
+ DialogId dialog_id, const td_api::object_ptr<td_api::MessageTopic> &topic_id,
td_api::object_ptr<td_api::InputMessageReplyTo> &&reply_to, tl_object_ptr<td_api::messageSendOptions> &&options,
tl_object_ptr<td_api::ReplyMarkup> &&reply_markup,
tl_object_ptr<td_api::InputMessageContent> &&input_message_content) {
@@ -21163,7 +21143,8 @@ Result<td_api::object_ptr<td_api::message>> MessagesManager::send_message(
}
}
- auto input_reply_to = create_message_input_reply_to(d, top_thread_message_id, std::move(reply_to), false);
+ TRY_RESULT(message_topic, MessageTopic::get_send_message_topic(td_, dialog_id, topic_id));
+ auto input_reply_to = create_message_input_reply_to(d, message_topic, std::move(reply_to), false);
if (input_message_content->get_id() == td_api::inputMessageForwarded::ID) {
auto input_message = td_api::move_object_as<td_api::inputMessageForwarded>(input_message_content);
@@ -21171,7 +21152,7 @@ Result<td_api::object_ptr<td_api::message>> MessagesManager::send_message(
copy_options.input_reply_to = std::move(input_reply_to);
TRY_RESULT_ASSIGN(copy_options.reply_markup, get_dialog_reply_markup(dialog_id, std::move(reply_markup)));
return forward_message(
- dialog_id, top_thread_message_id, DialogId(input_message->from_chat_id_), MessageId(input_message->message_id_),
+ dialog_id, topic_id, DialogId(input_message->from_chat_id_), MessageId(input_message->message_id_),
std::move(options), input_message->in_game_share_,
input_message->replace_video_start_timestamp_ ? max(0, input_message->new_video_start_timestamp_) : -1,
std::move(copy_options), false, MessageId());
@@ -21183,7 +21164,6 @@ Result<td_api::object_ptr<td_api::message>> MessagesManager::send_message(
TRY_RESULT(message_content, process_input_message_content(dialog_id, std::move(input_message_content),
!message_send_options.allow_paid));
TRY_STATUS(can_use_message_send_options(message_send_options, message_content));
- TRY_STATUS(can_use_top_thread_message_id(d, top_thread_message_id, input_reply_to));
// there must be no errors after get_message_to_send call
@@ -21193,14 +21173,14 @@ Result<td_api::object_ptr<td_api::message>> MessagesManager::send_message(
unique_ptr<Message> message;
Message *m;
if (message_send_options.only_preview) {
- message = create_message_to_send(d, top_thread_message_id, std::move(input_reply_to), message_send_options,
+ message = create_message_to_send(d, message_topic, std::move(input_reply_to), message_send_options,
std::move(content), message_content.invert_media, false, nullptr, DialogId(),
message_content.via_bot_user_id.is_valid(), DialogId());
m = message.get();
} else {
- m = get_message_to_send(d, top_thread_message_id, std::move(input_reply_to), message_send_options,
- std::move(content), message_content.invert_media, &need_update_dialog_pos, false, nullptr,
- DialogId(), message_content.via_bot_user_id.is_valid());
+ m = get_message_to_send(d, message_topic, std::move(input_reply_to), message_send_options, std::move(content),
+ message_content.invert_media, &need_update_dialog_pos, false, nullptr, DialogId(),
+ message_content.via_bot_user_id.is_valid());
}
m->reply_markup = std::move(message_reply_markup);
m->via_bot_user_id = message_content.via_bot_user_id;
@@ -21338,17 +21318,6 @@ Result<MessagesManager::MessageSendOptions> MessagesManager::process_message_sen
result.only_preview = options->only_preview_;
TRY_RESULT_ASSIGN(result.schedule_date, get_message_schedule_date(std::move(options->scheduling_state_)));
result.sending_id = options->sending_id_;
- if (options->direct_messages_chat_topic_id_ != 0) {
- if (td_->dialog_manager_->is_admined_monoforum_channel(dialog_id)) {
- result.monoforum_topic_id =
- td_->saved_messages_manager_->get_topic_id(dialog_id, options->direct_messages_chat_topic_id_);
- if (!result.monoforum_topic_id.is_valid()) {
- return Status::Error(400, "Invalid channel direct messages topic specified");
- }
- }
- } else if (td_->dialog_manager_->is_admined_monoforum_channel(dialog_id)) {
- return Status::Error(400, "Channel direct messages topic must be specified");
- }
if (result.schedule_date != 0) {
auto dialog_type = dialog_id.get_type();
@@ -21480,7 +21449,7 @@ int64 MessagesManager::generate_new_media_album_id() {
}
Result<td_api::object_ptr<td_api::messages>> MessagesManager::send_message_group(
- DialogId dialog_id, const MessageId top_thread_message_id,
+ DialogId dialog_id, const td_api::object_ptr<td_api::MessageTopic> &topic_id,
td_api::object_ptr<td_api::InputMessageReplyTo> &&reply_to, tl_object_ptr<td_api::messageSendOptions> &&options,
vector<tl_object_ptr<td_api::InputMessageContent>> &&input_message_contents) {
Dialog *d = get_dialog_force(dialog_id, "send_message_group");
@@ -21512,8 +21481,8 @@ Result<td_api::object_ptr<td_api::messages>> MessagesManager::send_message_group
}
TRY_STATUS(check_message_group_message_contents(message_contents));
- auto input_reply_to = create_message_input_reply_to(d, top_thread_message_id, std::move(reply_to), false);
- TRY_STATUS(can_use_top_thread_message_id(d, top_thread_message_id, input_reply_to));
+ TRY_RESULT(message_topic, MessageTopic::get_send_message_topic(td_, dialog_id, topic_id));
+ auto input_reply_to = create_message_input_reply_to(d, message_topic, std::move(reply_to), false);
int64 media_album_id = 0;
if (message_contents.size() > 1) {
@@ -21529,12 +21498,12 @@ Result<td_api::object_ptr<td_api::messages>> MessagesManager::send_message_group
unique_ptr<Message> message;
Message *m;
if (message_send_options.only_preview) {
- message = create_message_to_send(d, top_thread_message_id, input_reply_to.clone(), message_send_options,
+ message = create_message_to_send(d, message_topic, input_reply_to.clone(), message_send_options,
std::move(message_content.content), message_content.invert_media, i != 0,
nullptr, DialogId(), false, DialogId());
m = message.get();
} else {
- m = get_message_to_send(d, top_thread_message_id, input_reply_to.clone(), message_send_options,
+ m = get_message_to_send(d, message_topic, input_reply_to.clone(), message_send_options,
dup_message_content(td_, dialog_id, message_content.content.get(),
MessageContentDupType::Send, MessageCopyOptions()),
message_content.invert_media, &need_update_dialog_pos, i != 0);
@@ -22491,7 +22460,7 @@ Result<MessageId> MessagesManager::send_bot_start_message(UserId bot_user_id, Di
text_entities.emplace_back(MessageEntity::Type::BotCommand, 0, narrow_cast<int32>(text.size()));
bool need_update_dialog_pos = false;
Message *m = get_message_to_send(
- d, MessageId(), MessageInputReplyTo(), MessageSendOptions(),
+ d, MessageTopic(), MessageInputReplyTo(), MessageSendOptions(),
create_text_message_content(text, std::move(text_entities), WebPageId(), false, false, false, string()), false,
&need_update_dialog_pos);
m->is_bot_start_message = true;
@@ -22585,7 +22554,7 @@ void MessagesManager::do_send_bot_start_message(UserId bot_user_id, DialogId dia
}
Result<td_api::object_ptr<td_api::message>> MessagesManager::send_inline_query_result_message(
- DialogId dialog_id, const MessageId top_thread_message_id,
+ DialogId dialog_id, const td_api::object_ptr<td_api::MessageTopic> &topic_id,
td_api::object_ptr<td_api::InputMessageReplyTo> &&reply_to, tl_object_ptr<td_api::messageSendOptions> &&options,
int64 query_id, const string &result_id, bool hide_via_bot) {
Dialog *d = get_dialog_force(dialog_id, "send_inline_query_result_message");
@@ -22622,10 +22591,10 @@ Result<td_api::object_ptr<td_api::message>> MessagesManager::send_inline_query_r
return Status::Error(400, "Inline query result not found");
}
- auto input_reply_to = create_message_input_reply_to(d, top_thread_message_id, std::move(reply_to), false);
+ TRY_RESULT(message_topic, MessageTopic::get_send_message_topic(td_, dialog_id, topic_id));
+ auto input_reply_to = create_message_input_reply_to(d, message_topic, std::move(reply_to), false);
TRY_STATUS(can_use_message_send_options(message_send_options, content->message_content, MessageSelfDestructType()));
TRY_STATUS(can_send_message_content(dialog_id, content->message_content.get(), false, true, td_));
- TRY_STATUS(can_use_top_thread_message_id(d, top_thread_message_id, input_reply_to));
auto message_content = dup_message_content(td_, dialog_id, content->message_content.get(),
MessageContentDupType::SendViaBot, MessageCopyOptions());
@@ -22633,12 +22602,12 @@ Result<td_api::object_ptr<td_api::message>> MessagesManager::send_inline_query_r
unique_ptr<Message> message;
Message *m;
if (message_send_options.only_preview) {
- message = create_message_to_send(d, top_thread_message_id, std::move(input_reply_to), message_send_options,
+ message = create_message_to_send(d, message_topic, std::move(input_reply_to), message_send_options,
std::move(message_content), content->invert_media, false, nullptr, DialogId(),
true, DialogId());
m = message.get();
} else {
- m = get_message_to_send(d, top_thread_message_id, std::move(input_reply_to), message_send_options,
+ m = get_message_to_send(d, message_topic, std::move(input_reply_to), message_send_options,
std::move(message_content), content->invert_media, &need_update_dialog_pos, false, nullptr,
DialogId(), true);
}
@@ -23979,15 +23948,15 @@ void MessagesManager::send_forward_message_query(int32 flags, DialogId to_dialog
}
Result<td_api::object_ptr<td_api::message>> MessagesManager::forward_message(
- DialogId to_dialog_id, MessageId top_thread_message_id, DialogId from_dialog_id, MessageId message_id,
- tl_object_ptr<td_api::messageSendOptions> &&options, bool in_game_share, int32 new_video_start_timestamp,
- MessageCopyOptions &&copy_options, bool add_offer, MessageId reply_to_message_id) {
+ DialogId to_dialog_id, const td_api::object_ptr<td_api::MessageTopic> &topic_id, DialogId from_dialog_id,
+ MessageId message_id, tl_object_ptr<td_api::messageSendOptions> &&options, bool in_game_share,
+ int32 new_video_start_timestamp, MessageCopyOptions &&copy_options, bool add_offer, MessageId reply_to_message_id) {
bool need_copy = copy_options.send_copy;
vector<MessageCopyOptions> all_copy_options;
all_copy_options.push_back(std::move(copy_options));
- TRY_RESULT(result, forward_messages(to_dialog_id, top_thread_message_id, from_dialog_id, {message_id},
- std::move(options), in_game_share, new_video_start_timestamp,
- std::move(all_copy_options), add_offer, reply_to_message_id));
+ TRY_RESULT(result,
+ forward_messages(to_dialog_id, topic_id, from_dialog_id, {message_id}, std::move(options), in_game_share,
+ new_video_start_timestamp, std::move(all_copy_options), add_offer, reply_to_message_id));
CHECK(result->messages_.size() == 1);
if (result->messages_[0] == nullptr) {
return Status::Error(400,
@@ -24020,14 +23989,11 @@ void MessagesManager::add_offer(DialogId dialog_id, MessageId message_id,
if (m->forward_info == nullptr) {
copy_options = MessageCopyOptions(true, false);
}
+ td_api::object_ptr<td_api::MessageTopic> topic_id;
if (td_->dialog_manager_->is_admined_monoforum_channel(dialog_id)) {
- if (options->direct_messages_chat_topic_id_ == 0) {
- options->direct_messages_chat_topic_id_ = m->saved_messages_topic_id.get_unique_id();
- } else if (options->direct_messages_chat_topic_id_ != m->saved_messages_topic_id.get_unique_id()) {
- return promise.set_error(400, "Wrong direct channel messages topic identifier specified");
- }
+ topic_id = td_api::make_object<td_api::messageTopicDirectMessages>(m->saved_messages_topic_id.get_unique_id());
}
- promise.set_result(forward_message(dialog_id, MessageId(), dialog_id, message_id, std::move(options), false, -1,
+ promise.set_result(forward_message(dialog_id, topic_id, dialog_id, message_id, std::move(options), false, -1,
std::move(copy_options), true,
m->suggested_post == nullptr ? MessageId() : message_id));
}
@@ -24156,7 +24122,7 @@ void MessagesManager::fix_forwarded_message(Message *m, DialogId to_dialog_id, c
}
Result<MessagesManager::ForwardedMessages> MessagesManager::get_forwarded_messages(
- DialogId to_dialog_id, MessageId top_thread_message_id, DialogId from_dialog_id,
+ DialogId to_dialog_id, const td_api::object_ptr<td_api::MessageTopic> &topic_id, DialogId from_dialog_id,
const vector<MessageId> &message_ids, tl_object_ptr<td_api::messageSendOptions> &&options,
int32 new_video_start_timestamp, vector<MessageCopyOptions> &&copy_options, bool add_offer) {
CHECK(copy_options.size() == message_ids.size());
@@ -24191,7 +24157,10 @@ Result<MessagesManager::ForwardedMessages> MessagesManager::get_forwarded_messag
TRY_RESULT(message_send_options, process_message_send_options(to_dialog_id, std::move(options), false, false,
add_offer || message_ids.size() == 1u,
static_cast<int32>(message_ids.size())));
- TRY_STATUS(can_use_top_thread_message_id(to_dialog, top_thread_message_id, MessageInputReplyTo()));
+ TRY_RESULT(message_topic, MessageTopic::get_send_message_topic(td_, to_dialog_id, topic_id));
+ if (message_topic.is_thread()) {
+ return Status::Error(400, "Can't forward messages to a specific message thread");
+ }
{
MessageId last_message_id;
@@ -24214,7 +24183,7 @@ Result<MessagesManager::ForwardedMessages> MessagesManager::get_forwarded_messag
bool can_use_server_forward = true;
for (auto &copy_option : copy_options) {
- if (!copy_option.is_supported_server_side(top_thread_message_id)) {
+ if (!copy_option.is_supported_server_side(td_, message_topic)) {
can_use_server_forward = false;
break;
}
@@ -24292,11 +24261,6 @@ Result<MessagesManager::ForwardedMessages> MessagesManager::get_forwarded_messag
continue;
}
- if (can_use_top_thread_message_id(to_dialog, top_thread_message_id, input_reply_to).is_error()) {
- LOG(INFO) << "Ignore invalid message thread ID " << top_thread_message_id;
- top_thread_message_id = MessageId();
- }
-
if (new_video_start_timestamp >= 0) {
set_message_content_video_start_timestamp(content.get(), new_video_start_timestamp);
}
@@ -24327,7 +24291,7 @@ Result<MessagesManager::ForwardedMessages> MessagesManager::get_forwarded_messag
{std::move(content), new_invert_media, forwarded_message->media_album_id, i});
}
}
- result.top_thread_message_id = top_thread_message_id;
+ result.message_topic = std::move(message_topic);
if (2 <= forwarded_message_contents.size() && forwarded_message_contents.size() <= MAX_GROUPED_MESSAGES) {
std::unordered_set<MessageContentType, MessageContentTypeHash> message_content_types;
@@ -24369,12 +24333,13 @@ Result<MessagesManager::ForwardedMessages> MessagesManager::get_forwarded_messag
}
Result<td_api::object_ptr<td_api::messages>> MessagesManager::forward_messages(
- DialogId to_dialog_id, MessageId top_thread_message_id, DialogId from_dialog_id, vector<MessageId> message_ids,
- tl_object_ptr<td_api::messageSendOptions> &&options, bool in_game_share, int32 new_video_start_timestamp,
- vector<MessageCopyOptions> &&copy_options, bool add_offer, MessageId suggested_post_reply_to_message_id) {
+ DialogId to_dialog_id, const td_api::object_ptr<td_api::MessageTopic> &topic_id, DialogId from_dialog_id,
+ vector<MessageId> message_ids, tl_object_ptr<td_api::messageSendOptions> &&options, bool in_game_share,
+ int32 new_video_start_timestamp, vector<MessageCopyOptions> &&copy_options, bool add_offer,
+ MessageId suggested_post_reply_to_message_id) {
TRY_RESULT(forwarded_messages_info,
- get_forwarded_messages(to_dialog_id, top_thread_message_id, from_dialog_id, message_ids,
- std::move(options), new_video_start_timestamp, std::move(copy_options), add_offer));
+ get_forwarded_messages(to_dialog_id, topic_id, from_dialog_id, message_ids, std::move(options),
+ new_video_start_timestamp, std::move(copy_options), add_offer));
auto from_dialog = forwarded_messages_info.from_dialog;
auto to_dialog = forwarded_messages_info.to_dialog;
const auto message_send_options = forwarded_messages_info.message_send_options;
@@ -24382,7 +24347,7 @@ Result<td_api::object_ptr<td_api::messages>> MessagesManager::forward_messages(
auto &forwarded_message_contents = forwarded_messages_info.forwarded_message_contents;
auto drop_author = forwarded_messages_info.drop_author;
auto drop_media_captions = forwarded_messages_info.drop_media_captions;
- top_thread_message_id = forwarded_messages_info.top_thread_message_id;
+ auto message_topic = forwarded_messages_info.message_topic;
FlatHashMap<MessageId, MessageId, MessageIdHash> forwarded_message_id_to_new_message_id;
vector<td_api::object_ptr<td_api::message>> result(message_ids.size());
@@ -24415,13 +24380,13 @@ Result<td_api::object_ptr<td_api::messages>> MessagesManager::forward_messages(
unique_ptr<Message> message;
Message *m;
if (message_send_options.only_preview) {
- message = create_message_to_send(
- to_dialog, top_thread_message_id, std::move(input_reply_to), message_send_options, std::move(content),
- forwarded_message_contents[j].invert_media, j + 1 != forwarded_message_contents.size(),
- std::move(forward_info), from_dialog_id, false, DialogId());
+ message = create_message_to_send(to_dialog, message_topic, std::move(input_reply_to), message_send_options,
+ std::move(content), forwarded_message_contents[j].invert_media,
+ j + 1 != forwarded_message_contents.size(), std::move(forward_info),
+ from_dialog_id, false, DialogId());
m = message.get();
} else {
- m = get_message_to_send(to_dialog, top_thread_message_id, std::move(input_reply_to), message_send_options,
+ m = get_message_to_send(to_dialog, message_topic, std::move(input_reply_to), message_send_options,
std::move(content), forwarded_message_contents[j].invert_media, &need_update_dialog_pos,
j + 1 != forwarded_message_contents.size(), std::move(forward_info), from_dialog_id);
}
@@ -24486,9 +24451,9 @@ Result<td_api::object_ptr<td_api::messages>> MessagesManager::forward_messages(
unique_ptr<Message> message;
Message *m;
if (message_send_options.only_preview) {
- message = create_message_to_send(to_dialog, top_thread_message_id, std::move(input_reply_to),
- message_send_options, std::move(copied_message.content),
- copied_message.invert_media, false, nullptr, DialogId(), is_copy, DialogId());
+ message = create_message_to_send(to_dialog, message_topic, std::move(input_reply_to), message_send_options,
+ std::move(copied_message.content), copied_message.invert_media, false, nullptr,
+ DialogId(), is_copy, DialogId());
m = message.get();
} else {
if (need_invalidate_authentication_code) {
@@ -24497,7 +24462,7 @@ Result<td_api::object_ptr<td_api::messages>> MessagesManager::forward_messages(
extract_authentication_codes(from_dialog_id, forwarded_message, authentication_codes);
}
- m = get_message_to_send(to_dialog, top_thread_message_id, std::move(input_reply_to), message_send_options,
+ m = get_message_to_send(to_dialog, message_topic, std::move(input_reply_to), message_send_options,
std::move(copied_message.content), copied_message.invert_media, &need_update_dialog_pos,
false, nullptr, DialogId(), is_copy);
}
@@ -24561,7 +24526,7 @@ Result<td_api::object_ptr<td_api::messages>> MessagesManager::send_quick_reply_s
CHECK(d != nullptr);
MessageSendOptions message_send_options(false, false, false, false, false, false, false, 0, sending_id,
- MessageEffectId(), 0, SavedMessagesTopicId(), SuggestedPost());
+ MessageEffectId(), 0, SuggestedPost());
FlatHashMap<MessageId, MessageId, MessageIdHash> original_message_id_to_new_message_id;
vector<td_api::object_ptr<td_api::message>> result;
vector<Message *> sent_messages;
@@ -24576,7 +24541,7 @@ Result<td_api::object_ptr<td_api::messages>> MessagesManager::send_quick_reply_s
}
}
- Message *m = get_message_to_send(d, MessageId(), std::move(input_reply_to), message_send_options,
+ Message *m = get_message_to_send(d, MessageTopic(), std::move(input_reply_to), message_send_options,
std::move(content.content_), content.invert_media_, &need_update_dialog_pos, false,
nullptr, DialogId(), true);
m->via_bot_user_id = content.via_bot_user_id_;
@@ -24787,12 +24752,11 @@ Result<vector<MessageId>> MessagesManager::resend_messages(DialogId dialog_id, v
message->allow_paid, false, message->suggested_post != nullptr, get_message_schedule_date(message.get()),
message->sending_id, message->effect_id,
required_paid_message_star_count == 0 ? message->paid_message_star_count : paid_message_star_count,
- dialog_id.get_type() == DialogType::Channel ? message->saved_messages_topic_id : SavedMessagesTopicId(),
message->suggested_post == nullptr ? SuggestedPost() : *message->suggested_post);
- Message *m = get_message_to_send(d, message->top_thread_message_id, std::move(message->input_reply_to), options,
- std::move(new_contents[i]), message->invert_media, &need_update_dialog_pos, false,
- nullptr, DialogId(), message->is_copy,
- need_another_sender ? DialogId() : get_message_sender(message.get()));
+ Message *m = get_message_to_send(
+ d, get_send_message_topic(dialog_id, message.get()), std::move(message->input_reply_to), options,
+ std::move(new_contents[i]), message->invert_media, &need_update_dialog_pos, false, nullptr, DialogId(),
+ message->is_copy, need_another_sender ? DialogId() : get_message_sender(message.get()));
m->reply_markup = std::move(message->reply_markup);
// m->via_bot_user_id = message->via_bot_user_id;
m->disable_web_page_preview = message->disable_web_page_preview;
@@ -24824,7 +24788,7 @@ void MessagesManager::send_screenshot_taken_notification_message(Dialog *d) {
auto dialog_type = d->dialog_id.get_type();
if (dialog_type == DialogType::User) {
bool need_update_dialog_pos = false;
- const Message *m = get_message_to_send(d, MessageId(), MessageInputReplyTo(), MessageSendOptions(),
+ const Message *m = get_message_to_send(d, MessageTopic(), MessageInputReplyTo(), MessageSendOptions(),
create_screenshot_taken_message_content(), false, &need_update_dialog_pos);
do_send_screenshot_taken_notification_message(d->dialog_id, m, 0);
@@ -29765,7 +29729,7 @@ void MessagesManager::set_dialog_message_ttl(DialogId dialog_id, int32 ttl, Prom
} else {
bool need_update_dialog_pos = false;
Message *m =
- get_message_to_send(d, MessageId(), MessageInputReplyTo(), MessageSendOptions(),
+ get_message_to_send(d, MessageTopic(), MessageInputReplyTo(), MessageSendOptions(),
create_chat_set_ttl_message_content(ttl, UserId()), false, &need_update_dialog_pos);
send_update_new_message(d, m);
diff --git a/td/telegram/MessagesManager.h b/td/telegram/MessagesManager.h
index 232fb01af..777ab6854 100644
--- a/td/telegram/MessagesManager.h
+++ b/td/telegram/MessagesManager.h
@@ -442,13 +442,13 @@ class MessagesManager final : public Actor {
bool for_draft);
Result<td_api::object_ptr<td_api::message>> send_message(
- DialogId dialog_id, const MessageId top_thread_message_id,
+ DialogId dialog_id, const td_api::object_ptr<td_api::MessageTopic> &topic_id,
td_api::object_ptr<td_api::InputMessageReplyTo> &&reply_to, tl_object_ptr<td_api::messageSendOptions> &&options,
tl_object_ptr<td_api::ReplyMarkup> &&reply_markup,
tl_object_ptr<td_api::InputMessageContent> &&input_message_content) TD_WARN_UNUSED_RESULT;
Result<td_api::object_ptr<td_api::messages>> send_message_group(
- DialogId dialog_id, const MessageId top_thread_message_id,
+ DialogId dialog_id, const td_api::object_ptr<td_api::MessageTopic> &topic_id,
td_api::object_ptr<td_api::InputMessageReplyTo> &&reply_to, tl_object_ptr<td_api::messageSendOptions> &&options,
vector<tl_object_ptr<td_api::InputMessageContent>> &&input_message_contents) TD_WARN_UNUSED_RESULT;
@@ -456,14 +456,14 @@ class MessagesManager final : public Actor {
const string &parameter) TD_WARN_UNUSED_RESULT;
Result<td_api::object_ptr<td_api::message>> send_inline_query_result_message(
- DialogId dialog_id, const MessageId top_thread_message_id,
+ DialogId dialog_id, const td_api::object_ptr<td_api::MessageTopic> &topic_id,
td_api::object_ptr<td_api::InputMessageReplyTo> &&reply_to, tl_object_ptr<td_api::messageSendOptions> &&options,
int64 query_id, const string &result_id, bool hide_via_bot) TD_WARN_UNUSED_RESULT;
Result<td_api::object_ptr<td_api::messages>> forward_messages(
- DialogId to_dialog_id, MessageId top_thread_message_id, DialogId from_dialog_id, vector<MessageId> message_ids,
- tl_object_ptr<td_api::messageSendOptions> &&options, bool in_game_share, int32 new_video_start_timestamp,
- vector<MessageCopyOptions> &&copy_options, bool add_offer = false,
+ DialogId to_dialog_id, const td_api::object_ptr<td_api::MessageTopic> &topic_id, DialogId from_dialog_id,
+ vector<MessageId> message_ids, tl_object_ptr<td_api::messageSendOptions> &&options, bool in_game_share,
+ int32 new_video_start_timestamp, vector<MessageCopyOptions> &&copy_options, bool add_offer = false,
MessageId suggested_post_reply_to_message_id = MessageId()) TD_WARN_UNUSED_RESULT;
void add_offer(DialogId dialog_id, MessageId message_id, td_api::object_ptr<td_api::messageSendOptions> &&options,
@@ -1547,14 +1547,13 @@ class MessagesManager final : public Actor {
int32 sending_id = 0;
MessageEffectId effect_id;
int64 paid_message_star_count = 0;
- SavedMessagesTopicId monoforum_topic_id;
SuggestedPost suggested_post;
MessageSendOptions() = default;
MessageSendOptions(bool disable_notification, bool from_background, bool update_stickersets_order,
bool protect_content, bool allow_paid, bool only_preview, bool has_suggested_post,
int32 schedule_date, int32 sending_id, MessageEffectId effect_id, int64 paid_message_star_count,
- SavedMessagesTopicId monoforum_topic_id, SuggestedPost &&suggested_post)
+ SuggestedPost &&suggested_post)
: disable_notification(disable_notification)
, from_background(from_background)
, update_stickersets_order(update_stickersets_order)
@@ -1566,7 +1565,6 @@ class MessagesManager final : public Actor {
, sending_id(sending_id)
, effect_id(effect_id)
, paid_message_star_count(paid_message_star_count)
- , monoforum_topic_id(monoforum_topic_id)
, suggested_post(std::move(suggested_post)) {
}
};
@@ -1740,14 +1738,14 @@ class MessagesManager final : public Actor {
int64 generate_new_random_id(const Dialog *d);
- unique_ptr<Message> create_message_to_send(Dialog *d, MessageId top_thread_message_id,
+ unique_ptr<Message> create_message_to_send(Dialog *d, const MessageTopic &message_topic,
MessageInputReplyTo &&input_reply_to, const MessageSendOptions &options,
unique_ptr<MessageContent> &&content, bool invert_media,
bool suppress_reply_info, unique_ptr<MessageForwardInfo> forward_info,
DialogId real_forward_from_dialog_id, bool is_copy,
- DialogId send_as_dialog_id) const;
+ DialogId send_as_dialog_id);
- Message *get_message_to_send(Dialog *d, MessageId top_thread_message_id, MessageInputReplyTo &&input_reply_to,
+ Message *get_message_to_send(Dialog *d, const MessageTopic &message_topic, MessageInputReplyTo &&input_reply_to,
const MessageSendOptions &options, unique_ptr<MessageContent> &&content,
bool invert_media, bool *need_update_dialog_pos, bool suppress_reply_info = false,
unique_ptr<MessageForwardInfo> forward_info = nullptr,
@@ -1855,7 +1853,8 @@ class MessagesManager final : public Actor {
int32 new_video_start_timestamp, int64 paid_message_star_count,
unique_ptr<SuggestedPost> &&suggested_post, Promise<Unit> &&promise);
- Result<td_api::object_ptr<td_api::message>> forward_message(DialogId to_dialog_id, MessageId top_thread_message_id,
+ Result<td_api::object_ptr<td_api::message>> forward_message(DialogId to_dialog_id,
+ const td_api::object_ptr<td_api::MessageTopic> &topic_id,
DialogId from_dialog_id, MessageId message_id,
td_api::object_ptr<td_api::messageSendOptions> &&options,
bool in_game_share, int32 new_video_start_timestamp,
@@ -1896,12 +1895,13 @@ class MessagesManager final : public Actor {
bool drop_media_captions = false;
Dialog *from_dialog = nullptr;
- MessageId top_thread_message_id;
+ MessageTopic message_topic;
Dialog *to_dialog = nullptr;
MessageSendOptions message_send_options;
};
- Result<ForwardedMessages> get_forwarded_messages(DialogId to_dialog_id, MessageId top_thread_message_id,
+ Result<ForwardedMessages> get_forwarded_messages(DialogId to_dialog_id,
+ const td_api::object_ptr<td_api::MessageTopic> &topic_id,
DialogId from_dialog_id, const vector<MessageId> &message_ids,
td_api::object_ptr<td_api::messageSendOptions> &&options,
int32 new_video_start_timestamp,
@@ -3477,7 +3477,7 @@ class MessagesManager final : public Actor {
FlatHashMap<MessageFullId, MessageId, MessageFullIdHash> yet_unsent_message_full_id_to_persistent_message_id_;
FlatHashMap<MessageFullId, std::set<MessageId>, MessageFullIdHash>
- yet_unsent_thread_message_ids_; // {dialog_id, top_thread_message_id} -> yet unsent message IDs
+ yet_unsent_thread_message_ids_; // {dialog_id, top_thread_message_id} -> yet unsent message identifiers
FlatHashMap<DialogId, unique_ptr<SuffixLoadQueries>, DialogIdHash> dialog_suffix_load_queries_;
diff --git a/td/telegram/Requests.cpp b/td/telegram/Requests.cpp
index 6c9483ada..2238acb6c 100644
--- a/td/telegram/Requests.cpp
+++ b/td/telegram/Requests.cpp
@@ -3913,8 +3913,8 @@ void Requests::on_request(uint64 id, const td_api::setChatMessageSender &request
void Requests::on_request(uint64 id, td_api::sendMessage &request) {
auto r_sent_message = td_->messages_manager_->send_message(
- DialogId(request.chat_id_), MessageId(request.message_thread_id_), std::move(request.reply_to_),
- std::move(request.options_), std::move(request.reply_markup_), std::move(request.input_message_content_));
+ DialogId(request.chat_id_), request.topic_id_, std::move(request.reply_to_), std::move(request.options_),
+ std::move(request.reply_markup_), std::move(request.input_message_content_));
if (r_sent_message.is_error()) {
send_closure(td_actor_, &Td::send_error, id, r_sent_message.move_as_error());
} else {
@@ -3924,8 +3924,8 @@ void Requests::on_request(uint64 id, td_api::sendMessage &request) {
void Requests::on_request(uint64 id, td_api::sendMessageAlbum &request) {
auto r_messages = td_->messages_manager_->send_message_group(
- DialogId(request.chat_id_), MessageId(request.message_thread_id_), std::move(request.reply_to_),
- std::move(request.options_), std::move(request.input_message_contents_));
+ DialogId(request.chat_id_), request.topic_id_, std::move(request.reply_to_), std::move(request.options_),
+ std::move(request.input_message_contents_));
if (r_messages.is_error()) {
send_closure(td_actor_, &Td::send_error, id, r_messages.move_as_error());
} else {
@@ -3954,8 +3954,8 @@ void Requests::on_request(uint64 id, td_api::sendInlineQueryResultMessage &reque
CLEAN_INPUT_STRING(request.result_id_);
auto r_sent_message = td_->messages_manager_->send_inline_query_result_message(
- DialogId(request.chat_id_), MessageId(request.message_thread_id_), std::move(request.reply_to_),
- std::move(request.options_), request.query_id_, request.result_id_, request.hide_via_bot_);
+ DialogId(request.chat_id_), request.topic_id_, std::move(request.reply_to_), std::move(request.options_),
+ request.query_id_, request.result_id_, request.hide_via_bot_);
if (r_sent_message.is_error()) {
send_closure(td_actor_, &Td::send_error, id, r_sent_message.move_as_error());
} else {
@@ -4571,8 +4571,8 @@ void Requests::on_request(uint64 id, td_api::forwardMessages &request) {
transform(input_message_ids, [send_copy = request.send_copy_, remove_caption = request.remove_caption_](
MessageId) { return MessageCopyOptions(send_copy, remove_caption); });
auto r_messages = td_->messages_manager_->forward_messages(
- DialogId(request.chat_id_), MessageId(request.message_thread_id_), DialogId(request.from_chat_id_),
- std::move(input_message_ids), std::move(request.options_), false, -1, std::move(message_copy_options));
+ DialogId(request.chat_id_), request.topic_id_, DialogId(request.from_chat_id_), std::move(input_message_ids),
+ std::move(request.options_), false, -1, std::move(message_copy_options));
if (r_messages.is_error()) {
send_closure(td_actor_, &Td::send_error, id, r_messages.move_as_error());
} else {
diff --git a/td/telegram/cli.cpp b/td/telegram/cli.cpp
index 418b7d338..23a305355 100644
--- a/td/telegram/cli.cpp
+++ b/td/telegram/cli.cpp
@@ -2726,11 +2726,11 @@ class CliClient final : public Actor {
return;
}
auto id = send_request(td_api::make_object<td_api::sendMessage>(
- chat_id, message_thread_id_, get_input_message_reply_to(),
- td_api::make_object<td_api::messageSendOptions>(
- direct_messages_chat_topic_id_, get_input_suggested_post_info(), disable_notification, from_background,
- false, use_test_dc_, paid_message_star_count_, false, as_message_scheduling_state(schedule_date_),
- message_effect_id_, Random::fast(1, 1000), only_preview_),
+ chat_id, get_message_topic_id(), get_input_message_reply_to(),
+ td_api::make_object<td_api::messageSendOptions>(get_input_suggested_post_info(), disable_notification,
+ from_background, false, use_test_dc_, paid_message_star_count_,
+ false, as_message_scheduling_state(schedule_date_),
+ message_effect_id_, Random::fast(1, 1000), only_preview_),
nullptr, std::move(input_message_content)));
if (id != 0) {
query_id_to_send_message_info_[id].start_time = Time::now();
@@ -2747,9 +2747,8 @@ class CliClient final : public Actor {
td_api::object_ptr<td_api::messageSendOptions> default_message_send_options() const {
return td_api::make_object<td_api::messageSendOptions>(
- direct_messages_chat_topic_id_, get_input_suggested_post_info(), false, false, false, use_test_dc_,
- paid_message_star_count_, true, as_message_scheduling_state(schedule_date_), message_effect_id_,
- Random::fast(1, 1000), only_preview_);
+ get_input_suggested_post_info(), false, false, false, use_test_dc_, paid_message_star_count_, true,
+ as_message_scheduling_state(schedule_date_), message_effect_id_, Random::fast(1, 1000), only_preview_);
}
void set_draft_message(ChatId chat_id, td_api::object_ptr<td_api::draftMessage> &&draft_message) {
@@ -4938,7 +4937,7 @@ class CliClient final : public Actor {
string message_ids;
get_args(args, chat_id, from_chat_id, message_ids);
send_request(td_api::make_object<td_api::forwardMessages>(
- chat_id, message_thread_id_, from_chat_id, as_message_ids(message_ids), default_message_send_options(),
+ chat_id, get_message_topic_id(), from_chat_id, as_message_ids(message_ids), default_message_send_options(),
op[0] == 'c', rand_bool()));
} else if (op == "sqrsm") {
ChatId chat_id;
@@ -6026,7 +6025,7 @@ class CliClient final : public Actor {
quick_reply_shortcut_name_, reply_message_id_, std::move(input_message_contents)));
} else {
send_request(td_api::make_object<td_api::sendMessageAlbum>(
- chat_id, message_thread_id_, get_input_message_reply_to(), default_message_send_options(),
+ chat_id, get_message_topic_id(), get_input_message_reply_to(), default_message_send_options(),
std::move(input_message_contents)));
}
} else if (op == "savt") {
@@ -6341,7 +6340,8 @@ class CliClient final : public Actor {
get_args(args, chat_id, query_id, result_id);
if (quick_reply_shortcut_name_.empty()) {
send_request(td_api::make_object<td_api::sendInlineQueryResultMessage>(
- chat_id, message_thread_id_, nullptr, default_message_send_options(), query_id, result_id, op == "siqrh"));
+ chat_id, get_message_topic_id(), get_input_message_reply_to(), default_message_send_options(), query_id,
+ result_id, op == "siqrh"));
} else {
send_request(td_api::make_object<td_api::addQuickReplyShortcutInlineQueryResultMessage>(
quick_reply_shortcut_name_, reply_message_id_, query_id, result_id, op == "siqrh"));
diff --git a/td/tl/TlObject.h b/td/tl/TlObject.h
index d0d13aa4f..0b0640f10 100644
--- a/td/tl/TlObject.h
+++ b/td/tl/TlObject.h
@@ -190,7 +190,7 @@ using tl_object_ptr = tl::unique_ptr<Type>;
* auto get_me_request = td::make_tl_object<td::td_api::getMe>();
* auto message_text = td::make_tl_object<td::td_api::formattedText>("Hello, world!!!",
* td::td_api::array<td::tl_object_ptr<td::td_api::textEntity>>());
- * auto send_message_request = td::make_tl_object<td::td_api::sendMessage>(chat_id, 0, nullptr, nullptr, nullptr,
+ * auto send_message_request = td::make_tl_object<td::td_api::sendMessage>(chat_id, nullptr, nullptr, nullptr, nullptr,
* td::make_tl_object<td::td_api::inputMessageText>(std::move(message_text), nullptr, true));
* \endcode
*
diff --git a/test/online.cpp b/test/online.cpp
index 96fa72bfc..87c548657 100644
--- a/test/online.cpp
+++ b/test/online.cpp
@@ -336,7 +336,7 @@ class UploadFile : public Task {
write_file(content_path_, content_).ensure();
send_query(td::make_tl_object<td::td_api::sendMessage>(
- chat_id_, 0, nullptr, nullptr, nullptr,
+ chat_id_, nullptr, nullptr, nullptr, nullptr,
td::make_tl_object<td::td_api::inputMessageDocument>(
td::make_tl_object<td::td_api::inputFileLocal>(content_path_), nullptr, true,
td::make_tl_object<td::td_api::formattedText>("tag", td::Auto()))),
diff --git a/test/tdclient.cpp b/test/tdclient.cpp
index 0c2b12330..a558d23b6 100644
--- a/test/tdclient.cpp
+++ b/test/tdclient.cpp
@@ -310,7 +310,7 @@ class SetUsername final : public TestClinetTask {
CHECK(res->get_id() == td::td_api::chat::ID);
auto chat = td::move_tl_object_as<td::td_api::chat>(res);
this->send_query(td::make_tl_object<td::td_api::sendMessage>(
- chat->id_, 0, nullptr, nullptr, nullptr,
+ chat->id_, nullptr, nullptr, nullptr, nullptr,
td::make_tl_object<td::td_api::inputMessageText>(
td::make_tl_object<td::td_api::formattedText>(PSTRING() << tag_ << " INIT", td::Auto()),
nullptr, false)),
@@ -381,7 +381,7 @@ class TestA final : public TestClinetTask {
for (int i = 0; i < 20; i++) {
this->send_query(
td::make_tl_object<td::td_api::sendMessage>(
- chat->id_, 0, nullptr, nullptr, nullptr,
+ chat->id_, nullptr, nullptr, nullptr, nullptr,
td::make_tl_object<td::td_api::inputMessageText>(
td::make_tl_object<td::td_api::formattedText>(PSTRING() << tag_ << " " << (1000 + i), td::Auto()),
nullptr, false)),
@@ -430,7 +430,7 @@ class TestSecretChat final : public TestClinetTask {
for (int i = 0; i < 20; i++) {
send_query(
td::make_tl_object<td::td_api::sendMessage>(
- chat_id_, 0, nullptr, nullptr, nullptr,
+ chat_id_, nullptr, nullptr, nullptr, nullptr,
td::make_tl_object<td::td_api::inputMessageText>(
td::make_tl_object<td::td_api::formattedText>(PSTRING() << tag_ << " " << (1000 + i), td::Auto()),
nullptr, false)),
@@ -494,7 +494,7 @@ class TestFileGenerated final : public TestClinetTask {
file.flush_write().ensure(); // important
file.close();
send_query(td::make_tl_object<td::td_api::sendMessage>(
- chat_id_, 0, nullptr, nullptr, nullptr,
+ chat_id_, nullptr, nullptr, nullptr, nullptr,
td::make_tl_object<td::td_api::inputMessageDocument>(
td::make_tl_object<td::td_api::inputFileGenerated>(file_path, "square", 0),
td::make_tl_object<td::td_api::inputThumbnail>(
@@ -503,7 +503,7 @@ class TestFileGenerated final : public TestClinetTask {
[](auto res) { check_td_error(res); });
send_query(td::make_tl_object<td::td_api::sendMessage>(
- chat_id_, 0, nullptr, nullptr, nullptr,
+ chat_id_, nullptr, nullptr, nullptr, nullptr,
td::make_tl_object<td::td_api::inputMessageDocument>(
td::make_tl_object<td::td_api::inputFileGenerated>(file_path, "square", 0), nullptr, true,
td::make_tl_object<td::td_api::formattedText>(tag_, td::Auto()))),
@@ -611,7 +611,7 @@ class CheckTestC final : public TestClinetTask {
void one_file() {
send_query(td::make_tl_object<td::td_api::sendMessage>(
- chat_id_, 0, nullptr, nullptr, nullptr,
+ chat_id_, nullptr, nullptr, nullptr, nullptr,
td::make_tl_object<td::td_api::inputMessageText>(
td::make_tl_object<td::td_api::formattedText>(PSTRING() << tag_ << " ONE_FILE", td::Auto()),
nullptr, false)),