From dc79cdc0b11b5fad3aa7a2846335f740a3ca1909 Mon Sep 17 00:00:00 2001 From: levlam Date: Tue, 9 Apr 2019 18:38:57 +0300 Subject: [PATCH] Add Document class. GitOrigin-RevId: e1a5a8235f341cf0955ee37086a99a17e7b123de --- CMakeLists.txt | 2 + td/telegram/AnimationsManager.cpp | 7 +- td/telegram/Document.cpp | 39 ++++++ td/telegram/Document.h | 30 +++++ td/telegram/DocumentsManager.cpp | 85 +++++++------ td/telegram/DocumentsManager.h | 17 ++- td/telegram/DocumentsManager.hpp | 4 +- td/telegram/Game.cpp | 20 +-- td/telegram/InlineQueriesManager.cpp | 69 +++++----- td/telegram/MessageContent.cpp | 28 ++-- td/telegram/NotificationManager.cpp | 24 ++-- td/telegram/StickersManager.cpp | 5 +- td/telegram/WebPagesManager.cpp | 183 +++++++++++++-------------- 13 files changed, 288 insertions(+), 225 deletions(-) create mode 100644 td/telegram/Document.cpp create mode 100644 td/telegram/Document.h diff --git a/CMakeLists.txt b/CMakeLists.txt index 0ec7ec177..45a935301 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -362,6 +362,7 @@ set(TDLIB_SOURCE td/telegram/DialogDb.cpp td/telegram/DialogId.cpp td/telegram/DialogParticipant.cpp + td/telegram/Document.cpp td/telegram/DocumentsManager.cpp td/telegram/DraftMessage.cpp td/telegram/FileReferenceManager.cpp @@ -494,6 +495,7 @@ set(TDLIB_SOURCE td/telegram/DialogDb.h td/telegram/DialogId.h td/telegram/DialogParticipant.h + td/telegram/Document.h td/telegram/DocumentsManager.h td/telegram/DraftMessage.h td/telegram/FileReferenceManager.h diff --git a/td/telegram/AnimationsManager.cpp b/td/telegram/AnimationsManager.cpp index 8d1b7ef06..9f5b82a31 100644 --- a/td/telegram/AnimationsManager.cpp +++ b/td/telegram/AnimationsManager.cpp @@ -8,6 +8,7 @@ #include "td/telegram/AuthManager.h" #include "td/telegram/DialogId.h" +#include "td/telegram/Document.h" #include "td/telegram/DocumentsManager.h" #include "td/telegram/FileReferenceManager.h" #include "td/telegram/files/FileManager.h" @@ -549,12 +550,12 @@ void AnimationsManager::on_get_saved_animations( CHECK(document_constructor_id == telegram_api::document::ID); auto document = td_->documents_manager_->on_get_document(move_tl_object_as(document_ptr), DialogId()); - if (document.first != DocumentsManager::DocumentType::Animation) { - LOG(ERROR) << "Receive " << static_cast(document.first) << " instead of animation as saved animation"; + if (document.type != Document::Type::Animation) { + LOG(ERROR) << "Receive " << document << " instead of animation as saved animation"; continue; } if (!is_repair) { - saved_animation_ids.push_back(document.second); + saved_animation_ids.push_back(document.file_id); } } diff --git a/td/telegram/Document.cpp b/td/telegram/Document.cpp new file mode 100644 index 000000000..e53480f62 --- /dev/null +++ b/td/telegram/Document.cpp @@ -0,0 +1,39 @@ +// +// Copyright Aliaksei Levin (levlam@telegram.org), Arseny Smirnov (arseny30@gmail.com) 2014-2019 +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +#include "td/telegram/Document.h" + +namespace td { + +StringBuilder &operator<<(StringBuilder &string_builder, const Document &document) { + auto type = [&] { + switch (document.type) { + case Document::Type::Unknown: + return "Unknown"; + case Document::Type::Animation: + return "Animation"; + case Document::Type::Audio: + return "Audio"; + case Document::Type::General: + return "Document"; + case Document::Type::Sticker: + return "Sticker"; + case Document::Type::Video: + return "Video"; + case Document::Type::VideoNote: + return "VideoNote"; + case Document::Type::VoiceNote: + return "VoiceNote"; + default: + return "Unreachable"; + } + }(); + + return string_builder << '[' << type << ' ' << document.file_id << ']'; +} + + +} // namespace td diff --git a/td/telegram/Document.h b/td/telegram/Document.h new file mode 100644 index 000000000..b439b4427 --- /dev/null +++ b/td/telegram/Document.h @@ -0,0 +1,30 @@ +// +// Copyright Aliaksei Levin (levlam@telegram.org), Arseny Smirnov (arseny30@gmail.com) 2014-2019 +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +#pragma once + +#include "td/telegram/files/FileId.h" + +#include "td/utils/common.h" +#include "td/utils/StringBuilder.h" + +namespace td { + +struct Document { + // append only + enum class Type : int32 { Unknown, Animation, Audio, General, Sticker, Video, VideoNote, VoiceNote }; + + Type type = Type::Unknown; + FileId file_id; + + Document() = default; + Document(Type type, FileId file_id): type(type), file_id(file_id) { + } +}; + +StringBuilder &operator<<(StringBuilder &string_builder, const Document &document); + +} // namespace td diff --git a/td/telegram/DocumentsManager.cpp b/td/telegram/DocumentsManager.cpp index 09e43b866..ba76d1872 100644 --- a/td/telegram/DocumentsManager.cpp +++ b/td/telegram/DocumentsManager.cpp @@ -8,6 +8,7 @@ #include "td/telegram/AnimationsManager.h" #include "td/telegram/AudiosManager.h" +#include "td/telegram/Document.h" #include "td/telegram/files/FileEncryptionKey.h" #include "td/telegram/files/FileLocation.h" #include "td/telegram/files/FileManager.h" @@ -59,9 +60,9 @@ tl_object_ptr DocumentsManager::get_document_object(FileId fil td_->file_manager_->get_file_object(file_id)); } -std::pair DocumentsManager::on_get_document( - RemoteDocument remote_document, DialogId owner_dialog_id, MultiPromiseActor *load_data_multipromise_ptr, - DocumentType default_document_type) { +Document DocumentsManager::on_get_document(RemoteDocument remote_document, DialogId owner_dialog_id, + MultiPromiseActor *load_data_multipromise_ptr, + Document::Type default_document_type) { tl_object_ptr animated; tl_object_ptr video; tl_object_ptr audio; @@ -132,37 +133,37 @@ std::pair DocumentsManager::on_get_docum Slice default_extension; bool supports_streaming = false; bool has_webp_thumbnail = false; - if (type_attributes == 1 || default_document_type != DocumentType::General) { // not a general document - if (animated != nullptr || default_document_type == DocumentType::Animation) { - document_type = DocumentType::Animation; + if (type_attributes == 1 || default_document_type != Document::Type::General) { // not a general document + if (animated != nullptr || default_document_type == Document::Type::Animation) { + document_type = Document::Type::Animation; file_type = FileType::Animation; default_extension = Slice("mp4"); - } else if (audio != nullptr || default_document_type == DocumentType::Audio || - default_document_type == DocumentType::VoiceNote) { - bool is_voice_note = default_document_type == DocumentType::VoiceNote; + } else if (audio != nullptr || default_document_type == Document::Type::Audio || + default_document_type == Document::Type::VoiceNote) { + bool is_voice_note = default_document_type == Document::Type::VoiceNote; if (audio != nullptr) { is_voice_note = (audio->flags_ & telegram_api::documentAttributeAudio::VOICE_MASK) != 0; } if (is_voice_note) { - document_type = DocumentType::VoiceNote; + document_type = Document::Type::VoiceNote; file_type = FileType::VoiceNote; default_extension = Slice("oga"); file_name.clear(); } else { - document_type = DocumentType::Audio; + document_type = Document::Type::Audio; file_type = FileType::Audio; default_extension = Slice("mp3"); } - } else if (sticker != nullptr || default_document_type == DocumentType::Sticker) { - document_type = DocumentType::Sticker; + } else if (sticker != nullptr || default_document_type == Document::Type::Sticker) { + document_type = Document::Type::Sticker; file_type = FileType::Sticker; default_extension = Slice("webp"); owner_dialog_id = DialogId(); file_name.clear(); has_webp_thumbnail = td_->stickers_manager_->has_webp_thumbnail(sticker); - } else if (video != nullptr || default_document_type == DocumentType::Video || - default_document_type == DocumentType::VideoNote) { - bool is_video_note = default_document_type == DocumentType::VideoNote; + } else if (video != nullptr || default_document_type == Document::Type::Video || + default_document_type == Document::Type::VideoNote) { + bool is_video_note = default_document_type == Document::Type::VideoNote; if (video != nullptr) { is_video_note = (video->flags_ & telegram_api::documentAttributeVideo::ROUND_MESSAGE_MASK) != 0; if (!is_video_note) { @@ -170,11 +171,11 @@ std::pair DocumentsManager::on_get_docum } } if (is_video_note) { - document_type = DocumentType::VideoNote; + document_type = Document::Type::VideoNote; file_type = FileType::VideoNote; file_name.clear(); } else { - document_type = DocumentType::Video; + document_type = Document::Type::Video; file_type = FileType::Video; } default_extension = Slice("mp4"); @@ -207,7 +208,7 @@ std::pair DocumentsManager::on_get_docum mime_type = std::move(document->mime_type_); file_reference = document->file_reference_.as_slice().str(); - if (document_type != DocumentType::VoiceNote) { + if (document_type != Document::Type::VoiceNote) { thumbnail = get_photo_size(td_->file_manager_.get(), FileType::Thumbnail, 0, 0, "", owner_dialog_id, std::move(document->thumb_), has_webp_thumbnail); } @@ -224,10 +225,10 @@ std::pair DocumentsManager::on_get_docum file_type = FileType::Encrypted; encryption_key = FileEncryptionKey{document->key_.as_slice(), document->iv_.as_slice()}; if (encryption_key.empty()) { - return {DocumentType::Unknown, FileId()}; + return {Document::Type::Unknown, FileId()}; } - if (document_type != DocumentType::VoiceNote) { + if (document_type != Document::Type::VoiceNote) { thumbnail = get_thumbnail_photo_size(td_->file_manager_.get(), std::move(document->thumb_), owner_dialog_id, document->thumb_w_, document->thumb_h_); } @@ -245,7 +246,7 @@ std::pair DocumentsManager::on_get_docum auto r_http_url = parse_url(web_document->url_); if (r_http_url.is_error()) { LOG(ERROR) << "Can't parse URL " << web_document->url_; - return {DocumentType::Unknown, FileId()}; + return {Document::Type::Unknown, FileId()}; } auto http_url = r_http_url.move_as_ok(); @@ -262,7 +263,7 @@ std::pair DocumentsManager::on_get_docum if (web_document->url_.find('.') == string::npos) { LOG(ERROR) << "Receive invalid URL " << web_document->url_; - return {DocumentType::Unknown, FileId()}; + return {Document::Type::Unknown, FileId()}; } url = std::move(web_document->url_); @@ -279,7 +280,7 @@ std::pair DocumentsManager::on_get_docum LOG(DEBUG) << "Receive document with id = " << id << " of type " << static_cast(document_type); if (!is_web && !DcId::is_valid(dc_id)) { LOG(ERROR) << "Wrong dc_id = " << dc_id; - return {DocumentType::Unknown, FileId()}; + return {Document::Type::Unknown, FileId()}; } auto suggested_file_name = file_name; @@ -307,7 +308,7 @@ std::pair DocumentsManager::on_get_docum auto r_file_id = td_->file_manager_->from_persistent_id(url, file_type); if (r_file_id.is_error()) { LOG(ERROR) << "Can't register URL: " << r_file_id.error(); - return {DocumentType::Unknown, FileId()}; + return {Document::Type::Unknown, FileId()}; } file_id = r_file_id.move_as_ok(); } @@ -321,12 +322,12 @@ std::pair DocumentsManager::on_get_docum } switch (document_type) { - case DocumentType::Animation: + case Document::Type::Animation: // TODO use has_stickers td_->animations_manager_->create_animation(file_id, std::move(thumbnail), std::move(file_name), std::move(mime_type), video_duration, dimensions, !is_web); break; - case DocumentType::Audio: { + case Document::Type::Audio: { int32 duration = 0; string title; string performer; @@ -339,23 +340,23 @@ std::pair DocumentsManager::on_get_docum duration, std::move(title), std::move(performer), !is_web); break; } - case DocumentType::General: + case Document::Type::General: td_->documents_manager_->create_document(file_id, std::move(thumbnail), std::move(file_name), std::move(mime_type), !is_web); break; - case DocumentType::Sticker: + case Document::Type::Sticker: td_->stickers_manager_->create_sticker(file_id, std::move(thumbnail), dimensions, true, std::move(sticker), load_data_multipromise_ptr); break; - case DocumentType::Video: + case Document::Type::Video: td_->videos_manager_->create_video(file_id, std::move(thumbnail), has_stickers, vector(), std::move(file_name), std::move(mime_type), video_duration, dimensions, supports_streaming, !is_web); break; - case DocumentType::VideoNote: + case Document::Type::VideoNote: td_->video_notes_manager_->create_video_note(file_id, std::move(thumbnail), video_duration, dimensions, !is_web); break; - case DocumentType::VoiceNote: { + case Document::Type::VoiceNote: { int32 duration = 0; string waveform; if (audio != nullptr) { @@ -366,14 +367,14 @@ std::pair DocumentsManager::on_get_docum !is_web); break; } - case DocumentType::Unknown: + case Document::Type::Unknown: default: UNREACHABLE(); } return {document_type, file_id}; } -FileId DocumentsManager::on_get_document(unique_ptr new_document, bool replace) { +FileId DocumentsManager::on_get_document(unique_ptr new_document, bool replace) { auto file_id = new_document->file_id; LOG(INFO) << "Receive document " << file_id; auto &d = documents_[new_document->file_id]; @@ -408,7 +409,7 @@ FileId DocumentsManager::on_get_document(unique_ptr new_document, bool void DocumentsManager::create_document(FileId file_id, PhotoSize thumbnail, string file_name, string mime_type, bool replace) { - auto d = make_unique(); + auto d = make_unique(); d->file_id = file_id; d->file_name = std::move(file_name); d->mime_type = std::move(mime_type); @@ -416,7 +417,7 @@ void DocumentsManager::create_document(FileId file_id, PhotoSize thumbnail, stri on_get_document(std::move(d), replace); } -const DocumentsManager::Document *DocumentsManager::get_document(FileId file_id) const { +const DocumentsManager::GeneralDocument *DocumentsManager::get_document(FileId file_id) const { auto document = documents_.find(file_id); if (document == documents_.end()) { return nullptr; @@ -448,7 +449,7 @@ bool DocumentsManager::has_input_media(FileId file_id, FileId thumbnail_file_id, SecretInputMedia DocumentsManager::get_secret_input_media(FileId document_file_id, tl_object_ptr input_file, const string &caption, BufferSlice thumbnail) const { - const Document *document = get_document(document_file_id); + const GeneralDocument *document = get_document(document_file_id); CHECK(document != nullptr); auto file_view = td_->file_manager_->get_file_view(document_file_id); auto &encryption_key = file_view.encryption_key(); @@ -491,7 +492,7 @@ tl_object_ptr DocumentsManager::get_input_media( } if (input_file != nullptr) { - const Document *document = get_document(file_id); + const GeneralDocument *document = get_document(file_id); CHECK(document != nullptr); vector> attributes; @@ -525,11 +526,11 @@ void DocumentsManager::delete_document_thumbnail(FileId file_id) { } FileId DocumentsManager::dup_document(FileId new_id, FileId old_id) { - const Document *old_document = get_document(old_id); + const GeneralDocument *old_document = get_document(old_id); CHECK(old_document != nullptr); auto &new_document = documents_[new_id]; CHECK(!new_document); - new_document = make_unique(*old_document); + new_document = make_unique(*old_document); new_document->file_id = new_id; new_document->thumbnail.file_id = td_->file_manager_->dup_file_id(new_document->thumbnail.file_id); return new_id; @@ -542,7 +543,7 @@ bool DocumentsManager::merge_documents(FileId new_id, FileId old_id, bool can_de } LOG(INFO) << "Merge documents " << new_id << " and " << old_id; - const Document *old_ = get_document(old_id); + const GeneralDocument *old_ = get_document(old_id); CHECK(old_ != nullptr); if (old_id == new_id) { return old_->is_changed; @@ -559,7 +560,7 @@ bool DocumentsManager::merge_documents(FileId new_id, FileId old_id, bool can_de documents_.emplace(new_id, std::move(old)); } } else { - Document *new_ = new_it->second.get(); + GeneralDocument *new_ = new_it->second.get(); CHECK(new_ != nullptr); if (old_->thumbnail != new_->thumbnail) { diff --git a/td/telegram/DocumentsManager.h b/td/telegram/DocumentsManager.h index f9e29be29..ec845dbc7 100644 --- a/td/telegram/DocumentsManager.h +++ b/td/telegram/DocumentsManager.h @@ -11,6 +11,7 @@ #include "td/telegram/telegram_api.h" #include "td/telegram/DialogId.h" +#include "td/telegram/Document.h" #include "td/telegram/files/FileId.h" #include "td/telegram/Photo.h" #include "td/telegram/SecretInputMedia.h" @@ -30,8 +31,6 @@ class DocumentsManager { public: explicit DocumentsManager(Td *td); - enum class DocumentType : int32 { Unknown, Animation, Audio, General, Sticker, Video, VideoNote, VoiceNote }; - class RemoteDocument { public: tl_object_ptr document; @@ -77,9 +76,9 @@ class DocumentsManager { tl_object_ptr get_document_object(FileId file_id); - std::pair on_get_document(RemoteDocument remote_document, DialogId owner_dialog_id, - MultiPromiseActor *load_data_multipromise_ptr = nullptr, - DocumentType default_document_type = DocumentType::General); + Document on_get_document(RemoteDocument remote_document, DialogId owner_dialog_id, + MultiPromiseActor *load_data_multipromise_ptr = nullptr, + Document::Type default_document_type = Document::Type::General); void create_document(FileId file_id, PhotoSize thumbnail, string file_name, string mime_type, bool replace); @@ -110,7 +109,7 @@ class DocumentsManager { string get_document_search_text(FileId file_id) const; private: - class Document { + class GeneralDocument { public: string file_name; string mime_type; @@ -120,12 +119,12 @@ class DocumentsManager { bool is_changed = true; }; - const Document *get_document(FileId file_id) const; + const GeneralDocument *get_document(FileId file_id) const; - FileId on_get_document(unique_ptr new_document, bool replace); + FileId on_get_document(unique_ptr new_document, bool replace); Td *td_; - std::unordered_map, FileIdHash> documents_; // file_id -> Document + std::unordered_map, FileIdHash> documents_; // file_id -> GeneralDocument }; } // namespace td diff --git a/td/telegram/DocumentsManager.hpp b/td/telegram/DocumentsManager.hpp index 52e0c8d9b..45fe9dfdf 100644 --- a/td/telegram/DocumentsManager.hpp +++ b/td/telegram/DocumentsManager.hpp @@ -21,7 +21,7 @@ void DocumentsManager::store_document(FileId file_id, StorerT &storer) const { LOG(DEBUG) << "Store document " << file_id; auto it = documents_.find(file_id); CHECK(it != documents_.end()); - const Document *document = it->second.get(); + const GeneralDocument *document = it->second.get(); store(document->file_name, storer); store(document->mime_type, storer); store(document->thumbnail, storer); @@ -30,7 +30,7 @@ void DocumentsManager::store_document(FileId file_id, StorerT &storer) const { template FileId DocumentsManager::parse_document(ParserT &parser) { - auto document = make_unique(); + auto document = make_unique(); parse(document->file_name, parser); parse(document->mime_type, parser); parse(document->thumbnail, parser); diff --git a/td/telegram/Game.cpp b/td/telegram/Game.cpp index 1c01e905d..2eddd9966 100644 --- a/td/telegram/Game.cpp +++ b/td/telegram/Game.cpp @@ -11,6 +11,7 @@ #include "td/telegram/AnimationsManager.h" #include "td/telegram/ContactsManager.h" +#include "td/telegram/Document.h" #include "td/telegram/DocumentsManager.h" #include "td/telegram/misc.h" #include "td/telegram/Photo.h" @@ -42,21 +43,10 @@ Game::Game(Td *td, string title, string description, tl_object_ptrdocuments_manager_->on_get_document(move_tl_object_as(document), owner_dialog_id); - switch (parsed_document.first) { - case DocumentsManager::DocumentType::Animation: - animation_file_id_ = parsed_document.second; - break; - case DocumentsManager::DocumentType::Audio: - case DocumentsManager::DocumentType::General: - case DocumentsManager::DocumentType::Sticker: - case DocumentsManager::DocumentType::Video: - case DocumentsManager::DocumentType::VideoNote: - case DocumentsManager::DocumentType::VoiceNote: - case DocumentsManager::DocumentType::Unknown: - LOG(ERROR) << "Receive non-animation document in the game"; - break; - default: - UNREACHABLE(); + if (parsed_document.type == Document::Type::Animation) { + animation_file_id_ = parsed_document.file_id; + } else { + LOG(ERROR) << "Receive non-animation document in the game"; } } } diff --git a/td/telegram/InlineQueriesManager.cpp b/td/telegram/InlineQueriesManager.cpp index c90c83a2a..d9c7b9569 100644 --- a/td/telegram/InlineQueriesManager.cpp +++ b/td/telegram/InlineQueriesManager.cpp @@ -17,6 +17,7 @@ #include "td/telegram/AuthManager.h" #include "td/telegram/Contact.h" #include "td/telegram/ContactsManager.h" +#include "td/telegram/Document.h" #include "td/telegram/DocumentsManager.h" #include "td/telegram/files/FileManager.h" #include "td/telegram/files/FileType.h" @@ -1150,17 +1151,17 @@ void InlineQueriesManager::on_get_inline_query_results(UserId bot_user_id, uint6 auto parsed_document = td_->documents_manager_->on_get_document( move_tl_object_as(document_ptr), DialogId()); - switch (parsed_document.first) { - case DocumentsManager::DocumentType::Animation: { + switch (parsed_document.type) { + case Document::Type::Animation: { LOG_IF(WARNING, result->type_ != "gif") << "Wrong result type " << result->type_; auto animation = make_tl_object(); animation->id_ = std::move(result->id_); animation->animation_ = - td_->animations_manager_->get_animation_object(parsed_document.second, "inlineQueryResultAnimation"); + td_->animations_manager_->get_animation_object(parsed_document.file_id, "inlineQueryResultAnimation"); animation->title_ = std::move(result->title_); - if (!register_inline_message_content(results->query_id_, animation->id_, parsed_document.second, + if (!register_inline_message_content(results->query_id_, animation->id_, parsed_document.file_id, std::move(result->send_message_), td_api::inputMessageAnimation::ID)) { continue; @@ -1168,30 +1169,30 @@ void InlineQueriesManager::on_get_inline_query_results(UserId bot_user_id, uint6 output_result = std::move(animation); break; } - case DocumentsManager::DocumentType::Audio: { + case Document::Type::Audio: { LOG_IF(WARNING, result->type_ != "audio") << "Wrong result type " << result->type_; auto audio = make_tl_object(); audio->id_ = std::move(result->id_); - audio->audio_ = td_->audios_manager_->get_audio_object(parsed_document.second); + audio->audio_ = td_->audios_manager_->get_audio_object(parsed_document.file_id); - if (!register_inline_message_content(results->query_id_, audio->id_, parsed_document.second, + if (!register_inline_message_content(results->query_id_, audio->id_, parsed_document.file_id, std::move(result->send_message_), td_api::inputMessageAudio::ID)) { continue; } output_result = std::move(audio); break; } - case DocumentsManager::DocumentType::General: { + case Document::Type::General: { LOG_IF(WARNING, result->type_ != "file") << "Wrong result type " << result->type_; auto document = make_tl_object(); document->id_ = std::move(result->id_); - document->document_ = td_->documents_manager_->get_document_object(parsed_document.second); + document->document_ = td_->documents_manager_->get_document_object(parsed_document.file_id); document->title_ = std::move(result->title_); document->description_ = std::move(result->description_); - if (!register_inline_message_content(results->query_id_, document->id_, parsed_document.second, + if (!register_inline_message_content(results->query_id_, document->id_, parsed_document.file_id, std::move(result->send_message_), td_api::inputMessageDocument::ID)) { continue; @@ -1199,48 +1200,48 @@ void InlineQueriesManager::on_get_inline_query_results(UserId bot_user_id, uint6 output_result = std::move(document); break; } - case DocumentsManager::DocumentType::Sticker: { + case Document::Type::Sticker: { LOG_IF(WARNING, result->type_ != "sticker") << "Wrong result type " << result->type_; auto sticker = make_tl_object(); sticker->id_ = std::move(result->id_); - sticker->sticker_ = td_->stickers_manager_->get_sticker_object(parsed_document.second); + sticker->sticker_ = td_->stickers_manager_->get_sticker_object(parsed_document.file_id); - if (!register_inline_message_content(results->query_id_, sticker->id_, parsed_document.second, + if (!register_inline_message_content(results->query_id_, sticker->id_, parsed_document.file_id, std::move(result->send_message_), td_api::inputMessageSticker::ID)) { continue; } output_result = std::move(sticker); break; } - case DocumentsManager::DocumentType::Video: { + case Document::Type::Video: { LOG_IF(WARNING, result->type_ != "video") << "Wrong result type " << result->type_; auto video = make_tl_object(); video->id_ = std::move(result->id_); - video->video_ = td_->videos_manager_->get_video_object(parsed_document.second); + video->video_ = td_->videos_manager_->get_video_object(parsed_document.file_id); video->title_ = std::move(result->title_); video->description_ = std::move(result->description_); - if (!register_inline_message_content(results->query_id_, video->id_, parsed_document.second, + if (!register_inline_message_content(results->query_id_, video->id_, parsed_document.file_id, std::move(result->send_message_), td_api::inputMessageVideo::ID)) { continue; } output_result = std::move(video); break; } - case DocumentsManager::DocumentType::VideoNote: + case Document::Type::VideoNote: // FIXME break; - case DocumentsManager::DocumentType::VoiceNote: { + case Document::Type::VoiceNote: { LOG_IF(WARNING, result->type_ != "voice") << "Wrong result type " << result->type_; auto voice_note = make_tl_object(); voice_note->id_ = std::move(result->id_); - voice_note->voice_note_ = td_->voice_notes_manager_->get_voice_note_object(parsed_document.second); + voice_note->voice_note_ = td_->voice_notes_manager_->get_voice_note_object(parsed_document.file_id); voice_note->title_ = std::move(result->title_); - if (!register_inline_message_content(results->query_id_, voice_note->id_, parsed_document.second, + if (!register_inline_message_content(results->query_id_, voice_note->id_, parsed_document.file_id, std::move(result->send_message_), td_api::inputMessageVoiceNote::ID)) { continue; @@ -1248,7 +1249,7 @@ void InlineQueriesManager::on_get_inline_query_results(UserId bot_user_id, uint6 output_result = std::move(voice_note); break; } - case DocumentsManager::DocumentType::Unknown: + case Document::Type::Unknown: // invalid document break; default: @@ -1418,21 +1419,21 @@ void InlineQueriesManager::on_get_inline_query_results(UserId bot_user_id, uint6 } auto default_document_type = [type = result->type_, is_animation] { if (type == "audio") { - return DocumentsManager::DocumentType::Audio; + return Document::Type::Audio; } if (is_animation) { - return DocumentsManager::DocumentType::Animation; + return Document::Type::Animation; } if (type == "sticker") { - return DocumentsManager::DocumentType::Sticker; + return Document::Type::Sticker; } if (type == "video") { - return DocumentsManager::DocumentType::Video; + return Document::Type::Video; } if (type == "voice") { - return DocumentsManager::DocumentType::VoiceNote; + return Document::Type::VoiceNote; } - return DocumentsManager::DocumentType::General; + return Document::Type::General; }(); auto parsed_document = td_->documents_manager_->on_get_document( @@ -1441,11 +1442,11 @@ void InlineQueriesManager::on_get_inline_query_results(UserId bot_user_id, uint6 std::move(result->thumb_)), std::move(attributes)}, DialogId(), nullptr, default_document_type); - auto file_id = parsed_document.second; + auto file_id = parsed_document.file_id; if (!file_id.is_valid()) { continue; } - if (result->type_ == "audio" && parsed_document.first == DocumentsManager::DocumentType::Audio) { + if (result->type_ == "audio" && parsed_document.type == Document::Type::Audio) { auto audio = make_tl_object(); audio->id_ = std::move(result->id_); audio->audio_ = td_->audios_manager_->get_audio_object(file_id); @@ -1454,7 +1455,7 @@ void InlineQueriesManager::on_get_inline_query_results(UserId bot_user_id, uint6 continue; } output_result = std::move(audio); - } else if (result->type_ == "file" && parsed_document.first == DocumentsManager::DocumentType::General) { + } else if (result->type_ == "file" && parsed_document.type == Document::Type::General) { auto document = make_tl_object(); document->id_ = std::move(result->id_); document->document_ = td_->documents_manager_->get_document_object(file_id); @@ -1465,7 +1466,7 @@ void InlineQueriesManager::on_get_inline_query_results(UserId bot_user_id, uint6 continue; } output_result = std::move(document); - } else if (is_animation && parsed_document.first == DocumentsManager::DocumentType::Animation) { + } else if (is_animation && parsed_document.type == Document::Type::Animation) { auto animation = make_tl_object(); animation->id_ = std::move(result->id_); animation->animation_ = @@ -1476,7 +1477,7 @@ void InlineQueriesManager::on_get_inline_query_results(UserId bot_user_id, uint6 continue; } output_result = std::move(animation); - } else if (result->type_ == "sticker" && parsed_document.first == DocumentsManager::DocumentType::Sticker) { + } else if (result->type_ == "sticker" && parsed_document.type == Document::Type::Sticker) { auto sticker = make_tl_object(); sticker->id_ = std::move(result->id_); sticker->sticker_ = td_->stickers_manager_->get_sticker_object(file_id); @@ -1485,7 +1486,7 @@ void InlineQueriesManager::on_get_inline_query_results(UserId bot_user_id, uint6 continue; } output_result = std::move(sticker); - } else if (result->type_ == "video" && parsed_document.first == DocumentsManager::DocumentType::Video) { + } else if (result->type_ == "video" && parsed_document.type == Document::Type::Video) { auto video = make_tl_object(); video->id_ = std::move(result->id_); video->video_ = td_->videos_manager_->get_video_object(file_id); @@ -1496,7 +1497,7 @@ void InlineQueriesManager::on_get_inline_query_results(UserId bot_user_id, uint6 continue; } output_result = std::move(video); - } else if (result->type_ == "voice" && parsed_document.first == DocumentsManager::DocumentType::VoiceNote) { + } else if (result->type_ == "voice" && parsed_document.type == Document::Type::VoiceNote) { auto voice_note = make_tl_object(); voice_note->id_ = std::move(result->id_); voice_note->voice_note_ = td_->voice_notes_manager_->get_voice_note_object(file_id); diff --git a/td/telegram/MessageContent.cpp b/td/telegram/MessageContent.cpp index 85e272f6c..210efeae0 100644 --- a/td/telegram/MessageContent.cpp +++ b/td/telegram/MessageContent.cpp @@ -16,6 +16,7 @@ #include "td/telegram/ChatId.h" #include "td/telegram/Contact.h" #include "td/telegram/ContactsManager.h" +#include "td/telegram/Document.h" #include "td/telegram/DocumentsManager.h" #include "td/telegram/DocumentsManager.hpp" #include "td/telegram/files/FileId.h" @@ -3491,29 +3492,28 @@ static tl_object_ptr secret_to_telegram(FromT &from) { return res; } -static unique_ptr get_document_message_content( - std::pair &&parsed_document, FormattedText &&caption, bool is_opened) { - auto document_type = parsed_document.first; - auto file_id = parsed_document.second; - if (document_type != DocumentsManager::DocumentType::Unknown) { +static unique_ptr get_document_message_content(Document &&parsed_document, FormattedText &&caption, + bool is_opened) { + auto file_id = parsed_document.file_id; + if (parsed_document.type != Document::Type::Unknown) { CHECK(file_id.is_valid()); } - switch (document_type) { - case DocumentsManager::DocumentType::Animation: + switch (parsed_document.type) { + case Document::Type::Animation: return make_unique(file_id, std::move(caption)); - case DocumentsManager::DocumentType::Audio: + case Document::Type::Audio: return make_unique(file_id, std::move(caption)); - case DocumentsManager::DocumentType::General: + case Document::Type::General: return make_unique(file_id, std::move(caption)); - case DocumentsManager::DocumentType::Sticker: + case Document::Type::Sticker: return make_unique(file_id); - case DocumentsManager::DocumentType::Unknown: + case Document::Type::Unknown: return make_unique(); - case DocumentsManager::DocumentType::Video: + case Document::Type::Video: return make_unique(file_id, std::move(caption)); - case DocumentsManager::DocumentType::VideoNote: + case Document::Type::VideoNote: return make_unique(file_id, is_opened); - case DocumentsManager::DocumentType::VoiceNote: + case Document::Type::VoiceNote: return make_unique(file_id, std::move(caption), is_opened); default: UNREACHABLE(); diff --git a/td/telegram/NotificationManager.cpp b/td/telegram/NotificationManager.cpp index 0afbbf4cc..ddc0bf364 100644 --- a/td/telegram/NotificationManager.cpp +++ b/td/telegram/NotificationManager.cpp @@ -12,6 +12,7 @@ #include "td/telegram/ConfigShared.h" #include "td/telegram/ContactsManager.h" #include "td/telegram/DeviceTokenManager.h" +#include "td/telegram/Document.h" #include "td/telegram/DocumentsManager.h" #include "td/telegram/files/FileManager.h" #include "td/telegram/Global.h" @@ -3236,18 +3237,17 @@ Status NotificationManager::process_push_notification_payload(string payload, Pr } break; case telegram_api::document::ID: { - std::pair attached_document = - td_->documents_manager_->on_get_document(telegram_api::move_object_as(result), - dialog_id); - switch (attached_document.first) { - case DocumentsManager::DocumentType::Animation: - case DocumentsManager::DocumentType::Audio: - case DocumentsManager::DocumentType::General: - case DocumentsManager::DocumentType::Sticker: - case DocumentsManager::DocumentType::Unknown: - case DocumentsManager::DocumentType::Video: - case DocumentsManager::DocumentType::VideoNote: - case DocumentsManager::DocumentType::VoiceNote: + auto parsed_document = td_->documents_manager_->on_get_document( + telegram_api::move_object_as(result), dialog_id); + switch (parsed_document.type) { + case Document::Type::Animation: + case Document::Type::Audio: + case Document::Type::General: + case Document::Type::Sticker: + case Document::Type::Unknown: + case Document::Type::Video: + case Document::Type::VideoNote: + case Document::Type::VoiceNote: break; default: UNREACHABLE(); diff --git a/td/telegram/StickersManager.cpp b/td/telegram/StickersManager.cpp index c6363ca11..b8817555f 100644 --- a/td/telegram/StickersManager.cpp +++ b/td/telegram/StickersManager.cpp @@ -15,6 +15,7 @@ #include "td/telegram/ConfigShared.h" #include "td/telegram/ContactsManager.h" #include "td/telegram/DialogId.h" +#include "td/telegram/Document.h" #include "td/telegram/DocumentsManager.h" #include "td/telegram/FileReferenceManager.h" #include "td/telegram/files/FileLocation.h" @@ -3432,11 +3433,11 @@ void StickersManager::on_uploaded_sticker_file(FileId file_id, tl_object_ptrdocuments_manager_->on_get_document( move_tl_object_as(document_ptr), DialogId(), nullptr); - if (parsed_document.first != DocumentsManager::DocumentType::General) { + if (parsed_document.type != Document::Type::General) { return promise.set_error(Status::Error(400, "Wrong file type")); } - td_->documents_manager_->merge_documents(parsed_document.second, file_id, true); + td_->documents_manager_->merge_documents(parsed_document.file_id, file_id, true); promise.set_value(Unit()); } diff --git a/td/telegram/WebPagesManager.cpp b/td/telegram/WebPagesManager.cpp index f59964ddd..630e1de12 100644 --- a/td/telegram/WebPagesManager.cpp +++ b/td/telegram/WebPagesManager.cpp @@ -15,6 +15,7 @@ #include "td/telegram/AudiosManager.hpp" #include "td/telegram/ChannelId.h" #include "td/telegram/ContactsManager.h" +#include "td/telegram/Document.h" #include "td/telegram/DocumentsManager.h" #include "td/telegram/DocumentsManager.hpp" #include "td/telegram/FileReferenceManager.h" @@ -209,8 +210,7 @@ class WebPagesManager::WebPage { Dimensions embed_dimensions; int32 duration = 0; string author; - DocumentsManager::DocumentType document_type = DocumentsManager::DocumentType::Unknown; - FileId document_file_id; + Document document; WebPageInstantView instant_view; FileSourceId file_source_id; @@ -229,7 +229,7 @@ class WebPagesManager::WebPage { bool has_embed_dimensions = has_embed && embed_dimensions != Dimensions(); bool has_duration = duration > 0; bool has_author = !author.empty(); - bool has_document = document_type != DocumentsManager::DocumentType::Unknown; + bool has_document = document.type != Document::Type::Unknown; bool has_instant_view = !instant_view.is_empty; bool is_instant_view_v2 = instant_view.is_v2; bool has_no_hash = true; @@ -283,30 +283,30 @@ class WebPagesManager::WebPage { Td *td = storer.context()->td().get_actor_unsafe(); CHECK(td != nullptr); - store(document_type, storer); - switch (document_type) { - case DocumentsManager::DocumentType::Animation: - td->animations_manager_->store_animation(document_file_id, storer); + store(document.type, storer); + switch (document.type) { + case Document::Type::Animation: + td->animations_manager_->store_animation(document.file_id, storer); break; - case DocumentsManager::DocumentType::Audio: - td->audios_manager_->store_audio(document_file_id, storer); + case Document::Type::Audio: + td->audios_manager_->store_audio(document.file_id, storer); break; - case DocumentsManager::DocumentType::General: - td->documents_manager_->store_document(document_file_id, storer); + case Document::Type::General: + td->documents_manager_->store_document(document.file_id, storer); break; - case DocumentsManager::DocumentType::Sticker: - td->stickers_manager_->store_sticker(document_file_id, false, storer); + case Document::Type::Sticker: + td->stickers_manager_->store_sticker(document.file_id, false, storer); break; - case DocumentsManager::DocumentType::Video: - td->videos_manager_->store_video(document_file_id, storer); + case Document::Type::Video: + td->videos_manager_->store_video(document.file_id, storer); break; - case DocumentsManager::DocumentType::VideoNote: - td->video_notes_manager_->store_video_note(document_file_id, storer); + case Document::Type::VideoNote: + td->video_notes_manager_->store_video_note(document.file_id, storer); break; - case DocumentsManager::DocumentType::VoiceNote: - td->voice_notes_manager_->store_voice_note(document_file_id, storer); + case Document::Type::VoiceNote: + td->voice_notes_manager_->store_voice_note(document.file_id, storer); break; - case DocumentsManager::DocumentType::Unknown: + case Document::Type::Unknown: default: UNREACHABLE(); } @@ -385,36 +385,36 @@ class WebPagesManager::WebPage { Td *td = parser.context()->td().get_actor_unsafe(); CHECK(td != nullptr); - parse(document_type, parser); - switch (document_type) { - case DocumentsManager::DocumentType::Animation: - document_file_id = td->animations_manager_->parse_animation(parser); + parse(document.type, parser); + switch (document.type) { + case Document::Type::Animation: + document.file_id = td->animations_manager_->parse_animation(parser); break; - case DocumentsManager::DocumentType::Audio: - document_file_id = td->audios_manager_->parse_audio(parser); + case Document::Type::Audio: + document.file_id = td->audios_manager_->parse_audio(parser); break; - case DocumentsManager::DocumentType::General: - document_file_id = td->documents_manager_->parse_document(parser); + case Document::Type::General: + document.file_id = td->documents_manager_->parse_document(parser); break; - case DocumentsManager::DocumentType::Sticker: - document_file_id = td->stickers_manager_->parse_sticker(false, parser); + case Document::Type::Sticker: + document.file_id = td->stickers_manager_->parse_sticker(false, parser); break; - case DocumentsManager::DocumentType::Video: - document_file_id = td->videos_manager_->parse_video(parser); + case Document::Type::Video: + document.file_id = td->videos_manager_->parse_video(parser); break; - case DocumentsManager::DocumentType::VideoNote: - document_file_id = td->video_notes_manager_->parse_video_note(parser); + case Document::Type::VideoNote: + document.file_id = td->video_notes_manager_->parse_video_note(parser); break; - case DocumentsManager::DocumentType::VoiceNote: - document_file_id = td->voice_notes_manager_->parse_voice_note(parser); + case Document::Type::VoiceNote: + document.file_id = td->voice_notes_manager_->parse_voice_note(parser); break; - case DocumentsManager::DocumentType::Unknown: + case Document::Type::Unknown: default: UNREACHABLE(); } - if (!document_file_id.is_valid()) { - LOG(ERROR) << "Parse invalid document_file_id"; - document_type = DocumentsManager::DocumentType::Unknown; + if (!document.file_id.is_valid()) { + LOG(ERROR) << "Parse invalid document.file_id"; + document = Document(); } } @@ -2207,8 +2207,7 @@ WebPageId WebPagesManager::on_get_web_page(tl_object_ptr if (document_id == telegram_api::document::ID) { auto parsed_document = td_->documents_manager_->on_get_document( move_tl_object_as(web_page->document_), owner_dialog_id); - page->document_type = parsed_document.first; - page->document_file_id = parsed_document.second; + page->document = parsed_document; } } if (web_page->flags_ & WEBPAGE_FLAG_HAS_INSTANT_VIEW) { @@ -2808,26 +2807,26 @@ tl_object_ptr WebPagesManager::get_web_page_object(WebPageId we web_page->url, web_page->display_url, web_page->type, web_page->site_name, web_page->title, web_page->description, get_photo_object(td_->file_manager_.get(), &web_page->photo), web_page->embed_url, web_page->embed_type, web_page->embed_dimensions.width, web_page->embed_dimensions.height, web_page->duration, web_page->author, - web_page->document_type == DocumentsManager::DocumentType::Animation - ? td_->animations_manager_->get_animation_object(web_page->document_file_id, "get_web_page_object") + web_page->document.type == Document::Type::Animation + ? td_->animations_manager_->get_animation_object(web_page->document.file_id, "get_web_page_object") : nullptr, - web_page->document_type == DocumentsManager::DocumentType::Audio - ? td_->audios_manager_->get_audio_object(web_page->document_file_id) + web_page->document.type == Document::Type::Audio + ? td_->audios_manager_->get_audio_object(web_page->document.file_id) : nullptr, - web_page->document_type == DocumentsManager::DocumentType::General - ? td_->documents_manager_->get_document_object(web_page->document_file_id) + web_page->document.type == Document::Type::General + ? td_->documents_manager_->get_document_object(web_page->document.file_id) : nullptr, - web_page->document_type == DocumentsManager::DocumentType::Sticker - ? td_->stickers_manager_->get_sticker_object(web_page->document_file_id) + web_page->document.type == Document::Type::Sticker + ? td_->stickers_manager_->get_sticker_object(web_page->document.file_id) : nullptr, - web_page->document_type == DocumentsManager::DocumentType::Video - ? td_->videos_manager_->get_video_object(web_page->document_file_id) + web_page->document.type == Document::Type::Video + ? td_->videos_manager_->get_video_object(web_page->document.file_id) : nullptr, - web_page->document_type == DocumentsManager::DocumentType::VideoNote - ? td_->video_notes_manager_->get_video_note_object(web_page->document_file_id) + web_page->document.type == Document::Type::VideoNote + ? td_->video_notes_manager_->get_video_note_object(web_page->document.file_id) : nullptr, - web_page->document_type == DocumentsManager::DocumentType::VoiceNote - ? td_->voice_notes_manager_->get_voice_note_object(web_page->document_file_id) + web_page->document.type == Document::Type::VoiceNote + ? td_->voice_notes_manager_->get_voice_note_object(web_page->document.file_id) : nullptr, instant_view_version); } @@ -3534,47 +3533,47 @@ void WebPagesManager::on_get_web_page_instant_view(WebPage *web_page, tl_object_ auto document = move_tl_object_as(document_ptr); auto document_id = document->id_; auto parsed_document = td_->documents_manager_->on_get_document(std::move(document), owner_dialog_id); - if (parsed_document.first == DocumentsManager::DocumentType::Animation) { - animations.emplace(document_id, parsed_document.second); - } else if (parsed_document.first == DocumentsManager::DocumentType::Audio) { - audios.emplace(document_id, parsed_document.second); - } else if (parsed_document.first == DocumentsManager::DocumentType::General) { - documents.emplace(document_id, parsed_document.second); - } else if (parsed_document.first == DocumentsManager::DocumentType::Video) { - videos.emplace(document_id, parsed_document.second); + if (parsed_document.type == Document::Type::Animation) { + animations.emplace(document_id, parsed_document.file_id); + } else if (parsed_document.type == Document::Type::Audio) { + audios.emplace(document_id, parsed_document.file_id); + } else if (parsed_document.type == Document::Type::General) { + documents.emplace(document_id, parsed_document.file_id); + } else if (parsed_document.type == Document::Type::Video) { + videos.emplace(document_id, parsed_document.file_id); } else { - LOG(ERROR) << "Receive document of the wrong type " << static_cast(parsed_document.first); + LOG(ERROR) << "Receive document of the wrong type: " << parsed_document; } } } - if (web_page->document_type == DocumentsManager::DocumentType::Animation) { - auto file_view = td_->file_manager_->get_file_view(web_page->document_file_id); + if (web_page->document.type == Document::Type::Animation) { + auto file_view = td_->file_manager_->get_file_view(web_page->document.file_id); if (file_view.has_remote_location()) { - animations.emplace(file_view.remote_location().get_id(), web_page->document_file_id); + animations.emplace(file_view.remote_location().get_id(), web_page->document.file_id); } else { LOG(ERROR) << "Animation has no remote location"; } } - if (web_page->document_type == DocumentsManager::DocumentType::Audio) { - auto file_view = td_->file_manager_->get_file_view(web_page->document_file_id); + if (web_page->document.type == Document::Type::Audio) { + auto file_view = td_->file_manager_->get_file_view(web_page->document.file_id); if (file_view.has_remote_location()) { - audios.emplace(file_view.remote_location().get_id(), web_page->document_file_id); + audios.emplace(file_view.remote_location().get_id(), web_page->document.file_id); } else { LOG(ERROR) << "Audio has no remote location"; } } - if (web_page->document_type == DocumentsManager::DocumentType::General) { - auto file_view = td_->file_manager_->get_file_view(web_page->document_file_id); + if (web_page->document.type == Document::Type::General) { + auto file_view = td_->file_manager_->get_file_view(web_page->document.file_id); if (file_view.has_remote_location()) { - documents.emplace(file_view.remote_location().get_id(), web_page->document_file_id); + documents.emplace(file_view.remote_location().get_id(), web_page->document.file_id); } else { LOG(ERROR) << "Document has no remote location"; } } - if (web_page->document_type == DocumentsManager::DocumentType::Video) { - auto file_view = td_->file_manager_->get_file_view(web_page->document_file_id); + if (web_page->document.type == Document::Type::Video) { + auto file_view = td_->file_manager_->get_file_view(web_page->document.file_id); if (file_view.has_remote_location()) { - videos.emplace(file_view.remote_location().get_id(), web_page->document_file_id); + videos.emplace(file_view.remote_location().get_id(), web_page->document.file_id); } else { LOG(ERROR) << "Video has no remote location"; } @@ -3827,27 +3826,27 @@ vector WebPagesManager::get_web_page_file_ids(const WebPage *web_page) c } vector result = photo_get_file_ids(web_page->photo); - if (web_page->document_file_id.is_valid()) { - result.push_back(web_page->document_file_id); + 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); + 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 DocumentsManager::DocumentType::Audio: - thumbnail_file_id = td_->audios_manager_->get_audio_thumbnail_file_id(web_page->document_file_id); + case Document::Type::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); + case Document::Type::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); + case Document::Type::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); + case Document::Type::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); + 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;