Explicitly call drop_user_full_photos.
This commit is contained in:
parent
252df2ff43
commit
a80794ffeb
@ -11972,7 +11972,7 @@ void ContactsManager::on_get_user_full(tl_object_ptr<telegram_api::userFull> &&u
|
|||||||
register_user_photo(u, user_id, user_full->fallback_photo);
|
register_user_photo(u, user_id, user_full->fallback_photo);
|
||||||
}
|
}
|
||||||
if (photo_ptr->is_empty()) {
|
if (photo_ptr->is_empty()) {
|
||||||
drop_user_photos(user_id, true, false, "on_get_user_full");
|
drop_user_photos(user_id, true, "on_get_user_full");
|
||||||
}
|
}
|
||||||
|
|
||||||
// User must be updated before UserFull
|
// User must be updated before UserFull
|
||||||
@ -12650,10 +12650,11 @@ void ContactsManager::on_update_user_photo(User *u, UserId user_id,
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool is_empty = photo == nullptr || photo->get_id() == telegram_api::userProfilePhotoEmpty::ID;
|
auto new_photo_id = get_profile_photo_id(photo);
|
||||||
old_photo = std::move(photo);
|
old_photo = std::move(photo);
|
||||||
|
|
||||||
drop_user_photos(user_id, is_empty, true, "on_update_user_photo");
|
drop_user_photos(user_id, new_photo_id == 0, "on_update_user_photo");
|
||||||
|
drop_user_full_photos(get_user_full(user_id), user_id, new_photo_id); // must not load UserFull
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -12682,10 +12683,9 @@ void ContactsManager::do_update_user_photo(User *u, UserId user_id, ProfilePhoto
|
|||||||
u->is_changed = true;
|
u->is_changed = true;
|
||||||
|
|
||||||
if (invalidate_photo_cache) {
|
if (invalidate_photo_cache) {
|
||||||
drop_user_photos(user_id, !u->photo.small_file_id.is_valid(), true, source);
|
drop_user_photos(user_id, u->photo.id == 0, source);
|
||||||
} else {
|
|
||||||
drop_user_full_photos(get_user_full(user_id), user_id, u->photo.id); // must not load UserFull
|
|
||||||
}
|
}
|
||||||
|
drop_user_full_photos(get_user_full(user_id), user_id, u->photo.id); // must not load UserFull
|
||||||
} else if (need_update_dialog_photo_minithumbnail(u->photo.minithumbnail, new_photo.minithumbnail)) {
|
} else if (need_update_dialog_photo_minithumbnail(u->photo.minithumbnail, new_photo.minithumbnail)) {
|
||||||
LOG(DEBUG) << "Photo minithumbnail has changed for " << user_id << " from " << source;
|
LOG(DEBUG) << "Photo minithumbnail has changed for " << user_id << " from " << source;
|
||||||
u->photo.minithumbnail = std::move(new_photo.minithumbnail);
|
u->photo.minithumbnail = std::move(new_photo.minithumbnail);
|
||||||
@ -13247,7 +13247,7 @@ void ContactsManager::drop_user_full_photos(UserFull *user_full, UserId user_id,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ContactsManager::drop_user_photos(UserId user_id, bool is_empty, bool drop_user_full_photo, const char *source) {
|
void ContactsManager::drop_user_photos(UserId user_id, bool is_empty, const char *source) {
|
||||||
LOG(INFO) << "Drop user photos to " << (is_empty ? "empty" : "unknown") << " from " << source;
|
LOG(INFO) << "Drop user photos to " << (is_empty ? "empty" : "unknown") << " from " << source;
|
||||||
auto user_photos = user_photos_.get_pointer(user_id);
|
auto user_photos = user_photos_.get_pointer(user_id);
|
||||||
if (user_photos != nullptr) {
|
if (user_photos != nullptr) {
|
||||||
@ -13262,40 +13262,12 @@ void ContactsManager::drop_user_photos(UserId user_id, bool is_empty, bool drop_
|
|||||||
user_photos->offset = user_photos->count;
|
user_photos->offset = user_photos->count;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (drop_user_full_photo) {
|
|
||||||
auto user_full = get_user_full(user_id); // must not load UserFull
|
|
||||||
if (user_full != nullptr) {
|
|
||||||
if (!user_full->photo.is_empty()) {
|
|
||||||
user_full->photo = Photo();
|
|
||||||
user_full->is_changed = true;
|
|
||||||
}
|
|
||||||
if (!user_full->personal_photo.is_empty()) {
|
|
||||||
user_full->personal_photo = Photo();
|
|
||||||
user_full->is_changed = true;
|
|
||||||
}
|
|
||||||
if (!user_full->fallback_photo.is_empty()) {
|
|
||||||
user_full->fallback_photo = Photo();
|
|
||||||
user_full->is_changed = true;
|
|
||||||
}
|
|
||||||
if (!is_empty) {
|
|
||||||
if (user_full->expires_at > 0.0) {
|
|
||||||
user_full->expires_at = 0.0;
|
|
||||||
user_full->need_save_to_database = true;
|
|
||||||
}
|
|
||||||
reload_user_full(user_id, Auto());
|
|
||||||
}
|
|
||||||
if (user_full->is_update_user_full_sent) {
|
|
||||||
update_user_full(user_full, user_id, "drop_user_photos");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ContactsManager::drop_user_full(UserId user_id) {
|
void ContactsManager::drop_user_full(UserId user_id) {
|
||||||
auto user_full = get_user_full_force(user_id);
|
auto user_full = get_user_full_force(user_id);
|
||||||
|
|
||||||
drop_user_photos(user_id, false, false, "drop_user_full");
|
drop_user_photos(user_id, false, "drop_user_full");
|
||||||
|
|
||||||
if (user_full == nullptr) {
|
if (user_full == nullptr) {
|
||||||
return;
|
return;
|
||||||
|
@ -1375,7 +1375,7 @@ class ContactsManager final : public Actor {
|
|||||||
void add_set_profile_photo_to_cache(UserId user_id, Photo &&photo, bool is_fallback);
|
void add_set_profile_photo_to_cache(UserId user_id, Photo &&photo, bool is_fallback);
|
||||||
bool delete_profile_photo_from_cache(UserId user_id, int64 profile_photo_id, bool send_updates);
|
bool delete_profile_photo_from_cache(UserId user_id, int64 profile_photo_id, bool send_updates);
|
||||||
void drop_user_full_photos(UserFull *user_full, UserId user_id, int64 expected_photo_id);
|
void drop_user_full_photos(UserFull *user_full, UserId user_id, int64 expected_photo_id);
|
||||||
void drop_user_photos(UserId user_id, bool is_empty, bool drop_user_full_photo, const char *source);
|
void drop_user_photos(UserId user_id, bool is_empty, const char *source);
|
||||||
void drop_user_full(UserId user_id);
|
void drop_user_full(UserId user_id);
|
||||||
|
|
||||||
void on_update_chat_status(Chat *c, ChatId chat_id, DialogParticipantStatus status);
|
void on_update_chat_status(Chat *c, ChatId chat_id, DialogParticipantStatus status);
|
||||||
|
@ -25,6 +25,13 @@
|
|||||||
|
|
||||||
namespace td {
|
namespace td {
|
||||||
|
|
||||||
|
int64 get_profile_photo_id(const tl_object_ptr<telegram_api::UserProfilePhoto> &profile_photo_ptr) {
|
||||||
|
if (profile_photo_ptr != nullptr && profile_photo_ptr->get_id() == telegram_api::userProfilePhoto::ID) {
|
||||||
|
return static_cast<const telegram_api::userProfilePhoto *>(profile_photo_ptr.get())->photo_id_;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
ProfilePhoto get_profile_photo(FileManager *file_manager, UserId user_id, int64 user_access_hash,
|
ProfilePhoto get_profile_photo(FileManager *file_manager, UserId user_id, int64 user_access_hash,
|
||||||
tl_object_ptr<telegram_api::UserProfilePhoto> &&profile_photo_ptr) {
|
tl_object_ptr<telegram_api::UserProfilePhoto> &&profile_photo_ptr) {
|
||||||
ProfilePhoto result;
|
ProfilePhoto result;
|
||||||
|
@ -65,6 +65,8 @@ struct Photo {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
int64 get_profile_photo_id(const tl_object_ptr<telegram_api::UserProfilePhoto> &profile_photo_ptr);
|
||||||
|
|
||||||
ProfilePhoto get_profile_photo(FileManager *file_manager, UserId user_id, int64 user_access_hash,
|
ProfilePhoto get_profile_photo(FileManager *file_manager, UserId user_id, int64 user_access_hash,
|
||||||
tl_object_ptr<telegram_api::UserProfilePhoto> &&profile_photo_ptr);
|
tl_object_ptr<telegram_api::UserProfilePhoto> &&profile_photo_ptr);
|
||||||
tl_object_ptr<td_api::profilePhoto> get_profile_photo_object(FileManager *file_manager,
|
tl_object_ptr<td_api::profilePhoto> get_profile_photo_object(FileManager *file_manager,
|
||||||
|
Loading…
Reference in New Issue
Block a user