From 2027cb081bbaa429ae55157ef82f5746a42d7835 Mon Sep 17 00:00:00 2001 From: levlam Date: Fri, 23 Aug 2019 18:22:14 +0300 Subject: [PATCH] Use Document::append_file_ids. GitOrigin-RevId: d877b3e75c68388ca34d72b6983528003ffd0ba0 --- td/telegram/Game.cpp | 8 +------- td/telegram/WebPageBlock.cpp | 28 ++++------------------------ 2 files changed, 5 insertions(+), 31 deletions(-) diff --git a/td/telegram/Game.cpp b/td/telegram/Game.cpp index 75866fab0..d7743fd36 100644 --- a/td/telegram/Game.cpp +++ b/td/telegram/Game.cpp @@ -78,13 +78,7 @@ UserId Game::get_bot_user_id() const { vector 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); - } - } + Document(Document::Type::Animation, animation_file_id_).append_file_ids(td, result); return result; } diff --git a/td/telegram/WebPageBlock.cpp b/td/telegram/WebPageBlock.cpp index 54dcdb02d..fd83fc5a8 100644 --- a/td/telegram/WebPageBlock.cpp +++ b/td/telegram/WebPageBlock.cpp @@ -73,12 +73,7 @@ class RichText { void append_file_ids(vector &file_ids) const { if (type == RichText::Type::Icon) { CHECK(document_file_id.is_valid()); - file_ids.push_back(document_file_id); - auto thumbnail_file_id = - G()->td().get_actor_unsafe()->documents_manager_->get_document_thumbnail_file_id(document_file_id); - if (thumbnail_file_id.is_valid()) { - file_ids.push_back(thumbnail_file_id); - } + Document(Document::Type::General, document_file_id).append_file_ids(G()->td().get_actor_unsafe(), file_ids); } else { for (auto &text : texts) { text.append_file_ids(file_ids); @@ -921,12 +916,7 @@ class WebPageBlockAnimation : public WebPageBlock { void append_file_ids(vector &file_ids) const override { caption.append_file_ids(file_ids); if (animation_file_id.is_valid()) { - file_ids.push_back(animation_file_id); - auto thumbnail_file_id = - G()->td().get_actor_unsafe()->animations_manager_->get_animation_thumbnail_file_id(animation_file_id); - if (thumbnail_file_id.is_valid()) { - file_ids.push_back(thumbnail_file_id); - } + Document(Document::Type::Animation, animation_file_id).append_file_ids(G()->td().get_actor_unsafe(), file_ids); } } @@ -1046,12 +1036,7 @@ class WebPageBlockVideo : public WebPageBlock { void append_file_ids(vector &file_ids) const override { caption.append_file_ids(file_ids); if (video_file_id.is_valid()) { - file_ids.push_back(video_file_id); - auto thumbnail_file_id = - G()->td().get_actor_unsafe()->videos_manager_->get_video_thumbnail_file_id(video_file_id); - if (thumbnail_file_id.is_valid()) { - file_ids.push_back(thumbnail_file_id); - } + Document(Document::Type::Video, video_file_id).append_file_ids(G()->td().get_actor_unsafe(), file_ids); } } @@ -1404,12 +1389,7 @@ class WebPageBlockAudio : public WebPageBlock { void append_file_ids(vector &file_ids) const override { if (audio_file_id.is_valid()) { - file_ids.push_back(audio_file_id); - auto thumbnail_file_id = - G()->td().get_actor_unsafe()->audios_manager_->get_audio_thumbnail_file_id(audio_file_id); - if (thumbnail_file_id.is_valid()) { - file_ids.push_back(thumbnail_file_id); - } + Document(Document::Type::Audio, audio_file_id).append_file_ids(G()->td().get_actor_unsafe(), file_ids); } caption.append_file_ids(file_ids); }