From e8fba23b593c59bbd0115db4a8e16bde6a65ac7c Mon Sep 17 00:00:00 2001 From: John Preston Date: Tue, 25 Nov 2025 19:05:55 +0400 Subject: [PATCH] Don't allow sending stars from stream admin. --- Telegram/Resources/langs/lang.strings | 3 ++ .../calls/group/calls_group_stars_box.cpp | 22 ++++++--- .../calls/group/calls_group_stars_box.h | 1 + .../history_view_compose_controls.cpp | 4 +- .../payments/ui/payments_reaction_box.cpp | 49 ++++++++++++------- .../payments/ui/payments_reaction_box.h | 1 + 6 files changed, 51 insertions(+), 29 deletions(-) diff --git a/Telegram/Resources/langs/lang.strings b/Telegram/Resources/langs/lang.strings index 3bd8414182..af85c3c495 100644 --- a/Telegram/Resources/langs/lang.strings +++ b/Telegram/Resources/langs/lang.strings @@ -4791,6 +4791,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL "lng_paid_react_send" = "Send {price}"; "lng_paid_react_agree" = "By sending stars, you agree to the {link}."; "lng_paid_react_agree_link" = "Terms of Service"; +"lng_paid_react_admin_cant" = "You can't send Stars to your own Live Story."; "lng_paid_react_toast#one" = "Star Sent!"; "lng_paid_react_toast#other" = "Stars Sent!"; "lng_paid_react_toast_anonymous#one" = "Star sent anonymously!"; @@ -4812,6 +4813,8 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL "lng_paid_reaction_title" = "React with Stars"; "lng_paid_reaction_about" = "Highlight and pin your message by sending Stars to {name}."; "lng_paid_reaction_button" = "Send {stars}"; +"lng_paid_admin_title" = "Receive Stars from Viewers"; +"lng_paid_admin_about" = "Viewers can send you Star Reactions."; "lng_sensitive_tag" = "18+"; "lng_sensitive_title" = "18+"; diff --git a/Telegram/SourceFiles/calls/group/calls_group_stars_box.cpp b/Telegram/SourceFiles/calls/group/calls_group_stars_box.cpp index 6239aa4464..e287398b0b 100644 --- a/Telegram/SourceFiles/calls/group/calls_group_stars_box.cpp +++ b/Telegram/SourceFiles/calls/group/calls_group_stars_box.cpp @@ -43,18 +43,21 @@ void VideoStreamStarsBox( VideoStreamStarsBoxArgs &&args) { args.show->session().credits().load(); + const auto admin = args.admin; const auto sending = args.sending; auto submitText = [=](rpl::producer amount) { auto nice = std::move(amount) | rpl::map([=](int count) { return Ui::CreditsEmojiSmall().append( Lang::FormatCountDecimal(count)); }); - return (sending - ? tr::lng_paid_reaction_button - : tr::lng_paid_comment_button)( - lt_stars, - std::move(nice), - Ui::Text::RichLangValue); + return admin + ? tr::lng_box_ok(tr::marked) + : (sending + ? tr::lng_paid_reaction_button + : tr::lng_paid_comment_button)( + lt_stars, + std::move(nice), + tr::rich); }; const auto &show = args.show; const auto session = &show->session(); @@ -121,14 +124,17 @@ void VideoStreamStarsBox( .submit = std::move(submitText), .colorings = show->session().appConfig().groupCallColorings(), .balanceValue = session->credits().balanceValue(), - .send = [weak, save = args.save](int count, uint64 barePeerId) { - save(count); + .send = [=, save = args.save](int count, uint64 barePeerId) { + if (!admin) { + save(count); + } if (const auto strong = weak.get()) { strong->closeBox(); } }, .videoStreamChoosing = !sending, .videoStreamSending = sending, + .videoStreamAdmin = admin, .dark = true, }); } diff --git a/Telegram/SourceFiles/calls/group/calls_group_stars_box.h b/Telegram/SourceFiles/calls/group/calls_group_stars_box.h index cc6edac47f..1b1af61371 100644 --- a/Telegram/SourceFiles/calls/group/calls_group_stars_box.h +++ b/Telegram/SourceFiles/calls/group/calls_group_stars_box.h @@ -39,6 +39,7 @@ struct VideoStreamStarsBoxArgs { int min = 0; int current = 0; bool sending = false; + bool admin = false; Fn save; QString name; }; diff --git a/Telegram/SourceFiles/history/view/controls/history_view_compose_controls.cpp b/Telegram/SourceFiles/history/view/controls/history_view_compose_controls.cpp index 708c7be30e..c90d5b0286 100644 --- a/Telegram/SourceFiles/history/view/controls/history_view_compose_controls.cpp +++ b/Telegram/SourceFiles/history/view/controls/history_view_compose_controls.cpp @@ -1448,7 +1448,7 @@ void ComposeControls::setStarsReactionCounter( _starsReaction->setAcceptBoth(); _starsReaction->clicks( ) | rpl::start_with_next([=](Qt::MouseButton button) { - if (button == Qt::LeftButton) { + if (_chosenStarsCount && button == Qt::LeftButton) { _starsReactionIncrements.fire({ .count = 1 }); startStarsSendEffect(); } else { @@ -1457,6 +1457,7 @@ void ComposeControls::setStarsReactionCounter( .top = _starsReactionTop.current(), .current = 0, .sending = true, + .admin = !_chosenStarsCount, .save = crl::guard(_starsReaction, [=](int count) { _starsReactionIncrements.fire({ .count = count, @@ -1465,7 +1466,6 @@ void ComposeControls::setStarsReactionCounter( }), .name = _history ? _history->peer->shortName() : QString(), })); - } }, _starsReaction->lifetime()); diff --git a/Telegram/SourceFiles/payments/ui/payments_reaction_box.cpp b/Telegram/SourceFiles/payments/ui/payments_reaction_box.cpp index 1fa9b384bc..d09378fff5 100644 --- a/Telegram/SourceFiles/payments/ui/payments_reaction_box.cpp +++ b/Telegram/SourceFiles/payments/ui/payments_reaction_box.cpp @@ -493,6 +493,7 @@ void PaidReactionsBox( const auto colorings = args.colorings; const auto videoStreamChoosing = args.videoStreamChoosing; const auto videoStreamSending = args.videoStreamSending; + const auto videoStreamAdmin = args.videoStreamAdmin; const auto videoStream = videoStreamChoosing || videoStreamSending; const auto initialShownPeer = ranges::find( args.top, @@ -514,7 +515,7 @@ void PaidReactionsBox( count); return Ui::ColorFromSerialized(coloring.bgLight); }; - AddStarSelectBubble( + const auto bubble = AddStarSelectBubble( content, BoxShowFinishes(box), state->chosen.value(), @@ -544,8 +545,12 @@ void PaidReactionsBox( content, std::move(args.top), colorings, - state->chosen.value(), - state->shownPeer.value(), + (videoStreamAdmin + ? rpl::single(state->chosen.current()) + : state->chosen.value()), + (videoStreamAdmin + ? rpl::single(state->shownPeer.current()) + : state->shownPeer.value()), [=](uint64 barePeerId) { state->shownPeer = state->savedShownPeer = barePeerId; }, @@ -564,7 +569,9 @@ void PaidReactionsBox( box->addRow( object_ptr( box, - (videoStreamChoosing + (videoStreamAdmin + ? tr::lng_paid_admin_title() + : videoStreamChoosing ? tr::lng_paid_comment_title() : videoStreamSending ? tr::lng_paid_reaction_title() @@ -579,22 +586,24 @@ void PaidReactionsBox( + QMargins(0, st::lineWidth, 0, st::boostBottomSkip))); const auto label = CreateChild( labelWrap, - (videoStream + (videoStreamAdmin + ? tr::lng_paid_admin_about(tr::marked) + : videoStream ? (videoStreamChoosing ? tr::lng_paid_comment_about : tr::lng_paid_reaction_about)( lt_name, - rpl::single(Text::Bold(args.name)), - Text::RichLangValue) + rpl::single(tr::bold(args.name)), + tr::rich) : already ? tr::lng_paid_react_already( lt_count, rpl::single(already) | tr::to_count(), - Text::RichLangValue) + tr::rich) : tr::lng_paid_react_about( lt_channel, - rpl::single(Text::Bold(args.name)), - Text::RichLangValue)), + rpl::single(tr::bold(args.name)), + tr::rich)), dark ? st::darkEditStarsText : st::boostText); label->setTryMakeSimilarLines(true); labelWrap->widthValue() | rpl::start_with_next([=](int width) { @@ -630,15 +639,17 @@ void PaidReactionsBox( AddDividerText( content, - tr::lng_paid_react_agree( - lt_link, - rpl::combine( - tr::lng_paid_react_agree_link(), - tr::lng_group_invite_subscription_about_url() - ) | rpl::map([](const QString &text, const QString &url) { - return Ui::Text::Link(text, url); - }), - Ui::Text::RichLangValue), + (videoStreamAdmin + ? tr::lng_paid_react_admin_cant(tr::marked) + : tr::lng_paid_react_agree( + lt_link, + rpl::combine( + tr::lng_paid_react_agree_link(), + tr::lng_group_invite_subscription_about_url() + ) | rpl::map([](const QString &text, const QString &url) { + return tr::link(text, url); + }), + tr::rich)), st::defaultBoxDividerLabelPadding, dark ? st::groupCallDividerLabel : st::defaultDividerLabel); diff --git a/Telegram/SourceFiles/payments/ui/payments_reaction_box.h b/Telegram/SourceFiles/payments/ui/payments_reaction_box.h index 7bf16b6074..3d3416ebfd 100644 --- a/Telegram/SourceFiles/payments/ui/payments_reaction_box.h +++ b/Telegram/SourceFiles/payments/ui/payments_reaction_box.h @@ -56,6 +56,7 @@ struct PaidReactionBoxArgs { Fn send; bool videoStreamChoosing = false; bool videoStreamSending = false; + bool videoStreamAdmin = false; bool dark = false; };