Fix adding thumbnails to file_ids list.

GitOrigin-RevId: 880d7b1720050685b502925aa281c6de4945e1fb
This commit is contained in:
levlam 2019-02-28 21:40:57 +03:00
parent eddaa5252c
commit 8edd3b3811
5 changed files with 33 additions and 5 deletions

View File

@ -84,10 +84,14 @@ UserId Game::get_bot_user_id() const {
return bot_user_id_;
}
vector<FileId> Game::get_file_ids() const {
vector<FileId> Game::get_file_ids(const Td *td) const {
auto result = photo_get_file_ids(photo_);
if (animation_file_id_.is_valid()) {
result.push_back(animation_file_id_);
auto thumbnail_file_id = td->animations_manager_->get_animation_thumbnail_file_id(animation_file_id_);
if (thumbnail_file_id.is_valid()) {
result.push_back(thumbnail_file_id);
}
}
return result;
}

View File

@ -57,7 +57,7 @@ class Game {
UserId get_bot_user_id() const;
vector<FileId> get_file_ids() const;
vector<FileId> get_file_ids(const Td *td) const;
void set_text(FormattedText &&text);

View File

@ -4639,7 +4639,7 @@ vector<FileId> get_message_content_file_ids(const MessageContent *content, const
case MessageContentType::Sticker:
return td->stickers_manager_->get_sticker_file_ids(static_cast<const MessageSticker *>(content)->file_id);
case MessageContentType::Game:
return static_cast<const MessageGame *>(content)->game.get_file_ids();
return static_cast<const MessageGame *>(content)->game.get_file_ids(td);
case MessageContentType::Invoice:
return photo_get_file_ids(static_cast<const MessageInvoice *>(content)->photo);
case MessageContentType::ChatChangePhoto:

View File

@ -3821,7 +3821,7 @@ void WebPagesManager::append_page_block_caption_file_ids(const PageBlockCaption
append_rich_text_file_ids(caption.credit, file_ids);
}
vector<FileId> WebPagesManager::get_web_page_file_ids(const WebPage *web_page) {
vector<FileId> WebPagesManager::get_web_page_file_ids(const WebPage *web_page) const {
if (web_page == nullptr) {
return vector<FileId>();
}
@ -3829,6 +3829,30 @@ vector<FileId> WebPagesManager::get_web_page_file_ids(const WebPage *web_page) {
vector<FileId> result = photo_get_file_ids(web_page->photo);
if (web_page->document_file_id.is_valid()) {
result.push_back(web_page->document_file_id);
FileId thumbnail_file_id;
switch (web_page->document_type) {
case DocumentsManager::DocumentType::Animation:
thumbnail_file_id = td_->animations_manager_->get_animation_thumbnail_file_id(web_page->document_file_id);
break;
case DocumentsManager::DocumentType::Audio:
thumbnail_file_id = td_->audios_manager_->get_audio_thumbnail_file_id(web_page->document_file_id);
break;
case DocumentsManager::DocumentType::General:
thumbnail_file_id = td_->documents_manager_->get_document_thumbnail_file_id(web_page->document_file_id);
break;
case DocumentsManager::DocumentType::Sticker:
thumbnail_file_id = td_->stickers_manager_->get_sticker_thumbnail_file_id(web_page->document_file_id);
break;
case DocumentsManager::DocumentType::Video:
thumbnail_file_id = td_->videos_manager_->get_video_thumbnail_file_id(web_page->document_file_id);
break;
case DocumentsManager::DocumentType::VideoNote:
thumbnail_file_id = td_->video_notes_manager_->get_video_note_thumbnail_file_id(web_page->document_file_id);
break;
}
if (thumbnail_file_id.is_valid()) {
result.push_back(thumbnail_file_id);
}
}
if (!web_page->instant_view.is_empty) {
for (auto &page_block : web_page->instant_view.page_blocks) {

View File

@ -246,7 +246,7 @@ class WebPagesManager : public Actor {
static void append_page_block_caption_file_ids(const PageBlockCaption &caption, vector<FileId> &file_ids);
static vector<FileId> get_web_page_file_ids(const WebPage *web_page);
vector<FileId> get_web_page_file_ids(const WebPage *web_page) const;
Td *td_;
ActorShared<> parent_;