mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-05 06:33:57 +02:00
Show "View Message" button in sponsored.
This commit is contained in:
parent
edf93b0031
commit
bba7010e74
5 changed files with 14 additions and 5 deletions
|
@ -151,7 +151,9 @@ 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 = [](not_null<PeerData*> peer) {
|
const auto makeFrom = [](
|
||||||
|
not_null<PeerData*> peer,
|
||||||
|
bool exactPost = false) {
|
||||||
const auto channel = peer->asChannel();
|
const auto channel = peer->asChannel();
|
||||||
return SponsoredFrom{
|
return SponsoredFrom{
|
||||||
.peer = peer,
|
.peer = peer,
|
||||||
|
@ -161,12 +163,14 @@ void SponsoredMessages::append(
|
||||||
.isChannel = (channel != nullptr),
|
.isChannel = (channel != nullptr),
|
||||||
.isPublic = (channel && channel->isPublic()),
|
.isPublic = (channel && channel->isPublic()),
|
||||||
.isBot = (peer->isUser() && peer->asUser()->isBot()),
|
.isBot = (peer->isUser() && peer->asUser()->isBot()),
|
||||||
|
.isExactPost = exactPost,
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
const auto from = [&]() -> SponsoredFrom {
|
const auto from = [&]() -> SponsoredFrom {
|
||||||
if (data.vfrom_id()) {
|
if (data.vfrom_id()) {
|
||||||
return makeFrom(
|
return makeFrom(
|
||||||
_session->data().peer(peerFromMTP(*data.vfrom_id())));
|
_session->data().peer(peerFromMTP(*data.vfrom_id())),
|
||||||
|
(data.vchannel_post() != nullptr));
|
||||||
}
|
}
|
||||||
Assert(data.vchat_invite());
|
Assert(data.vchat_invite());
|
||||||
return data.vchat_invite()->match([](const MTPDchatInvite &data) {
|
return data.vchat_invite()->match([](const MTPDchatInvite &data) {
|
||||||
|
|
|
@ -28,6 +28,7 @@ struct SponsoredFrom {
|
||||||
bool isChannel = false;
|
bool isChannel = false;
|
||||||
bool isPublic = false;
|
bool isPublic = false;
|
||||||
bool isBot = false;
|
bool isBot = false;
|
||||||
|
bool isExactPost = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct SponsoredMessage {
|
struct SponsoredMessage {
|
||||||
|
|
|
@ -107,6 +107,7 @@ struct HistoryMessageSponsored : public RuntimeComponent<HistoryMessageSponsored
|
||||||
User,
|
User,
|
||||||
Group,
|
Group,
|
||||||
Broadcast,
|
Broadcast,
|
||||||
|
Post,
|
||||||
Bot,
|
Bot,
|
||||||
};
|
};
|
||||||
std::unique_ptr<HiddenSenderInfo> sender;
|
std::unique_ptr<HiddenSenderInfo> sender;
|
||||||
|
|
|
@ -1947,7 +1947,9 @@ void HistoryMessage::setSponsoredFrom(const Data::SponsoredFrom &from) {
|
||||||
false);
|
false);
|
||||||
|
|
||||||
using Type = HistoryMessageSponsored::Type;
|
using Type = HistoryMessageSponsored::Type;
|
||||||
sponsored->type = from.isBot
|
sponsored->type = from.isExactPost
|
||||||
|
? Type::Post
|
||||||
|
: from.isBot
|
||||||
? Type::Bot
|
? Type::Bot
|
||||||
: from.isBroadcast
|
: from.isBroadcast
|
||||||
? Type::Broadcast
|
? Type::Broadcast
|
||||||
|
|
|
@ -36,10 +36,11 @@ using SponsoredType = HistoryMessageSponsored::Type;
|
||||||
inline auto SponsoredPhrase(SponsoredType type) {
|
inline auto SponsoredPhrase(SponsoredType type) {
|
||||||
const auto phrase = [&] {
|
const auto phrase = [&] {
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case SponsoredType::Bot: return tr::lng_view_button_bot;
|
case SponsoredType::User: return tr::lng_view_button_user;
|
||||||
case SponsoredType::Group: return tr::lng_view_button_group;
|
case SponsoredType::Group: return tr::lng_view_button_group;
|
||||||
case SponsoredType::Broadcast: return tr::lng_view_button_channel;
|
case SponsoredType::Broadcast: return tr::lng_view_button_channel;
|
||||||
case SponsoredType::User: return tr::lng_view_button_user;
|
case SponsoredType::Post: return tr::lng_view_button_message;
|
||||||
|
case SponsoredType::Bot: return tr::lng_view_button_bot;
|
||||||
}
|
}
|
||||||
Unexpected("SponsoredType in SponsoredPhrase.");
|
Unexpected("SponsoredType in SponsoredPhrase.");
|
||||||
}();
|
}();
|
||||||
|
|
Loading…
Add table
Reference in a new issue