Add Document.get_file_ids method.
GitOrigin-RevId: a885722f10800b5d64ac6f398a4526c874bd2668
This commit is contained in:
parent
9f5096cd6f
commit
d42df63ba9
@ -6,8 +6,49 @@
|
||||
//
|
||||
#include "td/telegram/Document.h"
|
||||
|
||||
#include "td/telegram/AnimationsManager.h"
|
||||
#include "td/telegram/AudiosManager.h"
|
||||
#include "td/telegram/DocumentsManager.h"
|
||||
#include "td/telegram/StickersManager.h"
|
||||
#include "td/telegram/Td.h"
|
||||
#include "td/telegram/VideosManager.h"
|
||||
#include "td/telegram/VideoNotesManager.h"
|
||||
#include "td/telegram/VoiceNotesManager.h"
|
||||
|
||||
namespace td {
|
||||
|
||||
vector<FileId> Document::get_file_ids(const Td *td) const {
|
||||
vector<FileId> result;
|
||||
if (empty()) {
|
||||
return result;
|
||||
}
|
||||
CHECK(file_id.is_valid());
|
||||
|
||||
result.push_back(file_id);
|
||||
FileId thumbnail_file_id = [&] {
|
||||
switch (type) {
|
||||
case Type::Animation:
|
||||
return td->animations_manager_->get_animation_thumbnail_file_id(file_id);
|
||||
case Type::Audio:
|
||||
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:
|
||||
return td->video_notes_manager_->get_video_note_thumbnail_file_id(file_id);
|
||||
default:
|
||||
return FileId();
|
||||
}
|
||||
}();
|
||||
if (thumbnail_file_id.is_valid()) {
|
||||
result.push_back(thumbnail_file_id);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
StringBuilder &operator<<(StringBuilder &string_builder, const Document &document) {
|
||||
auto type = [&] {
|
||||
switch (document.type) {
|
||||
|
@ -13,6 +13,8 @@
|
||||
|
||||
namespace td {
|
||||
|
||||
class Td;
|
||||
|
||||
struct Document {
|
||||
// append only
|
||||
enum class Type : int32 { Unknown, Animation, Audio, General, Sticker, Video, VideoNote, VoiceNote };
|
||||
@ -27,6 +29,8 @@ struct Document {
|
||||
bool empty() const {
|
||||
return type == Type::Unknown;
|
||||
}
|
||||
|
||||
vector<FileId> get_file_ids(const Td *td) const;
|
||||
};
|
||||
|
||||
StringBuilder &operator<<(StringBuilder &string_builder, const Document &document);
|
||||
|
@ -9,14 +9,21 @@
|
||||
#include "td/telegram/Document.h"
|
||||
|
||||
#include "td/telegram/AnimationsManager.h"
|
||||
#include "td/telegram/AnimationsManager.hpp"
|
||||
#include "td/telegram/AudiosManager.h"
|
||||
#include "td/telegram/AudiosManager.hpp"
|
||||
#include "td/telegram/DocumentsManager.h"
|
||||
#include "td/telegram/DocumentsManager.hpp"
|
||||
#include "td/telegram/files/FileId.hpp"
|
||||
#include "td/telegram/StickersManager.h"
|
||||
#include "td/telegram/StickersManager.hpp"
|
||||
#include "td/telegram/Td.h"
|
||||
#include "td/telegram/VideosManager.h"
|
||||
#include "td/telegram/VideosManager.hpp"
|
||||
#include "td/telegram/VideoNotesManager.h"
|
||||
#include "td/telegram/VideoNotesManager.hpp"
|
||||
#include "td/telegram/VoiceNotesManager.h"
|
||||
#include "td/telegram/VoiceNotesManager.hpp"
|
||||
|
||||
#include "td/utils/logging.h"
|
||||
#include "td/utils/tl_helpers.h"
|
||||
|
@ -3765,34 +3765,8 @@ 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.file_id.is_valid()) {
|
||||
result.push_back(web_page->document.file_id);
|
||||
FileId thumbnail_file_id;
|
||||
switch (web_page->document.type) {
|
||||
case Document::Type::Animation:
|
||||
thumbnail_file_id = td_->animations_manager_->get_animation_thumbnail_file_id(web_page->document.file_id);
|
||||
break;
|
||||
case Document::Type::Audio:
|
||||
thumbnail_file_id = td_->audios_manager_->get_audio_thumbnail_file_id(web_page->document.file_id);
|
||||
break;
|
||||
case Document::Type::General:
|
||||
thumbnail_file_id = td_->documents_manager_->get_document_thumbnail_file_id(web_page->document.file_id);
|
||||
break;
|
||||
case Document::Type::Sticker:
|
||||
thumbnail_file_id = td_->stickers_manager_->get_sticker_thumbnail_file_id(web_page->document.file_id);
|
||||
break;
|
||||
case Document::Type::Video:
|
||||
thumbnail_file_id = td_->videos_manager_->get_video_thumbnail_file_id(web_page->document.file_id);
|
||||
break;
|
||||
case Document::Type::VideoNote:
|
||||
thumbnail_file_id = td_->video_notes_manager_->get_video_note_thumbnail_file_id(web_page->document.file_id);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
if (thumbnail_file_id.is_valid()) {
|
||||
result.push_back(thumbnail_file_id);
|
||||
}
|
||||
if (!web_page->document.empty()) {
|
||||
append(result, web_page->document.get_file_ids(td_));
|
||||
}
|
||||
if (!web_page->instant_view.is_empty) {
|
||||
for (auto &page_block : web_page->instant_view.page_blocks) {
|
||||
|
Loading…
Reference in New Issue
Block a user