2
0
mirror of https://github.com/telegramdesktop/tdesktop synced 2025-09-02 07:25:46 +00:00

Added initial api support of stickerset attribute in web pages.

This commit is contained in:
23rd
2024-04-18 05:14:19 +03:00
committed by John Preston
parent a3b8397361
commit f43f99cff2
6 changed files with 52 additions and 0 deletions

View File

@@ -3377,6 +3377,7 @@ not_null<WebPageData*> Session::processWebpage(
nullptr,
WebPageCollage(),
nullptr,
nullptr,
0,
QString(),
false,
@@ -3402,6 +3403,7 @@ not_null<WebPageData*> Session::webpage(
nullptr,
WebPageCollage(),
nullptr,
nullptr,
0,
QString(),
false,
@@ -3420,6 +3422,7 @@ not_null<WebPageData*> Session::webpage(
DocumentData *document,
WebPageCollage &&collage,
std::unique_ptr<Iv::Data> iv,
std::unique_ptr<WebPageStickerSet> stickerSet,
int duration,
const QString &author,
bool hasLargeMedia,
@@ -3438,6 +3441,7 @@ not_null<WebPageData*> Session::webpage(
document,
std::move(collage),
std::move(iv),
std::move(stickerSet),
duration,
author,
hasLargeMedia,
@@ -3490,6 +3494,29 @@ void Session::webpageApplyFields(
}
return nullptr;
};
using WebPageStickerSetPtr = std::unique_ptr<WebPageStickerSet>;
const auto lookupStickerSet = [&]() -> WebPageStickerSetPtr {
if (const auto attributes = data.vattributes()) {
for (const auto &attribute : attributes->v) {
auto result = attribute.match([&](
const MTPDwebPageAttributeStickerSet &data) {
auto result = std::make_unique<WebPageStickerSet>();
result->isEmoji = data.is_emojis();
result->isTextColor = data.is_text_color();
for (const auto &tl : data.vstickers().v) {
result->items.push_back(processDocument(tl));
}
return result;
}, [](const auto &) {
return WebPageStickerSetPtr(nullptr);
});
if (!result->items.empty()) {
return result;
}
}
}
return nullptr;
};
auto story = (Data::Story*)nullptr;
auto storyId = FullStoryId();
if (const auto attributes = data.vattributes()) {
@@ -3581,6 +3608,7 @@ void Session::webpageApplyFields(
: lookupThemeDocument()),
WebPageCollage(this, data),
std::move(iv),
lookupStickerSet(),
data.vduration().value_or_empty(),
qs(data.vauthor().value_or_empty()),
data.is_has_large_media(),
@@ -3600,6 +3628,7 @@ void Session::webpageApplyFields(
DocumentData *document,
WebPageCollage &&collage,
std::unique_ptr<Iv::Data> iv,
std::unique_ptr<WebPageStickerSet> stickerSet,
int duration,
const QString &author,
bool hasLargeMedia,
@@ -3617,6 +3646,7 @@ void Session::webpageApplyFields(
document,
std::move(collage),
std::move(iv),
std::move(stickerSet),
duration,
author,
hasLargeMedia,