Add profile photo file source.
GitOrigin-RevId: 7324c1a4927e135c84a6406b606684297f2447ff
This commit is contained in:
parent
d04a1a61cc
commit
62a01e2b61
@ -6180,6 +6180,8 @@ void ContactsManager::update_user(User *u, UserId user_id, bool from_binlog, boo
|
||||
}
|
||||
}
|
||||
|
||||
add_user_photo_id(u, user_id, u->photo.id, dialog_photo_get_file_ids(u->photo));
|
||||
|
||||
UserFull *user_full = get_user_full(user_id);
|
||||
if (user_full != nullptr) {
|
||||
user_full->photos.clear();
|
||||
@ -6517,12 +6519,20 @@ void ContactsManager::on_get_user_photos(UserId user_id, int32 offset, int32 lim
|
||||
LOG_IF(ERROR, limit < photo_count) << "Requested not more than " << limit << " photos, but " << photo_count
|
||||
<< " returned";
|
||||
|
||||
User *u = get_user(user_id);
|
||||
if (u == nullptr) {
|
||||
LOG(ERROR) << "Can't find " << user_id;
|
||||
return;
|
||||
}
|
||||
|
||||
if (offset == -1) {
|
||||
// from reload_user_profile_photo
|
||||
CHECK(limit == 1);
|
||||
for (auto &photo : photos) {
|
||||
if (photo->get_id() == telegram_api::photo::ID) {
|
||||
get_photo(td_->file_manager_.get(), telegram_api::move_object_as<telegram_api::photo>(photo), DialogId());
|
||||
for (auto &photo_ptr : photos) {
|
||||
if (photo_ptr->get_id() == telegram_api::photo::ID) {
|
||||
auto photo = get_photo(td_->file_manager_.get(), telegram_api::move_object_as<telegram_api::photo>(photo_ptr),
|
||||
DialogId());
|
||||
add_user_photo_id(u, user_id, photo.id, photo_get_file_ids(photo));
|
||||
}
|
||||
}
|
||||
return;
|
||||
@ -6557,6 +6567,7 @@ void ContactsManager::on_get_user_photos(UserId user_id, int32 offset, int32 lim
|
||||
|
||||
user->photos.push_back(
|
||||
get_photo(td_->file_manager_.get(), telegram_api::move_object_as<telegram_api::photo>(photo), DialogId()));
|
||||
add_user_photo_id(u, user_id, user->photos.back().id, photo_get_file_ids(user->photos.back()));
|
||||
}
|
||||
}
|
||||
|
||||
@ -6878,6 +6889,15 @@ void ContactsManager::do_update_user_photo(User *u, UserId user_id,
|
||||
}
|
||||
}
|
||||
|
||||
void ContactsManager::add_user_photo_id(User *u, UserId user_id, int64 photo_id, const vector<FileId> &photo_file_ids) {
|
||||
if (photo_id > 0 && !photo_file_ids.empty() && u->photo_ids.insert(photo_id).second) {
|
||||
auto file_source_id = td_->file_reference_manager_->create_user_photo_file_source(user_id, photo_id);
|
||||
for (auto &file_id : photo_file_ids) {
|
||||
td_->file_manager_->add_file_source(file_id, file_source_id);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void ContactsManager::on_update_user_online(UserId user_id, tl_object_ptr<telegram_api::UserStatus> &&status) {
|
||||
if (!user_id.is_valid()) {
|
||||
LOG(ERROR) << "Receive invalid " << user_id;
|
||||
|
@ -480,6 +480,8 @@ class ContactsManager : public Actor {
|
||||
LinkState outbound = LinkState::Unknown;
|
||||
LinkState inbound = LinkState::Unknown;
|
||||
|
||||
std::unordered_set<int64> photo_ids;
|
||||
|
||||
bool is_received = false;
|
||||
bool is_verified = false;
|
||||
bool is_deleted = true;
|
||||
@ -859,6 +861,8 @@ class ContactsManager : public Actor {
|
||||
|
||||
void do_update_user_photo(User *u, UserId user_id, tl_object_ptr<telegram_api::UserProfilePhoto> &&photo);
|
||||
|
||||
void add_user_photo_id(User *u, UserId user_id, int64 photo_id, const vector<FileId> &photo_file_ids);
|
||||
|
||||
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);
|
||||
|
@ -1796,7 +1796,7 @@ void FileManager::run_download(FileNodePtr node) {
|
||||
QueryId id = queries_container_.create(Query{file_id, Query::DownloadWaitFileReferece});
|
||||
node->download_id_ = id;
|
||||
if (node->download_was_update_file_reference_) {
|
||||
on_error(id, Status::Error("Can't download file: have valid source id, but do not allowed to use it"));
|
||||
on_error(id, Status::Error("Can't download file: have no valid file reference"));
|
||||
return;
|
||||
}
|
||||
node->download_was_update_file_reference_ = true;
|
||||
|
Loading…
Reference in New Issue
Block a user