Delay applying user photos for bots.
GitOrigin-RevId: ee32e9f6e9445f439a5a21cafe1b726be86a0503
This commit is contained in:
parent
deed26ee04
commit
ed06ae67f4
@ -2904,11 +2904,18 @@ tl_object_ptr<telegram_api::inputEncryptedChat> ContactsManager::get_input_encry
|
||||
return make_tl_object<telegram_api::inputEncryptedChat>(secret_chat_id.get(), sc->access_hash);
|
||||
}
|
||||
|
||||
const DialogPhoto *ContactsManager::get_user_dialog_photo(UserId user_id) const {
|
||||
const DialogPhoto *ContactsManager::get_user_dialog_photo(UserId user_id) {
|
||||
auto u = get_user(user_id);
|
||||
if (u == nullptr) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
auto it = pending_user_photos_.find(user_id);
|
||||
if (it != pending_user_photos_.end()) {
|
||||
do_update_user_photo(u, user_id, std::move(it->second));
|
||||
pending_user_photos_.erase(it);
|
||||
update_user(u, user_id);
|
||||
}
|
||||
return &u->photo;
|
||||
}
|
||||
|
||||
@ -2928,7 +2935,7 @@ const DialogPhoto *ContactsManager::get_channel_dialog_photo(ChannelId channel_i
|
||||
return &c->photo;
|
||||
}
|
||||
|
||||
const DialogPhoto *ContactsManager::get_secret_chat_dialog_photo(SecretChatId secret_chat_id) const {
|
||||
const DialogPhoto *ContactsManager::get_secret_chat_dialog_photo(SecretChatId secret_chat_id) {
|
||||
auto c = get_secret_chat(secret_chat_id);
|
||||
if (c == nullptr) {
|
||||
return nullptr;
|
||||
@ -6669,8 +6676,31 @@ void ContactsManager::on_update_user_photo(UserId user_id, tl_object_ptr<telegra
|
||||
}
|
||||
|
||||
void ContactsManager::on_update_user_photo(User *u, UserId user_id,
|
||||
tl_object_ptr<telegram_api::UserProfilePhoto> &&photo_ptr) {
|
||||
ProfilePhoto new_photo = get_profile_photo(td_->file_manager_.get(), std::move(photo_ptr));
|
||||
tl_object_ptr<telegram_api::UserProfilePhoto> &&photo) {
|
||||
if (td_->auth_manager_->is_bot() && !G()->parameters().use_file_db && !u->is_photo_inited) {
|
||||
bool is_empty = photo == nullptr || photo->get_id() == telegram_api::userProfilePhotoEmpty::ID;
|
||||
pending_user_photos_[user_id] = std::move(photo);
|
||||
|
||||
UserFull *user_full = get_user_full(user_id);
|
||||
if (user_full != nullptr) {
|
||||
user_full->photos.clear();
|
||||
if (is_empty) {
|
||||
user_full->photo_count = 0;
|
||||
} else {
|
||||
user_full->photo_count = -1;
|
||||
}
|
||||
user_full->photos_offset = user_full->photo_count;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
do_update_user_photo(u, user_id, std::move(photo));
|
||||
}
|
||||
|
||||
void ContactsManager::do_update_user_photo(User *u, UserId user_id,
|
||||
tl_object_ptr<telegram_api::UserProfilePhoto> &&photo) {
|
||||
u->is_photo_inited = true;
|
||||
ProfilePhoto new_photo = get_profile_photo(td_->file_manager_.get(), std::move(photo));
|
||||
|
||||
if (new_photo != u->photo) {
|
||||
u->photo = new_photo;
|
||||
|
@ -85,10 +85,10 @@ class ContactsManager : public Actor {
|
||||
AccessRights access_rights) const;
|
||||
bool have_input_encrypted_peer(SecretChatId secret_chat_id, AccessRights access_rights) const;
|
||||
|
||||
const DialogPhoto *get_user_dialog_photo(UserId user_id) const;
|
||||
const DialogPhoto *get_user_dialog_photo(UserId user_id);
|
||||
const DialogPhoto *get_chat_dialog_photo(ChatId chat_id) const;
|
||||
const DialogPhoto *get_channel_dialog_photo(ChannelId channel_id) const;
|
||||
const DialogPhoto *get_secret_chat_dialog_photo(SecretChatId secret_chat_id) const;
|
||||
const DialogPhoto *get_secret_chat_dialog_photo(SecretChatId secret_chat_id);
|
||||
|
||||
string get_user_title(UserId user_id) const;
|
||||
string get_chat_title(ChatId chat_id) const;
|
||||
@ -465,6 +465,8 @@ class ContactsManager : public Actor {
|
||||
bool is_inline_bot = false;
|
||||
bool need_location_bot = false;
|
||||
|
||||
bool is_photo_inited = false;
|
||||
|
||||
bool is_name_changed = true;
|
||||
bool is_username_changed = true;
|
||||
bool is_photo_changed = true;
|
||||
@ -819,10 +821,12 @@ class ContactsManager : public Actor {
|
||||
|
||||
void on_update_user_name(User *u, UserId user_id, string &&first_name, string &&last_name, string &&username);
|
||||
void on_update_user_phone_number(User *u, UserId user_id, string &&phone_number);
|
||||
void on_update_user_photo(User *u, UserId user_id, tl_object_ptr<telegram_api::UserProfilePhoto> &&photo_ptr);
|
||||
void on_update_user_photo(User *u, UserId user_id, tl_object_ptr<telegram_api::UserProfilePhoto> &&photo);
|
||||
void on_update_user_online(User *u, UserId user_id, tl_object_ptr<telegram_api::UserStatus> &&status);
|
||||
void on_update_user_links(User *u, UserId user_id, LinkState outbound, LinkState inbound);
|
||||
|
||||
void do_update_user_photo(User *u, UserId user_id, tl_object_ptr<telegram_api::UserProfilePhoto> &&photo);
|
||||
|
||||
void on_update_user_full_is_blocked(UserFull *user_full, UserId user_id, bool is_blocked);
|
||||
bool on_update_user_full_bot_info(UserFull *user_full, UserId user_id, int32 bot_info_version,
|
||||
tl_object_ptr<telegram_api::botInfo> &&bot_info);
|
||||
@ -1013,6 +1017,7 @@ class ContactsManager : public Actor {
|
||||
std::unordered_map<UserId, User, UserIdHash> users_;
|
||||
std::unordered_map<UserId, UserFull, UserIdHash> users_full_;
|
||||
mutable std::unordered_set<UserId, UserIdHash> unknown_users_;
|
||||
std::unordered_map<UserId, tl_object_ptr<telegram_api::UserProfilePhoto>, UserIdHash> pending_user_photos_;
|
||||
|
||||
std::unordered_map<ChatId, Chat, ChatIdHash> chats_;
|
||||
std::unordered_map<ChatId, ChatFull, ChatIdHash> chats_full_;
|
||||
|
Reference in New Issue
Block a user