Add total_count to FoundMessages.

GitOrigin-RevId: ade2685b5d19dfb5cf31d4e952074879393915ee
This commit is contained in:
levlam 2020-08-21 15:08:47 +03:00
parent f9c0ddae06
commit ca3d263c25
4 changed files with 16 additions and 9 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_offset The offset for the next request. If empty, there are no more results
foundMessages messages:vector<message> next_offset:string = FoundMessages;
//@description Contains a list of messages found by a search @total_count Approximate total count of messages found; -1 if unknown @messages List of messages @next_offset The offset for the next request. If empty, there are no more results
foundMessages total_count:int32 messages:vector<message> next_offset:string = FoundMessages;
//@class NotificationSettingsScope @description Describes the types of chats to which notification settings are applied

Binary file not shown.

View File

@ -8917,7 +8917,7 @@ void MessagesManager::on_get_message_public_forwards_result(int64 random_id, int
<< m->message_id.get_server_message_id().get();
}
// it->second.total_count = total_count;
it->second.total_count = total_count;
}
void MessagesManager::on_failed_get_message_public_forwards(int64 random_id) {
@ -19093,7 +19093,8 @@ td_api::object_ptr<td_api::foundMessages> MessagesManager::get_found_messages_ob
}
}
return td_api::make_object<td_api::foundMessages>(std::move(result), found_messages.next_offset);
return td_api::make_object<td_api::foundMessages>(found_messages.total_count, std::move(result),
found_messages.next_offset);
}
MessagesManager::FoundMessages MessagesManager::offline_search_messages(
@ -19151,16 +19152,17 @@ MessagesManager::FoundMessages MessagesManager::offline_search_messages(
G()->td_db()->get_messages_db_async()->get_messages_fts(
std::move(fts_query),
PromiseCreator::lambda([random_id, promise = std::move(promise)](Result<MessagesDbFtsResult> fts_result) mutable {
PromiseCreator::lambda([random_id, offset = std::move(offset), limit,
promise = std::move(promise)](Result<MessagesDbFtsResult> fts_result) mutable {
send_closure(G()->messages_manager(), &MessagesManager::on_messages_db_fts_result, std::move(fts_result),
random_id, std::move(promise));
std::move(offset), limit, random_id, std::move(promise));
}));
return {};
}
void MessagesManager::on_messages_db_fts_result(Result<MessagesDbFtsResult> result, int64 random_id,
Promise<Unit> &&promise) {
void MessagesManager::on_messages_db_fts_result(Result<MessagesDbFtsResult> result, string offset, int32 limit,
int64 random_id, Promise<Unit> &&promise) {
if (G()->close_flag()) {
result = Status::Error(500, "Request aborted");
}
@ -19184,6 +19186,9 @@ void MessagesManager::on_messages_db_fts_result(Result<MessagesDbFtsResult> resu
}
it->second.next_offset = fts_result.next_search_id <= 1 ? string() : to_string(fts_result.next_search_id);
it->second.total_count = offset.empty() && fts_result.messages.size() < static_cast<size_t>(limit)
? static_cast<int32>(fts_result.messages.size())
: -1;
promise.set_value(Unit());
}

View File

@ -660,6 +660,7 @@ class MessagesManager : public Actor {
struct FoundMessages {
vector<FullMessageId> full_message_ids;
string next_offset;
int32 total_count = 0;
};
td_api::object_ptr<td_api::foundMessages> get_found_messages_object(const FoundMessages &found_messages);
@ -2495,7 +2496,8 @@ class MessagesManager : public Actor {
int32 offset, int32 limit, Result<std::vector<BufferSlice>> r_messages,
Promise<> promise);
void on_messages_db_fts_result(Result<MessagesDbFtsResult> result, int64 random_id, Promise<> &&promise);
void on_messages_db_fts_result(Result<MessagesDbFtsResult> result, string offset, int32 limit, int64 random_id,
Promise<> &&promise);
void on_messages_db_calls_result(Result<MessagesDbCallsResult> result, int64 random_id, MessageId first_db_message_id,
SearchMessagesFilter filter, Promise<Unit> &&promise);