mirror of
https://github.com/telegramdesktop/tdesktop
synced 2025-08-31 14:38:15 +00:00
Show large photos in web pages with IV.
This commit is contained in:
@@ -1259,7 +1259,7 @@ not_null<WebPageData*> Session::webpage(const MTPDwebPagePending &data) {
|
||||
const auto result = webpage(data.vid.v);
|
||||
webpageApplyFields(
|
||||
result,
|
||||
QString(),
|
||||
WebPageType::Article,
|
||||
QString(),
|
||||
QString(),
|
||||
QString(),
|
||||
@@ -1282,7 +1282,7 @@ not_null<WebPageData*> Session::webpage(
|
||||
const TextWithEntities &content) {
|
||||
return webpage(
|
||||
id,
|
||||
qsl("article"),
|
||||
WebPageType::Article,
|
||||
QString(),
|
||||
QString(),
|
||||
siteName,
|
||||
@@ -1298,7 +1298,7 @@ not_null<WebPageData*> Session::webpage(
|
||||
|
||||
not_null<WebPageData*> Session::webpage(
|
||||
WebPageId id,
|
||||
const QString &type,
|
||||
WebPageType type,
|
||||
const QString &url,
|
||||
const QString &displayUrl,
|
||||
const QString &siteName,
|
||||
@@ -1347,7 +1347,7 @@ void Session::webpageApplyFields(
|
||||
const auto pendingTill = TimeId(0);
|
||||
webpageApplyFields(
|
||||
page,
|
||||
data.has_type() ? qs(data.vtype) : qsl("article"),
|
||||
ParseWebPageType(data),
|
||||
qs(data.vurl),
|
||||
qs(data.vdisplay_url),
|
||||
siteName,
|
||||
@@ -1363,7 +1363,7 @@ void Session::webpageApplyFields(
|
||||
|
||||
void Session::webpageApplyFields(
|
||||
not_null<WebPageData*> page,
|
||||
const QString &type,
|
||||
WebPageType type,
|
||||
const QString &url,
|
||||
const QString &displayUrl,
|
||||
const QString &siteName,
|
||||
|
@@ -17,6 +17,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||
class HistoryItem;
|
||||
class BoxContent;
|
||||
struct WebPageCollage;
|
||||
enum class WebPageType;
|
||||
|
||||
namespace HistoryView {
|
||||
struct Group;
|
||||
@@ -302,7 +303,7 @@ public:
|
||||
const TextWithEntities &content);
|
||||
not_null<WebPageData*> webpage(
|
||||
WebPageId id,
|
||||
const QString &type,
|
||||
WebPageType type,
|
||||
const QString &url,
|
||||
const QString &displayUrl,
|
||||
const QString &siteName,
|
||||
@@ -484,7 +485,7 @@ private:
|
||||
const MTPDwebPage &data);
|
||||
void webpageApplyFields(
|
||||
not_null<WebPageData*> page,
|
||||
const QString &type,
|
||||
WebPageType type,
|
||||
const QString &url,
|
||||
const QString &displayUrl,
|
||||
const QString &siteName,
|
||||
|
@@ -128,12 +128,22 @@ WebPageCollage ExtractCollage(const MTPDwebPage &data) {
|
||||
|
||||
} // namespace
|
||||
|
||||
WebPageType ParseWebPageType(const MTPDwebPage &page) {
|
||||
const auto type = page.has_type() ? qs(page.vtype) : QString();
|
||||
if (type == qstr("photo")) return WebPageType::Photo;
|
||||
if (type == qstr("video")) return WebPageType::Video;
|
||||
if (type == qstr("profile")) return WebPageType::Profile;
|
||||
return page.has_cached_page()
|
||||
? WebPageType::ArticleWithIV
|
||||
: WebPageType::Article;
|
||||
}
|
||||
|
||||
WebPageCollage::WebPageCollage(const MTPDwebPage &data)
|
||||
: WebPageCollage(ExtractCollage(data)) {
|
||||
}
|
||||
|
||||
bool WebPageData::applyChanges(
|
||||
const QString &newType,
|
||||
WebPageType newType,
|
||||
const QString &newUrl,
|
||||
const QString &newDisplayUrl,
|
||||
const QString &newSiteName,
|
||||
@@ -153,7 +163,6 @@ bool WebPageData::applyChanges(
|
||||
return false;
|
||||
}
|
||||
|
||||
const auto resultType = toWebPageType(newType);
|
||||
const auto resultUrl = TextUtilities::Clean(newUrl);
|
||||
const auto resultDisplayUrl = TextUtilities::Clean(
|
||||
newDisplayUrl);
|
||||
@@ -177,7 +186,7 @@ bool WebPageData::applyChanges(
|
||||
return QString();
|
||||
}();
|
||||
|
||||
if (type == resultType
|
||||
if (type == newType
|
||||
&& url == resultUrl
|
||||
&& displayUrl == resultDisplayUrl
|
||||
&& siteName == resultSiteName
|
||||
@@ -194,7 +203,7 @@ bool WebPageData::applyChanges(
|
||||
if (pendingTill > 0 && newPendingTill <= 0) {
|
||||
Auth().api().clearWebPageRequest(this);
|
||||
}
|
||||
type = resultType;
|
||||
type = newType;
|
||||
url = resultUrl;
|
||||
displayUrl = resultDisplayUrl;
|
||||
siteName = resultSiteName;
|
||||
|
@@ -10,19 +10,15 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||
#include "data/data_photo.h"
|
||||
#include "data/data_document.h"
|
||||
|
||||
enum WebPageType {
|
||||
WebPagePhoto,
|
||||
WebPageVideo,
|
||||
WebPageProfile,
|
||||
WebPageArticle
|
||||
enum class WebPageType {
|
||||
Photo,
|
||||
Video,
|
||||
Profile,
|
||||
Article,
|
||||
ArticleWithIV,
|
||||
};
|
||||
|
||||
inline WebPageType toWebPageType(const QString &type) {
|
||||
if (type == qstr("photo")) return WebPagePhoto;
|
||||
if (type == qstr("video")) return WebPageVideo;
|
||||
if (type == qstr("profile")) return WebPageProfile;
|
||||
return WebPageArticle;
|
||||
}
|
||||
WebPageType ParseWebPageType(const MTPDwebPage &type);
|
||||
|
||||
struct WebPageCollage {
|
||||
using Item = base::variant<PhotoData*, DocumentData*>;
|
||||
@@ -37,37 +33,9 @@ struct WebPageCollage {
|
||||
struct WebPageData {
|
||||
WebPageData(const WebPageId &id) : id(id) {
|
||||
}
|
||||
WebPageData(
|
||||
const WebPageId &id,
|
||||
WebPageType type,
|
||||
const QString &url,
|
||||
const QString &displayUrl,
|
||||
const QString &siteName,
|
||||
const QString &title,
|
||||
const TextWithEntities &description,
|
||||
PhotoData *photo,
|
||||
DocumentData *document,
|
||||
WebPageCollage &&collage,
|
||||
int duration,
|
||||
const QString &author,
|
||||
int pendingTill)
|
||||
: id(id)
|
||||
, type(type)
|
||||
, url(url)
|
||||
, displayUrl(displayUrl)
|
||||
, siteName(siteName)
|
||||
, title(title)
|
||||
, description(description)
|
||||
, duration(duration)
|
||||
, author(author)
|
||||
, photo(photo)
|
||||
, document(document)
|
||||
, collage(std::move(collage))
|
||||
, pendingTill(pendingTill) {
|
||||
}
|
||||
|
||||
bool applyChanges(
|
||||
const QString &newType,
|
||||
WebPageType newType,
|
||||
const QString &newUrl,
|
||||
const QString &newDisplayUrl,
|
||||
const QString &newSiteName,
|
||||
@@ -81,7 +49,7 @@ struct WebPageData {
|
||||
int newPendingTill);
|
||||
|
||||
WebPageId id = 0;
|
||||
WebPageType type = WebPageArticle;
|
||||
WebPageType type = WebPageType::Article;
|
||||
QString url;
|
||||
QString displayUrl;
|
||||
QString siteName;
|
||||
|
Reference in New Issue
Block a user