Add source to MessagesManager::get_history_impl.
This commit is contained in:
parent
2dba29669f
commit
c071678be1
@ -9815,7 +9815,7 @@ void MessagesManager::on_get_history(DialogId dialog_id, MessageId from_message_
|
|||||||
if (from_the_end) {
|
if (from_the_end) {
|
||||||
get_history_from_the_end_impl(d, false, false, std::move(promise), "on_get_history");
|
get_history_from_the_end_impl(d, false, false, std::move(promise), "on_get_history");
|
||||||
} else {
|
} else {
|
||||||
get_history_impl(d, from_message_id, offset, limit, false, false, std::move(promise));
|
get_history_impl(d, from_message_id, offset, limit, false, false, std::move(promise), "on_get_history");
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -23246,7 +23246,8 @@ void MessagesManager::on_get_history_from_database(DialogId dialog_id, MessageId
|
|||||||
if (from_the_end) {
|
if (from_the_end) {
|
||||||
get_history_from_the_end_impl(d, true, only_local, std::move(promise), "on_get_history_from_database 20");
|
get_history_from_the_end_impl(d, true, only_local, std::move(promise), "on_get_history_from_database 20");
|
||||||
} else {
|
} else {
|
||||||
get_history_impl(d, from_message_id, offset, limit, true, only_local, std::move(promise));
|
get_history_impl(d, from_message_id, offset, limit, true, only_local, std::move(promise),
|
||||||
|
"on_get_history_from_database 20");
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -23551,23 +23552,12 @@ void MessagesManager::on_get_history_finished(const PendingGetHistoryQuery &quer
|
|||||||
}
|
}
|
||||||
|
|
||||||
void MessagesManager::get_history_impl(const Dialog *d, MessageId from_message_id, int32 offset, int32 limit,
|
void MessagesManager::get_history_impl(const Dialog *d, MessageId from_message_id, int32 offset, int32 limit,
|
||||||
bool from_database, bool only_local, Promise<Unit> &&promise) {
|
bool from_database, bool only_local, Promise<Unit> &&promise,
|
||||||
|
const char *source) {
|
||||||
TRY_STATUS_PROMISE(promise, G()->close_status());
|
TRY_STATUS_PROMISE(promise, G()->close_status());
|
||||||
CHECK(d != nullptr);
|
CHECK(d != nullptr);
|
||||||
CHECK(from_message_id.is_valid());
|
CHECK(from_message_id.is_valid());
|
||||||
|
|
||||||
if (offset >= -1) {
|
|
||||||
// get history before some server or local message
|
|
||||||
limit = clamp(limit + offset + 1, MAX_GET_HISTORY / 2, MAX_GET_HISTORY);
|
|
||||||
offset = -1;
|
|
||||||
} else {
|
|
||||||
// get history around some server or local message
|
|
||||||
int32 messages_to_load = max(MAX_GET_HISTORY, limit);
|
|
||||||
int32 max_add = max(messages_to_load - limit - 2, 0);
|
|
||||||
offset -= max_add;
|
|
||||||
limit = MAX_GET_HISTORY;
|
|
||||||
}
|
|
||||||
|
|
||||||
auto dialog_id = d->dialog_id;
|
auto dialog_id = d->dialog_id;
|
||||||
if (!have_input_peer(dialog_id, AccessRights::Read)) {
|
if (!have_input_peer(dialog_id, AccessRights::Read)) {
|
||||||
// can't get history in dialogs without read access
|
// can't get history in dialogs without read access
|
||||||
@ -23581,6 +23571,18 @@ void MessagesManager::get_history_impl(const Dialog *d, MessageId from_message_i
|
|||||||
from_database = false;
|
from_database = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (offset >= -1) {
|
||||||
|
// get history before some server or local message
|
||||||
|
limit = clamp(limit + offset + 1, MAX_GET_HISTORY / 2, MAX_GET_HISTORY);
|
||||||
|
offset = -1;
|
||||||
|
} else {
|
||||||
|
// get history around some server or local message
|
||||||
|
int32 messages_to_load = max(MAX_GET_HISTORY, limit);
|
||||||
|
int32 max_add = max(messages_to_load - limit - 2, 0);
|
||||||
|
offset -= max_add;
|
||||||
|
limit = MAX_GET_HISTORY;
|
||||||
|
}
|
||||||
|
|
||||||
PendingGetHistoryQuery query;
|
PendingGetHistoryQuery query;
|
||||||
query.dialog_id_ = dialog_id;
|
query.dialog_id_ = dialog_id;
|
||||||
query.from_message_id_ = from_message_id;
|
query.from_message_id_ = from_message_id;
|
||||||
@ -23591,7 +23593,7 @@ void MessagesManager::get_history_impl(const Dialog *d, MessageId from_message_i
|
|||||||
|
|
||||||
if (from_database) {
|
if (from_database) {
|
||||||
LOG(INFO) << "Get history in " << dialog_id << " from " << from_message_id << " with offset " << offset
|
LOG(INFO) << "Get history in " << dialog_id << " from " << from_message_id << " with offset " << offset
|
||||||
<< " and limit " << limit << " from database";
|
<< " and limit " << limit << " from database from " << source;
|
||||||
|
|
||||||
query.old_last_message_id_ = d->last_database_message_id;
|
query.old_last_message_id_ = d->last_database_message_id;
|
||||||
|
|
||||||
@ -23639,7 +23641,7 @@ void MessagesManager::get_history_impl(const Dialog *d, MessageId from_message_i
|
|||||||
});
|
});
|
||||||
|
|
||||||
LOG(INFO) << "Get history in " << dialog_id << " from " << from_message_id << " with offset " << offset
|
LOG(INFO) << "Get history in " << dialog_id << " from " << from_message_id << " with offset " << offset
|
||||||
<< " and limit " << limit << " from server";
|
<< " and limit " << limit << " from server from " << source;
|
||||||
td_->create_handler<GetHistoryQuery>(std::move(query_promise))
|
td_->create_handler<GetHistoryQuery>(std::move(query_promise))
|
||||||
->send(dialog_id, from_message_id.get_next_server_message_id(), d->last_new_message_id, offset, limit);
|
->send(dialog_id, from_message_id.get_next_server_message_id(), d->last_new_message_id, offset, limit);
|
||||||
}
|
}
|
||||||
@ -23668,7 +23670,8 @@ void MessagesManager::load_messages_impl(const Dialog *d, MessageId from_message
|
|||||||
get_history_from_the_end_impl(d, from_database, only_local, std::move(promise), "load_messages_impl");
|
get_history_from_the_end_impl(d, from_database, only_local, std::move(promise), "load_messages_impl");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
get_history_impl(d, from_message_id, offset, limit, from_database, only_local, std::move(promise));
|
get_history_impl(d, from_message_id, offset, limit, from_database, only_local, std::move(promise),
|
||||||
|
"load_messages_impl");
|
||||||
}
|
}
|
||||||
|
|
||||||
vector<MessageId> MessagesManager::get_dialog_scheduled_messages(DialogId dialog_id, bool force, bool ignore_result,
|
vector<MessageId> MessagesManager::get_dialog_scheduled_messages(DialogId dialog_id, bool force, bool ignore_result,
|
||||||
@ -40251,7 +40254,7 @@ void MessagesManager::suffix_load_loop(const Dialog *d, SuffixLoadQueries *queri
|
|||||||
queries->suffix_load_has_query_ = true;
|
queries->suffix_load_has_query_ = true;
|
||||||
queries->suffix_load_query_message_id_ = from_message_id;
|
queries->suffix_load_query_message_id_ = from_message_id;
|
||||||
if (from_message_id.is_valid()) {
|
if (from_message_id.is_valid()) {
|
||||||
get_history_impl(d, from_message_id, -1, MAX_GET_HISTORY, true, true, std::move(promise));
|
get_history_impl(d, from_message_id, -1, MAX_GET_HISTORY, true, true, std::move(promise), "suffix_load_loop");
|
||||||
} else {
|
} else {
|
||||||
CHECK(from_message_id == MessageId());
|
CHECK(from_message_id == MessageId());
|
||||||
get_history_from_the_end_impl(d, true, true, std::move(promise), "suffix_load_loop");
|
get_history_from_the_end_impl(d, true, true, std::move(promise), "suffix_load_loop");
|
||||||
|
@ -2244,7 +2244,7 @@ class MessagesManager final : public Actor {
|
|||||||
void on_get_history_finished(const PendingGetHistoryQuery &query, Result<Unit> &&result);
|
void on_get_history_finished(const PendingGetHistoryQuery &query, Result<Unit> &&result);
|
||||||
|
|
||||||
void get_history_impl(const Dialog *d, MessageId from_message_id, int32 offset, int32 limit, bool from_database,
|
void get_history_impl(const Dialog *d, MessageId from_message_id, int32 offset, int32 limit, bool from_database,
|
||||||
bool only_local, Promise<Unit> &&promise);
|
bool only_local, Promise<Unit> &&promise, const char *source);
|
||||||
|
|
||||||
void load_messages(DialogId dialog_id, MessageId from_message_id, int32 offset, int32 limit, int left_tries,
|
void load_messages(DialogId dialog_id, MessageId from_message_id, int32 offset, int32 limit, int left_tries,
|
||||||
bool only_local, Promise<Unit> &&promise);
|
bool only_local, Promise<Unit> &&promise);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user