diff --git a/Telegram/SourceFiles/data/data_channel.cpp b/Telegram/SourceFiles/data/data_channel.cpp index 2f7694395..6162024fd 100644 --- a/Telegram/SourceFiles/data/data_channel.cpp +++ b/Telegram/SourceFiles/data/data_channel.cpp @@ -1089,7 +1089,8 @@ void ApplyChannelUpdate( | Flag::CanGetStatistics | Flag::ViewAsMessages | Flag::CanViewRevenue - | Flag::PaidMediaAllowed; + | Flag::PaidMediaAllowed + | Flag::CanViewCreditsRevenue; channel->setFlags((channel->flags() & ~mask) | (update.is_can_set_username() ? Flag::CanSetUsername : Flag()) | (update.is_can_view_participants() @@ -1107,7 +1108,10 @@ void ApplyChannelUpdate( ? Flag::ViewAsMessages : Flag()) | (update.is_paid_media_allowed() ? Flag::PaidMediaAllowed : Flag()) - | (update.is_can_view_revenue() ? Flag::CanViewRevenue : Flag())); + | (update.is_can_view_revenue() ? Flag::CanViewRevenue : Flag()) + | (update.is_can_view_stars_revenue() + ? Flag::CanViewCreditsRevenue + : Flag())); channel->setUserpicPhoto(update.vchat_photo()); if (const auto migratedFrom = update.vmigrated_from_chat_id()) { channel->addFlags(Flag::Megagroup); diff --git a/Telegram/SourceFiles/data/data_channel.h b/Telegram/SourceFiles/data/data_channel.h index d6f880bda..81ad7778d 100644 --- a/Telegram/SourceFiles/data/data_channel.h +++ b/Telegram/SourceFiles/data/data_channel.h @@ -67,6 +67,7 @@ enum class ChannelDataFlag : uint64 { SimilarExpanded = (1ULL << 31), CanViewRevenue = (1ULL << 32), PaidMediaAllowed = (1ULL << 33), + CanViewCreditsRevenue = (1ULL << 34), }; inline constexpr bool is_flag_type(ChannelDataFlag) { return true; }; using ChannelDataFlags = base::flags; diff --git a/Telegram/SourceFiles/info/channel_statistics/earn/info_channel_earn_list.cpp b/Telegram/SourceFiles/info/channel_statistics/earn/info_channel_earn_list.cpp index 84ad81390..c16acc204 100644 --- a/Telegram/SourceFiles/info/channel_statistics/earn/info_channel_earn_list.cpp +++ b/Telegram/SourceFiles/info/channel_statistics/earn/info_channel_earn_list.cpp @@ -281,6 +281,9 @@ void InnerWidget::load() { rpl::lifetime apiPremiumBotLifetime; }; const auto state = lifetime().make_state(_peer); + using ChannelFlag = ChannelDataFlag; + const auto canViewCredits = !_peer->isChannel() + || (_peer->asChannel()->flags() & ChannelFlag::CanViewCreditsRevenue); Info::Statistics::FillLoading( this, @@ -363,7 +366,11 @@ void InnerWidget::load() { _state.premiumBotId = bot->id; state->apiCredits.request( ) | rpl::start_with_error_done([=](const QString &error) { - fail(error); + if (canViewCredits) { + fail(error); + } else { + _state.creditsEarn = {}; + } finish(); }, [=] { _state.creditsEarn = state->apiCredits.data(); diff --git a/Telegram/SourceFiles/window/window_peer_menu.cpp b/Telegram/SourceFiles/window/window_peer_menu.cpp index f8259eec7..74f6f7ed8 100644 --- a/Telegram/SourceFiles/window/window_peer_menu.cpp +++ b/Telegram/SourceFiles/window/window_peer_menu.cpp @@ -1090,6 +1090,8 @@ void Filler::addViewStatistics() { using Flag = ChannelDataFlag; const auto canGetStats = (channel->flags() & Flag::CanGetStatistics); const auto canViewEarn = (channel->flags() & Flag::CanViewRevenue); + const auto canViewCreditsEarn + = (channel->flags() & Flag::CanViewCreditsRevenue); if (canGetStats) { _addAction(tr::lng_stats_title(tr::now), [=] { if (const auto strong = weak.get()) { @@ -1107,7 +1109,7 @@ void Filler::addViewStatistics() { } }, &st::menuIconBoosts); } - if (canViewEarn) { + if (canViewEarn || canViewCreditsEarn) { _addAction(tr::lng_channel_earn_title(tr::now), [=] { if (const auto strong = weak.get()) { controller->showSection(Info::ChannelEarn::Make(peer));