diff --git a/Telegram/Resources/langs/lang.strings b/Telegram/Resources/langs/lang.strings index 7f316c55a..426a7dfb4 100644 --- a/Telegram/Resources/langs/lang.strings +++ b/Telegram/Resources/langs/lang.strings @@ -2027,11 +2027,15 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL "lng_action_gift_transferred" = "{user} transferred you a gift"; "lng_action_gift_transferred_mine" = "You transferred a gift to {user}"; "lng_action_gift_received_anonymous" = "Unknown user sent you a gift for {cost}"; +"lng_action_gift_sent_channel" = "{user} sent a gift to {name} for {cost}"; "lng_action_gift_self_bought" = "You bought a gift for {cost}"; "lng_action_gift_self_subtitle" = "Saved Gift"; "lng_action_gift_self_about#one" = "Display this gift on your page or convert it to **{count}** Star."; "lng_action_gift_self_about#other" = "Display this gift on your page or convert it to **{count}** Stars."; "lng_action_gift_self_about_unique" = "You can display this gift on your page or turn it into unique collectible and send to others."; +"lng_action_gift_channel_about#one" = "Display this gift in channel's Gifts or convert it to **{count}** Star."; +"lng_action_gift_channel_about#other" = "Display this gift in channel's Gifts or convert it to **{count}** Stars."; +"lng_action_gift_channel_about_unique" = "You can display this gift in channel's Gifts or turn it into unique collectible."; "lng_action_gift_for_stars#one" = "{count} Star"; "lng_action_gift_for_stars#other" = "{count} Stars"; "lng_action_gift_got_subtitle" = "Gift from {user}"; @@ -2118,6 +2122,8 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL "lng_peer_gifts_title" = "Gifts"; "lng_peer_gifts_about" = "These gifts were sent to {user} by other users."; "lng_peer_gifts_about_mine" = "These gifts were sent to you by other users. Click on a gift to convert it to Stars or change its privacy settings."; +"lng_peer_gifts_notify" = "Notify About New Gifts"; +"lng_peer_gifts_notify_enabled" = "You will receive a message from Telegram when your channel receives a gift."; "lng_premium_gift_duration_months#one" = "for {count} month"; "lng_premium_gift_duration_months#other" = "for {count} months"; @@ -2968,6 +2974,10 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL "lng_boost_group_needs_level_emoji#one" = "Your group needs to reach **Level {count}** to set emoji pack."; "lng_boost_group_needs_level_emoji#other" = "Your group needs to reach **Level {count}** to set emoji pack."; +"lng_boost_channel_title_wear" = "Wear Item"; +"lng_boost_channel_needs_level_wear#one" = "Your channel needs **Level {count}** to wear collectibles."; +"lng_boost_channel_needs_level_wear#other" = "Your channel needs **Level {count}** to wear collectibles."; + "lng_boost_channel_ask" = "Ask your **Premium** subscribers to boost your channel with this link:"; "lng_boost_channel_ask_button" = "Copy Link"; "lng_boost_channel_or" = "or"; @@ -3247,10 +3257,16 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL "lng_gift_send_anonymous" = "Hide My Name"; "lng_gift_send_anonymous_self" = "Hide my name and message from visitors to my profile."; "lng_gift_send_anonymous_about" = "You can hide your name and message from visitors to {user}'s profile. {recipient} will still see your name and message."; +"lng_gift_send_anonymous_about_channel" = "You can hide your name and message from all visitors of this channel except its admins."; "lng_gift_send_unique" = "Make Unique for {price}"; "lng_gift_send_unique_about" = "Enable this to let {user} turn your gift into a unique collectible. {link}"; +"lng_gift_send_unique_about_channel" = "Enable this to let the admins of {name} turn your gift into a unique collectible. {link}"; "lng_gift_send_unique_link" = "Learn More >"; "lng_gift_send_premium_about" = "Only {user} will see your message."; +"lng_gift_send_limited_sold#one" = "{count} sold"; +"lng_gift_send_limited_sold#other" = "{count} sold"; +"lng_gift_send_limited_left#one" = "{count} left"; +"lng_gift_send_limited_left#other" = "{count} left"; "lng_gift_send_button" = "Send a Gift for {cost}"; "lng_gift_send_button_self" = "Buy a Gift for {cost}"; "lng_gift_sent_title" = "Gift Sent!"; @@ -3264,6 +3280,8 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL "lng_gift_anonymous_hint" = "Only you can see the sender's name."; "lng_gift_hidden_hint" = "This gift is hidden. Only you can see it."; "lng_gift_visible_hint" = "This gift is visible to visitors of your page."; +"lng_gift_hidden_hint_channel" = "This gift is hidden from visitors of your channel."; +"lng_gift_visible_hint_channel" = "This gift is visible in your channel's Gifts."; "lng_gift_availability" = "Availability"; "lng_gift_from_hidden" = "Hidden User"; "lng_gift_visibility" = "Visibility"; @@ -3274,6 +3292,8 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL "lng_gift_self_status" = "buy yourself a gift"; "lng_gift_self_title" = "Buy a Gift"; "lng_gift_self_about" = "Buy yourself a gift to display on your page or reserve for later.\n\nLimited-edition gifts upgraded to collectibles can be gifted to others later."; +"lng_gift_channel_title" = "Send a Gift"; +"lng_gift_channel_about" = "Select a gift to show appreciation for {name}."; "lng_gift_unique_owner" = "Owner"; "lng_gift_unique_owner_change" = "change"; "lng_gift_unique_status" = "Status"; @@ -3317,6 +3337,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL "lng_gift_upgrade_about" = "Turn your gift into a unique collectible\nthat you can transfer or auction."; "lng_gift_upgrade_preview_title" = "Make Unique"; "lng_gift_upgrade_preview_about" = "Let {name} turn your gift into a unique collectible."; +"lng_gift_upgrade_preview_about_channel" = "Let the admins of {name} turn your gift into a unique collectible."; "lng_gift_upgrade_unique_title" = "Unique"; "lng_gift_upgrade_unique_about" = "Get a unique number, model, backdrop and symbol for your gift."; "lng_gift_upgrade_transferable_title" = "Transferable"; diff --git a/Telegram/SourceFiles/boxes/star_gift_box.cpp b/Telegram/SourceFiles/boxes/star_gift_box.cpp index 07da724b0..99f8accc1 100644 --- a/Telegram/SourceFiles/boxes/star_gift_box.cpp +++ b/Telegram/SourceFiles/boxes/star_gift_box.cpp @@ -274,8 +274,14 @@ auto GenerateGiftMedia( ? tr::lng_action_gift_self_about_unique( tr::now, Text::RichLangValue) + : (recipient->isBroadcast() && gift.info.starsToUpgrade) + ? tr::lng_action_gift_channel_about_unique( + tr::now, + Text::RichLangValue) : (recipient->isSelf() ? tr::lng_action_gift_self_about + : recipient->isBroadcast() + ? tr::lng_action_gift_channel_about : tr::lng_action_gift_got_stars_text)( tr::now, lt_count, @@ -482,6 +488,15 @@ void PreviewWrap::prepare(rpl::producer<GiftDetails> details) { ? tr::lng_action_gift_unique_received(tr::now, lt_user, name) : _recipient->isSelf() ? tr::lng_action_gift_self_bought(tr::now, lt_cost, cost) + : _recipient->isBroadcast() + ? tr::lng_action_gift_sent_channel( + tr::now, + lt_user, + name, + lt_name, + _recipient->name(), + lt_cost, + cost) : tr::lng_action_gift_received( tr::now, lt_user, @@ -1218,7 +1233,7 @@ void AddUpgradeButton( not_null<Ui::VerticalLayout*> container, not_null<Main::Session*> session, int cost, - QString name, + not_null<PeerData*> peer, Fn<void(bool)> toggled, Fn<void()> preview) { const auto button = container->add( @@ -1265,12 +1280,19 @@ void AddUpgradeButton( AddSkip(container); const auto about = AddDividerText( container, - tr::lng_gift_send_unique_about( - lt_user, - rpl::single(TextWithEntities{ name }), - lt_link, - tr::lng_gift_send_unique_link() | Text::ToLink(), - Text::WithEntities)); + (peer->isBroadcast() + ? tr::lng_gift_send_unique_about_channel( + lt_name, + rpl::single(TextWithEntities{ peer->name() }), + lt_link, + tr::lng_gift_send_unique_link() | Text::ToLink(), + Text::WithEntities) + : tr::lng_gift_send_unique_about( + lt_user, + rpl::single(TextWithEntities{ peer->shortName() }), + lt_link, + tr::lng_gift_send_unique_link() | Text::ToLink(), + Text::WithEntities))); about->setClickHandlerFilter([=](const auto &...) { preview(); return false; @@ -1383,15 +1405,11 @@ void SendGiftBox( if (const auto stars = std::get_if<GiftTypeStars>(&descriptor)) { const auto cost = stars->info.starsToUpgrade; if (cost > 0 && !peer->isSelf()) { - const auto user = peer->asUser(); - Assert(user != nullptr); - const auto id = stars->info.id; - const auto name = user->shortName(); const auto showing = std::make_shared<bool>(); AddDivider(container); AddSkip(container); - AddUpgradeButton(container, session, cost, name, [=](bool on) { + AddUpgradeButton(container, session, cost, peer, [=](bool on) { auto now = state->details.current(); now.upgraded = on; state->details = std::move(now); @@ -1404,7 +1422,7 @@ void SendGiftBox( .controller = window, .stargiftId = id, .ready = [=](bool) { *showing = false; }, - .user = user, + .peer = peer, .cost = int(cost), }); }); @@ -1432,6 +1450,8 @@ void SendGiftBox( }, [&](const GiftTypeStars &) { AddDividerText(container, peer->isSelf() ? tr::lng_gift_send_anonymous_self() + : peer->isBroadcast() + ? tr::lng_gift_send_anonymous_about_channel() : tr::lng_gift_send_anonymous_about( lt_user, rpl::single(peer->shortName()), @@ -1711,7 +1731,7 @@ void GiftBox( window->showSettings(Settings::CreditsId()); return false; }; - if (!peer->isSelf()) { + if (peer->isUser() && !peer->isSelf()) { const auto premiumClickHandlerFilter = [=](const auto &...) { Settings::ShowPremium(window, u"gift_send"_q); return false; @@ -1731,9 +1751,16 @@ void GiftBox( AddBlock(content, window, { .subtitle = (peer->isSelf() ? tr::lng_gift_self_title() + : peer->isBroadcast() + ? tr::lng_gift_channel_title() : tr::lng_gift_stars_subtitle()), .about = (peer->isSelf() ? tr::lng_gift_self_about(Text::WithEntities) + : peer->isBroadcast() + ? tr::lng_gift_channel_about( + lt_name, + rpl::single(Text::Bold(peer->name())), + Text::WithEntities) : tr::lng_gift_stars_about( lt_name, rpl::single(Text::Bold(peer->shortName())), @@ -2366,9 +2393,11 @@ void AddUpgradeGiftCover( MakeUpgradeGiftStream(args), (args.itemId ? tr::lng_gift_upgrade_about() - : tr::lng_gift_upgrade_preview_about( - lt_name, - rpl::single(args.user->shortName())))); + : (args.peer->isBroadcast() + ? tr::lng_gift_upgrade_preview_about_channel + : tr::lng_gift_upgrade_preview_about)( + lt_name, + rpl::single(args.peer->shortName())))); } void UpgradeBox( @@ -2481,7 +2510,7 @@ void UpgradeBox( if (result != Payments::CheckoutResult::Paid) { state->sent = false; } else { - controller->showPeerHistory(args.user); + controller->showPeerHistory(args.peer); if (const auto strong = weak.data()) { strong->closeBox(); } @@ -2636,7 +2665,7 @@ void PaintPoints( void ShowStarGiftUpgradeBox(StarGiftUpgradeArgs &&args) { const auto weak = base::make_weak(args.controller); - const auto session = &args.user->session(); + const auto session = &args.peer->session(); session->api().request(MTPpayments_GetStarGiftUpgradePreview( MTP_long(args.stargiftId) )).done([=](const MTPpayments_StarGiftUpgradePreview &result) { diff --git a/Telegram/SourceFiles/boxes/star_gift_box.h b/Telegram/SourceFiles/boxes/star_gift_box.h index 8811f16c0..e0841b066 100644 --- a/Telegram/SourceFiles/boxes/star_gift_box.h +++ b/Telegram/SourceFiles/boxes/star_gift_box.h @@ -81,7 +81,7 @@ struct StarGiftUpgradeArgs { not_null<Window::SessionController*> controller; base::required<uint64> stargiftId; Fn<void(bool)> ready; - not_null<UserData*> user; + not_null<PeerData*> peer; MsgId itemId = 0; int cost = 0; bool canAddSender = false; diff --git a/Telegram/SourceFiles/history/history_item.cpp b/Telegram/SourceFiles/history/history_item.cpp index 449c8ec4d..1ff690236 100644 --- a/Telegram/SourceFiles/history/history_item.cpp +++ b/Telegram/SourceFiles/history/history_item.cpp @@ -5445,6 +5445,7 @@ void HistoryItem::setServiceMessageByAction(const MTPmessageAction &action) { }; const auto anonymous = _from->isServiceUser(); if (anonymous || _history->peer->isSelf()) { + // todo channel gifts result.text = (anonymous ? tr::lng_action_gift_received_anonymous : tr::lng_action_gift_self_bought)( diff --git a/Telegram/SourceFiles/history/view/media/history_view_premium_gift.cpp b/Telegram/SourceFiles/history/view/media/history_view_premium_gift.cpp index f7d94fe67..a0e972d3f 100644 --- a/Telegram/SourceFiles/history/view/media/history_view_premium_gift.cpp +++ b/Telegram/SourceFiles/history/view/media/history_view_premium_gift.cpp @@ -115,7 +115,7 @@ TextWithEntities PremiumGift::subtitle() { : (_data.starsToUpgrade && !_data.converted && _parent->history()->peer->isSelf()) - ? tr::lng_action_gift_self_about_unique( + ? tr::lng_action_gift_self_about_unique( // todo channel gifts tr::now, Ui::Text::RichLangValue) : (!_data.converted && !_data.starsConverted) @@ -127,7 +127,7 @@ TextWithEntities PremiumGift::subtitle() { : (_data.converted ? tr::lng_gift_got_stars : _parent->history()->peer->isSelf() - ? tr::lng_action_gift_self_about + ? tr::lng_action_gift_self_about // todo channel gifts : tr::lng_action_gift_got_stars_text)( tr::now, lt_count, diff --git a/Telegram/SourceFiles/settings/settings_credits_graphics.cpp b/Telegram/SourceFiles/settings/settings_credits_graphics.cpp index f2d222be4..38a65b229 100644 --- a/Telegram/SourceFiles/settings/settings_credits_graphics.cpp +++ b/Telegram/SourceFiles/settings/settings_credits_graphics.cpp @@ -1276,7 +1276,7 @@ void GenericCreditsEntryBox( && giftToSelf && !(couldConvert || nonConvertible)) ? tr::lng_action_gift_self_about_unique( - Ui::Text::WithEntities) + Ui::Text::WithEntities) // todo channel gifts : ((couldConvert || nonConvertible) ? (e.savedToProfile ? tr::lng_action_gift_can_remove_text @@ -1284,7 +1284,7 @@ void GenericCreditsEntryBox( Ui::Text::WithEntities) : rpl::combine( (canConvert - ? (giftToSelf + ? (giftToSelf // todo channel gifts ? tr::lng_action_gift_self_about : tr::lng_action_gift_got_stars_text) : tr::lng_gift_got_stars)( @@ -1400,7 +1400,7 @@ void GenericCreditsEntryBox( .controller = window, .stargiftId = e.stargiftId, .ready = [=](bool) { *upgradeGuard = false; }, - .user = starGiftSender, + .peer = starGiftSender, .itemId = itemId, .cost = e.starsUpgradedBySender ? 0 : e.starsToUpgrade, .canAddSender = !giftToSelf && !e.anonymous, @@ -1496,7 +1496,7 @@ void GenericCreditsEntryBox( box, (e.savedToProfile ? tr::lng_gift_visible_hint() - : tr::lng_gift_hidden_hint()), + : tr::lng_gift_hidden_hint()), // todo channel gifts st::creditsBoxAboutDivider))); } else if (gotStarGift && e.anonymous) { box->addRow(object_ptr<Ui::CenterWrap<>>( diff --git a/Telegram/SourceFiles/ui/boxes/boost_box.cpp b/Telegram/SourceFiles/ui/boxes/boost_box.cpp index 23e378146..4260eb05f 100644 --- a/Telegram/SourceFiles/ui/boxes/boost_box.cpp +++ b/Telegram/SourceFiles/ui/boxes/boost_box.cpp @@ -686,6 +686,8 @@ void AskBoostBox( return tr::lng_boost_channel_title_reactions(); }, [](AskBoostCpm) { return tr::lng_boost_channel_title_cpm(); + }, [](AskBoostWearCollectible) { + return tr::lng_boost_channel_title_wear(); }); auto reasonText = v::match(data.reason.data, [&]( AskBoostChannelColor data) { @@ -724,6 +726,11 @@ void AskBoostBox( lt_count, rpl::single(float64(data.requiredLevel)), Ui::Text::RichLangValue); + }, [&](AskBoostWearCollectible data) { + return tr::lng_boost_channel_needs_level_wear( + lt_count, + rpl::single(float64(data.requiredLevel)), + Ui::Text::RichLangValue); }); auto text = rpl::combine( std::move(reasonText), diff --git a/Telegram/SourceFiles/ui/boxes/boost_box.h b/Telegram/SourceFiles/ui/boxes/boost_box.h index 12c97c2c1..e232f0524 100644 --- a/Telegram/SourceFiles/ui/boxes/boost_box.h +++ b/Telegram/SourceFiles/ui/boxes/boost_box.h @@ -96,6 +96,10 @@ struct AskBoostCpm { int requiredLevel = 0; }; +struct AskBoostWearCollectible { + int requiredLevel = 0; +}; + struct AskBoostReason { std::variant< AskBoostChannelColor, @@ -103,7 +107,8 @@ struct AskBoostReason { AskBoostEmojiStatus, AskBoostEmojiPack, AskBoostCustomReactions, - AskBoostCpm> data; + AskBoostCpm, + AskBoostWearCollectible> data; }; struct AskBoostBoxData { diff --git a/Telegram/SourceFiles/window/window_peer_menu.cpp b/Telegram/SourceFiles/window/window_peer_menu.cpp index da0e52766..76fe469a3 100644 --- a/Telegram/SourceFiles/window/window_peer_menu.cpp +++ b/Telegram/SourceFiles/window/window_peer_menu.cpp @@ -302,7 +302,7 @@ private: void addNewMembers(); void addDeleteContact(); void addTTLSubmenu(bool addSeparator); - void addGiftPremium(); + void addSendGift(); void addCreateTopic(); void addViewAsMessages(); void addViewAsTopics(); @@ -1227,22 +1227,28 @@ void Filler::addTTLSubmenu(bool addSeparator) { } } -void Filler::addGiftPremium() { +void Filler::addSendGift() { const auto user = _peer->asUser(); - if (!user - || user->isInaccessible() - || user->isSelf() - || user->isBot() - || user->isNotificationsUser() - || user->isRepliesChat() - || user->isVerifyCodes() - || !user->session().premiumCanBuy()) { + const auto channel = _peer->asBroadcast(); + if (!user && !channel) { + return; + } else if (user + && (user->isInaccessible() + || user->isSelf() + || user->isBot() + || user->isNotificationsUser() + || user->isRepliesChat() + || user->isVerifyCodes() + || !user->session().premiumCanBuy())) { + return; + } else if (channel && channel->isForbidden()) { return; } + const auto peer = _peer; const auto navigation = _controller; _addAction(tr::lng_profile_gift_premium(tr::now), [=] { - Ui::ShowStarGiftBox(navigation, user); + Ui::ShowStarGiftBox(navigation, peer); }, &st::menuIconGiftPremium); } @@ -1446,9 +1452,9 @@ void Filler::fillProfileActions() { addNewContact(); addShareContact(); addEditContact(); - addGiftPremium(); addBotToGroup(); addNewMembers(); + addSendGift(); addViewStatistics(); addStoryArchive(); addManageChat();