From 4f7b5ca7da86caec207fdab08c02e1e4dd529055 Mon Sep 17 00:00:00 2001 From: 23rd <23rd@vivaldi.net> Date: Fri, 28 Jun 2024 13:24:03 +0300 Subject: [PATCH] Added process of server notification for disabled withdrawal feature. --- Telegram/SourceFiles/api/api_updates.cpp | 6 ++++++ Telegram/SourceFiles/api/api_updates.h | 3 +++ .../earn/info_earn_inner_widget.cpp | 20 ++++++++++++++++--- 3 files changed, 26 insertions(+), 3 deletions(-) diff --git a/Telegram/SourceFiles/api/api_updates.cpp b/Telegram/SourceFiles/api/api_updates.cpp index 2d7207bae..1951dc292 100644 --- a/Telegram/SourceFiles/api/api_updates.cpp +++ b/Telegram/SourceFiles/api/api_updates.cpp @@ -2121,6 +2121,8 @@ void Updates::feedUpdate(const MTPUpdate &update) { }; if (IsForceLogoutNotification(d)) { Core::App().forceLogOut(&session().account(), text); + } else if (IsWithdrawalNotification(d)) { + return; } else if (d.is_popup()) { const auto &windows = session().windows(); if (!windows.empty()) { @@ -2622,4 +2624,8 @@ void Updates::feedUpdate(const MTPUpdate &update) { } } +bool IsWithdrawalNotification(const MTPDupdateServiceNotification &data) { + return qs(data.vtype()).startsWith(u"API_WITHDRAWAL_FEATURE_DISABLED_"_q); +} + } // namespace Api diff --git a/Telegram/SourceFiles/api/api_updates.h b/Telegram/SourceFiles/api/api_updates.h index f21baa964..c028ae75a 100644 --- a/Telegram/SourceFiles/api/api_updates.h +++ b/Telegram/SourceFiles/api/api_updates.h @@ -211,4 +211,7 @@ private: }; +[[nodiscard]] bool IsWithdrawalNotification( + const MTPDupdateServiceNotification &); + } // namespace Api diff --git a/Telegram/SourceFiles/info/channel_statistics/earn/info_earn_inner_widget.cpp b/Telegram/SourceFiles/info/channel_statistics/earn/info_earn_inner_widget.cpp index e58149319..0623a7bce 100644 --- a/Telegram/SourceFiles/info/channel_statistics/earn/info_earn_inner_widget.cpp +++ b/Telegram/SourceFiles/info/channel_statistics/earn/info_earn_inner_widget.cpp @@ -11,6 +11,8 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "api/api_earn.h" #include "api/api_filter_updates.h" #include "api/api_statistics.h" +#include "api/api_text_entities.h" +#include "api/api_updates.h" #include "base/unixtime.h" #include "boxes/peers/edit_peer_color_box.h" // AddLevelBadge. #include "chat_helpers/stickers_emoji_pack.h" @@ -36,6 +38,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "statistics/chart_widget.h" #include "ui/basic_click_handlers.h" #include "ui/boxes/boost_box.h" +#include "ui/boxes/confirm_box.h" #include "ui/controls/userpic_button.h" #include "ui/effects/animation_value_f.h" #include "ui/effects/credits_graphics.h" @@ -288,9 +291,8 @@ void InnerWidget::load() { _loaded.events_starting_with(false) | rpl::map(!rpl::mappers::_1), _showFinished.events()); - const auto fail = [show = _controller->uiShow()](const QString &error) { - show->showToast(error); - }; + const auto show = _controller->uiShow(); + const auto fail = [=](const QString &error) { show->showToast(error); }; const auto finish = [=] { _loaded.fire(true); @@ -303,6 +305,7 @@ void InnerWidget::load() { const MTPUpdates &updates) { using TLCreditsUpdate = MTPDupdateStarsRevenueStatus; using TLCurrencyUpdate = MTPDupdateBroadcastRevenueTransactions; + using TLNotificationUpdate = MTPDupdateServiceNotification; Api::PerformForUpdate(updates, [&]( const TLCreditsUpdate &d) { if (peerId == peerFromMTP(d.vpeer())) { @@ -325,6 +328,17 @@ void InnerWidget::load() { _stateUpdated.fire({}); } }); + Api::PerformForUpdate(updates, [&]( + const TLNotificationUpdate &d) { + if (Api::IsWithdrawalNotification(d) && d.is_popup()) { + show->show(Ui::MakeInformBox(TextWithEntities{ + qs(d.vmessage()), + Api::EntitiesFromMTP(& + _peer->session(), + d.ventities().v), + })); + } + }); }, lifetime()); };