Skip to content

Commit

Permalink
f Support collages of media in webpage previews.
Browse files Browse the repository at this point in the history
  • Loading branch information
john-preston committed Oct 23, 2024
1 parent d699b7c commit c890d05
Showing 1 changed file with 24 additions and 28 deletions.
52 changes: 24 additions & 28 deletions Telegram/SourceFiles/data/data_web_page.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -231,10 +231,16 @@ WebPageType ParseWebPageType(const TLlinkPreviewType &type, bool hasIV) {
});
}, [&](const TLDlinkPreviewTypeDocument &data) {
return WebPageType::Document;
}, [&](const TLDlinkPreviewTypeEmbeddedAudioPlayer &data) {
}, [&](const TLDlinkPreviewTypeEmbeddedAnimationPlayer &data) {
return WebPageType::Video;
}, [&](const TLDlinkPreviewTypeEmbeddedAudioPlayer &data) {
return article;
}, [&](const TLDlinkPreviewTypeEmbeddedVideoPlayer &data) {
return WebPageType::Video;
}, [&](const TLDlinkPreviewTypeExternalAudio &data) {
return article;
}, [&](const TLDlinkPreviewTypeExternalVideo &data) {
return WebPageType::Video;
}, [&](const TLDlinkPreviewTypeInvoice &data) {
return article;
}, [&](const TLDlinkPreviewTypeMessage &data) {
Expand Down Expand Up @@ -317,10 +323,16 @@ WebPageType ParseWebPageType(const TLlinkPreviewType &type, bool hasIV) {
return photo(data);
}, [&](const TLDlinkPreviewTypeDocument &data) {
return null;
}, [&](const TLDlinkPreviewTypeEmbeddedAnimationPlayer &data) {
return null;
}, [&](const TLDlinkPreviewTypeEmbeddedAudioPlayer &data) {
return null;
}, [&](const TLDlinkPreviewTypeEmbeddedVideoPlayer &data) {
return null;
}, [&](const TLDlinkPreviewTypeExternalAudio &data) {
return null;
}, [&](const TLDlinkPreviewTypeExternalVideo &data) {
return null;
}, [&](const TLDlinkPreviewTypeInvoice &data) {
return null;
}, [&](const TLDlinkPreviewTypeMessage &data) {
Expand Down Expand Up @@ -374,7 +386,7 @@ WebPageType ParseWebPageType(const TLlinkPreviewType &type, bool hasIV) {
}, [&](const TLDlinkPreviewTypeArticle &data) {
return null;
}, [&](const TLDlinkPreviewTypeAudio &data) {
return data.vaudio() ? document(*data.vaudio()) : null;
return document(data.vaudio());
}, [&](const TLDlinkPreviewTypeBackground &data) {
return data.vdocument() ? document(*data.vdocument()) : null;
}, [&](const TLDlinkPreviewTypeChannelBoost &data) {
Expand All @@ -383,10 +395,16 @@ WebPageType ParseWebPageType(const TLlinkPreviewType &type, bool hasIV) {
return null;
}, [&](const TLDlinkPreviewTypeDocument &data) {
return document(data.vdocument());
}, [&](const TLDlinkPreviewTypeEmbeddedAnimationPlayer &data) {
return null;
}, [&](const TLDlinkPreviewTypeEmbeddedAudioPlayer &data) {
return null;
}, [&](const TLDlinkPreviewTypeEmbeddedVideoPlayer &data) {
return null;
}, [&](const TLDlinkPreviewTypeExternalAudio &data) {
return null;
}, [&](const TLDlinkPreviewTypeExternalVideo &data) {
return null;
}, [&](const TLDlinkPreviewTypeInvoice &data) {
return null;
}, [&](const TLDlinkPreviewTypeMessage &data) {
Expand All @@ -412,7 +430,7 @@ WebPageType ParseWebPageType(const TLlinkPreviewType &type, bool hasIV) {
}, [&](const TLDlinkPreviewTypeUser &data) {
return null;
}, [&](const TLDlinkPreviewTypeVideo &data) {
return data.vvideo() ? document(*data.vvideo()) : null;
return document(data.vvideo());
}, [&](const TLDlinkPreviewTypeVideoChat &data) {
return null;
}, [&](const TLDlinkPreviewTypeVideoNote &data) {
Expand Down Expand Up @@ -454,11 +472,11 @@ WebPageType ParseWebPageType(const TLlinkPreviewType &type, bool hasIV) {
return type.match([&](const TLDlinkPreviewTypeAnimation &data) {
return data.vanimation().data().vduration().v;
}, [&](const TLDlinkPreviewTypeAudio &data) {
return data.vduration().v;
return data.vaudio().data().vduration().v;
}, [&](const TLDlinkPreviewTypeEmbeddedVideoPlayer &data) {
return data.vduration().v;
}, [&](const TLDlinkPreviewTypeVideo &data) {
return data.vduration().v;
return data.vvideo().data().vduration().v;
}, [&](const TLDlinkPreviewTypeVideoNote &data) {
return data.vvideo_note().data().vduration().v;
}, [&](const TLDlinkPreviewTypeVoiceNote &data) {
Expand All @@ -468,28 +486,6 @@ WebPageType ParseWebPageType(const TLlinkPreviewType &type, bool hasIV) {
});
}

[[nodiscard]] QString ExtractAuthor(const TLlinkPreviewType &type) {
return type.match([&](const TLDlinkPreviewTypeAnimation &data) {
return data.vauthor().v;
}, [&](const TLDlinkPreviewTypeApp &data) {
return data.vauthor().v;
}, [&](const TLDlinkPreviewTypeArticle &data) {
return data.vauthor().v;
}, [&](const TLDlinkPreviewTypeAudio &data) {
return data.vauthor().v;
}, [&](const TLDlinkPreviewTypeDocument &data) {
return data.vauthor().v;
}, [&](const TLDlinkPreviewTypeEmbeddedAudioPlayer &data) {
return data.vauthor().v;
}, [&](const TLDlinkPreviewTypeEmbeddedVideoPlayer &data) {
return data.vauthor().v;
}, [&](const TLDlinkPreviewTypePhoto &data) {
return data.vauthor().v;
}, [&](const auto &) {
return QString();
});
}

} // namespace

#if 0 // mtp
Expand Down Expand Up @@ -600,7 +596,7 @@ void WebPageData::setFromTdb(const TLlinkPreview &data) {
ExtractDocument(_owner, fields.vtype()),
ExtractStickerSet(_owner, fields.vtype()),
ExtractDuration(fields.vtype()),
ExtractAuthor(fields.vtype()),
fields.vauthor().v,
fields.vhas_large_media().v,
0);

Expand Down

0 comments on commit c890d05

Please sign in to comment.