Drop UserFull photos, only if they are unknown.

This commit is contained in:
levlam 2022-12-26 22:11:14 +03:00
parent 3bb9e06f62
commit 206c8275f9

View File

@ -12665,9 +12665,11 @@ void ContactsManager::on_update_user_photo(User *u, UserId user_id,
old_photo = std::move(photo);
drop_user_photos(user_id, new_photo_id == 0, "on_update_user_photo");
// we didn't sent updateUser yet, so we must not sent updateUserFull with new_photo_id yet
drop_user_full_photos(get_user_full(user_id), user_id, 0,
"on_update_user_photo"); // must not load UserFull
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;
}
@ -12698,9 +12700,11 @@ void ContactsManager::do_update_user_photo(User *u, UserId user_id, ProfilePhoto
if (invalidate_photo_cache) {
drop_user_photos(user_id, u->photo.id == 0, source);
}
// we didn't sent updateUser yet, so we must not sent updateUserFull with u->photo.id yet
drop_user_full_photos(get_user_full(user_id), user_id, 0,
"do_update_user_photo"); // must not load UserFull
auto user_full = get_user_full(user_id); // must not load UserFull
if (user_full != nullptr && u->photo.id != get_user_full_profile_photo_id(user_full)) {
// we didn't sent updateUser yet, so we must not sent updateUserFull with u->photo.id yet
drop_user_full_photos(user_full, user_id, 0, "do_update_user_photo");
}
} else if (need_update_dialog_photo_minithumbnail(u->photo.minithumbnail, new_photo.minithumbnail)) {
LOG(DEBUG) << "Photo minithumbnail has changed for " << user_id << " from " << source;
u->photo.minithumbnail = std::move(new_photo.minithumbnail);