Added peer userpic to gift service messages.

This commit is contained in:
23rd 2025-01-27 21:06:25 +03:00
parent 23c9f7a957
commit f8e3e70273
2 changed files with 39 additions and 10 deletions

View file

@ -255,18 +255,26 @@ auto GenerateGiftMedia(
replacing,
sticker,
st::giftBoxPreviewStickerPadding));
const auto title = v::match(descriptor, [&](GiftTypePremium gift) {
auto title = v::match(descriptor, [&](GiftTypePremium gift) {
return tr::lng_action_gift_premium_months(
tr::now,
lt_count,
gift.months);
gift.months,
Text::Bold);
}, [&](const GiftTypeStars &gift) {
return recipient->isSelf()
? tr::lng_action_gift_self_subtitle(tr::now)
? tr::lng_action_gift_self_subtitle(tr::now, Text::Bold)
: tr::lng_action_gift_got_subtitle(
tr::now,
lt_user,
recipient->session().user()->shortName());
TextWithEntities()
.append(Text::SingleCustomEmoji(
recipient->owner().customEmojiManager(
).peerUserpicEmojiData(
recipient->session().user())))
.append(' ')
.append(recipient->session().user()->shortName()),
Text::Bold);
});
auto textFallback = v::match(descriptor, [&](GiftTypePremium gift) {
return tr::lng_action_gift_premium_about(
@ -298,15 +306,20 @@ auto GenerateGiftMedia(
auto description = data.text.empty()
? std::move(textFallback)
: data.text;
pushText(Text::Bold(title), st::giftBoxPreviewTitlePadding);
const auto context = Core::MarkedTextContext{
.session = &parent->history()->session(),
.customEmojiRepaint = [parent] { parent->repaint(); },
};
pushText(
std::move(title),
st::giftBoxPreviewTitlePadding,
{},
context);
pushText(
std::move(description),
st::giftBoxPreviewTextPadding,
{},
Core::MarkedTextContext{
.session = &parent->history()->session(),
.customEmojiRepaint = [parent] { parent->repaint(); },
});
context);
push(HistoryView::MakeGenericButtonPart(
(data.upgraded

View file

@ -72,6 +72,17 @@ TextWithEntities PremiumGift::title() {
const auto peer = _parent->history()->peer;
return peer->isSelf()
? tr::lng_action_gift_self_subtitle(tr::now, WithEntities)
: (peer->isServiceUser() && _data.channelFrom)
? tr::lng_action_gift_got_subtitle(
tr::now,
lt_user,
WithEntities({})
.append(SingleCustomEmoji(
peer->owner().customEmojiManager(
).peerUserpicEmojiData(_data.channelFrom)))
.append(' ')
.append(_data.channelFrom->shortName()),
WithEntities)
: peer->isServiceUser()
? tr::lng_gift_link_label_gift(tr::now, WithEntities)
: (outgoingGift()
@ -79,7 +90,12 @@ TextWithEntities PremiumGift::title() {
: tr::lng_action_gift_got_subtitle)(
tr::now,
lt_user,
WithEntities(peer->shortName()),
WithEntities({})
.append(SingleCustomEmoji(
peer->owner().customEmojiManager(
).peerUserpicEmojiData(peer)))
.append(' ')
.append(peer->shortName()),
WithEntities);
} else if (creditsPrize()) {
return tr::lng_prize_title(tr::now, WithEntities);