Use string new_offset in FoundMessages.

GitOrigin-RevId: b0d013e7d2513cc39f1c07013c837e6adb7e924a
This commit is contained in:
levlam 2020-08-18 15:10:03 +03:00
parent 5e20f6f90b
commit 605e0844fb
6 changed files with 32 additions and 26 deletions

View File

@ -681,8 +681,8 @@ message id:int53 sender_user_id:int32 chat_id:int53 sending_state:MessageSending
//@description Contains a list of messages @total_count Approximate total count of messages found @messages List of messages; messages may be null
messages total_count:int32 messages:vector<message> = Messages;
//@description Contains a list of messages found by a search @messages List of messages @next_from_search_id Value to pass as from_search_id to get more results
foundMessages messages:vector<message> next_from_search_id:int64 = FoundMessages;
//@description Contains a list of messages found by a search @messages List of messages @next_offset The offset for the next request. If empty, there are no more results
foundMessages messages:vector<message> next_offset:string = FoundMessages;
//@class NotificationSettingsScope @description Describes the types of chats to which notification settings are applied
@ -3595,10 +3595,10 @@ searchMessages chat_list:ChatList query:string offset_date:int32 offset_chat_id:
//@description Searches for messages in secret chats. Returns the results in reverse chronological order. For optimal performance the number of returned messages is chosen by the library
//@chat_id Identifier of the chat in which to search. Specify 0 to search in all secret chats @query Query to search for. If empty, searchChatMessages should be used instead
//@from_search_id The identifier from the result of a previous request, use 0 to get results from the last message
//@offset Offset of the first entry to return; use empty string to get results from the last message
//@limit The maximum number of messages to be returned; up to 100. Fewer messages may be returned than specified by the limit, even if the end of the message history has not been reached
//@filter A filter for the content of messages in the search results
searchSecretMessages chat_id:int53 query:string from_search_id:int64 limit:int32 filter:SearchMessagesFilter = FoundMessages;
searchSecretMessages chat_id:int53 query:string offset:string limit:int32 filter:SearchMessagesFilter = FoundMessages;
//@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 the library
//@from_message_id Identifier of the message from which to search; use 0 to get results from the last message

Binary file not shown.

View File

@ -18994,8 +18994,8 @@ void MessagesManager::on_search_dialog_messages_db_result(int64 random_id, Dialo
promise.set_value(Unit());
}
std::pair<int64, vector<FullMessageId>> MessagesManager::offline_search_messages(
DialogId dialog_id, const string &query, int64 from_search_id, int32 limit,
std::pair<string, vector<FullMessageId>> MessagesManager::offline_search_messages(
DialogId dialog_id, const string &query, const string &offset, int32 limit,
const tl_object_ptr<td_api::SearchMessagesFilter> &filter, int64 &random_id, Promise<> &&promise) {
if (!G()->parameters().use_message_db) {
promise.set_error(Status::Error(400, "Message database is required to search messages in secret chats"));
@ -19032,7 +19032,14 @@ std::pair<int64, vector<FullMessageId>> MessagesManager::offline_search_messages
fts_query.query = query;
fts_query.dialog_id = dialog_id;
fts_query.index_mask = search_messages_filter_index_mask(get_search_messages_filter(filter));
fts_query.from_search_id = from_search_id;
if (!offset.empty()) {
auto r_from_search_id = to_integer_safe<int64>(offset);
if (r_from_search_id.is_error()) {
promise.set_error(Status::Error(400, "Wrong offset specified"));
return {};
}
fts_query.from_search_id = r_from_search_id.ok();
}
fts_query.limit = limit;
do {
@ -19074,7 +19081,7 @@ void MessagesManager::on_messages_db_fts_result(Result<MessagesDbFtsResult> resu
}
}
it->second.first = fts_result.next_search_id;
it->second.first = fts_result.next_search_id <= 1 ? string() : to_string(fts_result.next_search_id);
promise.set_value(Unit());
}

View File

@ -653,8 +653,8 @@ class MessagesManager : public Actor {
const tl_object_ptr<td_api::SearchMessagesFilter> &filter,
int64 &random_id, bool use_db, Promise<Unit> &&promise);
std::pair<int64, vector<FullMessageId>> offline_search_messages(
DialogId dialog_id, const string &query, int64 from_search_id, int32 limit,
std::pair<string, vector<FullMessageId>> offline_search_messages(
DialogId dialog_id, const string &query, const string &offset, int32 limit,
const tl_object_ptr<td_api::SearchMessagesFilter> &filter, int64 &random_id, Promise<> &&promise);
std::pair<int32, vector<FullMessageId>> search_messages(FolderId folder_id, bool ignore_folder_id,
@ -2931,8 +2931,8 @@ class MessagesManager : public Actor {
std::unordered_map<int64, std::pair<int32, vector<MessageId>>>
found_dialog_recent_location_messages_; // random_id -> [total_count, [message_id]...]
std::unordered_map<int64, std::pair<int64, vector<FullMessageId>>>
found_fts_messages_; // random_id -> [from_search_id, [full_message_id]...]
std::unordered_map<int64, std::pair<string, vector<FullMessageId>>>
found_fts_messages_; // random_id -> [next_offset, [full_message_id]...]
std::unordered_map<FullMessageId, std::pair<string, string>, FullMessageIdHash> public_message_links_[2];

View File

@ -1465,19 +1465,19 @@ class SearchChatMessagesRequest : public RequestActor<> {
}
};
class OfflineSearchMessagesRequest : public RequestActor<> {
class SearchSecretMessagesRequest : public RequestActor<> {
DialogId dialog_id_;
string query_;
int64 from_search_id_;
string offset_;
int32 limit_;
tl_object_ptr<td_api::SearchMessagesFilter> filter_;
int64 random_id_;
std::pair<int64, vector<FullMessageId>> messages_;
std::pair<string, vector<FullMessageId>> messages_;
void do_run(Promise<Unit> &&promise) override {
messages_ = td->messages_manager_->offline_search_messages(dialog_id_, query_, from_search_id_, limit_, filter_,
random_id_, std::move(promise));
messages_ = td->messages_manager_->offline_search_messages(dialog_id_, query_, offset_, limit_, filter_, random_id_,
std::move(promise));
}
void do_send_result() override {
@ -1487,16 +1487,16 @@ class OfflineSearchMessagesRequest : public RequestActor<> {
result.push_back(td->messages_manager_->get_message_object(full_message_id));
}
send_result(make_tl_object<td_api::foundMessages>(std::move(result), messages_.first));
send_result(make_tl_object<td_api::foundMessages>(std::move(result), std::move(messages_.first)));
}
public:
OfflineSearchMessagesRequest(ActorShared<Td> td, uint64 request_id, int64 dialog_id, string query,
int64 from_search_id, int32 limit, tl_object_ptr<td_api::SearchMessagesFilter> filter)
SearchSecretMessagesRequest(ActorShared<Td> td, uint64 request_id, int64 dialog_id, string query, string offset,
int32 limit, tl_object_ptr<td_api::SearchMessagesFilter> filter)
: RequestActor(std::move(td), request_id)
, dialog_id_(dialog_id)
, query_(std::move(query))
, from_search_id_(from_search_id)
, offset_(std::move(offset))
, limit_(limit)
, filter_(std::move(filter))
, random_id_(0) {
@ -5463,7 +5463,7 @@ void Td::on_request(uint64 id, td_api::searchChatMessages &request) {
void Td::on_request(uint64 id, td_api::searchSecretMessages &request) {
CHECK_IS_USER();
CLEAN_INPUT_STRING(request.query_);
CREATE_REQUEST(OfflineSearchMessagesRequest, request.chat_id_, std::move(request.query_), request.from_search_id_,
CREATE_REQUEST(SearchSecretMessagesRequest, request.chat_id_, std::move(request.query_), std::move(request.offset_),
request.limit_, std::move(request.filter_));
}

View File

@ -2913,19 +2913,18 @@ class CliClient final : public Actor {
}
} else if (op == "ssm") {
string chat_id;
string from_search_id;
string offset;
string limit;
string filter;
string query;
std::tie(chat_id, args) = split(args);
std::tie(from_search_id, args) = split(args);
std::tie(offset, args) = split(args);
std::tie(limit, args) = split(args);
std::tie(filter, query) = split(args);
send_request(td_api::make_object<td_api::searchSecretMessages>(
as_chat_id(chat_id), query, to_integer<int64>(from_search_id), to_integer<int32>(limit),
get_search_messages_filter(filter)));
as_chat_id(chat_id), query, offset, to_integer<int32>(limit), get_search_messages_filter(filter)));
} else if (op == "ssd") {
schedule_date_ = args;
} else if (op == "sm" || op == "sms" || op == "smr" || op == "smf") {