Add searchChatMessages.saved_messages_topic_id.
This commit is contained in:
parent
341b59cb6c
commit
7d71562a24
@ -7196,7 +7196,8 @@ deleteChat chat_id:int53 = Ok;
|
||||
//-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
|
||||
//@message_thread_id If not 0, only messages in the specified thread will be returned; supergroups only
|
||||
searchChatMessages chat_id:int53 query:string sender_id:MessageSender from_message_id:int53 offset:int32 limit:int32 filter:SearchMessagesFilter message_thread_id:int53 = FoundChatMessages;
|
||||
//@saved_messages_topic If not null, only messages in the specified Saved Messages topic will be returned; pass null to return all messages or for chats other than Saved Messages
|
||||
searchChatMessages chat_id:int53 query:string sender_id:MessageSender from_message_id:int53 offset:int32 limit:int32 filter:SearchMessagesFilter message_thread_id:int53 saved_messages_topic:SavedMessagesTopic = FoundChatMessages;
|
||||
|
||||
//@description Searches for messages in all chats except secret chats. Returns the results in reverse chronological order (i.e., in order of decreasing (date, chat_id, message_id)).
|
||||
//-For optimal performance, the number of returned messages is chosen by TDLib and can be smaller than the specified limit
|
||||
|
@ -1724,6 +1724,7 @@ class GetMessagePositionQuery final : public Td::ResultHandler {
|
||||
class SearchMessagesQuery final : public Td::ResultHandler {
|
||||
Promise<Unit> promise_;
|
||||
DialogId dialog_id_;
|
||||
SavedMessagesTopicId saved_messages_topic_id_;
|
||||
string query_;
|
||||
DialogId sender_dialog_id_;
|
||||
MessageId from_message_id_;
|
||||
@ -1738,13 +1739,15 @@ class SearchMessagesQuery final : public Td::ResultHandler {
|
||||
explicit SearchMessagesQuery(Promise<Unit> &&promise) : promise_(std::move(promise)) {
|
||||
}
|
||||
|
||||
void send(DialogId dialog_id, const string &query, DialogId sender_dialog_id, MessageId from_message_id, int32 offset,
|
||||
int32 limit, MessageSearchFilter filter, MessageId top_thread_message_id, int64 random_id) {
|
||||
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,
|
||||
MessageId top_thread_message_id, int64 random_id) {
|
||||
auto input_peer = dialog_id.is_valid() ? td_->dialog_manager_->get_input_peer(dialog_id, AccessRights::Read)
|
||||
: make_tl_object<telegram_api::inputPeerEmpty>();
|
||||
CHECK(input_peer != nullptr);
|
||||
|
||||
dialog_id_ = dialog_id;
|
||||
saved_messages_topic_id_ = saved_messages_topic_id;
|
||||
query_ = query;
|
||||
sender_dialog_id_ = sender_dialog_id;
|
||||
from_message_id_ = from_message_id;
|
||||
@ -1757,6 +1760,7 @@ class SearchMessagesQuery final : public Td::ResultHandler {
|
||||
auto top_msg_id = top_thread_message_id.get_server_message_id().get();
|
||||
auto offset_id = from_message_id.get_server_message_id().get();
|
||||
if (filter == MessageSearchFilter::UnreadMention) {
|
||||
CHECK(!saved_messages_topic_id.is_valid());
|
||||
int32 flags = 0;
|
||||
if (top_thread_message_id.is_valid()) {
|
||||
flags |= telegram_api::messages_getUnreadMentions::TOP_MSG_ID_MASK;
|
||||
@ -1764,6 +1768,7 @@ class SearchMessagesQuery final : public Td::ResultHandler {
|
||||
send_query(G()->net_query_creator().create(telegram_api::messages_getUnreadMentions(
|
||||
flags, std::move(input_peer), top_msg_id, offset_id, offset, limit, std::numeric_limits<int32>::max(), 0)));
|
||||
} else if (filter == MessageSearchFilter::UnreadReaction) {
|
||||
CHECK(!saved_messages_topic_id.is_valid());
|
||||
int32 flags = 0;
|
||||
if (top_thread_message_id.is_valid()) {
|
||||
flags |= telegram_api::messages_getUnreadReactions::TOP_MSG_ID_MASK;
|
||||
@ -1772,6 +1777,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)));
|
||||
} else if (top_thread_message_id.is_valid() && query.empty() && !sender_dialog_id.is_valid() &&
|
||||
filter == MessageSearchFilter::Empty) {
|
||||
CHECK(!saved_messages_topic_id.is_valid());
|
||||
handle_errors_ = dialog_id.get_type() != DialogType::Channel ||
|
||||
!td_->contacts_manager_->is_broadcast_channel(dialog_id.get_channel_id());
|
||||
send_query(G()->net_query_creator().create(telegram_api::messages_getReplies(
|
||||
@ -1784,13 +1790,19 @@ class SearchMessagesQuery final : public Td::ResultHandler {
|
||||
sender_input_peer = td_->dialog_manager_->get_input_peer(sender_dialog_id, AccessRights::Know);
|
||||
CHECK(sender_input_peer != nullptr);
|
||||
}
|
||||
tl_object_ptr<telegram_api::InputPeer> saved_input_peer;
|
||||
if (saved_messages_topic_id.is_valid()) {
|
||||
flags |= telegram_api::messages_search::SAVED_PEER_ID_MASK;
|
||||
saved_input_peer = saved_messages_topic_id.get_input_peer(td_);
|
||||
CHECK(saved_input_peer != nullptr);
|
||||
}
|
||||
if (top_thread_message_id.is_valid()) {
|
||||
flags |= telegram_api::messages_search::TOP_MSG_ID_MASK;
|
||||
}
|
||||
|
||||
send_query(G()->net_query_creator().create(telegram_api::messages_search(
|
||||
flags, std::move(input_peer), query, std::move(sender_input_peer), nullptr, Auto(), top_msg_id,
|
||||
get_input_messages_filter(filter), 0, std::numeric_limits<int32>::max(), offset_id, offset, limit,
|
||||
flags, std::move(input_peer), query, std::move(sender_input_peer), std::move(saved_input_peer), Auto(),
|
||||
top_msg_id, get_input_messages_filter(filter), 0, std::numeric_limits<int32>::max(), offset_id, offset, limit,
|
||||
std::numeric_limits<int32>::max(), 0, 0)));
|
||||
}
|
||||
}
|
||||
@ -1814,17 +1826,19 @@ class SearchMessagesQuery final : public Td::ResultHandler {
|
||||
td_->messages_manager_->get_channel_difference_if_needed(
|
||||
dialog_id_, std::move(info),
|
||||
PromiseCreator::lambda([actor_id = td_->messages_manager_actor_.get(), dialog_id = dialog_id_,
|
||||
query = std::move(query_), sender_dialog_id = sender_dialog_id_,
|
||||
from_message_id = from_message_id_, offset = offset_, limit = limit_, filter = filter_,
|
||||
saved_messages_topic_id = saved_messages_topic_id_, query = std::move(query_),
|
||||
sender_dialog_id = sender_dialog_id_, from_message_id = from_message_id_,
|
||||
offset = offset_, limit = limit_, filter = filter_,
|
||||
top_thread_message_id = top_thread_message_id_, random_id = random_id_,
|
||||
promise = std::move(promise_)](Result<MessagesInfo> &&result) mutable {
|
||||
if (result.is_error()) {
|
||||
promise.set_error(result.move_as_error());
|
||||
} else {
|
||||
auto info = result.move_as_ok();
|
||||
send_closure(actor_id, &MessagesManager::on_get_dialog_messages_search_result, dialog_id, query,
|
||||
sender_dialog_id, from_message_id, offset, limit, filter, top_thread_message_id, random_id,
|
||||
info.total_count, std::move(info.messages), std::move(promise));
|
||||
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,
|
||||
top_thread_message_id, random_id, info.total_count, std::move(info.messages),
|
||||
std::move(promise));
|
||||
}
|
||||
}),
|
||||
"SearchMessagesQuery");
|
||||
@ -8710,9 +8724,10 @@ void MessagesManager::on_failed_get_message_search_result_calendar(DialogId dial
|
||||
}
|
||||
|
||||
void MessagesManager::on_get_dialog_messages_search_result(
|
||||
DialogId dialog_id, const string &query, DialogId sender_dialog_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, Promise<Unit> &&promise) {
|
||||
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,
|
||||
int64 random_id, int32 total_count, vector<tl_object_ptr<telegram_api::Message>> &&messages,
|
||||
Promise<Unit> &&promise) {
|
||||
TRY_STATUS_PROMISE(promise, G()->close_status());
|
||||
|
||||
LOG(INFO) << "Receive " << messages.size() << " found messages in " << dialog_id;
|
||||
@ -8720,6 +8735,7 @@ void MessagesManager::on_get_dialog_messages_search_result(
|
||||
CHECK(query.empty());
|
||||
CHECK(!sender_dialog_id.is_valid());
|
||||
CHECK(!top_thread_message_id.is_valid());
|
||||
CHECK(!saved_messages_topic_id.is_valid());
|
||||
auto it = found_call_messages_.find(random_id);
|
||||
CHECK(it != found_call_messages_.end());
|
||||
|
||||
@ -8868,7 +8884,7 @@ void MessagesManager::on_get_dialog_messages_search_result(
|
||||
total_count = static_cast<int32>(result.size());
|
||||
}
|
||||
if (query.empty() && !sender_dialog_id.is_valid() && filter != MessageSearchFilter::Empty &&
|
||||
!top_thread_message_id.is_valid()) {
|
||||
!top_thread_message_id.is_valid() && !saved_messages_topic_id.is_valid()) {
|
||||
bool from_the_end = !from_message_id.is_valid() ||
|
||||
(d->last_message_id != MessageId() && from_message_id > d->last_message_id) ||
|
||||
from_message_id >= MessageId::max();
|
||||
@ -19706,8 +19722,8 @@ std::pair<DialogId, vector<MessageId>> MessagesManager::get_message_thread_histo
|
||||
found_dialog_messages_[random_id]; // reserve place for result
|
||||
|
||||
td_->create_handler<SearchMessagesQuery>(std::move(promise))
|
||||
->send(dialog_id, string(), DialogId(), from_message_id.get_next_server_message_id(), offset, limit,
|
||||
MessageSearchFilter::Empty, message_id, random_id);
|
||||
->send(dialog_id, SavedMessagesTopicId(), string(), DialogId(), from_message_id.get_next_server_message_id(),
|
||||
offset, limit, MessageSearchFilter::Empty, message_id, random_id);
|
||||
return {};
|
||||
}
|
||||
|
||||
@ -19871,7 +19887,7 @@ void MessagesManager::on_get_message_calendar_from_database(int64 random_id, Dia
|
||||
MessagesManager::FoundDialogMessages MessagesManager::search_dialog_messages(
|
||||
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,
|
||||
int64 &random_id, bool use_db, Promise<Unit> &&promise) {
|
||||
SavedMessagesTopicId saved_messages_topic_id, int64 &random_id, bool use_db, Promise<Unit> &&promise) {
|
||||
if (random_id != 0) {
|
||||
// request has already been sent before
|
||||
auto it = found_dialog_messages_.find(random_id);
|
||||
@ -19885,8 +19901,9 @@ MessagesManager::FoundDialogMessages MessagesManager::search_dialog_messages(
|
||||
random_id = 0;
|
||||
}
|
||||
LOG(INFO) << "Search messages with query \"" << query << "\" in " << dialog_id << " sent by "
|
||||
<< oneline(to_string(sender)) << " in thread of " << top_thread_message_id << " filtered by " << filter
|
||||
<< " from " << from_message_id << " with offset " << offset << " and limit " << limit;
|
||||
<< oneline(to_string(sender)) << " in thread of " << top_thread_message_id << " and in "
|
||||
<< saved_messages_topic_id << " filtered by " << filter << " from " << from_message_id << " with offset "
|
||||
<< offset << " and limit " << limit;
|
||||
|
||||
FoundDialogMessages result;
|
||||
if (limit <= 0) {
|
||||
@ -19949,11 +19966,21 @@ MessagesManager::FoundDialogMessages MessagesManager::search_dialog_messages(
|
||||
|
||||
if (top_thread_message_id != MessageId()) {
|
||||
if (!top_thread_message_id.is_valid() || !top_thread_message_id.is_server()) {
|
||||
promise.set_error(Status::Error(400, "Invalid message thread ID specified"));
|
||||
promise.set_error(Status::Error(400, "Invalid message thread specified"));
|
||||
return result;
|
||||
}
|
||||
if (dialog_id.get_type() != DialogType::Channel || td_->dialog_manager_->is_broadcast_channel(dialog_id)) {
|
||||
promise.set_error(Status::Error(400, "Can't filter by message thread ID in the chat"));
|
||||
promise.set_error(Status::Error(400, "Can't filter by message thread in the chat"));
|
||||
return result;
|
||||
}
|
||||
}
|
||||
if (saved_messages_topic_id != SavedMessagesTopicId()) {
|
||||
if (dialog_id != td_->dialog_manager_->get_my_dialog_id()) {
|
||||
promise.set_error(Status::Error(400, "Can't filter by Saved Messages topic in the chat"));
|
||||
return result;
|
||||
}
|
||||
if (!saved_messages_topic_id.have_input_peer(td_)) {
|
||||
promise.set_error(Status::Error(400, "Invalid Saved Messages topic specified"));
|
||||
return result;
|
||||
}
|
||||
}
|
||||
@ -19963,11 +19990,6 @@ MessagesManager::FoundDialogMessages MessagesManager::search_dialog_messages(
|
||||
return result;
|
||||
}
|
||||
|
||||
do {
|
||||
random_id = Random::secure_int64();
|
||||
} while (random_id == 0 || found_dialog_messages_.count(random_id) > 0);
|
||||
found_dialog_messages_[random_id]; // reserve place for result
|
||||
|
||||
if (filter == MessageSearchFilter::UnreadMention || filter == MessageSearchFilter::UnreadReaction) {
|
||||
if (!query.empty()) {
|
||||
promise.set_error(Status::Error(400, "Non-empty query is unsupported with the specified filter"));
|
||||
@ -19977,11 +19999,21 @@ MessagesManager::FoundDialogMessages MessagesManager::search_dialog_messages(
|
||||
promise.set_error(Status::Error(400, "Filtering by sender is unsupported with the specified filter"));
|
||||
return result;
|
||||
}
|
||||
if (saved_messages_topic_id.is_valid()) {
|
||||
promise.set_value(Unit());
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
do {
|
||||
random_id = Random::secure_int64();
|
||||
} while (random_id == 0 || found_dialog_messages_.count(random_id) > 0);
|
||||
found_dialog_messages_[random_id]; // reserve place for result
|
||||
|
||||
// Trying to use database
|
||||
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()) {
|
||||
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)];
|
||||
auto fixed_from_message_id = from_message_id;
|
||||
@ -20025,8 +20057,8 @@ MessagesManager::FoundDialogMessages MessagesManager::search_dialog_messages(
|
||||
case DialogType::Chat:
|
||||
case DialogType::Channel:
|
||||
td_->create_handler<SearchMessagesQuery>(std::move(promise))
|
||||
->send(dialog_id, query, sender_dialog_id, from_message_id, offset, limit, filter, top_thread_message_id,
|
||||
random_id);
|
||||
->send(dialog_id, saved_messages_topic_id, query, sender_dialog_id, from_message_id, offset, limit, filter,
|
||||
top_thread_message_id, random_id);
|
||||
break;
|
||||
case DialogType::SecretChat:
|
||||
if (filter == MessageSearchFilter::UnreadMention || filter == MessageSearchFilter::Pinned ||
|
||||
@ -20117,7 +20149,8 @@ MessagesManager::FoundMessages MessagesManager::search_call_messages(const strin
|
||||
}
|
||||
|
||||
td_->create_handler<SearchMessagesQuery>(std::move(promise))
|
||||
->send(DialogId(), "", DialogId(), offset_message_id, 0, limit, filter, MessageId(), random_id);
|
||||
->send(DialogId(), SavedMessagesTopicId(), string(), DialogId(), offset_message_id, 0, limit, filter, MessageId(),
|
||||
random_id);
|
||||
return result;
|
||||
}
|
||||
|
||||
|
@ -172,10 +172,10 @@ class MessagesManager final : public Actor {
|
||||
Promise<Unit> &&promise);
|
||||
void on_failed_get_message_search_result_calendar(DialogId dialog_id, int64 random_id);
|
||||
|
||||
void on_get_dialog_messages_search_result(DialogId dialog_id, const string &query, DialogId sender_dialog_id,
|
||||
MessageId from_message_id, int32 offset, int32 limit,
|
||||
MessageSearchFilter filter, MessageId top_thread_message_id,
|
||||
int64 random_id, int32 total_count,
|
||||
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,
|
||||
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,
|
||||
Promise<Unit> &&promise);
|
||||
void on_failed_dialog_messages_search(DialogId dialog_id, int64 random_id);
|
||||
@ -696,7 +696,8 @@ class MessagesManager final : public Actor {
|
||||
const td_api::object_ptr<td_api::MessageSender> &sender,
|
||||
MessageId from_message_id, int32 offset, int32 limit,
|
||||
MessageSearchFilter filter, MessageId top_thread_message_id,
|
||||
int64 &random_id, bool use_db, Promise<Unit> &&promise);
|
||||
SavedMessagesTopicId saved_messages_topic_id, int64 &random_id,
|
||||
bool use_db, Promise<Unit> &&promise);
|
||||
|
||||
struct FoundMessages {
|
||||
vector<MessageFullId> message_full_ids;
|
||||
|
@ -6,6 +6,7 @@
|
||||
//
|
||||
#include "td/telegram/SavedMessagesTopicId.h"
|
||||
|
||||
#include "td/telegram/AccessRights.h"
|
||||
#include "td/telegram/Dependencies.h"
|
||||
#include "td/telegram/DialogManager.h"
|
||||
#include "td/telegram/MessageForwardInfo.h"
|
||||
@ -35,6 +36,28 @@ SavedMessagesTopicId::SavedMessagesTopicId(DialogId my_dialog_id, const MessageF
|
||||
dialog_id_ = my_dialog_id;
|
||||
}
|
||||
|
||||
SavedMessagesTopicId::SavedMessagesTopicId(const Td *td,
|
||||
const td_api::object_ptr<td_api::SavedMessagesTopic> &saved_messages_topic) {
|
||||
if (saved_messages_topic == nullptr) {
|
||||
return;
|
||||
}
|
||||
switch (saved_messages_topic->get_id()) {
|
||||
case td_api::savedMessagesTopicMyNotes::ID:
|
||||
dialog_id_ = td->dialog_manager_->get_my_dialog_id();
|
||||
break;
|
||||
case td_api::savedMessagesTopicAuthorHidden::ID:
|
||||
dialog_id_ = HIDDEN_AUTHOR_DIALOG_ID;
|
||||
break;
|
||||
case td_api::savedMessagesTopicSavedFromChat::ID:
|
||||
dialog_id_ =
|
||||
DialogId(static_cast<const td_api::savedMessagesTopicSavedFromChat *>(saved_messages_topic.get())->chat_id_);
|
||||
break;
|
||||
default:
|
||||
UNREACHABLE();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
td_api::object_ptr<td_api::SavedMessagesTopic> SavedMessagesTopicId::get_saved_messages_topic_object(Td *td) const {
|
||||
if (dialog_id_ == DialogId()) {
|
||||
return nullptr;
|
||||
@ -49,6 +72,15 @@ td_api::object_ptr<td_api::SavedMessagesTopic> SavedMessagesTopicId::get_saved_m
|
||||
td->messages_manager_->get_chat_id_object(dialog_id_, "savedMessagesTopicSavedFromChat"));
|
||||
}
|
||||
|
||||
bool SavedMessagesTopicId::have_input_peer(const Td *td) const {
|
||||
return dialog_id_.get_type() != DialogType::SecretChat &&
|
||||
td->dialog_manager_->have_input_peer(dialog_id_, AccessRights::Know);
|
||||
}
|
||||
|
||||
telegram_api::object_ptr<telegram_api::InputPeer> SavedMessagesTopicId::get_input_peer(const Td *td) const {
|
||||
return td->dialog_manager_->get_input_peer(dialog_id_, AccessRights::Know);
|
||||
}
|
||||
|
||||
void SavedMessagesTopicId::add_dependencies(Dependencies &dependencies) const {
|
||||
if (dialog_id_ == HIDDEN_AUTHOR_DIALOG_ID) {
|
||||
dependencies.add_dialog_dependencies(dialog_id_);
|
||||
|
@ -24,6 +24,8 @@ class SavedMessagesTopicId {
|
||||
|
||||
friend struct SavedMessagesTopicIdHash;
|
||||
|
||||
friend bool operator==(const SavedMessagesTopicId &lhs, const SavedMessagesTopicId &rhs);
|
||||
|
||||
friend StringBuilder &operator<<(StringBuilder &string_builder, SavedMessagesTopicId saved_messages_topic_id);
|
||||
|
||||
public:
|
||||
@ -34,22 +36,20 @@ class SavedMessagesTopicId {
|
||||
|
||||
SavedMessagesTopicId(DialogId my_dialog_id, const MessageForwardInfo *message_forward_info);
|
||||
|
||||
SavedMessagesTopicId(const Td *td, const td_api::object_ptr<td_api::SavedMessagesTopic> &saved_messages_topic);
|
||||
|
||||
bool is_valid() const {
|
||||
return dialog_id_.is_valid();
|
||||
}
|
||||
|
||||
td_api::object_ptr<td_api::SavedMessagesTopic> get_saved_messages_topic_object(Td *td) const;
|
||||
|
||||
bool have_input_peer(const Td *td) const;
|
||||
|
||||
telegram_api::object_ptr<telegram_api::InputPeer> get_input_peer(const Td *td) const;
|
||||
|
||||
void add_dependencies(Dependencies &dependencies) const;
|
||||
|
||||
bool operator==(const SavedMessagesTopicId &other) const {
|
||||
return dialog_id_ == other.dialog_id_;
|
||||
}
|
||||
|
||||
bool operator!=(const SavedMessagesTopicId &other) const {
|
||||
return dialog_id_ != other.dialog_id_;
|
||||
}
|
||||
|
||||
template <class StorerT>
|
||||
void store(StorerT &storer) const {
|
||||
dialog_id_.store(storer);
|
||||
@ -67,6 +67,14 @@ struct SavedMessagesTopicIdHash {
|
||||
}
|
||||
};
|
||||
|
||||
inline bool operator==(const SavedMessagesTopicId &lhs, const SavedMessagesTopicId &rhs) {
|
||||
return lhs.dialog_id_ == rhs.dialog_id_;
|
||||
}
|
||||
|
||||
inline bool operator!=(const SavedMessagesTopicId &lhs, const SavedMessagesTopicId &rhs) {
|
||||
return !(lhs == rhs);
|
||||
}
|
||||
|
||||
StringBuilder &operator<<(StringBuilder &string_builder, SavedMessagesTopicId saved_messages_topic_id);
|
||||
|
||||
} // namespace td
|
||||
|
@ -120,6 +120,7 @@
|
||||
#include "td/telegram/ReactionType.h"
|
||||
#include "td/telegram/ReportReason.h"
|
||||
#include "td/telegram/RequestActor.h"
|
||||
#include "td/telegram/SavedMessagesTopicId.h"
|
||||
#include "td/telegram/ScopeNotificationSettings.h"
|
||||
#include "td/telegram/SecretChatId.h"
|
||||
#include "td/telegram/SecretChatsManager.h"
|
||||
@ -1396,14 +1397,15 @@ class SearchChatMessagesRequest final : public RequestActor<> {
|
||||
int32 limit_;
|
||||
MessageSearchFilter filter_;
|
||||
MessageId top_thread_message_id_;
|
||||
SavedMessagesTopicId saved_messages_topic_id_;
|
||||
int64 random_id_;
|
||||
|
||||
MessagesManager::FoundDialogMessages messages_;
|
||||
|
||||
void do_run(Promise<Unit> &&promise) final {
|
||||
messages_ = td_->messages_manager_->search_dialog_messages(dialog_id_, query_, sender_id_, from_message_id_,
|
||||
offset_, limit_, filter_, top_thread_message_id_,
|
||||
random_id_, get_tries() == 3, std::move(promise));
|
||||
messages_ = td_->messages_manager_->search_dialog_messages(
|
||||
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));
|
||||
}
|
||||
|
||||
void do_send_result() final {
|
||||
@ -1422,7 +1424,8 @@ class SearchChatMessagesRequest final : public RequestActor<> {
|
||||
public:
|
||||
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,
|
||||
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)
|
||||
: RequestActor(std::move(td), request_id)
|
||||
, dialog_id_(dialog_id)
|
||||
, query_(std::move(query))
|
||||
@ -1432,6 +1435,7 @@ class SearchChatMessagesRequest final : public RequestActor<> {
|
||||
, limit_(limit)
|
||||
, filter_(get_message_search_filter(filter))
|
||||
, top_thread_message_id_(message_thread_id)
|
||||
, saved_messages_topic_id_(saved_messages_topic_id)
|
||||
, random_id_(0) {
|
||||
set_tries(3);
|
||||
}
|
||||
@ -5213,7 +5217,7 @@ void Td::on_request(uint64 id, td_api::searchChatMessages &request) {
|
||||
CLEAN_INPUT_STRING(request.query_);
|
||||
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.message_thread_id_);
|
||||
request.message_thread_id_, SavedMessagesTopicId(this, request.saved_messages_topic_));
|
||||
}
|
||||
|
||||
void Td::on_request(uint64 id, td_api::searchSecretMessages &request) {
|
||||
|
@ -340,8 +340,9 @@ class CliClient final : public Actor {
|
||||
if (!messages.messages_.empty()) {
|
||||
auto last_message_id = messages.messages_.back()->id_;
|
||||
LOG(ERROR) << (last_message_id >> 20);
|
||||
send_request(td_api::make_object<td_api::searchChatMessages>(search_chat_id_, "", nullptr, last_message_id, 0,
|
||||
100, as_search_messages_filter("pvi"), 0));
|
||||
send_request(td_api::make_object<td_api::searchChatMessages>(
|
||||
search_chat_id_, string(), nullptr, last_message_id, 0, 100, as_search_messages_filter("pvi"), 0,
|
||||
get_saved_messages_topic()));
|
||||
} else {
|
||||
search_chat_id_ = 0;
|
||||
}
|
||||
@ -945,6 +946,10 @@ class CliClient final : public Actor {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
td_api::object_ptr<td_api::SavedMessagesTopic> get_saved_messages_topic() const {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
td_api::object_ptr<td_api::linkPreviewOptions> get_link_preview_options() const {
|
||||
if (!link_preview_is_disabled_ && link_preview_url_.empty() && !link_preview_force_small_media_ &&
|
||||
!link_preview_force_large_media_ && !link_preview_show_above_text_) {
|
||||
@ -2835,12 +2840,13 @@ class CliClient final : public Actor {
|
||||
ChatId chat_id;
|
||||
string filter;
|
||||
get_args(args, chat_id, filter);
|
||||
send_request(td_api::make_object<td_api::searchChatMessages>(
|
||||
chat_id, "", nullptr, 0, 0, 100, as_search_messages_filter(filter), message_thread_id_));
|
||||
send_request(td_api::make_object<td_api::searchChatMessages>(chat_id, "", nullptr, 0, 0, 100,
|
||||
as_search_messages_filter(filter),
|
||||
message_thread_id_, get_saved_messages_topic()));
|
||||
} else if (op == "spvf") {
|
||||
search_chat_id_ = as_chat_id(args);
|
||||
send_request(td_api::make_object<td_api::searchChatMessages>(search_chat_id_, "", nullptr, 0, 0, 100,
|
||||
as_search_messages_filter("pvi"), 0));
|
||||
send_request(td_api::make_object<td_api::searchChatMessages>(
|
||||
search_chat_id_, "", nullptr, 0, 0, 100, as_search_messages_filter("pvi"), 0, get_saved_messages_topic()));
|
||||
} else if (op == "Search" || op == "SearchA" || op == "SearchM") {
|
||||
string query;
|
||||
string limit;
|
||||
@ -2861,13 +2867,14 @@ class CliClient final : public Actor {
|
||||
SearchQuery query;
|
||||
get_args(args, chat_id, query);
|
||||
send_request(td_api::make_object<td_api::searchChatMessages>(chat_id, query.query, nullptr, 0, 0, query.limit,
|
||||
nullptr, 0));
|
||||
nullptr, 0, get_saved_messages_topic()));
|
||||
} else if (op == "SMME") {
|
||||
ChatId chat_id;
|
||||
string limit;
|
||||
get_args(args, chat_id, limit);
|
||||
send_request(td_api::make_object<td_api::searchChatMessages>(
|
||||
chat_id, "", td_api::make_object<td_api::messageSenderUser>(my_id_), 0, 0, as_limit(limit), nullptr, 0));
|
||||
chat_id, "", td_api::make_object<td_api::messageSenderUser>(my_id_), 0, 0, as_limit(limit), nullptr, 0,
|
||||
get_saved_messages_topic()));
|
||||
} else if (op == "SMU" || op == "SMC") {
|
||||
ChatId chat_id;
|
||||
string sender_id;
|
||||
@ -2875,7 +2882,8 @@ class CliClient final : public Actor {
|
||||
string limit;
|
||||
get_args(args, chat_id, sender_id, from_message_id, limit);
|
||||
send_request(td_api::make_object<td_api::searchChatMessages>(chat_id, "", as_message_sender(sender_id),
|
||||
from_message_id, 0, as_limit(limit), nullptr, 0));
|
||||
from_message_id, 0, as_limit(limit), nullptr, 0,
|
||||
get_saved_messages_topic()));
|
||||
} else if (op == "SM") {
|
||||
ChatId chat_id;
|
||||
string filter;
|
||||
@ -2883,8 +2891,9 @@ class CliClient final : public Actor {
|
||||
MessageId offset_message_id;
|
||||
int32 offset;
|
||||
get_args(args, chat_id, filter, limit, offset_message_id, offset);
|
||||
send_request(td_api::make_object<td_api::searchChatMessages>(
|
||||
chat_id, "", nullptr, offset_message_id, offset, as_limit(limit), as_search_messages_filter(filter), 0));
|
||||
send_request(td_api::make_object<td_api::searchChatMessages>(chat_id, "", nullptr, offset_message_id, offset,
|
||||
as_limit(limit), as_search_messages_filter(filter),
|
||||
0, get_saved_messages_topic()));
|
||||
} else if (op == "SC") {
|
||||
string limit;
|
||||
string offset;
|
||||
@ -2916,7 +2925,8 @@ class CliClient final : public Actor {
|
||||
SearchQuery query;
|
||||
get_args(args, chat_id, offset_message_id, query);
|
||||
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()));
|
||||
} else if (op == "gcmbd") {
|
||||
ChatId chat_id;
|
||||
int32 date;
|
||||
|
Loading…
Reference in New Issue
Block a user