Add source to on_get_user and on_get_chat.

GitOrigin-RevId: a3f187dc0d7d981df6ca3f2566f66678b4ad4774
This commit is contained in:
levlam 2019-01-12 06:48:39 +03:00
parent f0dd4b1bad
commit e22e23a5ff
13 changed files with 136 additions and 129 deletions

View File

@ -918,7 +918,7 @@ void AuthManager::on_authorization(tl_object_ptr<telegram_api::auth_authorizatio
code_.clear();
password_.clear();
state_ = State::Ok;
td->contacts_manager_->on_get_user(std::move(auth->user_), true);
td->contacts_manager_->on_get_user(std::move(auth->user_), "on_authorization", true);
update_state(State::Ok, true);
if (!td->contacts_manager_->get_my_id().is_valid()) {
LOG(ERROR) << "Server doesn't send proper authorization";

View File

@ -242,7 +242,7 @@ void CallActor::update_call(tl_object_ptr<telegram_api::PhoneCall> call) {
void CallActor::update_call_inner(tl_object_ptr<telegram_api::phone_phoneCall> call) {
LOG(INFO) << "Update call with " << to_string(call);
send_closure(G()->contacts_manager(), &ContactsManager::on_get_users, std::move(call->users_));
send_closure(G()->contacts_manager(), &ContactsManager::on_get_users, std::move(call->users_), "UpdatePhoneCall");
update_call(std::move(call->phone_call_));
}

View File

@ -232,7 +232,7 @@ class GetWebAuthorizationsQuery : public Td::ResultHandler {
auto ptr = result_ptr.move_as_ok();
LOG(INFO) << "Receive result for GetWebAuthorizationsQuery: " << to_string(ptr);
td->contacts_manager_->on_get_users(std::move(ptr->users_));
td->contacts_manager_->on_get_users(std::move(ptr->users_), "GetWebAuthorizationsQuery");
auto results = make_tl_object<td_api::connectedWebsites>();
results->websites_.reserve(ptr->authorizations_.size());
@ -389,7 +389,7 @@ class GetBlockedUsersQuery : public Td::ResultHandler {
case telegram_api::contacts_blocked::ID: {
auto blocked_users = move_tl_object_as<telegram_api::contacts_blocked>(ptr);
td->contacts_manager_->on_get_users(std::move(blocked_users->users_));
td->contacts_manager_->on_get_users(std::move(blocked_users->users_), "GetBlockedUsersQuery");
td->contacts_manager_->on_get_blocked_users_result(offset_, limit_, random_id_,
narrow_cast<int32>(blocked_users->blocked_.size()),
std::move(blocked_users->blocked_));
@ -398,7 +398,7 @@ class GetBlockedUsersQuery : public Td::ResultHandler {
case telegram_api::contacts_blockedSlice::ID: {
auto blocked_users = move_tl_object_as<telegram_api::contacts_blockedSlice>(ptr);
td->contacts_manager_->on_get_users(std::move(blocked_users->users_));
td->contacts_manager_->on_get_users(std::move(blocked_users->users_), "GetBlockedUsersQuery");
td->contacts_manager_->on_get_blocked_users_result(offset_, limit_, random_id_, blocked_users->count_,
std::move(blocked_users->blocked_));
break;
@ -506,7 +506,7 @@ class ImportContactsQuery : public Td::ResultHandler {
auto ptr = result_ptr.move_as_ok();
LOG(INFO) << "Receive result for importContacts: " << to_string(ptr);
td->contacts_manager_->on_get_users(std::move(ptr->users_));
td->contacts_manager_->on_get_users(std::move(ptr->users_), "ImportContactsQuery");
for (auto &imported_contact : ptr->imported_) {
int64 client_id = imported_contact->client_id_;
if (client_id < 0 || client_id >= static_cast<int64>(imported_user_ids_.size())) {
@ -689,7 +689,7 @@ class UploadProfilePhotoQuery : public Td::ResultHandler {
auto ptr = result_ptr.move_as_ok();
LOG(INFO) << "Receive result for uploadProfilePhoto: " << to_string(ptr);
td->contacts_manager_->on_get_users(std::move(ptr->users_));
td->contacts_manager_->on_get_users(std::move(ptr->users_), "UploadProfilePhotoQuery");
// ignore ptr->photo_
td->file_manager_->delete_partial_remote_location(file_id_);
@ -797,7 +797,7 @@ class UpdateProfileQuery : public Td::ResultHandler {
}
LOG(DEBUG) << "Receive result for updateProfile " << to_string(result_ptr.ok());
td->contacts_manager_->on_get_user(result_ptr.move_as_ok());
td->contacts_manager_->on_get_user(result_ptr.move_as_ok(), "UpdateProfileQuery");
td->contacts_manager_->on_update_profile_success(flags_, first_name_, last_name_, about_);
promise_.set_value(Unit());
@ -851,7 +851,7 @@ class UpdateUsernameQuery : public Td::ResultHandler {
}
LOG(DEBUG) << "Receive result for updateUsername " << to_string(result_ptr.ok());
td->contacts_manager_->on_get_user(result_ptr.move_as_ok());
td->contacts_manager_->on_get_user(result_ptr.move_as_ok(), "UpdateUsernameQuery");
promise_.set_value(Unit());
}
@ -1852,7 +1852,7 @@ class GetUsersQuery : public Td::ResultHandler {
return on_error(id, result_ptr.move_as_error());
}
td->contacts_manager_->on_get_users(result_ptr.move_as_ok());
td->contacts_manager_->on_get_users(result_ptr.move_as_ok(), "GetUsersQuery");
promise_.set_value(Unit());
}
@ -1919,14 +1919,14 @@ class GetUserPhotosQuery : public Td::ResultHandler {
if (constructor_id == telegram_api::photos_photos::ID) {
auto photos = move_tl_object_as<telegram_api::photos_photos>(ptr);
td->contacts_manager_->on_get_users(std::move(photos->users_));
td->contacts_manager_->on_get_users(std::move(photos->users_), "GetUserPhotosQuery");
int32 photos_size = narrow_cast<int32>(photos->photos_.size());
td->contacts_manager_->on_get_user_photos(user_id_, offset_, limit_, photos_size, std::move(photos->photos_));
} else {
CHECK(constructor_id == telegram_api::photos_photosSlice::ID);
auto photos = move_tl_object_as<telegram_api::photos_photosSlice>(ptr);
td->contacts_manager_->on_get_users(std::move(photos->users_));
td->contacts_manager_->on_get_users(std::move(photos->users_), "GetUserPhotosQuery");
td->contacts_manager_->on_get_user_photos(user_id_, offset_, limit_, photos->count_, std::move(photos->photos_));
}
@ -1960,13 +1960,13 @@ class GetChatsQuery : public Td::ResultHandler {
switch (constructor_id) {
case telegram_api::messages_chats::ID: {
auto chats = move_tl_object_as<telegram_api::messages_chats>(chats_ptr);
td->contacts_manager_->on_get_chats(std::move(chats->chats_));
td->contacts_manager_->on_get_chats(std::move(chats->chats_), "GetChatsQuery");
break;
}
case telegram_api::messages_chatsSlice::ID: {
auto chats = move_tl_object_as<telegram_api::messages_chatsSlice>(chats_ptr);
LOG(ERROR) << "Receive chatsSlice in result of GetChatsQuery";
td->contacts_manager_->on_get_chats(std::move(chats->chats_));
td->contacts_manager_->on_get_chats(std::move(chats->chats_), "GetChatsQuery");
break;
}
default:
@ -1999,8 +1999,8 @@ class GetFullChatQuery : public Td::ResultHandler {
auto ptr = result_ptr.move_as_ok();
// LOG(INFO) << "Receive result for getFullChat query: " << to_string(ptr);
td->contacts_manager_->on_get_users(std::move(ptr->users_));
td->contacts_manager_->on_get_chats(std::move(ptr->chats_));
td->contacts_manager_->on_get_users(std::move(ptr->users_), "GetFullChatQuery");
td->contacts_manager_->on_get_chats(std::move(ptr->chats_), "GetFullChatQuery");
td->contacts_manager_->on_get_chat_full(std::move(ptr->full_chat_));
td->contacts_manager_->on_get_chat_full_success(chat_id_);
@ -2043,13 +2043,13 @@ class GetChannelsQuery : public Td::ResultHandler {
switch (constructor_id) {
case telegram_api::messages_chats::ID: {
auto chats = move_tl_object_as<telegram_api::messages_chats>(chats_ptr);
td->contacts_manager_->on_get_chats(std::move(chats->chats_));
td->contacts_manager_->on_get_chats(std::move(chats->chats_), "GetChannelsQuery");
break;
}
case telegram_api::messages_chatsSlice::ID: {
auto chats = move_tl_object_as<telegram_api::messages_chatsSlice>(chats_ptr);
LOG(ERROR) << "Receive chatsSlice in result of GetChannelsQuery";
td->contacts_manager_->on_get_chats(std::move(chats->chats_));
td->contacts_manager_->on_get_chats(std::move(chats->chats_), "GetChannelsQuery");
break;
}
default:
@ -2083,8 +2083,8 @@ class GetFullChannelQuery : public Td::ResultHandler {
auto ptr = result_ptr.move_as_ok();
// LOG(INFO) << "Receive result for getFullChannel query: " << to_string(ptr);
td->contacts_manager_->on_get_users(std::move(ptr->users_));
td->contacts_manager_->on_get_chats(std::move(ptr->chats_));
td->contacts_manager_->on_get_users(std::move(ptr->users_), "GetFullChannelQuery");
td->contacts_manager_->on_get_chats(std::move(ptr->chats_), "GetFullChannelQuery");
td->contacts_manager_->on_get_chat_full(std::move(ptr->full_chat_));
td->contacts_manager_->on_get_channel_full_success(channel_id_);
@ -2128,7 +2128,7 @@ class GetChannelParticipantQuery : public Td::ResultHandler {
auto participant = result_ptr.move_as_ok();
LOG(INFO) << "Receive result for GetChannelParticipantQuery: " << to_string(participant);
td->contacts_manager_->on_get_users(std::move(participant->users_));
td->contacts_manager_->on_get_users(std::move(participant->users_), "GetChannelParticipantQuery");
promise_.set_value(
td->contacts_manager_->get_dialog_participant(channel_id_, std::move(participant->participant_)));
}
@ -2183,7 +2183,7 @@ class GetChannelParticipantsQuery : public Td::ResultHandler {
switch (participants_ptr->get_id()) {
case telegram_api::channels_channelParticipants::ID: {
auto participants = telegram_api::move_object_as<telegram_api::channels_channelParticipants>(participants_ptr);
td->contacts_manager_->on_get_users(std::move(participants->users_));
td->contacts_manager_->on_get_users(std::move(participants->users_), "GetChannelParticipantsQuery");
td->contacts_manager_->on_get_channel_participants_success(channel_id_, std::move(filter_), offset_, limit_,
random_id_, participants->count_,
std::move(participants->participants_));
@ -2238,7 +2238,7 @@ class GetChannelAdministratorsQuery : public Td::ResultHandler {
switch (participants_ptr->get_id()) {
case telegram_api::channels_channelParticipants::ID: {
auto participants = telegram_api::move_object_as<telegram_api::channels_channelParticipants>(participants_ptr);
td->contacts_manager_->on_get_users(std::move(participants->users_));
td->contacts_manager_->on_get_users(std::move(participants->users_), "GetChannelAdministratorsQuery");
vector<UserId> administrator_user_ids;
administrator_user_ids.reserve(participants->participants_.size());
for (auto &participant : participants->participants_) {
@ -2288,7 +2288,7 @@ class GetSupportUserQuery : public Td::ResultHandler {
auto ptr = result_ptr.move_as_ok();
LOG(INFO) << "Receive result for GetSupportUserQuery: " << to_string(ptr);
td->contacts_manager_->on_get_user(std::move(ptr->user_), false, true);
td->contacts_manager_->on_get_user(std::move(ptr->user_), "GetSupportUserQuery", false, true);
promise_.set_value(Unit());
}
@ -4771,7 +4771,7 @@ void ContactsManager::on_get_created_public_channels(vector<tl_object_ptr<telegr
default:
UNREACHABLE();
}
on_get_chat(std::move(chat));
on_get_chat(std::move(chat), "on_get_created_public_channels");
}
}
@ -4878,7 +4878,7 @@ void ContactsManager::on_get_contacts(tl_object_ptr<telegram_api::contacts_Conta
}
contact_user_ids.insert(user_id);
}
on_get_users(std::move(contacts->users_));
on_get_users(std::move(contacts->users_), "on_get_contacts");
UserId my_id = get_my_id();
for (auto &p : users_) {
@ -4998,7 +4998,7 @@ void ContactsManager::on_update_online_status_privacy() {
void ContactsManager::on_get_contacts_link(tl_object_ptr<telegram_api::contacts_link> &&link) {
UserId user_id = get_user_id(link->user_);
on_get_user(std::move(link->user_));
on_get_user(std::move(link->user_), "on_get_contacts_link");
on_update_user_links(user_id, std::move(link->my_link_), std::move(link->foreign_link_));
}
@ -5041,21 +5041,22 @@ ChannelId ContactsManager::get_channel_id(const tl_object_ptr<telegram_api::Chat
}
}
void ContactsManager::on_get_user(tl_object_ptr<telegram_api::User> &&user_ptr, bool is_me, bool is_support) {
LOG(DEBUG) << "Receive " << to_string(user_ptr);
void ContactsManager::on_get_user(tl_object_ptr<telegram_api::User> &&user_ptr, const char *source, bool is_me,
bool is_support) {
LOG(DEBUG) << "Receive from " << source << ' ' << to_string(user_ptr);
int32 constructor_id = user_ptr->get_id();
if (constructor_id == telegram_api::userEmpty::ID) {
auto user = move_tl_object_as<telegram_api::userEmpty>(user_ptr);
UserId user_id(user->id_);
if (!user_id.is_valid()) {
LOG(ERROR) << "Receive invalid " << user_id;
LOG(ERROR) << "Receive invalid " << user_id << " from " << source;
return;
}
LOG(INFO) << "Receive empty " << user_id;
LOG(INFO) << "Receive empty " << user_id << " from " << source;
User *u = get_user_force(user_id);
if (u == nullptr) {
LOG(ERROR) << "Have no information about " << user_id << ", but received userEmpty";
LOG(ERROR) << "Have no information about " << user_id << ", but received userEmpty from " << source;
}
return;
}
@ -5068,9 +5069,9 @@ void ContactsManager::on_get_user(tl_object_ptr<telegram_api::User> &&user_ptr,
return;
}
int32 flags = user->flags_;
LOG(INFO) << "Receive " << user_id << " with flags " << flags;
LOG(INFO) << "Receive " << user_id << " with flags " << flags << " from " << source;
if (is_me && (flags & USER_FLAG_IS_ME) == 0) {
LOG(ERROR) << user_id << " doesn't have flag IS_ME, but must have it";
LOG(ERROR) << user_id << " doesn't have flag IS_ME, but must have it when received from " << source;
flags |= USER_FLAG_IS_ME;
}
@ -5144,10 +5145,12 @@ void ContactsManager::on_get_user(tl_object_ptr<telegram_api::User> &&user_ptr,
bool need_location_bot = (flags & USER_FLAG_NEED_LOCATION_BOT) != 0;
bool has_bot_info_version = (flags & USER_FLAG_HAS_BOT_INFO_VERSION) != 0;
LOG_IF(ERROR, !can_join_groups && !is_bot) << "Receive not bot which can't join groups";
LOG_IF(ERROR, can_read_all_group_messages && !is_bot) << "Receive not bot which can read all group messages";
LOG_IF(ERROR, is_inline_bot && !is_bot) << "Receive not bot which is inline bot";
LOG_IF(ERROR, need_location_bot && !is_inline_bot) << "Receive not inline bot which needs user location";
LOG_IF(ERROR, !can_join_groups && !is_bot) << "Receive not bot which can't join groups from " << source;
LOG_IF(ERROR, can_read_all_group_messages && !is_bot)
<< "Receive not bot which can read all group messages from " << source;
LOG_IF(ERROR, is_inline_bot && !is_bot) << "Receive not bot which is inline bot from " << source;
LOG_IF(ERROR, need_location_bot && !is_inline_bot)
<< "Receive not inline bot which needs user location from " << source;
if (is_received && !u->is_received) {
u->is_received = true;
@ -5168,14 +5171,14 @@ void ContactsManager::on_get_user(tl_object_ptr<telegram_api::User> &&user_ptr,
has_bot_info_version = false;
}
LOG_IF(ERROR, has_bot_info_version && !is_bot) << "Receive not bot which has bot info version";
LOG_IF(ERROR, has_bot_info_version && !is_bot) << "Receive not bot which has bot info version from " << source;
int32 bot_info_version = has_bot_info_version ? user->bot_info_version_ : -1;
if (is_verified != u->is_verified || is_bot != u->is_bot || can_join_groups != u->can_join_groups ||
can_read_all_group_messages != u->can_read_all_group_messages || restriction_reason != u->restriction_reason ||
is_inline_bot != u->is_inline_bot || inline_query_placeholder != u->inline_query_placeholder ||
need_location_bot != u->need_location_bot) {
LOG_IF(ERROR, is_bot != u->is_bot && !is_deleted && !u->is_deleted) << "User.is_bot has changed";
LOG_IF(ERROR, is_bot != u->is_bot && !is_deleted && !u->is_deleted) << "User.is_bot has changed from " << source;
u->is_verified = is_verified;
u->is_bot = is_bot;
u->can_join_groups = can_join_groups;
@ -5207,7 +5210,7 @@ void ContactsManager::on_get_user(tl_object_ptr<telegram_api::User> &&user_ptr,
}
bool has_language_code = (flags & USER_FLAG_HAS_LANGUAGE_CODE) != 0;
LOG_IF(ERROR, has_language_code && !td_->auth_manager_->is_bot()) << "Receive language code";
LOG_IF(ERROR, has_language_code && !td_->auth_manager_->is_bot()) << "Receive language code from " << source;
if (u->language_code != user->lang_code_ && !user->lang_code_.empty()) {
u->language_code = user->lang_code_;
@ -5443,7 +5446,7 @@ ContactsManager::User *ContactsManager::get_user_force(UserId user_id) {
false /*ignored*/, false /*ignored*/, false /*ignored*/, false /*ignored*/, false /*ignored*/,
false /*ignored*/, 777000, 1, "Telegram", "Updates", string(), "42777", std::move(profile_photo), nullptr, 0,
string(), string(), string());
on_get_user(std::move(user));
on_get_user(std::move(user), "get_user_force");
u = get_user(user_id);
CHECK(u != nullptr && u->is_received);
}
@ -6421,9 +6424,9 @@ void ContactsManager::update_channel_full(ChannelFull *channel_full, ChannelId c
}
}
void ContactsManager::on_get_users(vector<tl_object_ptr<telegram_api::User>> &&users) {
void ContactsManager::on_get_users(vector<tl_object_ptr<telegram_api::User>> &&users, const char *source) {
for (auto &user : users) {
on_get_user(std::move(user));
on_get_user(std::move(user), source);
}
}
@ -6434,7 +6437,7 @@ void ContactsManager::on_get_user_full(tl_object_ptr<telegram_api::userFull> &&u
return;
}
on_get_user(std::move(user_full->user_));
on_get_user(std::move(user_full->user_), "on_get_user_full");
const User *u = get_user(user_id);
if (u == nullptr) {
return;
@ -6572,23 +6575,23 @@ bool ContactsManager::on_update_user_full_bot_info(UserFull *user_full, UserId u
return true;
}
void ContactsManager::on_get_chat(tl_object_ptr<telegram_api::Chat> &&chat) {
LOG(DEBUG) << "Receive " << to_string(chat);
downcast_call(*chat, [this](auto &c) { this->on_chat_update(c); });
void ContactsManager::on_get_chat(tl_object_ptr<telegram_api::Chat> &&chat, const char *source) {
LOG(DEBUG) << "Receive from " << source << ' ' << to_string(chat);
downcast_call(*chat, [this, source](auto &c) { this->on_chat_update(c, source); });
}
void ContactsManager::on_get_chats(vector<tl_object_ptr<telegram_api::Chat>> &&chats) {
void ContactsManager::on_get_chats(vector<tl_object_ptr<telegram_api::Chat>> &&chats, const char *source) {
for (auto &chat : chats) {
auto constuctor_id = chat->get_id();
if (constuctor_id == telegram_api::channel::ID || constuctor_id == telegram_api::channelForbidden::ID) {
// apply info about megagroups before corresponding chats
on_get_chat(std::move(chat));
on_get_chat(std::move(chat), source);
chat = nullptr;
}
}
for (auto &chat : chats) {
if (chat != nullptr) {
on_get_chat(std::move(chat));
on_get_chat(std::move(chat), source);
chat = nullptr;
}
}
@ -7256,7 +7259,7 @@ bool ContactsManager::on_get_channel_error(ChannelId channel_id, const Status &s
}
telegram_api::channelForbidden update(flags, false /*ignored*/, false /*ignored*/, channel_id.get(),
c->access_hash, c->title, 0);
on_chat_update(update);
on_chat_update(update, "CHANNEL_PRIVATE");
} else if (!c->username.empty()) {
LOG(INFO) << "Drop username of " << channel_id;
on_update_channel_username(c, channel_id, "");
@ -7476,7 +7479,7 @@ void ContactsManager::on_get_dialog_invite_link_info(const string &invite_link,
LOG(ERROR) << "Receive invalid " << channel_id;
channel_id = ChannelId();
}
on_get_chat(std::move(chat_invite_already->chat_));
on_get_chat(std::move(chat_invite_already->chat_), "chatInviteAlready");
CHECK(chat_id == ChatId() || channel_id == ChannelId());
invite_link_info->chat_id = chat_id;
@ -7503,7 +7506,7 @@ void ContactsManager::on_get_dialog_invite_link_info(const string &invite_link,
if (!user_id.is_valid()) {
LOG(ERROR) << "Receive invalid " << user_id;
} else {
on_get_user(std::move(user));
on_get_user(std::move(user), "chatInvite");
}
invite_link_info->participant_user_ids.push_back(user_id);
}
@ -9305,30 +9308,30 @@ void ContactsManager::reload_dialog_administrators(DialogId dialog_id, int32 has
}
}
void ContactsManager::on_chat_update(telegram_api::chatEmpty &chat) {
void ContactsManager::on_chat_update(telegram_api::chatEmpty &chat, const char *source) {
ChatId chat_id(chat.id_);
if (!chat_id.is_valid()) {
LOG(ERROR) << "Receive invalid " << chat_id;
LOG(ERROR) << "Receive invalid " << chat_id << " from " << source;
return;
}
if (!have_chat(chat_id)) {
LOG(ERROR) << "Have no information about " << chat_id << " but received chatEmpty";
LOG(ERROR) << "Have no information about " << chat_id << " but received chatEmpty from " << source;
}
}
void ContactsManager::on_chat_update(telegram_api::chat &chat) {
auto debug_str = oneline(to_string(chat));
void ContactsManager::on_chat_update(telegram_api::chat &chat, const char *source) {
auto debug_str = PSTRING() << " from " << source << " in " << oneline(to_string(chat));
ChatId chat_id(chat.id_);
if (!chat_id.is_valid()) {
LOG(ERROR) << "Receive invalid " << chat_id << " in " << debug_str;
LOG(ERROR) << "Receive invalid " << chat_id << debug_str;
return;
}
bool has_left = 0 != (chat.flags_ & CHAT_FLAG_USER_HAS_LEFT);
bool was_kicked = 0 != (chat.flags_ & CHAT_FLAG_USER_WAS_KICKED);
if (was_kicked) {
LOG_IF(ERROR, has_left) << "Kicked and left in " << debug_str; // only one of the flags can be set
LOG_IF(ERROR, has_left) << "Kicked and left" << debug_str; // only one of the flags can be set
has_left = true;
}
@ -9342,7 +9345,7 @@ void ContactsManager::on_chat_update(telegram_api::chat &chat) {
if (chat.flags_ & CHAT_FLAG_WAS_MIGRATED) {
switch (chat.migrated_to_->get_id()) {
case telegram_api::inputChannelEmpty::ID: {
LOG(ERROR) << "Receive empty upgraded to supergroup for " << chat_id << " in " << debug_str;
LOG(ERROR) << "Receive empty upgraded to supergroup for " << chat_id << debug_str;
break;
}
case telegram_api::inputChannel::ID: {
@ -9350,7 +9353,7 @@ void ContactsManager::on_chat_update(telegram_api::chat &chat) {
migrated_to_channel_id = ChannelId(input_channel->channel_id_);
if (!have_channel(migrated_to_channel_id)) {
if (!migrated_to_channel_id.is_valid()) {
LOG(ERROR) << "Receive invalid " << migrated_to_channel_id << " in " << debug_str;
LOG(ERROR) << "Receive invalid " << migrated_to_channel_id << debug_str;
} else {
// temporarily create the channel
Channel *c = add_channel(migrated_to_channel_id, "on_chat_update");
@ -9379,7 +9382,7 @@ void ContactsManager::on_chat_update(telegram_api::chat &chat) {
on_update_chat_participant_count(c, chat_id, chat.participants_count_, chat.version_, debug_str);
}
if (c->date != chat.date_) {
LOG_IF(ERROR, c->date != 0) << "Chat creation date has changed from " << c->date << " to " << chat.date_ << " in "
LOG_IF(ERROR, c->date != 0) << "Chat creation date has changed from " << c->date << " to " << chat.date_
<< debug_str;
c->date = chat.date_;
c->is_changed = true;
@ -9393,10 +9396,10 @@ void ContactsManager::on_chat_update(telegram_api::chat &chat) {
update_chat(c, chat_id);
}
void ContactsManager::on_chat_update(telegram_api::chatForbidden &chat) {
void ContactsManager::on_chat_update(telegram_api::chatForbidden &chat, const char *source) {
ChatId chat_id(chat.id_);
if (!chat_id.is_valid()) {
LOG(ERROR) << "Receive invalid " << chat_id;
LOG(ERROR) << "Receive invalid " << chat_id << " from " << source;
return;
}
@ -9421,16 +9424,16 @@ void ContactsManager::on_chat_update(telegram_api::chatForbidden &chat) {
update_chat(c, chat_id);
}
void ContactsManager::on_chat_update(telegram_api::channel &channel) {
void ContactsManager::on_chat_update(telegram_api::channel &channel, const char *source) {
ChannelId channel_id(channel.id_);
if (!channel_id.is_valid()) {
LOG(ERROR) << "Receive invalid " << channel_id << ": " << to_string(channel);
LOG(ERROR) << "Receive invalid " << channel_id << " from " << source << ": " << to_string(channel);
return;
}
if (channel.flags_ == 0 && channel.access_hash_ == 0 && channel.title_.empty()) {
Channel *c = get_channel_force(channel_id);
LOG(ERROR) << "Receive empty " << to_string(channel) << ", have "
LOG(ERROR) << "Receive empty " << to_string(channel) << " from " << source << ", have "
<< to_string(get_supergroup_object(channel_id, c));
if (c == nullptr) {
min_channels_.insert(channel_id);
@ -9453,17 +9456,17 @@ void ContactsManager::on_chat_update(telegram_api::channel &channel) {
{
bool is_broadcast = (channel.flags_ & CHANNEL_FLAG_IS_BROADCAST) != 0;
LOG_IF(ERROR, is_broadcast == is_megagroup)
<< "Receive wrong channel flag is_broadcast == is_megagroup == " << is_megagroup << ": "
<< "Receive wrong channel flag is_broadcast == is_megagroup == " << is_megagroup << " from " << source << ": "
<< oneline(to_string(channel));
}
if (!is_megagroup && anyone_can_invite) {
LOG(ERROR) << "Anyone can invite new members to the " << channel_id;
LOG(ERROR) << "Anyone can invite new members to the " << channel_id << " from " << source;
anyone_can_invite = false;
}
if (is_megagroup) {
LOG_IF(ERROR, sign_messages) << "Need to sign messages in the supergroup " << channel_id;
LOG_IF(ERROR, sign_messages) << "Need to sign messages in the supergroup " << channel_id << " from " << source;
sign_messages = true;
}
@ -9510,7 +9513,7 @@ void ContactsManager::on_chat_update(telegram_api::channel &channel) {
return;
}
if (!has_access_hash) {
LOG(ERROR) << "Receive non-min " << channel_id << " without access_hash";
LOG(ERROR) << "Receive non-min " << channel_id << " without access_hash from " << source;
return;
}
@ -9551,16 +9554,16 @@ void ContactsManager::on_chat_update(telegram_api::channel &channel) {
update_channel(c, channel_id);
}
void ContactsManager::on_chat_update(telegram_api::channelForbidden &channel) {
void ContactsManager::on_chat_update(telegram_api::channelForbidden &channel, const char *source) {
ChannelId channel_id(channel.id_);
if (!channel_id.is_valid()) {
LOG(ERROR) << "Receive invalid " << channel_id << ": " << to_string(channel);
LOG(ERROR) << "Receive invalid " << channel_id << " from " << source << ": " << to_string(channel);
return;
}
if (channel.flags_ == 0 && channel.access_hash_ == 0 && channel.title_.empty()) {
Channel *c = get_channel_force(channel_id);
LOG(ERROR) << "Receive empty " << to_string(channel) << ", have "
LOG(ERROR) << "Receive empty " << to_string(channel) << " from " << source << ", have "
<< to_string(get_supergroup_object(channel_id, c));
if (c == nullptr) {
min_channels_.insert(channel_id);
@ -9595,7 +9598,7 @@ void ContactsManager::on_chat_update(telegram_api::channelForbidden &channel) {
{
bool is_broadcast = (channel.flags_ & CHANNEL_FLAG_IS_BROADCAST) != 0;
LOG_IF(ERROR, is_broadcast == is_megagroup)
<< "Receive wrong channel flag is_broadcast == is_megagroup == " << is_megagroup << ": "
<< "Receive wrong channel flag is_broadcast == is_megagroup == " << is_megagroup << " from " << source << ": "
<< oneline(to_string(channel));
}

View File

@ -125,8 +125,9 @@ class ContactsManager : public Actor {
void on_get_contacts_link(tl_object_ptr<telegram_api::contacts_link> &&link);
void on_get_user(tl_object_ptr<telegram_api::User> &&user, bool is_me = false, bool is_support = false);
void on_get_users(vector<tl_object_ptr<telegram_api::User>> &&users);
void on_get_user(tl_object_ptr<telegram_api::User> &&user, const char *source, bool is_me = false,
bool is_support = false);
void on_get_users(vector<tl_object_ptr<telegram_api::User>> &&users, const char *source);
void on_binlog_user_event(BinlogEvent &&event);
void on_binlog_chat_event(BinlogEvent &&event);
@ -138,8 +139,8 @@ class ContactsManager : public Actor {
void on_get_user_photos(UserId user_id, int32 offset, int32 limit, int32 total_count,
vector<tl_object_ptr<telegram_api::Photo>> photos);
void on_get_chat(tl_object_ptr<telegram_api::Chat> &&chat);
void on_get_chats(vector<tl_object_ptr<telegram_api::Chat>> &&chats);
void on_get_chat(tl_object_ptr<telegram_api::Chat> &&chat, const char *source);
void on_get_chats(vector<tl_object_ptr<telegram_api::Chat>> &&chats, const char *source);
void on_get_chat_full(tl_object_ptr<telegram_api::ChatFull> &&chat_full);
@ -888,11 +889,11 @@ class ContactsManager : public Actor {
void invalidate_chat_full(ChatId chat_id);
void on_chat_update(telegram_api::chatEmpty &chat);
void on_chat_update(telegram_api::chat &chat);
void on_chat_update(telegram_api::chatForbidden &chat);
void on_chat_update(telegram_api::channel &channel);
void on_chat_update(telegram_api::channelForbidden &channel);
void on_chat_update(telegram_api::chatEmpty &chat, const char *source);
void on_chat_update(telegram_api::chat &chat, const char *source);
void on_chat_update(telegram_api::chatForbidden &chat, const char *source);
void on_chat_update(telegram_api::channel &channel, const char *source);
void on_chat_update(telegram_api::channelForbidden &channel, const char *source);
void save_user(User *u, UserId user_id, bool from_binlog);
static string get_user_database_key(UserId user_id);

View File

@ -1107,7 +1107,7 @@ void InlineQueriesManager::on_get_inline_query_results(UserId bot_user_id, uint6
}
LOG(INFO) << to_string(results);
td_->contacts_manager_->on_get_users(std::move(results->users_));
td_->contacts_manager_->on_get_users(std::move(results->users_), "on_get_inline_query_results");
vector<tl_object_ptr<td_api::InlineQueryResult>> output_results;
for (auto &result_ptr : results->results_) {

View File

@ -98,8 +98,8 @@ class GetDialogQuery : public Td::ResultHandler {
auto result = result_ptr.move_as_ok();
LOG(INFO) << "Receive chat: " << to_string(result);
td->contacts_manager_->on_get_users(std::move(result->users_));
td->contacts_manager_->on_get_chats(std::move(result->chats_));
td->contacts_manager_->on_get_users(std::move(result->users_), "GetDialogQuery");
td->contacts_manager_->on_get_chats(std::move(result->chats_), "GetDialogQuery");
td->messages_manager_->on_get_dialogs(
std::move(result->dialogs_), -1, std::move(result->messages_),
PromiseCreator::lambda([td = td, dialog_id = dialog_id_](Result<> result) {
@ -145,8 +145,8 @@ class GetPinnedDialogsQuery : public NetActorOnce {
auto result = result_ptr.move_as_ok();
LOG(INFO) << "Receive pinned chats: " << to_string(result);
td->contacts_manager_->on_get_users(std::move(result->users_));
td->contacts_manager_->on_get_chats(std::move(result->chats_));
td->contacts_manager_->on_get_users(std::move(result->users_), "GetPinnedDialogsQuery");
td->contacts_manager_->on_get_chats(std::move(result->chats_), "GetPinnedDialogsQuery");
std::reverse(result->dialogs_.begin(), result->dialogs_.end());
td->messages_manager_->on_get_dialogs(std::move(result->dialogs_), -2, std::move(result->messages_),
std::move(promise_));
@ -381,8 +381,8 @@ class GetDialogListQuery : public NetActorOnce {
switch (ptr->get_id()) {
case telegram_api::messages_dialogs::ID: {
auto dialogs = move_tl_object_as<telegram_api::messages_dialogs>(ptr);
td->contacts_manager_->on_get_users(std::move(dialogs->users_));
td->contacts_manager_->on_get_chats(std::move(dialogs->chats_));
td->contacts_manager_->on_get_users(std::move(dialogs->users_), "GetDialogListQuery");
td->contacts_manager_->on_get_chats(std::move(dialogs->chats_), "GetDialogListQuery");
td->messages_manager_->on_get_dialogs(std::move(dialogs->dialogs_),
narrow_cast<int32>(dialogs->dialogs_.size()),
std::move(dialogs->messages_), std::move(promise_));
@ -390,8 +390,8 @@ class GetDialogListQuery : public NetActorOnce {
}
case telegram_api::messages_dialogsSlice::ID: {
auto dialogs = move_tl_object_as<telegram_api::messages_dialogsSlice>(ptr);
td->contacts_manager_->on_get_users(std::move(dialogs->users_));
td->contacts_manager_->on_get_chats(std::move(dialogs->chats_));
td->contacts_manager_->on_get_users(std::move(dialogs->users_), "GetDialogListQuery");
td->contacts_manager_->on_get_chats(std::move(dialogs->chats_), "GetDialogListQuery");
td->messages_manager_->on_get_dialogs(std::move(dialogs->dialogs_), max(dialogs->count_, 0),
std::move(dialogs->messages_), std::move(promise_));
break;
@ -427,8 +427,8 @@ class SearchPublicDialogsQuery : public Td::ResultHandler {
auto dialogs = result_ptr.move_as_ok();
LOG(INFO) << "Receive result for SearchPublicDialogsQuery " << to_string(dialogs);
td->contacts_manager_->on_get_users(std::move(dialogs->users_));
td->contacts_manager_->on_get_chats(std::move(dialogs->chats_));
td->contacts_manager_->on_get_users(std::move(dialogs->users_), "SearchPublicDialogsQuery");
td->contacts_manager_->on_get_chats(std::move(dialogs->chats_), "SearchPublicDialogsQuery");
td->messages_manager_->on_get_public_dialogs_search_result(query_, std::move(dialogs->my_results_),
std::move(dialogs->results_));
}
@ -3164,8 +3164,8 @@ class ResolveUsernameQuery : public Td::ResultHandler {
auto ptr = result_ptr.move_as_ok();
LOG(DEBUG) << "Receive result for resolveUsername " << to_string(ptr);
td->contacts_manager_->on_get_users(std::move(ptr->users_));
td->contacts_manager_->on_get_chats(std::move(ptr->chats_));
td->contacts_manager_->on_get_users(std::move(ptr->users_), "ResolveUsernameQuery");
td->contacts_manager_->on_get_chats(std::move(ptr->chats_), "ResolveUsernameQuery");
td->messages_manager_->on_resolved_username(username_, DialogId(ptr->peer_));
@ -6497,8 +6497,8 @@ MessagesManager::MessagesInfo MessagesManager::on_get_messages(
break;
}
td_->contacts_manager_->on_get_users(std::move(users));
td_->contacts_manager_->on_get_chats(std::move(chats));
td_->contacts_manager_->on_get_users(std::move(users), source);
td_->contacts_manager_->on_get_chats(std::move(chats), source);
return result;
}
@ -6850,7 +6850,7 @@ void MessagesManager::on_get_dialog_messages_search_result(DialogId dialog_id, c
}
for (auto &message : messages) {
auto new_message = on_get_message(std::move(message), false, dialog_id.get_type() == DialogType::Channel, false,
false, "search chat messages");
false, "SearchMessagesQuery");
if (new_message != FullMessageId()) {
if (new_message.get_dialog_id() != dialog_id) {
LOG(ERROR) << "Receive " << new_message << " instead of a message in " << dialog_id;
@ -11399,7 +11399,7 @@ void MessagesManager::on_get_common_dialogs(UserId user_id, vector<tl_object_ptr
UNREACHABLE();
}
CHECK(dialog_id.is_valid());
td_->contacts_manager_->on_get_chat(std::move(chat));
td_->contacts_manager_->on_get_chat(std::move(chat), "on_get_common_dialogs");
if (std::find(result.begin(), result.end(), dialog_id) == result.end()) {
force_create_dialog(dialog_id, "get common dialogs");
@ -16853,7 +16853,7 @@ void MessagesManager::on_get_game_high_scores(int64 random_id,
return;
}
td_->contacts_manager_->on_get_users(std::move(high_scores->users_));
td_->contacts_manager_->on_get_users(std::move(high_scores->users_), "on_get_game_high_scores");
result = make_tl_object<td_api::gameHighScores>();
@ -20543,8 +20543,8 @@ void MessagesManager::on_get_event_log(int64 random_id,
LOG(INFO) << "Receive " << to_string(events);
td_->contacts_manager_->on_get_users(std::move(events->users_));
td_->contacts_manager_->on_get_chats(std::move(events->chats_));
td_->contacts_manager_->on_get_users(std::move(events->users_), "on_get_event_log");
td_->contacts_manager_->on_get_chats(std::move(events->chats_), "on_get_event_log");
result = make_tl_object<td_api::chatEvents>();
result->events_.reserve(events->events_.size());
@ -23280,8 +23280,8 @@ void MessagesManager::on_get_channel_difference(
new_pts = request_pts + 1;
}
td_->contacts_manager_->on_get_users(std::move(difference->users_));
td_->contacts_manager_->on_get_chats(std::move(difference->chats_));
td_->contacts_manager_->on_get_users(std::move(difference->users_), "updates.channelDifference");
td_->contacts_manager_->on_get_chats(std::move(difference->chats_), "updates.channelDifference");
process_get_channel_difference_updates(dialog_id, std::move(difference->new_messages_),
std::move(difference->other_updates_));
@ -23308,8 +23308,8 @@ void MessagesManager::on_get_channel_difference(
}
}
td_->contacts_manager_->on_get_users(std::move(difference->users_));
td_->contacts_manager_->on_get_chats(std::move(difference->chats_));
td_->contacts_manager_->on_get_users(std::move(difference->users_), "updates.channelDifferenceTooLong");
td_->contacts_manager_->on_get_chats(std::move(difference->chats_), "updates.channelDifferenceTooLong");
on_get_channel_dialog(dialog_id, MessageId(ServerMessageId(difference->top_message_)),
MessageId(ServerMessageId(difference->read_inbox_max_id_)), difference->unread_count_,
@ -24400,8 +24400,8 @@ void MessagesManager::on_get_sponsored_dialog_id(tl_object_ptr<telegram_api::Pee
return;
}
td_->contacts_manager_->on_get_users(std::move(users));
td_->contacts_manager_->on_get_chats(std::move(chats));
td_->contacts_manager_->on_get_users(std::move(users), "on_get_sponsored_dialog_id");
td_->contacts_manager_->on_get_chats(std::move(chats), "on_get_sponsored_dialog_id");
set_sponsored_dialog_id(DialogId(peer));
}

View File

@ -271,7 +271,7 @@ class GetPaymentFormQuery : public Td::ResultHandler {
auto payment_form = result_ptr.move_as_ok();
LOG(INFO) << "Receive payment form: " << to_string(payment_form);
td->contacts_manager_->on_get_users(std::move(payment_form->users_));
td->contacts_manager_->on_get_users(std::move(payment_form->users_), "GetPaymentFormQuery");
bool can_save_credentials =
(payment_form->flags_ & telegram_api::payments_paymentForm::CAN_SAVE_CREDENTIALS_MASK) != 0;
@ -404,7 +404,7 @@ class GetPaymentReceiptQuery : public Td::ResultHandler {
auto payment_receipt = result_ptr.move_as_ok();
LOG(INFO) << "Receive payment receipt: " << to_string(payment_receipt);
td->contacts_manager_->on_get_users(std::move(payment_receipt->users_));
td->contacts_manager_->on_get_users(std::move(payment_receipt->users_), "GetPaymentReceiptQuery");
UserId payments_provider_user_id(payment_receipt->provider_id_);
if (!payments_provider_user_id.is_valid()) {

View File

@ -211,7 +211,7 @@ vector<int32> PrivacyManager::UserPrivacySettingRule::user_ids_as_td_api() const
Result<PrivacyManager::UserPrivacySettingRules> PrivacyManager::UserPrivacySettingRules::from_telegram_api(
tl_object_ptr<telegram_api::account_privacyRules> rules) {
G()->td().get_actor_unsafe()->contacts_manager_->on_get_users(std::move(rules->users_));
G()->td().get_actor_unsafe()->contacts_manager_->on_get_users(std::move(rules->users_), "on get privacy rules");
return from_telegram_api(std::move(rules->rules_));
}

View File

@ -927,7 +927,8 @@ void SecureManager::on_get_passport_authorization_form(
auto authorization_form = r_authorization_form.move_as_ok();
LOG(INFO) << "Receive " << to_string(authorization_form);
G()->td().get_actor_unsafe()->contacts_manager_->on_get_users(std::move(authorization_form->users_));
G()->td().get_actor_unsafe()->contacts_manager_->on_get_users(std::move(authorization_form->users_),
"on_get_passport_authoriation_form");
vector<vector<SuitableSecureValue>> required_types;
std::map<SecureValueType, SuitableSecureValue> all_types;

View File

@ -223,8 +223,8 @@ class GetRecentMeUrlsQuery : public Td::ResultHandler {
}
auto urls_full = result_ptr.move_as_ok();
td->contacts_manager_->on_get_users(std::move(urls_full->users_));
td->contacts_manager_->on_get_chats(std::move(urls_full->chats_));
td->contacts_manager_->on_get_users(std::move(urls_full->users_), "GetRecentMeUrlsQuery");
td->contacts_manager_->on_get_chats(std::move(urls_full->chats_), "GetRecentMeUrlsQuery");
auto urls = std::move(urls_full->urls_);
auto results = make_tl_object<td_api::tMeUrls>();

View File

@ -417,8 +417,10 @@ void TopDialogManager::on_result(NetQueryPtr net_query) {
set_is_enabled(true); // apply immediately
auto top_peers = move_tl_object_as<telegram_api::contacts_topPeers>(std::move(top_peers_parent));
send_closure(G()->contacts_manager(), &ContactsManager::on_get_users, std::move(top_peers->users_));
send_closure(G()->contacts_manager(), &ContactsManager::on_get_chats, std::move(top_peers->chats_));
send_closure(G()->contacts_manager(), &ContactsManager::on_get_users, std::move(top_peers->users_),
"on get top chats");
send_closure(G()->contacts_manager(), &ContactsManager::on_get_chats, std::move(top_peers->chats_),
"on get top chats");
for (auto &category : top_peers->categories_) {
auto dialog_category = top_dialog_category_from_telegram_api(*category->category_);
auto pos = static_cast<size_t>(dialog_category);

View File

@ -710,16 +710,16 @@ void UpdatesManager::on_get_updates(tl_object_ptr<telegram_api::Updates> &&updat
}
case telegram_api::updatesCombined::ID: {
auto updates = move_tl_object_as<telegram_api::updatesCombined>(updates_ptr);
td_->contacts_manager_->on_get_users(std::move(updates->users_));
td_->contacts_manager_->on_get_chats(std::move(updates->chats_));
td_->contacts_manager_->on_get_users(std::move(updates->users_), "updatesCombined");
td_->contacts_manager_->on_get_chats(std::move(updates->chats_), "updatesCombined");
on_pending_updates(std::move(updates->updates_), updates->seq_start_, updates->seq_, updates->date_,
"telegram_api::updatesCombined");
break;
}
case telegram_api::updates::ID: {
auto updates = move_tl_object_as<telegram_api::updates>(updates_ptr);
td_->contacts_manager_->on_get_users(std::move(updates->users_));
td_->contacts_manager_->on_get_chats(std::move(updates->chats_));
td_->contacts_manager_->on_get_users(std::move(updates->users_), "updates");
td_->contacts_manager_->on_get_chats(std::move(updates->chats_), "updates");
on_pending_updates(std::move(updates->updates_), updates->seq_, updates->seq_, updates->date_,
"telegram_api::updates");
break;
@ -1000,8 +1000,8 @@ void UpdatesManager::on_get_difference(tl_object_ptr<telegram_api::updates_Diffe
auto difference = move_tl_object_as<telegram_api::updates_difference>(difference_ptr);
VLOG(get_difference) << "In get difference receive " << difference->users_.size() << " users and "
<< difference->chats_.size() << " chats";
td_->contacts_manager_->on_get_users(std::move(difference->users_));
td_->contacts_manager_->on_get_chats(std::move(difference->chats_));
td_->contacts_manager_->on_get_users(std::move(difference->users_), "updates.difference");
td_->contacts_manager_->on_get_chats(std::move(difference->chats_), "updates.difference");
set_state(State::Type::ApplyingDifference);
@ -1025,8 +1025,8 @@ void UpdatesManager::on_get_difference(tl_object_ptr<telegram_api::updates_Diffe
VLOG(get_difference) << "In get difference receive " << difference->users_.size() << " users and "
<< difference->chats_.size() << " chats";
td_->contacts_manager_->on_get_users(std::move(difference->users_));
td_->contacts_manager_->on_get_chats(std::move(difference->chats_));
td_->contacts_manager_->on_get_users(std::move(difference->users_), "updates.differenceSlice");
td_->contacts_manager_->on_get_chats(std::move(difference->chats_), "updates.differenceSlice");
set_state(State::Type::ApplyingDifferenceSlice);

View File

@ -2491,7 +2491,7 @@ unique_ptr<WebPagesManager::PageBlock> WebPagesManager::get_page_block(
}
if (td_->contacts_manager_->have_channel_force(channel_id)) {
td_->contacts_manager_->on_get_chat(std::move(page_block->channel_));
td_->contacts_manager_->on_get_chat(std::move(page_block->channel_), "pageBlockChannel");
LOG(INFO) << "Receive known min " << channel_id;
return td::make_unique<PageBlockChatLink>(td_->contacts_manager_->get_channel_title(channel_id),
*td_->contacts_manager_->get_channel_dialog_photo(channel_id),