Use get_photo(telegram_api::Photo) whenever possible.
GitOrigin-RevId: 6ab86f8a10f8a80584cd7a4ada4fbbda19df9d96
This commit is contained in:
parent
e91da22a5b
commit
cf4433dc52
@ -853,7 +853,7 @@ pageBlockCover cover:PageBlock = PageBlock;
|
|||||||
//@description An embedded web page @url Web page URL, if available @html HTML-markup of the embedded page @poster_photo Poster photo, if available; may be null @width Block width, 0 if unknown @height Block height, 0 if unknown @caption Block caption @is_full_width True, if the block should be full width @allow_scrolling True, if scrolling should be allowed
|
//@description An embedded web page @url Web page URL, if available @html HTML-markup of the embedded page @poster_photo Poster photo, if available; may be null @width Block width, 0 if unknown @height Block height, 0 if unknown @caption Block caption @is_full_width True, if the block should be full width @allow_scrolling True, if scrolling should be allowed
|
||||||
pageBlockEmbedded url:string html:string poster_photo:photo width:int32 height:int32 caption:pageBlockCaption is_full_width:Bool allow_scrolling:Bool = PageBlock;
|
pageBlockEmbedded url:string html:string poster_photo:photo width:int32 height:int32 caption:pageBlockCaption is_full_width:Bool allow_scrolling:Bool = PageBlock;
|
||||||
|
|
||||||
//@description An embedded post @url Web page URL @author Post author @author_photo Post author photo @date Point in time (Unix timestamp) when the post was created; 0 if unknown @page_blocks Post content @caption Post caption
|
//@description An embedded post @url Web page URL @author Post author @author_photo Post author photo; may be null @date Point in time (Unix timestamp) when the post was created; 0 if unknown @page_blocks Post content @caption Post caption
|
||||||
pageBlockEmbeddedPost url:string author:string author_photo:photo date:int32 page_blocks:vector<PageBlock> caption:pageBlockCaption = PageBlock;
|
pageBlockEmbeddedPost url:string author:string author_photo:photo date:int32 page_blocks:vector<PageBlock> caption:pageBlockCaption = PageBlock;
|
||||||
|
|
||||||
//@description A collage @page_blocks Collage item contents @caption Block caption
|
//@description A collage @page_blocks Collage item contents @caption Block caption
|
||||||
|
@ -6544,19 +6544,12 @@ void ContactsManager::on_get_user_full(tl_object_ptr<telegram_api::userFull> &&u
|
|||||||
user->is_changed = true;
|
user->is_changed = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32 photo_id =
|
Photo photo = get_photo(td_->file_manager_.get(), std::move(user_full->profile_photo_), DialogId());
|
||||||
user_full->profile_photo_ == nullptr ? telegram_api::photoEmpty::ID : user_full->profile_photo_->get_id();
|
if (photo.id == -2) {
|
||||||
if (photo_id == telegram_api::photoEmpty::ID) {
|
|
||||||
user->photo_count = 0;
|
user->photo_count = 0;
|
||||||
user->photos_offset = 0;
|
user->photos_offset = 0;
|
||||||
user->photos.clear();
|
user->photos.clear();
|
||||||
} else {
|
|
||||||
CHECK(photo_id == telegram_api::photo::ID);
|
|
||||||
|
|
||||||
// Photo profile_photo =
|
|
||||||
// get_photo(td_->file_manager_.get(), move_tl_object_as<telegram_api::photo>(user_full->profile_photo_));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((user_full->flags_ & USER_FULL_FLAG_HAS_BOT_INFO) != 0 && !u->is_deleted) {
|
if ((user_full->flags_ & USER_FULL_FLAG_HAS_BOT_INFO) != 0 && !u->is_deleted) {
|
||||||
on_update_user_full_bot_info(user, user_id, u->bot_info_version, std::move(user_full->bot_info_));
|
on_update_user_full_bot_info(user, user_id, u->bot_info_version, std::move(user_full->bot_info_));
|
||||||
}
|
}
|
||||||
@ -6585,12 +6578,14 @@ void ContactsManager::on_get_user_photos(UserId user_id, int32 offset, int32 lim
|
|||||||
for (auto &photo_ptr : photos) {
|
for (auto &photo_ptr : photos) {
|
||||||
if (photo_ptr->get_id() == telegram_api::photo::ID) {
|
if (photo_ptr->get_id() == telegram_api::photo::ID) {
|
||||||
auto server_photo = telegram_api::move_object_as<telegram_api::photo>(photo_ptr);
|
auto server_photo = telegram_api::move_object_as<telegram_api::photo>(photo_ptr);
|
||||||
auto profile_photo = convert_photo_to_profile_photo(server_photo);
|
if (server_photo->id_ == u->photo.id) {
|
||||||
if (profile_photo) {
|
auto profile_photo = convert_photo_to_profile_photo(server_photo);
|
||||||
LOG_IF(ERROR, u->access_hash == -1) << "Receive profile photo of " << user_id << " without access hash";
|
if (profile_photo) {
|
||||||
get_profile_photo(td_->file_manager_.get(), user_id, u->access_hash, std::move(profile_photo));
|
LOG_IF(ERROR, u->access_hash == -1) << "Receive profile photo of " << user_id << " without access hash";
|
||||||
} else {
|
get_profile_photo(td_->file_manager_.get(), user_id, u->access_hash, std::move(profile_photo));
|
||||||
LOG(ERROR) << "Failed to get profile photo from " << to_string(server_photo);
|
} else {
|
||||||
|
LOG(ERROR) << "Failed to get profile photo from " << to_string(server_photo);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
auto photo = get_photo(td_->file_manager_.get(), std::move(server_photo), DialogId());
|
auto photo = get_photo(td_->file_manager_.get(), std::move(server_photo), DialogId());
|
||||||
@ -6618,17 +6613,15 @@ void ContactsManager::on_get_user_photos(UserId user_id, int32 offset, int32 lim
|
|||||||
}
|
}
|
||||||
|
|
||||||
for (auto &photo : photos) {
|
for (auto &photo : photos) {
|
||||||
int32 photo_id = photo->get_id();
|
auto user_photo = get_photo(td_->file_manager_.get(), std::move(photo), DialogId());
|
||||||
if (photo_id == telegram_api::photoEmpty::ID) {
|
if (user_photo.id == -2) {
|
||||||
LOG(ERROR) << "Have got empty profile photo in getUserPhotos request for " << user_id << " with offset " << offset
|
LOG(ERROR) << "Have got empty profile photo in getUserPhotos request for " << user_id << " with offset " << offset
|
||||||
<< " and limit " << limit << ". Receive " << photo_count << " photos out of " << total_count
|
<< " and limit " << limit << ". Receive " << photo_count << " photos out of " << total_count
|
||||||
<< " photos";
|
<< " photos";
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
CHECK(photo_id == telegram_api::photo::ID);
|
|
||||||
|
|
||||||
user->photos.push_back(
|
user->photos.push_back(std::move(user_photo));
|
||||||
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()));
|
add_user_photo_id(u, user_id, user->photos.back().id, photo_get_file_ids(user->photos.back()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -35,8 +35,10 @@ Game::Game(Td *td, string title, string description, tl_object_ptr<telegram_api:
|
|||||||
: title_(std::move(title)), description_(std::move(description)) {
|
: title_(std::move(title)), description_(std::move(description)) {
|
||||||
CHECK(td != nullptr);
|
CHECK(td != nullptr);
|
||||||
CHECK(photo != nullptr);
|
CHECK(photo != nullptr);
|
||||||
if (photo->get_id() == telegram_api::photo::ID) {
|
photo_ = get_photo(td->file_manager_.get(), std::move(photo), owner_dialog_id);
|
||||||
photo_ = get_photo(td->file_manager_.get(), move_tl_object_as<telegram_api::photo>(photo), owner_dialog_id);
|
if (photo_.id == -2) {
|
||||||
|
LOG(ERROR) << "Receive empty photo for game " << title;
|
||||||
|
photo_.id = 0; // to prevent null photo in td_api
|
||||||
}
|
}
|
||||||
if (document != nullptr) {
|
if (document != nullptr) {
|
||||||
int32 document_id = document->get_id();
|
int32 document_id = document->get_id();
|
||||||
|
@ -1268,15 +1268,11 @@ void InlineQueriesManager::on_get_inline_query_results(UserId bot_user_id, uint6
|
|||||||
LOG_IF(ERROR, !is_photo) << "Wrong result type " << result->type_;
|
LOG_IF(ERROR, !is_photo) << "Wrong result type " << result->type_;
|
||||||
auto photo = make_tl_object<td_api::inlineQueryResultPhoto>();
|
auto photo = make_tl_object<td_api::inlineQueryResultPhoto>();
|
||||||
photo->id_ = std::move(result->id_);
|
photo->id_ = std::move(result->id_);
|
||||||
auto photo_ptr = std::move(result->photo_);
|
Photo p = get_photo(td_->file_manager_.get(), std::move(result->photo_), DialogId());
|
||||||
int32 photo_id = photo_ptr->get_id();
|
if (p.id == -2) {
|
||||||
if (photo_id == telegram_api::photoEmpty::ID) {
|
|
||||||
LOG(ERROR) << "Receive empty cached photo in the result of inline query";
|
LOG(ERROR) << "Receive empty cached photo in the result of inline query";
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
CHECK(photo_id == telegram_api::photo::ID);
|
|
||||||
|
|
||||||
Photo p = get_photo(td_->file_manager_.get(), move_tl_object_as<telegram_api::photo>(photo_ptr), DialogId());
|
|
||||||
photo->photo_ = get_photo_object(td_->file_manager_.get(), &p);
|
photo->photo_ = get_photo_object(td_->file_manager_.get(), &p);
|
||||||
photo->title_ = std::move(result->title_);
|
photo->title_ = std::move(result->title_);
|
||||||
photo->description_ = std::move(result->description_);
|
photo->description_ = std::move(result->description_);
|
||||||
|
@ -3760,19 +3760,15 @@ unique_ptr<MessageContent> get_message_content(Td *td, FormattedText message,
|
|||||||
return make_unique<MessageExpiredPhoto>();
|
return make_unique<MessageExpiredPhoto>();
|
||||||
}
|
}
|
||||||
|
|
||||||
auto photo_ptr = std::move(message_photo->photo_);
|
auto photo = get_photo(td->file_manager_.get(), std::move(message_photo->photo_), owner_dialog_id);
|
||||||
int32 photo_id = photo_ptr->get_id();
|
if (photo.id == -2) {
|
||||||
if (photo_id == telegram_api::photoEmpty::ID) {
|
|
||||||
return make_unique<MessageExpiredPhoto>();
|
return make_unique<MessageExpiredPhoto>();
|
||||||
}
|
}
|
||||||
CHECK(photo_id == telegram_api::photo::ID);
|
|
||||||
|
|
||||||
if (ttl != nullptr && (message_photo->flags_ & telegram_api::messageMediaPhoto::TTL_SECONDS_MASK) != 0) {
|
if (ttl != nullptr && (message_photo->flags_ & telegram_api::messageMediaPhoto::TTL_SECONDS_MASK) != 0) {
|
||||||
*ttl = message_photo->ttl_seconds_;
|
*ttl = message_photo->ttl_seconds_;
|
||||||
}
|
}
|
||||||
return make_unique<MessagePhoto>(
|
return make_unique<MessagePhoto>(std::move(photo), std::move(message));
|
||||||
get_photo(td->file_manager_.get(), move_tl_object_as<telegram_api::photo>(photo_ptr), owner_dialog_id),
|
|
||||||
std::move(message));
|
|
||||||
}
|
}
|
||||||
case telegram_api::messageMediaGeo::ID: {
|
case telegram_api::messageMediaGeo::ID: {
|
||||||
auto message_geo_point = move_tl_object_as<telegram_api::messageMediaGeo>(media);
|
auto message_geo_point = move_tl_object_as<telegram_api::messageMediaGeo>(media);
|
||||||
@ -4130,16 +4126,11 @@ unique_ptr<MessageContent> get_action_message_content(Td *td, tl_object_ptr<tele
|
|||||||
}
|
}
|
||||||
case telegram_api::messageActionChatEditPhoto::ID: {
|
case telegram_api::messageActionChatEditPhoto::ID: {
|
||||||
auto chat_edit_photo = move_tl_object_as<telegram_api::messageActionChatEditPhoto>(action);
|
auto chat_edit_photo = move_tl_object_as<telegram_api::messageActionChatEditPhoto>(action);
|
||||||
|
auto photo = get_photo(td->file_manager_.get(), std::move(chat_edit_photo->photo_), owner_dialog_id);
|
||||||
auto photo_ptr = std::move(chat_edit_photo->photo_);
|
if (photo.id == -2) {
|
||||||
int32 photo_id = photo_ptr->get_id();
|
|
||||||
if (photo_id == telegram_api::photoEmpty::ID) {
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
CHECK(photo_id == telegram_api::photo::ID);
|
return make_unique<MessageChatChangePhoto>(std::move(photo));
|
||||||
|
|
||||||
return make_unique<MessageChatChangePhoto>(
|
|
||||||
get_photo(td->file_manager_.get(), move_tl_object_as<telegram_api::photo>(photo_ptr), owner_dialog_id));
|
|
||||||
}
|
}
|
||||||
case telegram_api::messageActionChatDeletePhoto::ID: {
|
case telegram_api::messageActionChatDeletePhoto::ID: {
|
||||||
return make_unique<MessageChatDeletePhoto>();
|
return make_unique<MessageChatDeletePhoto>();
|
||||||
|
@ -552,6 +552,11 @@ Photo get_photo(FileManager *file_manager, tl_object_ptr<telegram_api::photo> &&
|
|||||||
res.date = photo->date_;
|
res.date = photo->date_;
|
||||||
res.has_stickers = (photo->flags_ & telegram_api::photo::HAS_STICKERS_MASK) != 0;
|
res.has_stickers = (photo->flags_ & telegram_api::photo::HAS_STICKERS_MASK) != 0;
|
||||||
|
|
||||||
|
if (res.id == -2) {
|
||||||
|
LOG(ERROR) << "Receive photo with id " << res.id;
|
||||||
|
res.id = -3;
|
||||||
|
}
|
||||||
|
|
||||||
for (auto &size_ptr : photo->sizes_) {
|
for (auto &size_ptr : photo->sizes_) {
|
||||||
auto photo_size = get_photo_size(file_manager, {FileType::Photo, 0}, photo->id_, photo->access_hash_,
|
auto photo_size = get_photo_size(file_manager, {FileType::Photo, 0}, photo->id_, photo->access_hash_,
|
||||||
photo->file_reference_.as_slice().str(), DcId::create(photo->dc_id_),
|
photo->file_reference_.as_slice().str(), DcId::create(photo->dc_id_),
|
||||||
|
@ -441,12 +441,7 @@ WebPageId WebPagesManager::on_get_web_page(tl_object_ptr<telegram_api::WebPage>
|
|||||||
page->site_name = std::move(web_page->site_name_);
|
page->site_name = std::move(web_page->site_name_);
|
||||||
page->title = std::move(web_page->title_);
|
page->title = std::move(web_page->title_);
|
||||||
page->description = std::move(web_page->description_);
|
page->description = std::move(web_page->description_);
|
||||||
if ((web_page->flags_ & WEBPAGE_FLAG_HAS_PHOTO) && web_page->photo_->get_id() == telegram_api::photo::ID) {
|
page->photo = get_photo(td_->file_manager_.get(), std::move(web_page->photo_), owner_dialog_id);
|
||||||
page->photo = get_photo(td_->file_manager_.get(), move_tl_object_as<telegram_api::photo>(web_page->photo_),
|
|
||||||
owner_dialog_id);
|
|
||||||
} else {
|
|
||||||
page->photo.id = -2;
|
|
||||||
}
|
|
||||||
if (web_page->flags_ & WEBPAGE_FLAG_HAS_EMBEDDED_PREVIEW) {
|
if (web_page->flags_ & WEBPAGE_FLAG_HAS_EMBEDDED_PREVIEW) {
|
||||||
page->embed_url = std::move(web_page->embed_url_);
|
page->embed_url = std::move(web_page->embed_url_);
|
||||||
page->embed_type = std::move(web_page->embed_type_);
|
page->embed_type = std::move(web_page->embed_type_);
|
||||||
@ -1188,11 +1183,11 @@ void WebPagesManager::on_get_web_page_instant_view(WebPage *web_page, tl_object_
|
|||||||
CHECK(page != nullptr);
|
CHECK(page != nullptr);
|
||||||
std::unordered_map<int64, Photo> photos;
|
std::unordered_map<int64, Photo> photos;
|
||||||
for (auto &photo_ptr : page->photos_) {
|
for (auto &photo_ptr : page->photos_) {
|
||||||
if (photo_ptr->get_id() == telegram_api::photo::ID) {
|
Photo photo = get_photo(td_->file_manager_.get(), std::move(photo_ptr), owner_dialog_id);
|
||||||
Photo photo =
|
if (photo.id == -2 || photo.id == 0) {
|
||||||
get_photo(td_->file_manager_.get(), move_tl_object_as<telegram_api::photo>(photo_ptr), owner_dialog_id);
|
LOG(ERROR) << "Receive empty photo in web page instant view for " << web_page->url;
|
||||||
int64 photo_id = photo.id;
|
} else {
|
||||||
photos.emplace(photo_id, std::move(photo));
|
photos.emplace(photo.id, std::move(photo));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (web_page->photo.id != -2 && web_page->photo.id != 0) {
|
if (web_page->photo.id != -2 && web_page->photo.id != 0) {
|
||||||
|
Reference in New Issue
Block a user