mirror of
https://github.com/telegramdesktop/tdesktop
synced 2025-08-31 14:38:15 +00:00
Add unique gifts link preview.
This commit is contained in:
@@ -13,6 +13,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||
#include "apiwrap.h"
|
||||
#include "mainwidget.h"
|
||||
#include "api/api_bot.h"
|
||||
#include "api/api_premium.h"
|
||||
#include "api/api_text_entities.h"
|
||||
#include "api/api_user_names.h"
|
||||
#include "chat_helpers/stickers_lottie.h"
|
||||
@@ -3464,6 +3465,7 @@ not_null<WebPageData*> Session::processWebpage(
|
||||
WebPageCollage(),
|
||||
nullptr,
|
||||
nullptr,
|
||||
nullptr,
|
||||
0,
|
||||
QString(),
|
||||
false,
|
||||
@@ -3490,6 +3492,7 @@ not_null<WebPageData*> Session::webpage(
|
||||
WebPageCollage(),
|
||||
nullptr,
|
||||
nullptr,
|
||||
nullptr,
|
||||
0,
|
||||
QString(),
|
||||
false,
|
||||
@@ -3509,6 +3512,7 @@ not_null<WebPageData*> Session::webpage(
|
||||
WebPageCollage &&collage,
|
||||
std::unique_ptr<Iv::Data> iv,
|
||||
std::unique_ptr<WebPageStickerSet> stickerSet,
|
||||
std::shared_ptr<UniqueGift> uniqueGift,
|
||||
int duration,
|
||||
const QString &author,
|
||||
bool hasLargeMedia,
|
||||
@@ -3528,6 +3532,7 @@ not_null<WebPageData*> Session::webpage(
|
||||
std::move(collage),
|
||||
std::move(iv),
|
||||
std::move(stickerSet),
|
||||
std::move(uniqueGift),
|
||||
duration,
|
||||
author,
|
||||
hasLargeMedia,
|
||||
@@ -3562,6 +3567,7 @@ void Session::webpageApplyFields(
|
||||
}
|
||||
return nullptr;
|
||||
};
|
||||
|
||||
const auto lookupThemeDocument = [&]() -> DocumentData* {
|
||||
if (const auto attributes = data.vattributes()) {
|
||||
for (const auto &attribute : attributes->v) {
|
||||
@@ -3582,6 +3588,7 @@ void Session::webpageApplyFields(
|
||||
}
|
||||
return nullptr;
|
||||
};
|
||||
|
||||
using WebPageStickerSetPtr = std::unique_ptr<WebPageStickerSet>;
|
||||
const auto lookupStickerSet = [&]() -> WebPageStickerSetPtr {
|
||||
if (const auto attributes = data.vattributes()) {
|
||||
@@ -3605,6 +3612,21 @@ void Session::webpageApplyFields(
|
||||
}
|
||||
return nullptr;
|
||||
};
|
||||
|
||||
using UniqueGiftPtr = std::shared_ptr<UniqueGift>;
|
||||
const auto lookupUniqueGift = [&]() -> UniqueGiftPtr {
|
||||
if (const auto attributes = data.vattributes()) {
|
||||
for (const auto &attribute : attributes->v) {
|
||||
return attribute.match([&](
|
||||
const MTPDwebPageAttributeUniqueStarGift &data) {
|
||||
const auto gift = Api::FromTL(_session, data.vgift());
|
||||
return gift ? gift->unique : nullptr;
|
||||
}, [](const auto &) -> UniqueGiftPtr { return nullptr; });
|
||||
}
|
||||
}
|
||||
return nullptr;
|
||||
};
|
||||
|
||||
auto story = (Data::Story*)nullptr;
|
||||
auto storyId = FullStoryId();
|
||||
if (const auto attributes = data.vattributes()) {
|
||||
@@ -3697,6 +3719,7 @@ void Session::webpageApplyFields(
|
||||
WebPageCollage(this, data),
|
||||
std::move(iv),
|
||||
lookupStickerSet(),
|
||||
lookupUniqueGift(),
|
||||
data.vduration().value_or_empty(),
|
||||
qs(data.vauthor().value_or_empty()),
|
||||
data.is_has_large_media(),
|
||||
@@ -3717,6 +3740,7 @@ void Session::webpageApplyFields(
|
||||
WebPageCollage &&collage,
|
||||
std::unique_ptr<Iv::Data> iv,
|
||||
std::unique_ptr<WebPageStickerSet> stickerSet,
|
||||
std::shared_ptr<UniqueGift> uniqueGift,
|
||||
int duration,
|
||||
const QString &author,
|
||||
bool hasLargeMedia,
|
||||
@@ -3735,6 +3759,7 @@ void Session::webpageApplyFields(
|
||||
std::move(collage),
|
||||
std::move(iv),
|
||||
std::move(stickerSet),
|
||||
std::move(uniqueGift),
|
||||
duration,
|
||||
author,
|
||||
hasLargeMedia,
|
||||
|
Reference in New Issue
Block a user