Log unexpected photos in link preview.

This commit is contained in:
levlam 2024-07-05 15:22:26 +03:00
parent 0c7909d87e
commit 4896db62c1

View File

@ -1409,6 +1409,7 @@ td_api::object_ptr<td_api::LinkPreviewType> WebPagesManager::get_link_preview_ty
return td_api::make_object<td_api::linkPreviewTypeUnsupported>();
}
if (type == "background") {
LOG_IF(ERROR, !web_page->photo_.is_empty()) << "Receive photo for " << web_page->url_;
return td_api::make_object<td_api::linkPreviewTypeBackground>(
web_page->document_.type == Document::Type::General
? td_->documents_manager_->get_document_object(web_page->document_.file_id, PhotoFormat::Png)
@ -1437,9 +1438,11 @@ td_api::object_ptr<td_api::LinkPreviewType> WebPagesManager::get_link_preview_ty
get_chat_photo_object(td_->file_manager_.get(), web_page->photo_), type.size() > 10);
}
if (type == "chatlist") {
LOG_IF(ERROR, !web_page->photo_.is_empty()) << "Receive photo for " << web_page->url_;
return td_api::make_object<td_api::linkPreviewTypeShareableChatFolder>();
}
if (type == "giftcode") {
LOG_IF(ERROR, !web_page->photo_.is_empty()) << "Receive photo for " << web_page->url_;
return td_api::make_object<td_api::linkPreviewTypePremiumGiftCode>();
}
if (type == "group_boost") {
@ -1447,6 +1450,7 @@ td_api::object_ptr<td_api::LinkPreviewType> WebPagesManager::get_link_preview_ty
get_chat_photo_object(td_->file_manager_.get(), web_page->photo_));
}
if (type == "invoice") {
LOG_IF(ERROR, !web_page->photo_.is_empty()) << "Receive photo for " << web_page->url_;
return td_api::make_object<td_api::linkPreviewTypeInvoice>();
}
if (type == "livestream") {
@ -1459,9 +1463,11 @@ td_api::object_ptr<td_api::LinkPreviewType> WebPagesManager::get_link_preview_ty
get_chat_photo_object(td_->file_manager_.get(), web_page->photo_), type.size() > 10);
}
if (type == "message") {
LOG_IF(ERROR, !web_page->photo_.is_empty()) << "Receive photo for " << web_page->url_;
return td_api::make_object<td_api::linkPreviewTypeMessage>();
}
if (type == "stickerset") {
LOG_IF(ERROR, !web_page->photo_.is_empty()) << "Receive photo for " << web_page->url_;
auto stickers = transform(web_page->sticker_ids_, [&](FileId sticker_id) {
return td_->stickers_manager_->get_sticker_object(sticker_id);
});
@ -1481,6 +1487,7 @@ td_api::object_ptr<td_api::LinkPreviewType> WebPagesManager::get_link_preview_ty
}
}
if (type == "theme") {
LOG_IF(ERROR, !web_page->photo_.is_empty()) << "Receive photo for " << web_page->url_;
vector<td_api::object_ptr<td_api::document>> documents;
for (auto &document : web_page->documents_) {
if (document.type == Document::Type::General) {
@ -1550,6 +1557,7 @@ td_api::object_ptr<td_api::LinkPreviewType> WebPagesManager::get_link_preview_ty
}
if (web_page->type_ == "audio" ||
(web_page->document_.type == Document::Type::Audio && web_page->type_ == "document")) {
LOG_IF(ERROR, !web_page->photo_.is_empty()) << "Receive photo for " << web_page->url_;
auto audio = web_page->document_.type == Document::Type::Audio
? td_->audios_manager_->get_audio_object(web_page->document_.file_id)
: nullptr;
@ -1563,11 +1571,13 @@ td_api::object_ptr<td_api::LinkPreviewType> WebPagesManager::get_link_preview_ty
}
}
if (web_page->document_.type == Document::Type::General && web_page->type_ == "document") {
LOG_IF(ERROR, !web_page->photo_.is_empty()) << "Receive photo for " << web_page->url_;
auto document = td_->documents_manager_->get_document_object(web_page->document_.file_id, PhotoFormat::Jpeg);
return td_api::make_object<td_api::linkPreviewTypeDocument>(std::move(document), web_page->author_);
}
if (web_page->type_ == "gif" ||
(web_page->document_.type == Document::Type::Animation && web_page->type_ == "document")) {
LOG_IF(ERROR, !web_page->photo_.is_empty()) << "Receive photo for " << web_page->url_;
auto animation = web_page->document_.type == Document::Type::Animation
? td_->animations_manager_->get_animation_object(web_page->document_.file_id)
: nullptr;
@ -1588,11 +1598,13 @@ td_api::object_ptr<td_api::LinkPreviewType> WebPagesManager::get_link_preview_ty
}
}
if (web_page->document_.type == Document::Type::Sticker && web_page->type_ == "document") {
LOG_IF(ERROR, !web_page->photo_.is_empty()) << "Receive photo for " << web_page->url_;
auto sticker = td_->stickers_manager_->get_sticker_object(web_page->document_.file_id);
return td_api::make_object<td_api::linkPreviewTypeSticker>(std::move(sticker));
}
if (web_page->type_ == "video" ||
(web_page->document_.type == Document::Type::Video && web_page->type_ == "document")) {
LOG_IF(ERROR, !web_page->photo_.is_empty()) << "Receive photo for " << web_page->url_;
auto video = web_page->document_.type == Document::Type::Video
? td_->videos_manager_->get_video_object(web_page->document_.file_id)
: nullptr;
@ -1608,10 +1620,12 @@ td_api::object_ptr<td_api::LinkPreviewType> WebPagesManager::get_link_preview_ty
}
}
if (web_page->document_.type == Document::Type::VideoNote && web_page->type_ == "document") {
LOG_IF(ERROR, !web_page->photo_.is_empty()) << "Receive photo for " << web_page->url_;
auto video_note = td_->video_notes_manager_->get_video_note_object(web_page->document_.file_id);
return td_api::make_object<td_api::linkPreviewTypeVideoNote>(std::move(video_note));
}
if (web_page->document_.type == Document::Type::VoiceNote && web_page->type_ == "document") {
LOG_IF(ERROR, !web_page->photo_.is_empty()) << "Receive photo for " << web_page->url_;
auto voice_note = td_->voice_notes_manager_->get_voice_note_object(web_page->document_.file_id);
return td_api::make_object<td_api::linkPreviewTypeVoiceNote>(std::move(voice_note));
}