Add td_api::searchSavedMessages.

This commit is contained in:
levlam 2024-01-22 21:14:02 +03:00
parent e8f96d2520
commit e6611cdb8f
6 changed files with 81 additions and 39 deletions

View File

@ -7176,7 +7176,7 @@ getSavedMessagesTopics offset:string limit:int32 = FoundSavedMessagesTopics;
//@description Returns messages in a Saved Messages topic. The messages are returned in a reverse chronological order (i.e., in order of decreasing message_id) //@description Returns messages in a Saved Messages topic. The messages are returned in a reverse chronological order (i.e., in order of decreasing message_id)
//@saved_messages_topic Saved Messages topic which messages will be fetched //@saved_messages_topic Saved Messages topic which messages will be fetched
//@from_message_id Identifier of the message starting from which messages must be fetched; use 0 to get results from the last message //@from_message_id Identifier of the message starting from which messages must be fetched; use 0 to get results from the last message
//@offset Specify 0 to get results from exactly the from_message_id or a negative offset up to 99 to get additionally some newer messages //@offset Specify 0 to get results from exactly the message from_message_id or a negative offset up to 99 to get additionally some newer messages
//@limit The maximum number of messages to be returned; must be positive and can't be greater than 100. If the offset is negative, the limit must be greater than or equal to -offset. //@limit The maximum number of messages to be returned; must be positive and can't be greater than 100. If the offset is negative, the limit must be greater than or equal to -offset.
//-For optimal performance, the number of returned messages is chosen by TDLib and can be smaller than the specified limit //-For optimal performance, the number of returned messages is chosen by TDLib and can be smaller than the specified limit
getSavedMessagesTopicHistory saved_messages_topic:SavedMessagesTopic from_message_id:int53 offset:int32 limit:int32 = Messages; getSavedMessagesTopicHistory saved_messages_topic:SavedMessagesTopic from_message_id:int53 offset:int32 limit:int32 = Messages;
@ -7215,7 +7215,7 @@ getGroupsInCommon user_id:int53 offset_chat_id:int53 limit:int32 = Chats;
//-For optimal performance, the number of returned messages is chosen by TDLib. This is an offline request if only_local is true //-For optimal performance, the number of returned messages is chosen by TDLib. This is an offline request if only_local is true
//@chat_id Chat identifier //@chat_id Chat identifier
//@from_message_id Identifier of the message starting from which history must be fetched; use 0 to get results from the last message //@from_message_id Identifier of the message starting from which history must be fetched; use 0 to get results from the last message
//@offset Specify 0 to get results from exactly the from_message_id or a negative offset up to 99 to get additionally some newer messages //@offset Specify 0 to get results from exactly the message from_message_id or a negative offset up to 99 to get additionally some newer messages
//@limit The maximum number of messages to be returned; must be positive and can't be greater than 100. If the offset is negative, the limit must be greater than or equal to -offset. //@limit The maximum number of messages to be returned; must be positive and can't be greater than 100. If the offset is negative, the limit must be greater than or equal to -offset.
//-For optimal performance, the number of returned messages is chosen by TDLib and can be smaller than the specified limit //-For optimal performance, the number of returned messages is chosen by TDLib and can be smaller than the specified limit
//@only_local Pass true to get only messages that are available without sending network requests //@only_local Pass true to get only messages that are available without sending network requests
@ -7226,7 +7226,7 @@ getChatHistory chat_id:int53 from_message_id:int53 offset:int32 limit:int32 only
//@chat_id Chat identifier //@chat_id Chat identifier
//@message_id Message identifier, which thread history needs to be returned //@message_id Message identifier, which thread history needs to be returned
//@from_message_id Identifier of the message starting from which history must be fetched; use 0 to get results from the last message //@from_message_id Identifier of the message starting from which history must be fetched; use 0 to get results from the last message
//@offset Specify 0 to get results from exactly the from_message_id or a negative offset up to 99 to get additionally some newer messages //@offset Specify 0 to get results from exactly the message from_message_id or a negative offset up to 99 to get additionally some newer messages
//@limit The maximum number of messages to be returned; must be positive and can't be greater than 100. If the offset is negative, the limit must be greater than or equal to -offset. //@limit The maximum number of messages to be returned; must be positive and can't be greater than 100. If the offset is negative, the limit must be greater than or equal to -offset.
//-For optimal performance, the number of returned messages is chosen by TDLib and can be smaller than the specified limit //-For optimal performance, the number of returned messages is chosen by TDLib and can be smaller than the specified limit
getMessageThreadHistory chat_id:int53 message_id:int53 from_message_id:int53 offset:int32 limit:int32 = Messages; getMessageThreadHistory chat_id:int53 message_id:int53 from_message_id:int53 offset:int32 limit:int32 = Messages;
@ -7249,7 +7249,7 @@ deleteChat chat_id:int53 = Ok;
//@query Query to search for //@query Query to search for
//@sender_id Identifier of the sender of messages to search for; pass null to search for messages from any sender. Not supported in secret chats //@sender_id Identifier of the sender of messages to search for; pass null to search for messages from any sender. Not supported in secret chats
//@from_message_id Identifier of the message starting from which history must be fetched; use 0 to get results from the last message //@from_message_id Identifier of the message starting from which history must be fetched; use 0 to get results from the last message
//@offset Specify 0 to get results from exactly the from_message_id or a negative offset to get the specified message and some newer messages //@offset Specify 0 to get results from exactly the message from_message_id or a negative offset to get the specified message and some newer messages
//@limit The maximum number of messages to be returned; must be positive and can't be greater than 100. If the offset is negative, the limit must be greater than -offset. //@limit The maximum number of messages to be returned; must be positive and can't be greater than 100. If the offset is negative, the limit must be greater than -offset.
//-For optimal performance, the number of returned messages is chosen by TDLib and can be smaller than the specified limit //-For optimal performance, the number of returned messages is chosen by TDLib and can be smaller than the specified limit
//@filter Additional filter for messages to search; pass null to search for all messages //@filter Additional filter for messages to search; pass null to search for all messages
@ -7276,6 +7276,16 @@ searchMessages chat_list:ChatList query:string offset:string limit:int32 filter:
//@filter Additional filter for messages to search; pass null to search for all messages //@filter Additional filter for messages to search; pass null to search for all messages
searchSecretMessages chat_id:int53 query:string offset:string limit:int32 filter:SearchMessagesFilter = FoundMessages; searchSecretMessages chat_id:int53 query:string offset:string limit:int32 filter:SearchMessagesFilter = FoundMessages;
//@description Searches for messages tagged by the given reaction and with the given words in the Saved Messages chat. Returns the results in reverse chronological order, i.e. in order of decreasing message_id
//-For optimal performance, the number of returned messages is chosen by TDLib and can be smaller than the specified limit
//@tag Tag to search for; pass null to return all suitable messages
//@query Query to search for
//@from_message_id Identifier of the message starting from which messages must be fetched; use 0 to get results from the last message
//@offset Specify 0 to get results from exactly the message from_message_id or a negative offset to get the specified message and some newer messages
//@limit The maximum number of messages to be returned; must be positive and can't be greater than 100. If the offset is negative, the limit must be greater than -offset.
//-For optimal performance, the number of returned messages is chosen by TDLib and can be smaller than the specified limit
searchSavedMessages tag:ReactionType query:string from_message_id:int53 offset:int32 limit:int32 = FoundChatMessages;
//@description Searches for call messages. Returns the results in reverse chronological order (i.e., in order of decreasing message_id). For optimal performance, the number of returned messages is chosen by TDLib //@description Searches for call messages. Returns the results in reverse chronological order (i.e., in order of decreasing message_id). For optimal performance, the number of returned messages is chosen by TDLib
//@offset Offset of the first entry to return as received from the previous request; use empty string to get the first chunk of results //@offset Offset of the first entry to return as received from the previous request; use empty string to get the first chunk of results
//@limit The maximum number of messages to be returned; up to 100. For optimal performance, the number of returned messages is chosen by TDLib and can be smaller than the specified limit //@limit The maximum number of messages to be returned; up to 100. For optimal performance, the number of returned messages is chosen by TDLib and can be smaller than the specified limit

View File

@ -1987,6 +1987,7 @@ class SearchMessagesQuery final : public Td::ResultHandler {
int32 limit_; int32 limit_;
MessageSearchFilter filter_; MessageSearchFilter filter_;
MessageId top_thread_message_id_; MessageId top_thread_message_id_;
ReactionType tag_;
int64 random_id_; int64 random_id_;
bool handle_errors_ = true; bool handle_errors_ = true;
@ -1996,7 +1997,7 @@ class SearchMessagesQuery final : public Td::ResultHandler {
void send(DialogId dialog_id, SavedMessagesTopicId saved_messages_topic_id, const string &query, void send(DialogId dialog_id, SavedMessagesTopicId saved_messages_topic_id, const string &query,
DialogId sender_dialog_id, MessageId from_message_id, int32 offset, int32 limit, MessageSearchFilter filter, DialogId sender_dialog_id, MessageId from_message_id, int32 offset, int32 limit, MessageSearchFilter filter,
MessageId top_thread_message_id, int64 random_id) { MessageId top_thread_message_id, const ReactionType &tag, int64 random_id) {
auto input_peer = dialog_id.is_valid() ? td_->dialog_manager_->get_input_peer(dialog_id, AccessRights::Read) auto input_peer = dialog_id.is_valid() ? td_->dialog_manager_->get_input_peer(dialog_id, AccessRights::Read)
: make_tl_object<telegram_api::inputPeerEmpty>(); : make_tl_object<telegram_api::inputPeerEmpty>();
CHECK(input_peer != nullptr); CHECK(input_peer != nullptr);
@ -2010,12 +2011,14 @@ class SearchMessagesQuery final : public Td::ResultHandler {
limit_ = limit; limit_ = limit;
filter_ = filter; filter_ = filter;
top_thread_message_id_ = top_thread_message_id; top_thread_message_id_ = top_thread_message_id;
tag_ = tag;
random_id_ = random_id; random_id_ = random_id;
auto top_msg_id = top_thread_message_id.get_server_message_id().get(); auto top_msg_id = top_thread_message_id.get_server_message_id().get();
auto offset_id = from_message_id.get_server_message_id().get(); auto offset_id = from_message_id.get_server_message_id().get();
if (filter == MessageSearchFilter::UnreadMention) { if (filter == MessageSearchFilter::UnreadMention) {
CHECK(!saved_messages_topic_id.is_valid()); CHECK(!saved_messages_topic_id.is_valid());
CHECK(tag_.is_empty());
int32 flags = 0; int32 flags = 0;
if (top_thread_message_id.is_valid()) { if (top_thread_message_id.is_valid()) {
flags |= telegram_api::messages_getUnreadMentions::TOP_MSG_ID_MASK; flags |= telegram_api::messages_getUnreadMentions::TOP_MSG_ID_MASK;
@ -2024,6 +2027,7 @@ class SearchMessagesQuery final : public Td::ResultHandler {
flags, std::move(input_peer), top_msg_id, offset_id, offset, limit, std::numeric_limits<int32>::max(), 0))); flags, std::move(input_peer), top_msg_id, offset_id, offset, limit, std::numeric_limits<int32>::max(), 0)));
} else if (filter == MessageSearchFilter::UnreadReaction) { } else if (filter == MessageSearchFilter::UnreadReaction) {
CHECK(!saved_messages_topic_id.is_valid()); CHECK(!saved_messages_topic_id.is_valid());
CHECK(tag_.is_empty());
int32 flags = 0; int32 flags = 0;
if (top_thread_message_id.is_valid()) { if (top_thread_message_id.is_valid()) {
flags |= telegram_api::messages_getUnreadReactions::TOP_MSG_ID_MASK; flags |= telegram_api::messages_getUnreadReactions::TOP_MSG_ID_MASK;
@ -2033,6 +2037,7 @@ class SearchMessagesQuery final : public Td::ResultHandler {
} else if (top_thread_message_id.is_valid() && query.empty() && !sender_dialog_id.is_valid() && } else if (top_thread_message_id.is_valid() && query.empty() && !sender_dialog_id.is_valid() &&
filter == MessageSearchFilter::Empty) { filter == MessageSearchFilter::Empty) {
CHECK(!saved_messages_topic_id.is_valid()); CHECK(!saved_messages_topic_id.is_valid());
CHECK(tag_.is_empty());
handle_errors_ = dialog_id.get_type() != DialogType::Channel || handle_errors_ = dialog_id.get_type() != DialogType::Channel ||
!td_->contacts_manager_->is_broadcast_channel(dialog_id.get_channel_id()); !td_->contacts_manager_->is_broadcast_channel(dialog_id.get_channel_id());
send_query(G()->net_query_creator().create(telegram_api::messages_getReplies( send_query(G()->net_query_creator().create(telegram_api::messages_getReplies(
@ -2051,14 +2056,19 @@ class SearchMessagesQuery final : public Td::ResultHandler {
saved_input_peer = saved_messages_topic_id.get_input_peer(td_); saved_input_peer = saved_messages_topic_id.get_input_peer(td_);
CHECK(saved_input_peer != nullptr); CHECK(saved_input_peer != nullptr);
} }
vector<telegram_api::object_ptr<telegram_api::Reaction>> saved_reactions;
if (!tag.is_empty()) {
flags |= telegram_api::messages_search::SAVED_REACTION_MASK;
saved_reactions.push_back(tag.get_input_reaction());
}
if (top_thread_message_id.is_valid()) { if (top_thread_message_id.is_valid()) {
flags |= telegram_api::messages_search::TOP_MSG_ID_MASK; flags |= telegram_api::messages_search::TOP_MSG_ID_MASK;
} }
send_query(G()->net_query_creator().create(telegram_api::messages_search( send_query(G()->net_query_creator().create(telegram_api::messages_search(
flags, std::move(input_peer), query, std::move(sender_input_peer), std::move(saved_input_peer), Auto(), flags, std::move(input_peer), query, std::move(sender_input_peer), std::move(saved_input_peer),
top_msg_id, get_input_messages_filter(filter), 0, std::numeric_limits<int32>::max(), offset_id, offset, limit, std::move(saved_reactions), top_msg_id, get_input_messages_filter(filter), 0,
std::numeric_limits<int32>::max(), 0, 0))); std::numeric_limits<int32>::max(), offset_id, offset, limit, std::numeric_limits<int32>::max(), 0, 0)));
} }
} }
@ -2080,22 +2090,22 @@ class SearchMessagesQuery final : public Td::ResultHandler {
auto info = get_messages_info(td_, dialog_id_, result_ptr.move_as_ok(), "SearchMessagesQuery"); auto info = get_messages_info(td_, dialog_id_, result_ptr.move_as_ok(), "SearchMessagesQuery");
td_->messages_manager_->get_channel_difference_if_needed( td_->messages_manager_->get_channel_difference_if_needed(
dialog_id_, std::move(info), dialog_id_, std::move(info),
PromiseCreator::lambda([actor_id = td_->messages_manager_actor_.get(), dialog_id = dialog_id_, PromiseCreator::lambda(
saved_messages_topic_id = saved_messages_topic_id_, query = std::move(query_), [actor_id = td_->messages_manager_actor_.get(), dialog_id = dialog_id_,
sender_dialog_id = sender_dialog_id_, from_message_id = from_message_id_, saved_messages_topic_id = saved_messages_topic_id_, query = std::move(query_),
offset = offset_, limit = limit_, filter = filter_, sender_dialog_id = sender_dialog_id_, from_message_id = from_message_id_, offset = offset_, limit = limit_,
top_thread_message_id = top_thread_message_id_, random_id = random_id_, filter = filter_, top_thread_message_id = top_thread_message_id_, tag = std::move(tag_),
promise = std::move(promise_)](Result<MessagesInfo> &&result) mutable { random_id = random_id_, promise = std::move(promise_)](Result<MessagesInfo> &&result) mutable {
if (result.is_error()) { if (result.is_error()) {
promise.set_error(result.move_as_error()); promise.set_error(result.move_as_error());
} else { } else {
auto info = result.move_as_ok(); auto info = result.move_as_ok();
send_closure(actor_id, &MessagesManager::on_get_dialog_messages_search_result, dialog_id, send_closure(actor_id, &MessagesManager::on_get_dialog_messages_search_result, dialog_id,
saved_messages_topic_id, query, sender_dialog_id, from_message_id, offset, limit, filter, saved_messages_topic_id, query, sender_dialog_id, from_message_id, offset, limit, filter,
top_thread_message_id, random_id, info.total_count, std::move(info.messages), top_thread_message_id, tag, random_id, info.total_count, std::move(info.messages),
std::move(promise)); std::move(promise));
} }
}), }),
"SearchMessagesQuery"); "SearchMessagesQuery");
} }
@ -9065,8 +9075,8 @@ void MessagesManager::on_failed_get_message_search_result_calendar(int64 random_
void MessagesManager::on_get_dialog_messages_search_result( void MessagesManager::on_get_dialog_messages_search_result(
DialogId dialog_id, SavedMessagesTopicId saved_messages_topic_id, const string &query, DialogId sender_dialog_id, DialogId dialog_id, SavedMessagesTopicId saved_messages_topic_id, const string &query, DialogId sender_dialog_id,
MessageId from_message_id, int32 offset, int32 limit, MessageSearchFilter filter, MessageId top_thread_message_id, MessageId from_message_id, int32 offset, int32 limit, MessageSearchFilter filter, MessageId top_thread_message_id,
int64 random_id, int32 total_count, vector<tl_object_ptr<telegram_api::Message>> &&messages, const ReactionType &tag, int64 random_id, int32 total_count,
Promise<Unit> &&promise) { vector<tl_object_ptr<telegram_api::Message>> &&messages, Promise<Unit> &&promise) {
TRY_STATUS_PROMISE(promise, G()->close_status()); TRY_STATUS_PROMISE(promise, G()->close_status());
LOG(INFO) << "Receive " << messages.size() << " found messages in " << dialog_id; LOG(INFO) << "Receive " << messages.size() << " found messages in " << dialog_id;
@ -9075,6 +9085,7 @@ void MessagesManager::on_get_dialog_messages_search_result(
CHECK(!sender_dialog_id.is_valid()); CHECK(!sender_dialog_id.is_valid());
CHECK(!top_thread_message_id.is_valid()); CHECK(!top_thread_message_id.is_valid());
CHECK(!saved_messages_topic_id.is_valid()); CHECK(!saved_messages_topic_id.is_valid());
CHECK(tag.is_empty());
auto it = found_call_messages_.find(random_id); auto it = found_call_messages_.find(random_id);
CHECK(it != found_call_messages_.end()); CHECK(it != found_call_messages_.end());
@ -9223,7 +9234,7 @@ void MessagesManager::on_get_dialog_messages_search_result(
total_count = static_cast<int32>(result.size()); total_count = static_cast<int32>(result.size());
} }
if (query.empty() && !sender_dialog_id.is_valid() && filter != MessageSearchFilter::Empty && if (query.empty() && !sender_dialog_id.is_valid() && filter != MessageSearchFilter::Empty &&
!top_thread_message_id.is_valid() && !saved_messages_topic_id.is_valid()) { !top_thread_message_id.is_valid() && !saved_messages_topic_id.is_valid() && tag.is_empty()) {
bool from_the_end = !from_message_id.is_valid() || bool from_the_end = !from_message_id.is_valid() ||
(d->last_message_id != MessageId() && from_message_id > d->last_message_id) || (d->last_message_id != MessageId() && from_message_id > d->last_message_id) ||
from_message_id >= MessageId::max(); from_message_id >= MessageId::max();
@ -20338,7 +20349,7 @@ std::pair<DialogId, vector<MessageId>> MessagesManager::get_message_thread_histo
td_->create_handler<SearchMessagesQuery>(std::move(promise)) td_->create_handler<SearchMessagesQuery>(std::move(promise))
->send(dialog_id, SavedMessagesTopicId(), string(), DialogId(), from_message_id.get_next_server_message_id(), ->send(dialog_id, SavedMessagesTopicId(), string(), DialogId(), from_message_id.get_next_server_message_id(),
offset, limit, MessageSearchFilter::Empty, message_id, random_id); offset, limit, MessageSearchFilter::Empty, message_id, ReactionType(), random_id);
return {}; return {};
} }
@ -20510,7 +20521,8 @@ void MessagesManager::on_get_message_calendar_from_database(int64 random_id, Dia
MessagesManager::FoundDialogMessages MessagesManager::search_dialog_messages( MessagesManager::FoundDialogMessages MessagesManager::search_dialog_messages(
DialogId dialog_id, const string &query, const td_api::object_ptr<td_api::MessageSender> &sender, DialogId dialog_id, const string &query, const td_api::object_ptr<td_api::MessageSender> &sender,
MessageId from_message_id, int32 offset, int32 limit, MessageSearchFilter filter, MessageId top_thread_message_id, MessageId from_message_id, int32 offset, int32 limit, MessageSearchFilter filter, MessageId top_thread_message_id,
SavedMessagesTopicId saved_messages_topic_id, int64 &random_id, bool use_db, Promise<Unit> &&promise) { SavedMessagesTopicId saved_messages_topic_id, const ReactionType &tag, int64 &random_id, bool use_db,
Promise<Unit> &&promise) {
if (random_id != 0) { if (random_id != 0) {
// request has already been sent before // request has already been sent before
auto it = found_dialog_messages_.find(random_id); auto it = found_dialog_messages_.find(random_id);
@ -20633,7 +20645,7 @@ MessagesManager::FoundDialogMessages MessagesManager::search_dialog_messages(
// Trying to use database // Trying to use database
if (use_db && query.empty() && G()->use_message_database() && filter != MessageSearchFilter::Empty && if (use_db && query.empty() && G()->use_message_database() && filter != MessageSearchFilter::Empty &&
!sender_dialog_id.is_valid() && top_thread_message_id == MessageId() && !sender_dialog_id.is_valid() && top_thread_message_id == MessageId() &&
saved_messages_topic_id == SavedMessagesTopicId()) { saved_messages_topic_id == SavedMessagesTopicId() && tag.is_empty()) {
MessageId first_db_message_id = get_first_database_message_id_by_index(d, filter); MessageId first_db_message_id = get_first_database_message_id_by_index(d, filter);
int32 message_count = d->message_count_by_index[message_search_filter_index(filter)]; int32 message_count = d->message_count_by_index[message_search_filter_index(filter)];
auto fixed_from_message_id = from_message_id; auto fixed_from_message_id = from_message_id;
@ -20679,7 +20691,7 @@ MessagesManager::FoundDialogMessages MessagesManager::search_dialog_messages(
case DialogType::Channel: case DialogType::Channel:
td_->create_handler<SearchMessagesQuery>(std::move(promise)) td_->create_handler<SearchMessagesQuery>(std::move(promise))
->send(dialog_id, saved_messages_topic_id, query, sender_dialog_id, from_message_id, offset, limit, filter, ->send(dialog_id, saved_messages_topic_id, query, sender_dialog_id, from_message_id, offset, limit, filter,
top_thread_message_id, random_id); top_thread_message_id, tag, random_id);
break; break;
case DialogType::SecretChat: case DialogType::SecretChat:
if (filter == MessageSearchFilter::UnreadMention || filter == MessageSearchFilter::Pinned || if (filter == MessageSearchFilter::UnreadMention || filter == MessageSearchFilter::Pinned ||
@ -20771,7 +20783,7 @@ MessagesManager::FoundMessages MessagesManager::search_call_messages(const strin
td_->create_handler<SearchMessagesQuery>(std::move(promise)) td_->create_handler<SearchMessagesQuery>(std::move(promise))
->send(DialogId(), SavedMessagesTopicId(), string(), DialogId(), offset_message_id, 0, limit, filter, MessageId(), ->send(DialogId(), SavedMessagesTopicId(), string(), DialogId(), offset_message_id, 0, limit, filter, MessageId(),
random_id); ReactionType(), random_id);
return result; return result;
} }

View File

@ -175,8 +175,8 @@ class MessagesManager final : public Actor {
void on_get_dialog_messages_search_result(DialogId dialog_id, SavedMessagesTopicId saved_messages_topic_id, void on_get_dialog_messages_search_result(DialogId dialog_id, SavedMessagesTopicId saved_messages_topic_id,
const string &query, DialogId sender_dialog_id, MessageId from_message_id, const string &query, DialogId sender_dialog_id, MessageId from_message_id,
int32 offset, int32 limit, MessageSearchFilter filter, int32 offset, int32 limit, MessageSearchFilter filter,
MessageId top_thread_message_id, int64 random_id, int32 total_count, MessageId top_thread_message_id, const ReactionType &tag, int64 random_id,
vector<tl_object_ptr<telegram_api::Message>> &&messages, int32 total_count, vector<tl_object_ptr<telegram_api::Message>> &&messages,
Promise<Unit> &&promise); Promise<Unit> &&promise);
void on_failed_dialog_messages_search(DialogId dialog_id, int64 random_id); void on_failed_dialog_messages_search(DialogId dialog_id, int64 random_id);
@ -725,8 +725,8 @@ class MessagesManager final : public Actor {
const td_api::object_ptr<td_api::MessageSender> &sender, const td_api::object_ptr<td_api::MessageSender> &sender,
MessageId from_message_id, int32 offset, int32 limit, MessageId from_message_id, int32 offset, int32 limit,
MessageSearchFilter filter, MessageId top_thread_message_id, MessageSearchFilter filter, MessageId top_thread_message_id,
SavedMessagesTopicId saved_messages_topic_id, int64 &random_id, SavedMessagesTopicId saved_messages_topic_id, const ReactionType &tag,
bool use_db, Promise<Unit> &&promise); int64 &random_id, bool use_db, Promise<Unit> &&promise);
struct FoundMessages { struct FoundMessages {
vector<MessageFullId> message_full_ids; vector<MessageFullId> message_full_ids;

View File

@ -1402,6 +1402,7 @@ class SearchChatMessagesRequest final : public RequestActor<> {
MessageSearchFilter filter_; MessageSearchFilter filter_;
MessageId top_thread_message_id_; MessageId top_thread_message_id_;
SavedMessagesTopicId saved_messages_topic_id_; SavedMessagesTopicId saved_messages_topic_id_;
ReactionType tag_;
int64 random_id_; int64 random_id_;
MessagesManager::FoundDialogMessages messages_; MessagesManager::FoundDialogMessages messages_;
@ -1409,7 +1410,7 @@ class SearchChatMessagesRequest final : public RequestActor<> {
void do_run(Promise<Unit> &&promise) final { void do_run(Promise<Unit> &&promise) final {
messages_ = td_->messages_manager_->search_dialog_messages( messages_ = td_->messages_manager_->search_dialog_messages(
dialog_id_, query_, sender_id_, from_message_id_, offset_, limit_, filter_, top_thread_message_id_, dialog_id_, query_, sender_id_, from_message_id_, offset_, limit_, filter_, top_thread_message_id_,
saved_messages_topic_id_, random_id_, get_tries() == 3, std::move(promise)); saved_messages_topic_id_, tag_, random_id_, get_tries() == 3, std::move(promise));
} }
void do_send_result() final { void do_send_result() final {
@ -1429,7 +1430,7 @@ class SearchChatMessagesRequest final : public RequestActor<> {
SearchChatMessagesRequest(ActorShared<Td> td, uint64 request_id, int64 dialog_id, string query, SearchChatMessagesRequest(ActorShared<Td> td, uint64 request_id, int64 dialog_id, string query,
td_api::object_ptr<td_api::MessageSender> sender_id, int64 from_message_id, int32 offset, td_api::object_ptr<td_api::MessageSender> sender_id, int64 from_message_id, int32 offset,
int32 limit, tl_object_ptr<td_api::SearchMessagesFilter> filter, int64 message_thread_id, int32 limit, tl_object_ptr<td_api::SearchMessagesFilter> filter, int64 message_thread_id,
SavedMessagesTopicId saved_messages_topic_id) SavedMessagesTopicId saved_messages_topic_id, ReactionType tag)
: RequestActor(std::move(td), request_id) : RequestActor(std::move(td), request_id)
, dialog_id_(dialog_id) , dialog_id_(dialog_id)
, query_(std::move(query)) , query_(std::move(query))
@ -1440,6 +1441,7 @@ class SearchChatMessagesRequest final : public RequestActor<> {
, filter_(get_message_search_filter(filter)) , filter_(get_message_search_filter(filter))
, top_thread_message_id_(message_thread_id) , top_thread_message_id_(message_thread_id)
, saved_messages_topic_id_(saved_messages_topic_id) , saved_messages_topic_id_(saved_messages_topic_id)
, tag_(std::move(tag))
, random_id_(0) { , random_id_(0) {
set_tries(3); set_tries(3);
} }
@ -5281,7 +5283,7 @@ void Td::on_request(uint64 id, td_api::searchChatMessages &request) {
CLEAN_INPUT_STRING(request.query_); CLEAN_INPUT_STRING(request.query_);
CREATE_REQUEST(SearchChatMessagesRequest, request.chat_id_, std::move(request.query_), std::move(request.sender_id_), CREATE_REQUEST(SearchChatMessagesRequest, request.chat_id_, std::move(request.query_), std::move(request.sender_id_),
request.from_message_id_, request.offset_, request.limit_, std::move(request.filter_), request.from_message_id_, request.offset_, request.limit_, std::move(request.filter_),
request.message_thread_id_, SavedMessagesTopicId(this, request.saved_messages_topic_)); request.message_thread_id_, SavedMessagesTopicId(this, request.saved_messages_topic_), ReactionType());
} }
void Td::on_request(uint64 id, td_api::searchSecretMessages &request) { void Td::on_request(uint64 id, td_api::searchSecretMessages &request) {
@ -5305,6 +5307,14 @@ void Td::on_request(uint64 id, td_api::searchMessages &request) {
request.min_date_, request.max_date_); request.min_date_, request.max_date_);
} }
void Td::on_request(uint64 id, td_api::searchSavedMessages &request) {
CHECK_IS_USER();
CLEAN_INPUT_STRING(request.query_);
CREATE_REQUEST(SearchChatMessagesRequest, dialog_manager_->get_my_dialog_id().get(), std::move(request.query_),
nullptr, request.from_message_id_, request.offset_, request.limit_, nullptr, 0, SavedMessagesTopicId(),
ReactionType(request.tag_));
}
void Td::on_request(uint64 id, const td_api::searchCallMessages &request) { void Td::on_request(uint64 id, const td_api::searchCallMessages &request) {
CHECK_IS_USER(); CHECK_IS_USER();
CREATE_REQUEST(SearchCallMessagesRequest, std::move(request.offset_), request.limit_, request.only_missed_); CREATE_REQUEST(SearchCallMessagesRequest, std::move(request.offset_), request.limit_, request.only_missed_);

View File

@ -753,6 +753,8 @@ class Td final : public Actor {
void on_request(uint64 id, td_api::searchMessages &request); void on_request(uint64 id, td_api::searchMessages &request);
void on_request(uint64 id, td_api::searchSavedMessages &request);
void on_request(uint64 id, const td_api::searchCallMessages &request); void on_request(uint64 id, const td_api::searchCallMessages &request);
void on_request(uint64 id, td_api::searchOutgoingDocumentMessages &request); void on_request(uint64 id, td_api::searchOutgoingDocumentMessages &request);

View File

@ -2973,6 +2973,14 @@ class CliClient final : public Actor {
send_request(td_api::make_object<td_api::searchChatMessages>(chat_id, query.query, nullptr, offset_message_id, 0, send_request(td_api::make_object<td_api::searchChatMessages>(chat_id, query.query, nullptr, offset_message_id, 0,
query.limit, as_search_messages_filter(op), 0, query.limit, as_search_messages_filter(op), 0,
get_saved_messages_topic())); get_saved_messages_topic()));
} else if (op == "ssms") {
string tag;
MessageId from_message_id;
int32 offset;
SearchQuery query;
get_args(args, tag, from_message_id, offset, query);
send_request(td_api::make_object<td_api::searchSavedMessages>(as_reaction_type(tag), query.query, from_message_id,
offset, query.limit));
} else if (op == "gcmbd") { } else if (op == "gcmbd") {
ChatId chat_id; ChatId chat_id;
int32 date; int32 date;