2
0
mirror of https://github.com/telegramdesktop/tdesktop synced 2025-08-22 18:27:17 +00:00
tdesktop/Telegram/SourceFiles/data/data_web_page.h

148 lines
3.0 KiB
C
Raw Normal View History

/*
This file is part of Telegram Desktop,
the official desktop application for the Telegram messaging service.
For license and copyright information please follow this link:
https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
*/
#pragma once
2023-10-19 11:05:39 +04:00
#include "base/flags.h"
#include "data/data_photo.h"
#include "data/data_document.h"
class ChannelData;
2020-06-08 13:06:50 +04:00
namespace Data {
class Session;
2025-01-07 12:45:33 +04:00
struct UniqueGift;
2020-06-08 13:06:50 +04:00
} // namespace Data
namespace Iv {
class Data;
} // namespace Iv
2023-10-19 11:05:39 +04:00
enum class WebPageType : uint8 {
2023-10-20 17:48:15 +04:00
None,
2021-10-10 19:11:08 +03:00
Message,
2024-03-13 21:58:27 +04:00
Album,
2021-10-10 19:11:08 +03:00
Group,
2021-10-12 16:50:18 +04:00
GroupWithRequest,
GroupBoost,
2021-10-10 19:11:08 +03:00
Channel,
2021-10-12 16:50:18 +04:00
ChannelWithRequest,
ChannelBoost,
Giftcode,
2021-10-10 19:11:08 +03:00
Photo,
Video,
Document,
2021-10-10 19:11:08 +03:00
User,
Bot,
Profile,
BotApp,
2021-10-10 19:11:08 +03:00
2019-01-16 16:25:29 +04:00
WallPaper,
Theme,
2023-06-23 16:04:53 +04:00
Story,
StickerSet,
2021-10-10 19:11:08 +03:00
Article,
ArticleWithIV,
2021-10-10 19:11:08 +03:00
VoiceChat,
Livestream,
2024-05-23 13:07:03 +04:00
Factcheck,
};
2023-10-19 11:05:39 +04:00
[[nodiscard]] WebPageType ParseWebPageType(const MTPDwebPage &type);
2024-03-12 17:56:42 +04:00
[[nodiscard]] bool IgnoreIv(WebPageType type);
struct WebPageCollage {
using Item = std::variant<PhotoData*, DocumentData*>;
WebPageCollage() = default;
2020-06-08 13:06:50 +04:00
explicit WebPageCollage(
not_null<Data::Session*> owner,
const MTPDwebPage &data);
std::vector<Item> items;
};
struct WebPageStickerSet {
WebPageStickerSet() = default;
std::vector<not_null<DocumentData*>> items;
bool isEmoji = false;
bool isTextColor = false;
};
struct WebPageData {
2020-06-08 13:06:50 +04:00
WebPageData(not_null<Data::Session*> owner, const WebPageId &id);
~WebPageData();
2020-06-08 13:06:50 +04:00
[[nodiscard]] Data::Session &owner() const;
[[nodiscard]] Main::Session &session() const;
2017-12-31 12:39:21 +03:00
bool applyChanges(
WebPageType newType,
2017-12-31 12:39:21 +03:00
const QString &newUrl,
const QString &newDisplayUrl,
const QString &newSiteName,
const QString &newTitle,
const TextWithEntities &newDescription,
2023-06-23 16:04:53 +04:00
FullStoryId newStoryId,
2017-12-31 12:39:21 +03:00
PhotoData *newPhoto,
DocumentData *newDocument,
WebPageCollage &&newCollage,
std::unique_ptr<Iv::Data> newIv,
std::unique_ptr<WebPageStickerSet> newStickerSet,
2025-01-07 12:45:33 +04:00
std::shared_ptr<Data::UniqueGift> newUniqueGift,
2017-12-31 12:39:21 +03:00
int newDuration,
const QString &newAuthor,
2023-10-20 17:48:15 +04:00
bool newHasLargeMedia,
2017-12-31 12:39:21 +03:00
int newPendingTill);
static void ApplyChanges(
not_null<Main::Session*> session,
ChannelData *channel,
const MTPmessages_Messages &result);
2023-10-20 17:48:15 +04:00
[[nodiscard]] QString displayedSiteName() const;
2025-01-24 20:21:59 +04:00
[[nodiscard]] TimeId extractVideoTimestamp() const;
2023-10-25 21:23:54 +04:00
[[nodiscard]] bool computeDefaultSmallMedia() const;
[[nodiscard]] bool suggestEnlargePhoto() const;
2023-10-20 17:48:15 +04:00
const WebPageId id = 0;
WebPageType type = WebPageType::None;
QString url;
QString displayUrl;
QString siteName;
QString title;
TextWithEntities description;
2023-06-23 16:04:53 +04:00
FullStoryId storyId;
QString author;
PhotoData *photo = nullptr;
DocumentData *document = nullptr;
WebPageCollage collage;
std::unique_ptr<Iv::Data> iv;
std::unique_ptr<WebPageStickerSet> stickerSet;
2025-01-07 12:45:33 +04:00
std::shared_ptr<Data::UniqueGift> uniqueGift;
2023-10-19 11:05:39 +04:00
int duration = 0;
TimeId pendingTill = 0;
2023-10-20 17:48:15 +04:00
uint32 version : 30 = 0;
uint32 hasLargeMedia : 1 = 0;
uint32 failed : 1 = 0;
private:
void replaceDocumentGoodThumbnail();
2020-06-08 13:06:50 +04:00
const not_null<Data::Session*> _owner;
};