Immediately ignore user photo if it's identifier is still the same.
This commit is contained in:
parent
b41bb654e4
commit
6c5c26db7f
@ -13145,29 +13145,37 @@ void ContactsManager::on_update_user_phone_number(User *u, UserId user_id, strin
|
|||||||
|
|
||||||
void ContactsManager::on_update_user_photo(User *u, UserId user_id,
|
void ContactsManager::on_update_user_photo(User *u, UserId user_id,
|
||||||
tl_object_ptr<telegram_api::UserProfilePhoto> &&photo, const char *source) {
|
tl_object_ptr<telegram_api::UserProfilePhoto> &&photo, const char *source) {
|
||||||
if (td_->auth_manager_->is_bot() && !G()->use_chat_info_database() && !u->is_photo_inited) {
|
if (td_->auth_manager_->is_bot() && !G()->use_chat_info_database()) {
|
||||||
if (photo != nullptr && photo->get_id() == telegram_api::userProfilePhoto::ID) {
|
if (!u->is_photo_inited) {
|
||||||
auto *profile_photo = static_cast<telegram_api::userProfilePhoto *>(photo.get());
|
if (photo != nullptr && photo->get_id() == telegram_api::userProfilePhoto::ID) {
|
||||||
if ((profile_photo->flags_ & telegram_api::userProfilePhoto::STRIPPED_THUMB_MASK) != 0) {
|
auto *profile_photo = static_cast<telegram_api::userProfilePhoto *>(photo.get());
|
||||||
profile_photo->flags_ -= telegram_api::userProfilePhoto::STRIPPED_THUMB_MASK;
|
if ((profile_photo->flags_ & telegram_api::userProfilePhoto::STRIPPED_THUMB_MASK) != 0) {
|
||||||
profile_photo->stripped_thumb_ = BufferSlice();
|
profile_photo->flags_ -= telegram_api::userProfilePhoto::STRIPPED_THUMB_MASK;
|
||||||
|
profile_photo->stripped_thumb_ = BufferSlice();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
auto &old_photo = pending_user_photos_[user_id];
|
||||||
|
if (!LOG_IS_STRIPPED(ERROR) && to_string(old_photo) == to_string(photo)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
auto new_photo_id = get_profile_photo_id(photo);
|
||||||
|
old_photo = std::move(photo);
|
||||||
|
|
||||||
|
drop_user_photos(user_id, new_photo_id == 0, "on_update_user_photo");
|
||||||
|
auto user_full = get_user_full(user_id); // must not load UserFull
|
||||||
|
if (user_full != nullptr && new_photo_id != get_user_full_profile_photo_id(user_full)) {
|
||||||
|
// we didn't sent updateUser yet, so we must not sent updateUserFull with new_photo_id yet
|
||||||
|
drop_user_full_photos(user_full, user_id, 0, "on_update_user_photo");
|
||||||
}
|
}
|
||||||
}
|
|
||||||
auto &old_photo = pending_user_photos_[user_id];
|
|
||||||
if (!LOG_IS_STRIPPED(ERROR) && to_string(old_photo) == to_string(photo)) {
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
if (u->is_received) {
|
||||||
auto new_photo_id = get_profile_photo_id(photo);
|
auto new_photo_id = get_profile_photo_id(photo);
|
||||||
old_photo = std::move(photo);
|
if (new_photo_id == u->photo.id) {
|
||||||
|
return;
|
||||||
drop_user_photos(user_id, new_photo_id == 0, "on_update_user_photo");
|
}
|
||||||
auto user_full = get_user_full(user_id); // must not load UserFull
|
|
||||||
if (user_full != nullptr && new_photo_id != get_user_full_profile_photo_id(user_full)) {
|
|
||||||
// we didn't sent updateUser yet, so we must not sent updateUserFull with new_photo_id yet
|
|
||||||
drop_user_full_photos(user_full, user_id, 0, "on_update_user_photo");
|
|
||||||
}
|
}
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
do_update_user_photo(u, user_id, std::move(photo), source);
|
do_update_user_photo(u, user_id, std::move(photo), source);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user