MCPcopy Create free account
hub / github.com/TDesktop-x64/tdesktop / webpageApplyFields

Method webpageApplyFields

Telegram/SourceFiles/data/data_session.cpp:4103–4316  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

4101}
4102
4103void Session::webpageApplyFields(
4104 not_null<WebPageData*> page,
4105 const MTPDwebPage &data) {
4106 auto description = TextWithEntities{
4107 qs(data.vdescription().value_or_empty())
4108 };
4109 const auto siteName = qs(data.vsite_name().value_or_empty());
4110 auto parseFlags = TextParseLinks | TextParseMultiline;
4111 if (siteName == u"Twitter"_q || siteName == u"Instagram"_q) {
4112 parseFlags |= TextParseHashtags | TextParseMentions;
4113 }
4114 TextUtilities::ParseEntities(description, parseFlags);
4115 const auto pendingTill = TimeId(0);
4116 const auto photo = data.vphoto();
4117 const auto document = data.vdocument();
4118 const auto lookupInAttribute = [&](
4119 const MTPDwebPageAttributeTheme &data) -> DocumentData* {
4120 if (const auto documents = data.vdocuments()) {
4121 for (const auto &document : documents->v) {
4122 const auto processed = processDocument(document);
4123 if (processed->isTheme()) {
4124 return processed;
4125 }
4126 }
4127 }
4128 return nullptr;
4129 };
4130
4131 const auto lookupThemeDocument = [&]() -> DocumentData* {
4132 if (const auto attributes = data.vattributes()) {
4133 for (const auto &attribute : attributes->v) {
4134 const auto result = attribute.match([&](
4135 const MTPDwebPageAttributeTheme &data) {
4136 return lookupInAttribute(data);
4137 }, [](const MTPDwebPageAttributeStory &) {
4138 return (DocumentData*)nullptr;
4139 }, [](const MTPDwebPageAttributeStickerSet &) {
4140 return (DocumentData*)nullptr;
4141 }, [](const MTPDwebPageAttributeUniqueStarGift &) {
4142 return (DocumentData*)nullptr;
4143 }, [](const MTPDwebPageAttributeStarGiftCollection &) {
4144 return (DocumentData*)nullptr;
4145 }, [](const MTPDwebPageAttributeStarGiftAuction &) {
4146 return (DocumentData*)nullptr;
4147 }, [](const MTPDwebPageAttributeAiComposeTone &) {
4148 return (DocumentData*)nullptr;
4149 });
4150 if (result) {
4151 return result;
4152 }
4153 }
4154 }
4155 return nullptr;
4156 };
4157
4158 using WebPageStickerSetPtr = std::unique_ptr<WebPageStickerSet>;
4159 const auto lookupStickerSet = [&]() -> WebPageStickerSetPtr {
4160 if (const auto attributes = data.vattributes()) {

Callers

nothing calls this directly

Calls 15

qsFunction · 0.85
FullStoryIdClass · 0.85
peerFromMTPFunction · 0.85
ParseWebPageTypeFunction · 0.85
IgnoreIvFunction · 0.85
ParseRichPageFunction · 0.85
isThemeMethod · 0.80
applySingleMethod · 0.80
requestWebPageDelayedMethod · 0.80
apiMethod · 0.80
FromTLFunction · 0.70
WebPageCollageClass · 0.70

Tested by

no test coverage detected