mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-06 23:24:01 +02:00
Support "recommended" sponsored messages.
This commit is contained in:
parent
6dedf7c63e
commit
63940ea557
7 changed files with 14 additions and 3 deletions
|
@ -1576,6 +1576,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
"lng_signed_author" = "Author: {user}";
|
"lng_signed_author" = "Author: {user}";
|
||||||
"lng_in_reply_to" = "In reply to";
|
"lng_in_reply_to" = "In reply to";
|
||||||
"lng_sponsored" = "sponsored";
|
"lng_sponsored" = "sponsored";
|
||||||
|
"lng_recommended" = "recommended";
|
||||||
"lng_edited" = "edited";
|
"lng_edited" = "edited";
|
||||||
"lng_edited_date" = "Edited: {date}";
|
"lng_edited_date" = "Edited: {date}";
|
||||||
"lng_sent_date" = "Sent: {date}";
|
"lng_sent_date" = "Sent: {date}";
|
||||||
|
|
|
@ -152,7 +152,7 @@ void SponsoredMessages::append(
|
||||||
});
|
});
|
||||||
const auto randomId = data.vrandom_id().v;
|
const auto randomId = data.vrandom_id().v;
|
||||||
const auto hash = qs(data.vchat_invite_hash().value_or_empty());
|
const auto hash = qs(data.vchat_invite_hash().value_or_empty());
|
||||||
const auto makeFrom = [](
|
const auto makeFrom = [&](
|
||||||
not_null<PeerData*> peer,
|
not_null<PeerData*> peer,
|
||||||
bool exactPost = false) {
|
bool exactPost = false) {
|
||||||
const auto channel = peer->asChannel();
|
const auto channel = peer->asChannel();
|
||||||
|
@ -165,6 +165,7 @@ void SponsoredMessages::append(
|
||||||
.isPublic = (channel && channel->isPublic()),
|
.isPublic = (channel && channel->isPublic()),
|
||||||
.isBot = (peer->isUser() && peer->asUser()->isBot()),
|
.isBot = (peer->isUser() && peer->asUser()->isBot()),
|
||||||
.isExactPost = exactPost,
|
.isExactPost = exactPost,
|
||||||
|
.isRecommended = data.is_recommended(),
|
||||||
.userpic = { .location = peer->userpicLocation() },
|
.userpic = { .location = peer->userpicLocation() },
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
|
@ -30,6 +30,7 @@ struct SponsoredFrom {
|
||||||
bool isPublic = false;
|
bool isPublic = false;
|
||||||
bool isBot = false;
|
bool isBot = false;
|
||||||
bool isExactPost = false;
|
bool isExactPost = false;
|
||||||
|
bool isRecommended = false;
|
||||||
ImageWithLocation userpic;
|
ImageWithLocation userpic;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -121,6 +121,7 @@ struct HistoryMessageSponsored : public RuntimeComponent<HistoryMessageSponsored
|
||||||
};
|
};
|
||||||
std::unique_ptr<HiddenSenderInfo> sender;
|
std::unique_ptr<HiddenSenderInfo> sender;
|
||||||
Type type = Type::User;
|
Type type = Type::User;
|
||||||
|
bool recommended = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct HistoryMessageReply : public RuntimeComponent<HistoryMessageReply, HistoryItem> {
|
struct HistoryMessageReply : public RuntimeComponent<HistoryMessageReply, HistoryItem> {
|
||||||
|
|
|
@ -1787,6 +1787,7 @@ void HistoryMessage::setSponsoredFrom(const Data::SponsoredFrom &from) {
|
||||||
sponsored->sender = std::make_unique<HiddenSenderInfo>(
|
sponsored->sender = std::make_unique<HiddenSenderInfo>(
|
||||||
from.title,
|
from.title,
|
||||||
false);
|
false);
|
||||||
|
sponsored->recommended = from.isRecommended;
|
||||||
if (from.userpic.location.valid()) {
|
if (from.userpic.location.valid()) {
|
||||||
sponsored->sender->customUserpic.set(
|
sponsored->sender->customUserpic.set(
|
||||||
&history()->session(),
|
&history()->session(),
|
||||||
|
|
|
@ -426,7 +426,9 @@ void BottomInfo::layoutDateText() {
|
||||||
const auto name = _authorElided
|
const auto name = _authorElided
|
||||||
? st::msgDateFont->elided(author, maxWidth - afterAuthorWidth)
|
? st::msgDateFont->elided(author, maxWidth - afterAuthorWidth)
|
||||||
: author;
|
: author;
|
||||||
const auto full = (_data.flags & Data::Flag::Sponsored)
|
const auto full = (_data.flags & Data::Flag::Recommended)
|
||||||
|
? tr::lng_recommended(tr::now)
|
||||||
|
: (_data.flags & Data::Flag::Sponsored)
|
||||||
? tr::lng_sponsored(tr::now)
|
? tr::lng_sponsored(tr::now)
|
||||||
: (_data.flags & Data::Flag::Imported)
|
: (_data.flags & Data::Flag::Imported)
|
||||||
? (date + ' ' + tr::lng_imported(tr::now))
|
? (date + ' ' + tr::lng_imported(tr::now))
|
||||||
|
@ -586,7 +588,10 @@ BottomInfo::Data BottomInfoDataFromMessage(not_null<Message*> message) {
|
||||||
if (message->context() == Context::Replies) {
|
if (message->context() == Context::Replies) {
|
||||||
result.flags |= Flag::RepliesContext;
|
result.flags |= Flag::RepliesContext;
|
||||||
}
|
}
|
||||||
if (item->isSponsored()) {
|
if (const auto sponsored = item->Get<HistoryMessageSponsored>()) {
|
||||||
|
if (sponsored->recommended) {
|
||||||
|
result.flags |= Flag::Recommended;
|
||||||
|
}
|
||||||
result.flags |= Flag::Sponsored;
|
result.flags |= Flag::Sponsored;
|
||||||
}
|
}
|
||||||
if (item->isPinned() && message->context() != Context::Pinned) {
|
if (item->isPinned() && message->context() != Context::Pinned) {
|
||||||
|
|
|
@ -41,6 +41,7 @@ public:
|
||||||
Sponsored = 0x10,
|
Sponsored = 0x10,
|
||||||
Pinned = 0x20,
|
Pinned = 0x20,
|
||||||
Imported = 0x40,
|
Imported = 0x40,
|
||||||
|
Recommended = 0x80,
|
||||||
//Unread, // We don't want to pass and update it in Date for now.
|
//Unread, // We don't want to pass and update it in Date for now.
|
||||||
};
|
};
|
||||||
friend inline constexpr bool is_flag_type(Flag) { return true; };
|
friend inline constexpr bool is_flag_type(Flag) { return true; };
|
||||||
|
|
Loading…
Add table
Reference in a new issue