Add Document::append_file_ids.

GitOrigin-RevId: 309a322425278f09781897a8f7679ece73ecf055
This commit is contained in:
levlam 2019-08-23 18:03:06 +03:00
parent 219c35f007
commit 19de122bea
3 changed files with 20 additions and 10 deletions

View File

@ -14,16 +14,27 @@
#include "td/telegram/VideoNotesManager.h"
#include "td/telegram/VideosManager.h"
#include "td/utils/misc.h"
namespace td {
vector<FileId> Document::get_file_ids(const Td *td) const {
vector<FileId> result;
if (empty()) {
append_file_ids(td, result);
return result;
}
CHECK(file_id.is_valid());
}
result.push_back(file_id);
void Document::append_file_ids(const Td *td, vector<FileId> &file_ids) const {
if (!file_id.is_valid() || empty()) {
return;
}
if (type == Type::Sticker) {
append(file_ids, td->stickers_manager_->get_sticker_file_ids(file_id));
return;
}
file_ids.push_back(file_id);
FileId thumbnail_file_id = [&] {
switch (type) {
case Type::Animation:
@ -32,8 +43,6 @@ vector<FileId> Document::get_file_ids(const Td *td) const {
return td->audios_manager_->get_audio_thumbnail_file_id(file_id);
case Type::General:
return td->documents_manager_->get_document_thumbnail_file_id(file_id);
case Type::Sticker:
return td->stickers_manager_->get_sticker_thumbnail_file_id(file_id);
case Type::Video:
return td->videos_manager_->get_video_thumbnail_file_id(file_id);
case Type::VideoNote:
@ -43,9 +52,8 @@ vector<FileId> Document::get_file_ids(const Td *td) const {
}
}();
if (thumbnail_file_id.is_valid()) {
result.push_back(thumbnail_file_id);
file_ids.push_back(thumbnail_file_id);
}
return result;
}
StringBuilder &operator<<(StringBuilder &string_builder, const Document::Type &document_type) {

View File

@ -31,6 +31,8 @@ struct Document {
}
vector<FileId> get_file_ids(const Td *td) const;
void append_file_ids(const Td *td, vector<FileId> &file_ids) const;
};
StringBuilder &operator<<(StringBuilder &string_builder, const Document::Type &document_type);

View File

@ -1477,7 +1477,7 @@ vector<FileId> WebPagesManager::get_web_page_file_ids(const WebPage *web_page) c
vector<FileId> result = photo_get_file_ids(web_page->photo);
if (!web_page->document.empty()) {
append(result, web_page->document.get_file_ids(td_));
web_page->document.append_file_ids(td_, result);
}
if (!web_page->instant_view.is_empty) {
for (auto &page_block : web_page->instant_view.page_blocks) {