Add source to send_get_*_full_query.

GitOrigin-RevId: 5fdb3cc98f901ddfdcb562ba2c452fc5e2ed13cc
This commit is contained in:
levlam 2019-09-15 05:06:11 +03:00
parent eddbbe0d42
commit 9e51fcdb3f
2 changed files with 23 additions and 19 deletions

View File

@ -8477,7 +8477,7 @@ void ContactsManager::invalidate_invite_link_info(const string &invite_link) {
} }
void ContactsManager::repair_chat_participants(ChatId chat_id) { void ContactsManager::repair_chat_participants(ChatId chat_id) {
send_get_chat_full_query(chat_id, Auto()); send_get_chat_full_query(chat_id, Auto(), "repair_chat_participants");
} }
void ContactsManager::on_update_chat_add_user(ChatId chat_id, UserId inviter_user_id, UserId user_id, int32 date, void ContactsManager::on_update_chat_add_user(ChatId chat_id, UserId inviter_user_id, UserId user_id, int32 date,
@ -9352,17 +9352,17 @@ bool ContactsManager::get_user_full(UserId user_id, Promise<Unit> &&promise) {
return false; return false;
} }
send_get_user_full_query(user_id, std::move(input_user), std::move(promise)); send_get_user_full_query(user_id, std::move(input_user), std::move(promise), "get_user_full");
return false; return false;
} }
if (user_full->is_expired() || user_full->is_bot_info_expired(user->bot_info_version)) { if (user_full->is_expired() || user_full->is_bot_info_expired(user->bot_info_version)) {
auto input_user = get_input_user(user_id); auto input_user = get_input_user(user_id);
CHECK(input_user != nullptr); CHECK(input_user != nullptr);
if (td_->auth_manager_->is_bot()) { if (td_->auth_manager_->is_bot()) {
send_get_user_full_query(user_id, std::move(input_user), std::move(promise)); send_get_user_full_query(user_id, std::move(input_user), std::move(promise), "get expired user_full");
return false; return false;
} else { } else {
send_get_user_full_query(user_id, std::move(input_user), Auto()); send_get_user_full_query(user_id, std::move(input_user), Auto(), "get expired user_full");
} }
} }
@ -9371,7 +9371,8 @@ bool ContactsManager::get_user_full(UserId user_id, Promise<Unit> &&promise) {
} }
void ContactsManager::send_get_user_full_query(UserId user_id, tl_object_ptr<telegram_api::InputUser> &&input_user, void ContactsManager::send_get_user_full_query(UserId user_id, tl_object_ptr<telegram_api::InputUser> &&input_user,
Promise<Unit> &&promise) { Promise<Unit> &&promise, const char *source) {
LOG(INFO) << "Get full " << user_id << " from " << source;
auto send_query = auto send_query =
PromiseCreator::lambda([td = td_, input_user = std::move(input_user)](Result<Promise<Unit>> &&promise) mutable { PromiseCreator::lambda([td = td_, input_user = std::move(input_user)](Result<Promise<Unit>> &&promise) mutable {
if (promise.is_ok()) { if (promise.is_ok()) {
@ -9611,17 +9612,17 @@ bool ContactsManager::get_chat_full(ChatId chat_id, Promise<Unit> &&promise) {
auto chat_full = get_chat_full(chat_id); auto chat_full = get_chat_full(chat_id);
if (chat_full == nullptr) { if (chat_full == nullptr) {
LOG(INFO) << "Full " << chat_id << " not found"; LOG(INFO) << "Full " << chat_id << " not found";
send_get_chat_full_query(chat_id, std::move(promise)); send_get_chat_full_query(chat_id, std::move(promise), "get_chat_full");
return false; return false;
} }
if (is_chat_full_outdated(chat_full, chat, chat_id)) { if (is_chat_full_outdated(chat_full, chat, chat_id)) {
LOG(INFO) << "Have outdated full " << chat_id; LOG(INFO) << "Have outdated full " << chat_id;
if (td_->auth_manager_->is_bot()) { if (td_->auth_manager_->is_bot()) {
send_get_chat_full_query(chat_id, std::move(promise)); send_get_chat_full_query(chat_id, std::move(promise), "get expired chat_full");
return false; return false;
} else { } else {
send_get_chat_full_query(chat_id, Auto()); send_get_chat_full_query(chat_id, Auto(), "get expired chat_full");
} }
} }
@ -9629,7 +9630,8 @@ bool ContactsManager::get_chat_full(ChatId chat_id, Promise<Unit> &&promise) {
return true; return true;
} }
void ContactsManager::send_get_chat_full_query(ChatId chat_id, Promise<Unit> &&promise) { void ContactsManager::send_get_chat_full_query(ChatId chat_id, Promise<Unit> &&promise, const char *source) {
LOG(INFO) << "Get full " << chat_id << " from " << source;
auto send_query = PromiseCreator::lambda([td = td_, chat_id](Result<Promise<Unit>> &&promise) { auto send_query = PromiseCreator::lambda([td = td_, chat_id](Result<Promise<Unit>> &&promise) {
if (promise.is_ok()) { if (promise.is_ok()) {
td->create_handler<GetFullChatQuery>(promise.move_as_ok())->send(chat_id); td->create_handler<GetFullChatQuery>(promise.move_as_ok())->send(chat_id);
@ -9880,7 +9882,7 @@ ContactsManager::ChannelFull *ContactsManager::get_channel_full(ChannelId channe
if (channel_full->is_expired() && !td_->auth_manager_->is_bot()) { if (channel_full->is_expired() && !td_->auth_manager_->is_bot()) {
auto input_channel = get_input_channel(channel_id); auto input_channel = get_input_channel(channel_id);
CHECK(input_channel != nullptr); CHECK(input_channel != nullptr);
send_get_channel_full_query(channel_id, std::move(input_channel), Auto()); send_get_channel_full_query(channel_id, std::move(input_channel), Auto(), "update channel_full cache");
} }
return channel_full; return channel_full;
@ -9895,18 +9897,18 @@ bool ContactsManager::get_channel_full(ChannelId channel_id, Promise<Unit> &&pro
return false; return false;
} }
send_get_channel_full_query(channel_id, std::move(input_channel), std::move(promise)); send_get_channel_full_query(channel_id, std::move(input_channel), std::move(promise), "get channel_full");
return false; return false;
} }
if (channel_full->is_expired()) { if (channel_full->is_expired()) {
if (td_->auth_manager_->is_bot()) { if (td_->auth_manager_->is_bot()) {
auto input_channel = get_input_channel(channel_id); auto input_channel = get_input_channel(channel_id);
CHECK(input_channel != nullptr); CHECK(input_channel != nullptr);
send_get_channel_full_query(channel_id, std::move(input_channel), std::move(promise)); send_get_channel_full_query(channel_id, std::move(input_channel), std::move(promise), "get expired channel_full");
return false; return false;
} else { } else {
// request has already been sent in get_channel_full // request has already been sent in get_channel_full
// send_get_channel_full_query(channel_id, std::move(input_channel), Auto()); // send_get_channel_full_query(channel_id, std::move(input_channel), Auto(), "get expired channel_full");
} }
} }
@ -9916,7 +9918,8 @@ bool ContactsManager::get_channel_full(ChannelId channel_id, Promise<Unit> &&pro
void ContactsManager::send_get_channel_full_query(ChannelId channel_id, void ContactsManager::send_get_channel_full_query(ChannelId channel_id,
tl_object_ptr<telegram_api::InputChannel> &&input_channel, tl_object_ptr<telegram_api::InputChannel> &&input_channel,
Promise<Unit> &&promise) { Promise<Unit> &&promise, const char *source) {
LOG(INFO) << "Get full " << channel_id << " from " << source;
auto send_query = PromiseCreator::lambda( auto send_query = PromiseCreator::lambda(
[td = td_, channel_id, input_channel = std::move(input_channel)](Result<Promise<Unit>> &&promise) mutable { [td = td_, channel_id, input_channel = std::move(input_channel)](Result<Promise<Unit>> &&promise) mutable {
if (promise.is_ok()) { if (promise.is_ok()) {
@ -10139,7 +10142,7 @@ DialogParticipant ContactsManager::get_channel_participant(ChannelId channel_id,
if (force) { if (force) {
LOG(ERROR) << "Can't find cached UserFull"; LOG(ERROR) << "Can't find cached UserFull";
} else { } else {
send_get_user_full_query(user_id, std::move(input_user), std::move(promise)); send_get_user_full_query(user_id, std::move(input_user), std::move(promise), "get_channel_participant");
return DialogParticipant(); return DialogParticipant();
} }
} }
@ -10227,7 +10230,8 @@ std::pair<int32, vector<DialogParticipant>> ContactsManager::get_channel_partici
if (input_channel == nullptr) { if (input_channel == nullptr) {
promise.set_error(Status::Error(6, "Supergroup not found")); promise.set_error(Status::Error(6, "Supergroup not found"));
} else { } else {
send_get_channel_full_query(channel_id, std::move(input_channel), std::move(promise)); send_get_channel_full_query(channel_id, std::move(input_channel), std::move(promise),
"get_channel_participants");
} }
return result; return result;
} }

View File

@ -866,7 +866,7 @@ class ContactsManager : public Actor {
UserFull *get_user_full(UserId user_id); UserFull *get_user_full(UserId user_id);
void send_get_user_full_query(UserId user_id, tl_object_ptr<telegram_api::InputUser> &&input_user, void send_get_user_full_query(UserId user_id, tl_object_ptr<telegram_api::InputUser> &&input_user,
Promise<Unit> &&promise); Promise<Unit> &&promise, const char *source);
const Chat *get_chat(ChatId chat_id) const; const Chat *get_chat(ChatId chat_id) const;
Chat *get_chat(ChatId chat_id); Chat *get_chat(ChatId chat_id);
@ -877,7 +877,7 @@ class ContactsManager : public Actor {
const ChatFull *get_chat_full(ChatId chat_id) const; const ChatFull *get_chat_full(ChatId chat_id) const;
ChatFull *get_chat_full(ChatId chat_id); ChatFull *get_chat_full(ChatId chat_id);
void send_get_chat_full_query(ChatId chat_id, Promise<Unit> &&promise); void send_get_chat_full_query(ChatId chat_id, Promise<Unit> &&promise, const char *source);
const Channel *get_channel(ChannelId channel_id) const; const Channel *get_channel(ChannelId channel_id) const;
Channel *get_channel(ChannelId channel_id); Channel *get_channel(ChannelId channel_id);
@ -889,7 +889,7 @@ class ContactsManager : public Actor {
ChannelFull *get_channel_full(ChannelId channel_id); ChannelFull *get_channel_full(ChannelId channel_id);
void send_get_channel_full_query(ChannelId channel_id, tl_object_ptr<telegram_api::InputChannel> &&input_channel, void send_get_channel_full_query(ChannelId channel_id, tl_object_ptr<telegram_api::InputChannel> &&input_channel,
Promise<Unit> &&promise); Promise<Unit> &&promise, const char *source);
const SecretChat *get_secret_chat(SecretChatId secret_chat_id) const; const SecretChat *get_secret_chat(SecretChatId secret_chat_id) const;
SecretChat *get_secret_chat(SecretChatId secret_chat_id); SecretChat *get_secret_chat(SecretChatId secret_chat_id);