Allow to pass chat as MessageSender in searchChatMessages.
GitOrigin-RevId: 7b39f616b1677c03dab2bbe48311ba188ec9344b
This commit is contained in:
parent
e32e1c66e7
commit
b07d9634d6
@ -3657,13 +3657,13 @@ deleteChatHistory chat_id:int53 remove_from_chat_list:Bool revoke:Bool = Ok;
|
|||||||
//-(searchSecretMessages should be used instead), or without an enabled message database. For optimal performance the number of returned messages is chosen by the library
|
//-(searchSecretMessages should be used instead), or without an enabled message database. For optimal performance the number of returned messages is chosen by the library
|
||||||
//@chat_id Identifier of the chat in which to search messages
|
//@chat_id Identifier of the chat in which to search messages
|
||||||
//@query Query to search for
|
//@query Query to search for
|
||||||
//@sender_user_id If not 0, only messages sent by the specified user will be returned. Not supported in secret chats
|
//@sender If not null, only messages sent by the specified sender will be returned. 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 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. Fewer messages may be returned than specified by the limit, even if the end of the message history has not been reached
|
//@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. Fewer messages may be returned than specified by the limit, even if the end of the message history has not been reached
|
||||||
//@filter Filter for message content in the search results
|
//@filter Filter for message content in the search results
|
||||||
//@message_thread_id If not 0, only messages in the specified thread will be returned; supergroups only
|
//@message_thread_id If not 0, only messages in the specified thread will be returned; supergroups only
|
||||||
searchChatMessages chat_id:int53 query:string sender_user_id:int32 from_message_id:int53 offset:int32 limit:int32 filter:SearchMessagesFilter message_thread_id:int53 = Messages;
|
searchChatMessages chat_id:int53 query:string sender:MessageSender from_message_id:int53 offset:int32 limit:int32 filter:SearchMessagesFilter message_thread_id:int53 = Messages;
|
||||||
|
|
||||||
//@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)).
|
//@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 the library
|
//-For optimal performance the number of returned messages is chosen by the library
|
||||||
|
Binary file not shown.
@ -1286,7 +1286,7 @@ contacts.blockFromReplies#29a8962c flags:# delete_message:flags.0?true delete_hi
|
|||||||
messages.getMessages#63c66506 id:Vector<InputMessage> = messages.Messages;
|
messages.getMessages#63c66506 id:Vector<InputMessage> = messages.Messages;
|
||||||
messages.getDialogs#a0ee3b73 flags:# exclude_pinned:flags.0?true folder_id:flags.1?int offset_date:int offset_id:int offset_peer:InputPeer limit:int hash:int = messages.Dialogs;
|
messages.getDialogs#a0ee3b73 flags:# exclude_pinned:flags.0?true folder_id:flags.1?int offset_date:int offset_id:int offset_peer:InputPeer limit:int hash:int = messages.Dialogs;
|
||||||
messages.getHistory#dcbb8260 peer:InputPeer offset_id:int offset_date:int add_offset:int limit:int max_id:int min_id:int hash:int = messages.Messages;
|
messages.getHistory#dcbb8260 peer:InputPeer offset_id:int offset_date:int add_offset:int limit:int max_id:int min_id:int hash:int = messages.Messages;
|
||||||
messages.search#4e17810b flags:# peer:InputPeer q:string from_id:flags.0?InputUser top_msg_id:flags.1?int filter:MessagesFilter min_date:int max_date:int offset_id:int add_offset:int limit:int max_id:int min_id:int hash:int = messages.Messages;
|
messages.search#c352eec flags:# peer:InputPeer q:string from_id:flags.0?InputPeer top_msg_id:flags.1?int filter:MessagesFilter min_date:int max_date:int offset_id:int add_offset:int limit:int max_id:int min_id:int hash:int = messages.Messages;
|
||||||
messages.readHistory#e306d3a peer:InputPeer max_id:int = messages.AffectedMessages;
|
messages.readHistory#e306d3a peer:InputPeer max_id:int = messages.AffectedMessages;
|
||||||
messages.deleteHistory#1c015b09 flags:# just_clear:flags.0?true revoke:flags.1?true peer:InputPeer max_id:int = messages.AffectedHistory;
|
messages.deleteHistory#1c015b09 flags:# just_clear:flags.0?true revoke:flags.1?true peer:InputPeer max_id:int = messages.AffectedHistory;
|
||||||
messages.deleteMessages#e58e95d2 flags:# revoke:flags.0?true id:Vector<int> = messages.AffectedMessages;
|
messages.deleteMessages#e58e95d2 flags:# revoke:flags.0?true id:Vector<int> = messages.AffectedMessages;
|
||||||
|
Binary file not shown.
@ -1821,7 +1821,7 @@ class SearchMessagesQuery : public Td::ResultHandler {
|
|||||||
Promise<Unit> promise_;
|
Promise<Unit> promise_;
|
||||||
DialogId dialog_id_;
|
DialogId dialog_id_;
|
||||||
string query_;
|
string query_;
|
||||||
UserId sender_user_id_;
|
DialogId sender_dialog_id_;
|
||||||
MessageId from_message_id_;
|
MessageId from_message_id_;
|
||||||
int32 offset_;
|
int32 offset_;
|
||||||
int32 limit_;
|
int32 limit_;
|
||||||
@ -1834,9 +1834,8 @@ class SearchMessagesQuery : public Td::ResultHandler {
|
|||||||
explicit SearchMessagesQuery(Promise<Unit> &&promise) : promise_(std::move(promise)) {
|
explicit SearchMessagesQuery(Promise<Unit> &&promise) : promise_(std::move(promise)) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void send(DialogId dialog_id, const string &query, UserId sender_user_id,
|
void send(DialogId dialog_id, const string &query, DialogId sender_dialog_id, MessageId from_message_id, int32 offset,
|
||||||
telegram_api::object_ptr<telegram_api::InputUser> &&sender_input_user, MessageId from_message_id,
|
int32 limit, MessageSearchFilter filter, MessageId top_thread_message_id, int64 random_id) {
|
||||||
int32 offset, int32 limit, MessageSearchFilter filter, MessageId top_thread_message_id, int64 random_id) {
|
|
||||||
auto input_peer = dialog_id.is_valid() ? td->messages_manager_->get_input_peer(dialog_id, AccessRights::Read)
|
auto input_peer = dialog_id.is_valid() ? td->messages_manager_->get_input_peer(dialog_id, AccessRights::Read)
|
||||||
: make_tl_object<telegram_api::inputPeerEmpty>();
|
: make_tl_object<telegram_api::inputPeerEmpty>();
|
||||||
if (input_peer == nullptr) {
|
if (input_peer == nullptr) {
|
||||||
@ -1846,7 +1845,7 @@ class SearchMessagesQuery : public Td::ResultHandler {
|
|||||||
|
|
||||||
dialog_id_ = dialog_id;
|
dialog_id_ = dialog_id;
|
||||||
query_ = query;
|
query_ = query;
|
||||||
sender_user_id_ = sender_user_id;
|
sender_dialog_id_ = sender_dialog_id;
|
||||||
from_message_id_ = from_message_id;
|
from_message_id_ = from_message_id;
|
||||||
offset_ = offset;
|
offset_ = offset;
|
||||||
limit_ = limit;
|
limit_ = limit;
|
||||||
@ -1858,7 +1857,8 @@ class SearchMessagesQuery : public Td::ResultHandler {
|
|||||||
send_query(G()->net_query_creator().create(
|
send_query(G()->net_query_creator().create(
|
||||||
telegram_api::messages_getUnreadMentions(std::move(input_peer), from_message_id.get_server_message_id().get(),
|
telegram_api::messages_getUnreadMentions(std::move(input_peer), from_message_id.get_server_message_id().get(),
|
||||||
offset, limit, std::numeric_limits<int32>::max(), 0)));
|
offset, limit, std::numeric_limits<int32>::max(), 0)));
|
||||||
} else if (top_thread_message_id.is_valid() && !sender_user_id.is_valid() && filter == MessageSearchFilter::Empty) {
|
} else if (top_thread_message_id.is_valid() && !sender_dialog_id.is_valid() &&
|
||||||
|
filter == MessageSearchFilter::Empty) {
|
||||||
handle_errors_ = dialog_id.get_type() != DialogType::Channel ||
|
handle_errors_ = dialog_id.get_type() != DialogType::Channel ||
|
||||||
td->contacts_manager_->get_channel_type(dialog_id.get_channel_id()) != ChannelType::Broadcast;
|
td->contacts_manager_->get_channel_type(dialog_id.get_channel_id()) != ChannelType::Broadcast;
|
||||||
send_query(G()->net_query_creator().create(telegram_api::messages_getReplies(
|
send_query(G()->net_query_creator().create(telegram_api::messages_getReplies(
|
||||||
@ -1866,15 +1866,18 @@ class SearchMessagesQuery : public Td::ResultHandler {
|
|||||||
from_message_id.get_server_message_id().get(), 0, offset, limit, std::numeric_limits<int32>::max(), 0, 0)));
|
from_message_id.get_server_message_id().get(), 0, offset, limit, std::numeric_limits<int32>::max(), 0, 0)));
|
||||||
} else {
|
} else {
|
||||||
int32 flags = 0;
|
int32 flags = 0;
|
||||||
if (sender_input_user != nullptr) {
|
tl_object_ptr<telegram_api::InputPeer> sender_input_peer;
|
||||||
|
if (sender_dialog_id.is_valid()) {
|
||||||
flags |= telegram_api::messages_search::FROM_ID_MASK;
|
flags |= telegram_api::messages_search::FROM_ID_MASK;
|
||||||
|
sender_input_peer = td->messages_manager_->get_input_peer(sender_dialog_id, AccessRights::Read);
|
||||||
|
CHECK(sender_input_peer != nullptr);
|
||||||
}
|
}
|
||||||
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_user),
|
flags, std::move(input_peer), query, std::move(sender_input_peer),
|
||||||
top_thread_message_id.get_server_message_id().get(), get_input_messages_filter(filter), 0,
|
top_thread_message_id.get_server_message_id().get(), get_input_messages_filter(filter), 0,
|
||||||
std::numeric_limits<int32>::max(), from_message_id.get_server_message_id().get(), offset, limit,
|
std::numeric_limits<int32>::max(), from_message_id.get_server_message_id().get(), offset, limit,
|
||||||
std::numeric_limits<int32>::max(), 0, 0)));
|
std::numeric_limits<int32>::max(), 0, 0)));
|
||||||
@ -1894,7 +1897,7 @@ class SearchMessagesQuery : public Td::ResultHandler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
auto info = td->messages_manager_->on_get_messages(result_ptr.move_as_ok(), "SearchMessagesQuery");
|
auto info = td->messages_manager_->on_get_messages(result_ptr.move_as_ok(), "SearchMessagesQuery");
|
||||||
td->messages_manager_->on_get_dialog_messages_search_result(dialog_id_, query_, sender_user_id_, from_message_id_,
|
td->messages_manager_->on_get_dialog_messages_search_result(dialog_id_, query_, sender_dialog_id_, from_message_id_,
|
||||||
offset_, limit_, filter_, top_thread_message_id_,
|
offset_, limit_, filter_, top_thread_message_id_,
|
||||||
random_id_, info.total_count, std::move(info.messages));
|
random_id_, info.total_count, std::move(info.messages));
|
||||||
|
|
||||||
@ -9061,7 +9064,7 @@ void MessagesManager::on_failed_public_dialogs_search(const string &query, Statu
|
|||||||
}
|
}
|
||||||
|
|
||||||
void MessagesManager::on_get_dialog_messages_search_result(DialogId dialog_id, const string &query,
|
void MessagesManager::on_get_dialog_messages_search_result(DialogId dialog_id, const string &query,
|
||||||
UserId sender_user_id, MessageId from_message_id,
|
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,
|
MessageId top_thread_message_id, int64 random_id,
|
||||||
int32 total_count,
|
int32 total_count,
|
||||||
@ -9069,7 +9072,7 @@ void MessagesManager::on_get_dialog_messages_search_result(DialogId dialog_id, c
|
|||||||
LOG(INFO) << "Receive " << messages.size() << " found messages in " << dialog_id;
|
LOG(INFO) << "Receive " << messages.size() << " found messages in " << dialog_id;
|
||||||
if (!dialog_id.is_valid()) {
|
if (!dialog_id.is_valid()) {
|
||||||
CHECK(query.empty());
|
CHECK(query.empty());
|
||||||
CHECK(!sender_user_id.is_valid());
|
CHECK(!sender_dialog_id.is_valid());
|
||||||
CHECK(!top_thread_message_id.is_valid());
|
CHECK(!top_thread_message_id.is_valid());
|
||||||
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());
|
||||||
@ -9190,7 +9193,7 @@ void MessagesManager::on_get_dialog_messages_search_result(DialogId dialog_id, c
|
|||||||
<< " messages";
|
<< " messages";
|
||||||
total_count = static_cast<int32>(result.size());
|
total_count = static_cast<int32>(result.size());
|
||||||
}
|
}
|
||||||
if (query.empty() && !sender_user_id.is_valid() && filter != MessageSearchFilter::Empty &&
|
if (query.empty() && !sender_dialog_id.is_valid() && filter != MessageSearchFilter::Empty &&
|
||||||
!top_thread_message_id.is_valid() && G()->parameters().use_message_db) {
|
!top_thread_message_id.is_valid() && G()->parameters().use_message_db) {
|
||||||
bool update_dialog = false;
|
bool update_dialog = false;
|
||||||
|
|
||||||
@ -16854,7 +16857,7 @@ Result<unique_ptr<DialogFilter>> MessagesManager::create_dialog_filter(DialogFil
|
|||||||
}
|
}
|
||||||
dialog_filter->emoji = DialogFilter::get_emoji_by_icon_name(filter->icon_name_);
|
dialog_filter->emoji = DialogFilter::get_emoji_by_icon_name(filter->icon_name_);
|
||||||
if (dialog_filter->emoji.empty() && !filter->icon_name_.empty()) {
|
if (dialog_filter->emoji.empty() && !filter->icon_name_.empty()) {
|
||||||
return Status::Error(400, "Wrong icon name specified");
|
return Status::Error(400, "Invalid icon name specified");
|
||||||
}
|
}
|
||||||
dialog_filter->exclude_muted = filter->exclude_muted_;
|
dialog_filter->exclude_muted = filter->exclude_muted_;
|
||||||
dialog_filter->exclude_read = filter->exclude_read_;
|
dialog_filter->exclude_read = filter->exclude_read_;
|
||||||
@ -19858,15 +19861,15 @@ std::pair<DialogId, vector<MessageId>> MessagesManager::get_message_thread_histo
|
|||||||
found_dialog_messages_[random_id]; // reserve place for result
|
found_dialog_messages_[random_id]; // reserve place for result
|
||||||
|
|
||||||
td_->create_handler<SearchMessagesQuery>(std::move(promise))
|
td_->create_handler<SearchMessagesQuery>(std::move(promise))
|
||||||
->send(dialog_id, string(), UserId(), nullptr, from_message_id.get_next_server_message_id(), offset, limit,
|
->send(dialog_id, string(), DialogId(), from_message_id.get_next_server_message_id(), offset, limit,
|
||||||
MessageSearchFilter::Empty, message_id, random_id);
|
MessageSearchFilter::Empty, message_id, random_id);
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
std::pair<int32, vector<MessageId>> MessagesManager::search_dialog_messages(
|
std::pair<int32, vector<MessageId>> MessagesManager::search_dialog_messages(
|
||||||
DialogId dialog_id, const string &query, UserId sender_user_id, MessageId from_message_id, int32 offset,
|
DialogId dialog_id, const string &query, const td_api::object_ptr<td_api::MessageSender> &sender,
|
||||||
int32 limit, MessageSearchFilter filter, MessageId top_thread_message_id, int64 &random_id, bool use_db,
|
MessageId from_message_id, int32 offset, int32 limit, MessageSearchFilter filter, MessageId top_thread_message_id,
|
||||||
Promise<Unit> &&promise) {
|
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);
|
||||||
@ -19879,9 +19882,9 @@ std::pair<int32, vector<MessageId>> MessagesManager::search_dialog_messages(
|
|||||||
}
|
}
|
||||||
random_id = 0;
|
random_id = 0;
|
||||||
}
|
}
|
||||||
LOG(INFO) << "Search messages with query \"" << query << "\" in " << dialog_id << " sent by " << sender_user_id
|
LOG(INFO) << "Search messages with query \"" << query << "\" in " << dialog_id << " sent by "
|
||||||
<< " in thread of " << top_thread_message_id << " filtered by " << filter << " from " << from_message_id
|
<< oneline(to_string(sender)) << " in thread of " << top_thread_message_id << " filtered by " << filter
|
||||||
<< " with offset " << offset << " and limit " << limit;
|
<< " from " << from_message_id << " with offset " << offset << " and limit " << limit;
|
||||||
|
|
||||||
std::pair<int32, vector<MessageId>> result;
|
std::pair<int32, vector<MessageId>> result;
|
||||||
if (limit <= 0) {
|
if (limit <= 0) {
|
||||||
@ -19916,18 +19919,49 @@ std::pair<int32, vector<MessageId>> MessagesManager::search_dialog_messages(
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (filter == MessageSearchFilter::FailedToSend && sender_user_id.is_valid()) {
|
DialogId sender_dialog_id;
|
||||||
if (sender_user_id != td_->contacts_manager_->get_my_id()) {
|
if (sender != nullptr) {
|
||||||
|
switch (sender->get_id()) {
|
||||||
|
case td_api::messageSenderUser::ID:
|
||||||
|
sender_dialog_id = DialogId(UserId(static_cast<const td_api::messageSenderUser *>(sender.get())->user_id_));
|
||||||
|
break;
|
||||||
|
case td_api::messageSenderChat::ID:
|
||||||
|
sender_dialog_id = DialogId(static_cast<const td_api::messageSenderChat *>(sender.get())->chat_id_);
|
||||||
|
switch (sender_dialog_id.get_type()) {
|
||||||
|
case DialogType::User:
|
||||||
|
case DialogType::Chat:
|
||||||
|
case DialogType::Channel:
|
||||||
|
// ok
|
||||||
|
break;
|
||||||
|
case DialogType::SecretChat:
|
||||||
|
promise.set_value(Unit());
|
||||||
|
return result;
|
||||||
|
case DialogType::None:
|
||||||
|
promise.set_error(Status::Error(6, "Invalid sender chat identifier specified"));
|
||||||
|
return result;
|
||||||
|
default:
|
||||||
|
UNREACHABLE();
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
UNREACHABLE();
|
||||||
|
}
|
||||||
|
if (!have_input_peer(sender_dialog_id, AccessRights::Read)) {
|
||||||
|
promise.set_error(Status::Error(6, "Invalid message sender specified"));
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (sender_dialog_id == dialog_id && is_broadcast_channel(dialog_id)) {
|
||||||
|
sender_dialog_id = DialogId();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (filter == MessageSearchFilter::FailedToSend && sender_dialog_id.is_valid()) {
|
||||||
|
if (sender_dialog_id != get_my_dialog_id()) {
|
||||||
promise.set_value(Unit());
|
promise.set_value(Unit());
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
sender_user_id = UserId();
|
sender_dialog_id = DialogId();
|
||||||
}
|
|
||||||
|
|
||||||
auto input_user = td_->contacts_manager_->get_input_user(sender_user_id);
|
|
||||||
if (sender_user_id.is_valid() && input_user == nullptr) {
|
|
||||||
promise.set_error(Status::Error(6, "Wrong sender user identifier specified"));
|
|
||||||
return result;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (top_thread_message_id != MessageId()) {
|
if (top_thread_message_id != MessageId()) {
|
||||||
@ -19951,8 +19985,8 @@ std::pair<int32, vector<MessageId>> MessagesManager::search_dialog_messages(
|
|||||||
promise.set_error(Status::Error(6, "Non-empty query is unsupported with the specified filter"));
|
promise.set_error(Status::Error(6, "Non-empty query is unsupported with the specified filter"));
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
if (input_user != nullptr) {
|
if (sender_dialog_id.is_valid()) {
|
||||||
promise.set_error(Status::Error(6, "Filtering by sender user is unsupported with the specified filter"));
|
promise.set_error(Status::Error(6, "Filtering by sender is unsupported with the specified filter"));
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
if (top_thread_message_id != MessageId()) {
|
if (top_thread_message_id != MessageId()) {
|
||||||
@ -19963,7 +19997,8 @@ std::pair<int32, vector<MessageId>> MessagesManager::search_dialog_messages(
|
|||||||
|
|
||||||
// Trying to use database
|
// Trying to use database
|
||||||
if (use_db && query.empty() && G()->parameters().use_message_db && filter != MessageSearchFilter::Empty &&
|
if (use_db && query.empty() && G()->parameters().use_message_db && filter != MessageSearchFilter::Empty &&
|
||||||
input_user == nullptr && top_thread_message_id == MessageId()) { // TODO support filter by users in the database
|
!sender_dialog_id.is_valid() &&
|
||||||
|
top_thread_message_id == MessageId()) { // TODO support filter by users in the database
|
||||||
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;
|
||||||
@ -19998,8 +20033,8 @@ std::pair<int32, vector<MessageId>> MessagesManager::search_dialog_messages(
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
LOG(DEBUG) << "Search messages on server in " << dialog_id << " with query \"" << query << "\" from user "
|
LOG(DEBUG) << "Search messages on server in " << dialog_id << " with query \"" << query << "\" from "
|
||||||
<< sender_user_id << " in thread of " << top_thread_message_id << " from " << from_message_id
|
<< sender_dialog_id << " in thread of " << top_thread_message_id << " from " << from_message_id
|
||||||
<< " and with limit " << limit;
|
<< " and with limit " << limit;
|
||||||
|
|
||||||
switch (dialog_id.get_type()) {
|
switch (dialog_id.get_type()) {
|
||||||
@ -20008,8 +20043,8 @@ std::pair<int32, vector<MessageId>> MessagesManager::search_dialog_messages(
|
|||||||
case DialogType::Chat:
|
case DialogType::Chat:
|
||||||
case DialogType::Channel:
|
case DialogType::Channel:
|
||||||
td_->create_handler<SearchMessagesQuery>(std::move(promise))
|
td_->create_handler<SearchMessagesQuery>(std::move(promise))
|
||||||
->send(dialog_id, query, sender_user_id, std::move(input_user), from_message_id, offset, limit, filter,
|
->send(dialog_id, query, sender_dialog_id, from_message_id, offset, limit, filter, top_thread_message_id,
|
||||||
top_thread_message_id, random_id);
|
random_id);
|
||||||
break;
|
break;
|
||||||
case DialogType::SecretChat:
|
case DialogType::SecretChat:
|
||||||
if (filter == MessageSearchFilter::UnreadMention) {
|
if (filter == MessageSearchFilter::UnreadMention) {
|
||||||
@ -20098,7 +20133,7 @@ std::pair<int32, vector<FullMessageId>> MessagesManager::search_call_messages(Me
|
|||||||
|
|
||||||
LOG(DEBUG) << "Search call messages on server from " << from_message_id << " and with limit " << limit;
|
LOG(DEBUG) << "Search call messages on server from " << from_message_id << " and with limit " << limit;
|
||||||
td_->create_handler<SearchMessagesQuery>(std::move(promise))
|
td_->create_handler<SearchMessagesQuery>(std::move(promise))
|
||||||
->send(DialogId(), "", UserId(), nullptr, from_message_id, 0, limit, filter, MessageId(), random_id);
|
->send(DialogId(), "", DialogId(), from_message_id, 0, limit, filter, MessageId(), random_id);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -20609,7 +20644,7 @@ MessagesManager::FoundMessages MessagesManager::offline_search_messages(DialogId
|
|||||||
if (!offset.empty()) {
|
if (!offset.empty()) {
|
||||||
auto r_from_search_id = to_integer_safe<int64>(offset);
|
auto r_from_search_id = to_integer_safe<int64>(offset);
|
||||||
if (r_from_search_id.is_error()) {
|
if (r_from_search_id.is_error()) {
|
||||||
promise.set_error(Status::Error(400, "Wrong offset specified"));
|
promise.set_error(Status::Error(400, "Invalid offset specified"));
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
fts_query.from_search_id = r_from_search_id.ok();
|
fts_query.from_search_id = r_from_search_id.ok();
|
||||||
@ -20974,7 +21009,7 @@ int32 MessagesManager::get_dialog_message_count(DialogId dialog_id, MessageSearc
|
|||||||
case DialogType::Chat:
|
case DialogType::Chat:
|
||||||
case DialogType::Channel:
|
case DialogType::Channel:
|
||||||
td_->create_handler<SearchMessagesQuery>(std::move(promise))
|
td_->create_handler<SearchMessagesQuery>(std::move(promise))
|
||||||
->send(dialog_id, "", UserId(), nullptr, MessageId(), 0, 1, filter, MessageId(), random_id);
|
->send(dialog_id, "", DialogId(), MessageId(), 0, 1, filter, MessageId(), random_id);
|
||||||
break;
|
break;
|
||||||
case DialogType::None:
|
case DialogType::None:
|
||||||
case DialogType::SecretChat:
|
case DialogType::SecretChat:
|
||||||
@ -21561,14 +21596,14 @@ MessagesManager::FoundMessages MessagesManager::get_message_public_forwards(Full
|
|||||||
if (!offset.empty()) {
|
if (!offset.empty()) {
|
||||||
auto parts = full_split(offset, ',');
|
auto parts = full_split(offset, ',');
|
||||||
if (parts.size() != 3) {
|
if (parts.size() != 3) {
|
||||||
promise.set_error(Status::Error(3, "Wrong offset specified"));
|
promise.set_error(Status::Error(3, "Invalid offset specified"));
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
auto r_offset_date = to_integer_safe<int32>(parts[0]);
|
auto r_offset_date = to_integer_safe<int32>(parts[0]);
|
||||||
auto r_offset_dialog_id = to_integer_safe<int64>(parts[1]);
|
auto r_offset_dialog_id = to_integer_safe<int64>(parts[1]);
|
||||||
auto r_offset_message_id = to_integer_safe<int32>(parts[2]);
|
auto r_offset_message_id = to_integer_safe<int32>(parts[2]);
|
||||||
if (r_offset_date.is_error() || r_offset_dialog_id.is_error() || r_offset_message_id.is_error()) {
|
if (r_offset_date.is_error() || r_offset_dialog_id.is_error() || r_offset_message_id.is_error()) {
|
||||||
promise.set_error(Status::Error(3, "Wrong offset specified"));
|
promise.set_error(Status::Error(3, "Invalid offset specified"));
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -22481,7 +22516,7 @@ Result<InputMessageContent> MessagesManager::process_input_message_content(
|
|||||||
TRY_RESULT(content, get_input_message_content(dialog_id, std::move(input_message_content), td_));
|
TRY_RESULT(content, get_input_message_content(dialog_id, std::move(input_message_content), td_));
|
||||||
|
|
||||||
if (content.ttl < 0 || content.ttl > MAX_PRIVATE_MESSAGE_TTL) {
|
if (content.ttl < 0 || content.ttl > MAX_PRIVATE_MESSAGE_TTL) {
|
||||||
return Status::Error(10, "Wrong message TTL specified");
|
return Status::Error(10, "Invalid message TTL specified");
|
||||||
}
|
}
|
||||||
if (content.ttl > 0 && dialog_id.get_type() != DialogType::User) {
|
if (content.ttl > 0 && dialog_id.get_type() != DialogType::User) {
|
||||||
return Status::Error(10, "Message TTL can be specified only in private chats");
|
return Status::Error(10, "Message TTL can be specified only in private chats");
|
||||||
@ -22622,7 +22657,7 @@ Result<vector<MessageId>> MessagesManager::send_message_group(
|
|||||||
TRY_RESULT(message_content, process_input_message_content(dialog_id, std::move(input_message_content)));
|
TRY_RESULT(message_content, process_input_message_content(dialog_id, std::move(input_message_content)));
|
||||||
TRY_STATUS(can_use_message_send_options(message_send_options, message_content));
|
TRY_STATUS(can_use_message_send_options(message_send_options, message_content));
|
||||||
if (!is_allowed_media_group_content(message_content.content->get_type())) {
|
if (!is_allowed_media_group_content(message_content.content->get_type())) {
|
||||||
return Status::Error(5, "Wrong message content type");
|
return Status::Error(5, "Invalid message content type");
|
||||||
}
|
}
|
||||||
|
|
||||||
message_contents.emplace_back(std::move(message_content.content), message_content.ttl);
|
message_contents.emplace_back(std::move(message_content.content), message_content.ttl);
|
||||||
@ -22821,7 +22856,7 @@ void MessagesManager::on_message_media_uploaded(DialogId dialog_id, const Messag
|
|||||||
default:
|
default:
|
||||||
LOG(ERROR) << "Have wrong input media " << to_string(input_media);
|
LOG(ERROR) << "Have wrong input media " << to_string(input_media);
|
||||||
send_closure_later(actor_id(this), &MessagesManager::on_upload_message_media_finished, m->media_album_id,
|
send_closure_later(actor_id(this), &MessagesManager::on_upload_message_media_finished, m->media_album_id,
|
||||||
dialog_id, message_id, Status::Error(400, "Wrong input media"));
|
dialog_id, message_id, Status::Error(400, "Invalid input media"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -22845,7 +22880,7 @@ void MessagesManager::on_secret_message_media_uploaded(DialogId dialog_id, const
|
|||||||
default:
|
default:
|
||||||
LOG(ERROR) << "Have wrong secret input media " << to_string(secret_input_media->input_file_);
|
LOG(ERROR) << "Have wrong secret input media " << to_string(secret_input_media->input_file_);
|
||||||
return send_closure_later(actor_id(this), &MessagesManager::on_upload_message_media_finished, m->media_album_id,
|
return send_closure_later(actor_id(this), &MessagesManager::on_upload_message_media_finished, m->media_album_id,
|
||||||
dialog_id, m->message_id, Status::Error(400, "Wrong input media"));
|
dialog_id, m->message_id, Status::Error(400, "Invalid input media"));
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
// TODO use file_id, thumbnail_file_id, was_uploaded, was_thumbnail_uploaded,
|
// TODO use file_id, thumbnail_file_id, was_uploaded, was_thumbnail_uploaded,
|
||||||
@ -23855,7 +23890,7 @@ void MessagesManager::edit_message_live_location(FullMessageId full_message_id,
|
|||||||
|
|
||||||
Location location(input_location);
|
Location location(input_location);
|
||||||
if (location.empty() && input_location != nullptr) {
|
if (location.empty() && input_location != nullptr) {
|
||||||
return promise.set_error(Status::Error(400, "Wrong location specified"));
|
return promise.set_error(Status::Error(400, "Invalid location specified"));
|
||||||
}
|
}
|
||||||
|
|
||||||
auto r_new_reply_markup = get_reply_markup(std::move(reply_markup), td_->auth_manager_->is_bot(), true, false,
|
auto r_new_reply_markup = get_reply_markup(std::move(reply_markup), td_->auth_manager_->is_bot(), true, false,
|
||||||
@ -24158,7 +24193,7 @@ void MessagesManager::edit_inline_message_text(const string &inline_message_id,
|
|||||||
|
|
||||||
auto input_bot_inline_message_id = td_->inline_queries_manager_->get_input_bot_inline_message_id(inline_message_id);
|
auto input_bot_inline_message_id = td_->inline_queries_manager_->get_input_bot_inline_message_id(inline_message_id);
|
||||||
if (input_bot_inline_message_id == nullptr) {
|
if (input_bot_inline_message_id == nullptr) {
|
||||||
return promise.set_error(Status::Error(400, "Wrong inline message identifier specified"));
|
return promise.set_error(Status::Error(400, "Invalid inline message identifier specified"));
|
||||||
}
|
}
|
||||||
|
|
||||||
int32 flags = 0;
|
int32 flags = 0;
|
||||||
@ -24187,12 +24222,12 @@ void MessagesManager::edit_inline_message_live_location(const string &inline_mes
|
|||||||
|
|
||||||
auto input_bot_inline_message_id = td_->inline_queries_manager_->get_input_bot_inline_message_id(inline_message_id);
|
auto input_bot_inline_message_id = td_->inline_queries_manager_->get_input_bot_inline_message_id(inline_message_id);
|
||||||
if (input_bot_inline_message_id == nullptr) {
|
if (input_bot_inline_message_id == nullptr) {
|
||||||
return promise.set_error(Status::Error(400, "Wrong inline message identifier specified"));
|
return promise.set_error(Status::Error(400, "Invalid inline message identifier specified"));
|
||||||
}
|
}
|
||||||
|
|
||||||
Location location(input_location);
|
Location location(input_location);
|
||||||
if (location.empty() && input_location != nullptr) {
|
if (location.empty() && input_location != nullptr) {
|
||||||
return promise.set_error(Status::Error(400, "Wrong location specified"));
|
return promise.set_error(Status::Error(400, "Invalid location specified"));
|
||||||
}
|
}
|
||||||
|
|
||||||
int32 flags = 0;
|
int32 flags = 0;
|
||||||
@ -24243,12 +24278,12 @@ void MessagesManager::edit_inline_message_media(const string &inline_message_id,
|
|||||||
|
|
||||||
auto input_bot_inline_message_id = td_->inline_queries_manager_->get_input_bot_inline_message_id(inline_message_id);
|
auto input_bot_inline_message_id = td_->inline_queries_manager_->get_input_bot_inline_message_id(inline_message_id);
|
||||||
if (input_bot_inline_message_id == nullptr) {
|
if (input_bot_inline_message_id == nullptr) {
|
||||||
return promise.set_error(Status::Error(400, "Wrong inline message identifier specified"));
|
return promise.set_error(Status::Error(400, "Invalid inline message identifier specified"));
|
||||||
}
|
}
|
||||||
|
|
||||||
auto input_media = get_input_media(content.content.get(), td_, 0, true);
|
auto input_media = get_input_media(content.content.get(), td_, 0, true);
|
||||||
if (input_media == nullptr) {
|
if (input_media == nullptr) {
|
||||||
return promise.set_error(Status::Error(400, "Wrong message content specified"));
|
return promise.set_error(Status::Error(400, "Invalid message content specified"));
|
||||||
}
|
}
|
||||||
|
|
||||||
const FormattedText *caption = get_message_content_caption(content.content.get());
|
const FormattedText *caption = get_message_content_caption(content.content.get());
|
||||||
@ -24280,7 +24315,7 @@ void MessagesManager::edit_inline_message_caption(const string &inline_message_i
|
|||||||
|
|
||||||
auto input_bot_inline_message_id = td_->inline_queries_manager_->get_input_bot_inline_message_id(inline_message_id);
|
auto input_bot_inline_message_id = td_->inline_queries_manager_->get_input_bot_inline_message_id(inline_message_id);
|
||||||
if (input_bot_inline_message_id == nullptr) {
|
if (input_bot_inline_message_id == nullptr) {
|
||||||
return promise.set_error(Status::Error(400, "Wrong inline message identifier specified"));
|
return promise.set_error(Status::Error(400, "Invalid inline message identifier specified"));
|
||||||
}
|
}
|
||||||
|
|
||||||
td_->create_handler<EditInlineMessageQuery>(std::move(promise))
|
td_->create_handler<EditInlineMessageQuery>(std::move(promise))
|
||||||
@ -24303,7 +24338,7 @@ void MessagesManager::edit_inline_message_reply_markup(const string &inline_mess
|
|||||||
|
|
||||||
auto input_bot_inline_message_id = td_->inline_queries_manager_->get_input_bot_inline_message_id(inline_message_id);
|
auto input_bot_inline_message_id = td_->inline_queries_manager_->get_input_bot_inline_message_id(inline_message_id);
|
||||||
if (input_bot_inline_message_id == nullptr) {
|
if (input_bot_inline_message_id == nullptr) {
|
||||||
return promise.set_error(Status::Error(400, "Wrong inline message identifier specified"));
|
return promise.set_error(Status::Error(400, "Invalid inline message identifier specified"));
|
||||||
}
|
}
|
||||||
|
|
||||||
td_->create_handler<EditInlineMessageQuery>(std::move(promise))
|
td_->create_handler<EditInlineMessageQuery>(std::move(promise))
|
||||||
@ -24519,7 +24554,7 @@ void MessagesManager::set_game_score(FullMessageId full_message_id, bool edit_me
|
|||||||
|
|
||||||
auto input_user = td_->contacts_manager_->get_input_user(user_id);
|
auto input_user = td_->contacts_manager_->get_input_user(user_id);
|
||||||
if (input_user == nullptr) {
|
if (input_user == nullptr) {
|
||||||
return promise.set_error(Status::Error(400, "Wrong user identifier specified"));
|
return promise.set_error(Status::Error(400, "Invalid user identifier specified"));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!can_set_game_score(dialog_id, m)) {
|
if (!can_set_game_score(dialog_id, m)) {
|
||||||
@ -24539,7 +24574,7 @@ void MessagesManager::set_inline_game_score(const string &inline_message_id, boo
|
|||||||
|
|
||||||
auto input_bot_inline_message_id = td_->inline_queries_manager_->get_input_bot_inline_message_id(inline_message_id);
|
auto input_bot_inline_message_id = td_->inline_queries_manager_->get_input_bot_inline_message_id(inline_message_id);
|
||||||
if (input_bot_inline_message_id == nullptr) {
|
if (input_bot_inline_message_id == nullptr) {
|
||||||
return promise.set_error(Status::Error(400, "Wrong inline message identifier specified"));
|
return promise.set_error(Status::Error(400, "Invalid inline message identifier specified"));
|
||||||
}
|
}
|
||||||
|
|
||||||
auto input_user = td_->contacts_manager_->get_input_user(user_id);
|
auto input_user = td_->contacts_manager_->get_input_user(user_id);
|
||||||
@ -24606,7 +24641,7 @@ int64 MessagesManager::get_inline_game_high_scores(const string &inline_message_
|
|||||||
|
|
||||||
auto input_bot_inline_message_id = td_->inline_queries_manager_->get_input_bot_inline_message_id(inline_message_id);
|
auto input_bot_inline_message_id = td_->inline_queries_manager_->get_input_bot_inline_message_id(inline_message_id);
|
||||||
if (input_bot_inline_message_id == nullptr) {
|
if (input_bot_inline_message_id == nullptr) {
|
||||||
promise.set_error(Status::Error(400, "Wrong inline message identifier specified"));
|
promise.set_error(Status::Error(400, "Invalid inline message identifier specified"));
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -239,7 +239,7 @@ class MessagesManager : public Actor {
|
|||||||
vector<tl_object_ptr<telegram_api::Peer>> &&peers);
|
vector<tl_object_ptr<telegram_api::Peer>> &&peers);
|
||||||
void on_failed_public_dialogs_search(const string &query, Status &&error);
|
void on_failed_public_dialogs_search(const string &query, Status &&error);
|
||||||
|
|
||||||
void on_get_dialog_messages_search_result(DialogId dialog_id, const string &query, UserId sender_user_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,
|
MessageId from_message_id, int32 offset, int32 limit,
|
||||||
MessageSearchFilter filter, MessageId top_thread_message_id,
|
MessageSearchFilter filter, MessageId top_thread_message_id,
|
||||||
int64 random_id, int32 total_count,
|
int64 random_id, int32 total_count,
|
||||||
@ -709,8 +709,9 @@ class MessagesManager : public Actor {
|
|||||||
Promise<Unit> &&promise);
|
Promise<Unit> &&promise);
|
||||||
|
|
||||||
std::pair<int32, vector<MessageId>> search_dialog_messages(DialogId dialog_id, const string &query,
|
std::pair<int32, vector<MessageId>> search_dialog_messages(DialogId dialog_id, const string &query,
|
||||||
UserId sender_user_id, MessageId from_message_id,
|
const td_api::object_ptr<td_api::MessageSender> &sender,
|
||||||
int32 offset, int32 limit, MessageSearchFilter filter,
|
MessageId from_message_id, int32 offset, int32 limit,
|
||||||
|
MessageSearchFilter filter,
|
||||||
MessageId top_thread_message_id, int64 &random_id,
|
MessageId top_thread_message_id, int64 &random_id,
|
||||||
bool use_db, Promise<Unit> &&promise);
|
bool use_db, Promise<Unit> &&promise);
|
||||||
|
|
||||||
|
@ -1438,7 +1438,7 @@ class GetMessageThreadHistoryRequest : public RequestActor<> {
|
|||||||
class SearchChatMessagesRequest : public RequestActor<> {
|
class SearchChatMessagesRequest : public RequestActor<> {
|
||||||
DialogId dialog_id_;
|
DialogId dialog_id_;
|
||||||
string query_;
|
string query_;
|
||||||
UserId sender_user_id_;
|
td_api::object_ptr<td_api::MessageSender> sender_;
|
||||||
MessageId from_message_id_;
|
MessageId from_message_id_;
|
||||||
int32 offset_;
|
int32 offset_;
|
||||||
int32 limit_;
|
int32 limit_;
|
||||||
@ -1449,9 +1449,9 @@ class SearchChatMessagesRequest : public RequestActor<> {
|
|||||||
std::pair<int32, vector<MessageId>> messages_;
|
std::pair<int32, vector<MessageId>> messages_;
|
||||||
|
|
||||||
void do_run(Promise<Unit> &&promise) override {
|
void do_run(Promise<Unit> &&promise) override {
|
||||||
messages_ = td->messages_manager_->search_dialog_messages(dialog_id_, query_, sender_user_id_, from_message_id_,
|
messages_ = td->messages_manager_->search_dialog_messages(dialog_id_, query_, sender_, from_message_id_, offset_,
|
||||||
offset_, limit_, filter_, top_thread_message_id_,
|
limit_, filter_, top_thread_message_id_, random_id_,
|
||||||
random_id_, get_tries() == 3, std::move(promise));
|
get_tries() == 3, std::move(promise));
|
||||||
}
|
}
|
||||||
|
|
||||||
void do_send_result() override {
|
void do_send_result() override {
|
||||||
@ -1468,13 +1468,13 @@ class SearchChatMessagesRequest : public RequestActor<> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
SearchChatMessagesRequest(ActorShared<Td> td, uint64 request_id, int64 dialog_id, string query, int32 user_id,
|
SearchChatMessagesRequest(ActorShared<Td> td, uint64 request_id, int64 dialog_id, string query,
|
||||||
int64 from_message_id, int32 offset, int32 limit,
|
td_api::object_ptr<td_api::MessageSender> sender, int64 from_message_id, int32 offset,
|
||||||
tl_object_ptr<td_api::SearchMessagesFilter> filter, int64 message_thread_id)
|
int32 limit, tl_object_ptr<td_api::SearchMessagesFilter> filter, int64 message_thread_id)
|
||||||
: 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))
|
||||||
, sender_user_id_(user_id)
|
, sender_(std::move(sender))
|
||||||
, from_message_id_(from_message_id)
|
, from_message_id_(from_message_id)
|
||||||
, offset_(offset)
|
, offset_(offset)
|
||||||
, limit_(limit)
|
, limit_(limit)
|
||||||
@ -5537,7 +5537,7 @@ void Td::on_request(uint64 id, const td_api::getMessageThreadHistory &request) {
|
|||||||
void Td::on_request(uint64 id, td_api::searchChatMessages &request) {
|
void Td::on_request(uint64 id, td_api::searchChatMessages &request) {
|
||||||
CHECK_IS_USER();
|
CHECK_IS_USER();
|
||||||
CLEAN_INPUT_STRING(request.query_);
|
CLEAN_INPUT_STRING(request.query_);
|
||||||
CREATE_REQUEST(SearchChatMessagesRequest, request.chat_id_, std::move(request.query_), request.sender_user_id_,
|
CREATE_REQUEST(SearchChatMessagesRequest, request.chat_id_, std::move(request.query_), std::move(request.sender_),
|
||||||
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_);
|
request.message_thread_id_);
|
||||||
}
|
}
|
||||||
|
@ -318,7 +318,7 @@ class CliClient final : public Actor {
|
|||||||
auto last_message_id = messages.messages_.back()->id_;
|
auto last_message_id = messages.messages_.back()->id_;
|
||||||
LOG(ERROR) << (last_message_id >> 20);
|
LOG(ERROR) << (last_message_id >> 20);
|
||||||
send_request(td_api::make_object<td_api::searchChatMessages>(
|
send_request(td_api::make_object<td_api::searchChatMessages>(
|
||||||
search_chat_id_, "", 0, last_message_id, 0, 100,
|
search_chat_id_, "", nullptr, last_message_id, 0, 100,
|
||||||
td_api::make_object<td_api::searchMessagesFilterPhotoAndVideo>(), 0));
|
td_api::make_object<td_api::searchMessagesFilterPhotoAndVideo>(), 0));
|
||||||
} else {
|
} else {
|
||||||
search_chat_id_ = 0;
|
search_chat_id_ = 0;
|
||||||
@ -509,6 +509,15 @@ class CliClient final : public Actor {
|
|||||||
return as_message_id(str);
|
return as_message_id(str);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
td_api::object_ptr<td_api::MessageSender> as_message_sender(Slice str) const {
|
||||||
|
str = trim(str);
|
||||||
|
if (str.empty() || str[0] != '-') {
|
||||||
|
return td_api::make_object<td_api::messageSenderUser>(as_user_id(str));
|
||||||
|
} else {
|
||||||
|
return td_api::make_object<td_api::messageSenderChat>(as_chat_id(str));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static int32 as_button_id(Slice str) {
|
static int32 as_button_id(Slice str) {
|
||||||
return to_integer<int32>(trim(str));
|
return to_integer<int32>(trim(str));
|
||||||
}
|
}
|
||||||
@ -1877,13 +1886,14 @@ class CliClient final : public Actor {
|
|||||||
string message_thread_id;
|
string message_thread_id;
|
||||||
|
|
||||||
std::tie(chat_id, message_thread_id) = split(args);
|
std::tie(chat_id, message_thread_id) = split(args);
|
||||||
send_request(td_api::make_object<td_api::searchChatMessages>(as_chat_id(chat_id), "", 0, 0, 0, 100, nullptr,
|
send_request(td_api::make_object<td_api::searchChatMessages>(as_chat_id(chat_id), "", nullptr, 0, 0, 100, nullptr,
|
||||||
as_message_thread_id(message_thread_id)));
|
as_message_thread_id(message_thread_id)));
|
||||||
} else if (op == "spvf") {
|
} else if (op == "spvf") {
|
||||||
search_chat_id_ = as_chat_id(args);
|
search_chat_id_ = as_chat_id(args);
|
||||||
|
|
||||||
send_request(td_api::make_object<td_api::searchChatMessages>(
|
send_request(td_api::make_object<td_api::searchChatMessages>(
|
||||||
search_chat_id_, "", 0, 0, 0, 100, td_api::make_object<td_api::searchMessagesFilterPhotoAndVideo>(), 0));
|
search_chat_id_, "", nullptr, 0, 0, 100, td_api::make_object<td_api::searchMessagesFilterPhotoAndVideo>(),
|
||||||
|
0));
|
||||||
} else if (op == "Search" || op == "SearchA" || op == "SearchM") {
|
} else if (op == "Search" || op == "SearchA" || op == "SearchM") {
|
||||||
string from_date;
|
string from_date;
|
||||||
string limit;
|
string limit;
|
||||||
@ -1917,7 +1927,7 @@ class CliClient final : public Actor {
|
|||||||
limit = "10";
|
limit = "10";
|
||||||
}
|
}
|
||||||
|
|
||||||
send_request(td_api::make_object<td_api::searchChatMessages>(as_chat_id(chat_id), query, 0, 0, 0,
|
send_request(td_api::make_object<td_api::searchChatMessages>(as_chat_id(chat_id), query, nullptr, 0, 0,
|
||||||
to_integer<int32>(limit), nullptr, 0));
|
to_integer<int32>(limit), nullptr, 0));
|
||||||
} else if (op == "SMME") {
|
} else if (op == "SMME") {
|
||||||
string chat_id;
|
string chat_id;
|
||||||
@ -1928,21 +1938,22 @@ class CliClient final : public Actor {
|
|||||||
limit = "10";
|
limit = "10";
|
||||||
}
|
}
|
||||||
|
|
||||||
send_request(td_api::make_object<td_api::searchChatMessages>(as_chat_id(chat_id), "", my_id_, 0, 0,
|
send_request(td_api::make_object<td_api::searchChatMessages>(
|
||||||
to_integer<int32>(limit), nullptr, 0));
|
as_chat_id(chat_id), "", td_api::make_object<td_api::messageSenderUser>(my_id_), 0, 0,
|
||||||
} else if (op == "SMU") {
|
to_integer<int32>(limit), nullptr, 0));
|
||||||
|
} else if (op == "SMU" || op == "SMC") {
|
||||||
string chat_id;
|
string chat_id;
|
||||||
string user_id;
|
string sender_id;
|
||||||
string limit;
|
string limit;
|
||||||
|
|
||||||
std::tie(chat_id, args) = split(args);
|
std::tie(chat_id, args) = split(args);
|
||||||
std::tie(user_id, limit) = split(args);
|
std::tie(sender_id, limit) = split(args);
|
||||||
if (limit.empty()) {
|
if (limit.empty()) {
|
||||||
limit = "10";
|
limit = "10";
|
||||||
}
|
}
|
||||||
|
|
||||||
send_request(td_api::make_object<td_api::searchChatMessages>(as_chat_id(chat_id), "", as_user_id(user_id), 0, 0,
|
send_request(td_api::make_object<td_api::searchChatMessages>(
|
||||||
to_integer<int32>(limit), nullptr, 0));
|
as_chat_id(chat_id), "", as_message_sender(sender_id), 0, 0, to_integer<int32>(limit), nullptr, 0));
|
||||||
} else if (op == "SM") {
|
} else if (op == "SM") {
|
||||||
string chat_id;
|
string chat_id;
|
||||||
string filter;
|
string filter;
|
||||||
@ -1965,7 +1976,7 @@ class CliClient final : public Actor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
send_request(td_api::make_object<td_api::searchChatMessages>(
|
send_request(td_api::make_object<td_api::searchChatMessages>(
|
||||||
as_chat_id(chat_id), "", 0, as_message_id(offset_message_id), to_integer<int32>(offset),
|
as_chat_id(chat_id), "", nullptr, as_message_id(offset_message_id), to_integer<int32>(offset),
|
||||||
to_integer<int32>(limit), as_search_messages_filter(filter), 0));
|
to_integer<int32>(limit), as_search_messages_filter(filter), 0));
|
||||||
} else if (op == "SC") {
|
} else if (op == "SC") {
|
||||||
string limit;
|
string limit;
|
||||||
@ -2010,7 +2021,7 @@ class CliClient final : public Actor {
|
|||||||
limit = "10";
|
limit = "10";
|
||||||
}
|
}
|
||||||
send_request(td_api::make_object<td_api::searchChatMessages>(
|
send_request(td_api::make_object<td_api::searchChatMessages>(
|
||||||
as_chat_id(chat_id), query, 0, as_message_id(offset_message_id), 0, to_integer<int32>(limit),
|
as_chat_id(chat_id), query, nullptr, as_message_id(offset_message_id), 0, to_integer<int32>(limit),
|
||||||
td_api::make_object<td_api::searchMessagesFilterAudio>(), 0));
|
td_api::make_object<td_api::searchMessagesFilterAudio>(), 0));
|
||||||
} else if (op == "SearchDocument") {
|
} else if (op == "SearchDocument") {
|
||||||
string chat_id;
|
string chat_id;
|
||||||
@ -2028,7 +2039,7 @@ class CliClient final : public Actor {
|
|||||||
limit = "10";
|
limit = "10";
|
||||||
}
|
}
|
||||||
send_request(td_api::make_object<td_api::searchChatMessages>(
|
send_request(td_api::make_object<td_api::searchChatMessages>(
|
||||||
as_chat_id(chat_id), query, 0, to_integer<int64>(offset_message_id), 0, to_integer<int32>(limit),
|
as_chat_id(chat_id), query, nullptr, to_integer<int64>(offset_message_id), 0, to_integer<int32>(limit),
|
||||||
td_api::make_object<td_api::searchMessagesFilterDocument>(), 0));
|
td_api::make_object<td_api::searchMessagesFilterDocument>(), 0));
|
||||||
} else if (op == "SearchPhoto") {
|
} else if (op == "SearchPhoto") {
|
||||||
string chat_id;
|
string chat_id;
|
||||||
@ -2046,7 +2057,7 @@ class CliClient final : public Actor {
|
|||||||
limit = "10";
|
limit = "10";
|
||||||
}
|
}
|
||||||
send_request(td_api::make_object<td_api::searchChatMessages>(
|
send_request(td_api::make_object<td_api::searchChatMessages>(
|
||||||
as_chat_id(chat_id), query, 0, as_message_id(offset_message_id), 0, to_integer<int32>(limit),
|
as_chat_id(chat_id), query, nullptr, as_message_id(offset_message_id), 0, to_integer<int32>(limit),
|
||||||
td_api::make_object<td_api::searchMessagesFilterPhoto>(), 0));
|
td_api::make_object<td_api::searchMessagesFilterPhoto>(), 0));
|
||||||
} else if (op == "SearchChatPhoto") {
|
} else if (op == "SearchChatPhoto") {
|
||||||
string chat_id;
|
string chat_id;
|
||||||
@ -2064,7 +2075,7 @@ class CliClient final : public Actor {
|
|||||||
limit = "10";
|
limit = "10";
|
||||||
}
|
}
|
||||||
send_request(td_api::make_object<td_api::searchChatMessages>(
|
send_request(td_api::make_object<td_api::searchChatMessages>(
|
||||||
as_chat_id(chat_id), query, 0, as_message_id(offset_message_id), 0, to_integer<int32>(limit),
|
as_chat_id(chat_id), query, nullptr, as_message_id(offset_message_id), 0, to_integer<int32>(limit),
|
||||||
td_api::make_object<td_api::searchMessagesFilterChatPhoto>(), 0));
|
td_api::make_object<td_api::searchMessagesFilterChatPhoto>(), 0));
|
||||||
} else if (op == "gcmc") {
|
} else if (op == "gcmc") {
|
||||||
string chat_id;
|
string chat_id;
|
||||||
|
Loading…
Reference in New Issue
Block a user