Improve on_set_profile_photo.
This commit is contained in:
parent
aebf904513
commit
9b089bc194
@ -571,15 +571,16 @@ class UploadProfilePhotoQuery final : public Td::ResultHandler {
|
|||||||
return on_error(result_ptr.move_as_error());
|
return on_error(result_ptr.move_as_error());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!only_suggest_) {
|
|
||||||
td_->contacts_manager_->on_set_profile_photo(user_id_, result_ptr.move_as_ok(), is_fallback_, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (file_id_.is_valid()) {
|
if (file_id_.is_valid()) {
|
||||||
td_->file_manager_->delete_partial_remote_location(file_id_);
|
td_->file_manager_->delete_partial_remote_location(file_id_);
|
||||||
}
|
}
|
||||||
|
|
||||||
promise_.set_value(Unit());
|
if (!only_suggest_) {
|
||||||
|
td_->contacts_manager_->on_set_profile_photo(user_id_, result_ptr.move_as_ok(), is_fallback_, 0,
|
||||||
|
std::move(promise_));
|
||||||
|
} else {
|
||||||
|
promise_.set_value(Unit());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void on_error(Status status) final {
|
void on_error(Status status) final {
|
||||||
@ -637,9 +638,8 @@ class UpdateProfilePhotoQuery final : public Td::ResultHandler {
|
|||||||
return on_error(result_ptr.move_as_error());
|
return on_error(result_ptr.move_as_error());
|
||||||
}
|
}
|
||||||
|
|
||||||
td_->contacts_manager_->on_set_profile_photo(user_id_, result_ptr.move_as_ok(), is_fallback_, old_photo_id_);
|
td_->contacts_manager_->on_set_profile_photo(user_id_, result_ptr.move_as_ok(), is_fallback_, old_photo_id_,
|
||||||
|
std::move(promise_));
|
||||||
promise_.set_value(Unit());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void on_error(Status status) final {
|
void on_error(Status status) final {
|
||||||
@ -696,8 +696,7 @@ class DeleteContactProfilePhotoQuery final : public Td::ResultHandler {
|
|||||||
|
|
||||||
auto ptr = result_ptr.move_as_ok();
|
auto ptr = result_ptr.move_as_ok();
|
||||||
ptr->photo_ = nullptr;
|
ptr->photo_ = nullptr;
|
||||||
td_->contacts_manager_->on_set_profile_photo(user_id_, std::move(ptr), false, 0);
|
td_->contacts_manager_->on_set_profile_photo(user_id_, std::move(ptr), false, 0, std::move(promise_));
|
||||||
promise_.set_value(Unit());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void on_error(Status status) final {
|
void on_error(Status status) final {
|
||||||
@ -13531,7 +13530,7 @@ void ContactsManager::on_ignored_restriction_reasons_changed() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void ContactsManager::on_set_profile_photo(UserId user_id, tl_object_ptr<telegram_api::photos_photo> &&photo,
|
void ContactsManager::on_set_profile_photo(UserId user_id, tl_object_ptr<telegram_api::photos_photo> &&photo,
|
||||||
bool is_fallback, int64 old_photo_id) {
|
bool is_fallback, int64 old_photo_id, Promise<Unit> &&promise) {
|
||||||
LOG(INFO) << "Changed profile photo to " << to_string(photo);
|
LOG(INFO) << "Changed profile photo to " << to_string(photo);
|
||||||
|
|
||||||
bool is_bot = is_user_bot(user_id);
|
bool is_bot = is_user_bot(user_id);
|
||||||
@ -13539,10 +13538,21 @@ void ContactsManager::on_set_profile_photo(UserId user_id, tl_object_ptr<telegra
|
|||||||
if (is_my && !is_fallback) {
|
if (is_my && !is_fallback) {
|
||||||
delete_my_profile_photo_from_cache(old_photo_id);
|
delete_my_profile_photo_from_cache(old_photo_id);
|
||||||
}
|
}
|
||||||
|
bool have_user = false;
|
||||||
|
for (const auto &user : photo->users_) {
|
||||||
|
if (get_user_id(user) == user_id) {
|
||||||
|
have_user = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
on_get_users(std::move(photo->users_), "on_set_profile_photo");
|
on_get_users(std::move(photo->users_), "on_set_profile_photo");
|
||||||
if (!is_bot) {
|
if (!is_bot) {
|
||||||
add_set_profile_photo_to_cache(user_id, get_photo(td_, std::move(photo->photo_), DialogId(user_id)), is_fallback);
|
add_set_profile_photo_to_cache(user_id, get_photo(td_, std::move(photo->photo_), DialogId(user_id)), is_fallback);
|
||||||
}
|
}
|
||||||
|
if (have_user) {
|
||||||
|
promise.set_value(Unit());
|
||||||
|
} else {
|
||||||
|
reload_user(user_id, std::move(promise));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ContactsManager::on_delete_profile_photo(int64 profile_photo_id, Promise<Unit> promise) {
|
void ContactsManager::on_delete_profile_photo(int64 profile_photo_id, Promise<Unit> promise) {
|
||||||
|
@ -191,7 +191,7 @@ class ContactsManager final : public Actor {
|
|||||||
void on_update_user_need_phone_number_privacy_exception(UserId user_id, bool need_phone_number_privacy_exception);
|
void on_update_user_need_phone_number_privacy_exception(UserId user_id, bool need_phone_number_privacy_exception);
|
||||||
|
|
||||||
void on_set_profile_photo(UserId user_id, tl_object_ptr<telegram_api::photos_photo> &&photo, bool is_fallback,
|
void on_set_profile_photo(UserId user_id, tl_object_ptr<telegram_api::photos_photo> &&photo, bool is_fallback,
|
||||||
int64 old_photo_id);
|
int64 old_photo_id, Promise<Unit> &&promise);
|
||||||
|
|
||||||
void on_delete_profile_photo(int64 profile_photo_id, Promise<Unit> promise);
|
void on_delete_profile_photo(int64 profile_photo_id, Promise<Unit> promise);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user