diff --git a/Telegram/SourceFiles/info/peer_gifts/info_peer_gifts_common.cpp b/Telegram/SourceFiles/info/peer_gifts/info_peer_gifts_common.cpp index dd12b664681edd..b14fa711679212 100644 --- a/Telegram/SourceFiles/info/peer_gifts/info_peer_gifts_common.cpp +++ b/Telegram/SourceFiles/info/peer_gifts/info_peer_gifts_common.cpp @@ -429,7 +429,9 @@ DocumentData *LookupGiftSticker( not_null session, const GiftDescriptor &descriptor) { auto &packs = session->giftBoxStickersPacks(); +#if 0 // mtp packs.load(); +#endif return v::match(descriptor, [&](GiftTypePremium data) { return packs.lookup(data.months); }, [&](GiftTypeStars data) { diff --git a/Telegram/SourceFiles/info/peer_gifts/info_peer_gifts_widget.cpp b/Telegram/SourceFiles/info/peer_gifts/info_peer_gifts_widget.cpp index 46ec0f1d783f5a..291f2878a704f1 100644 --- a/Telegram/SourceFiles/info/peer_gifts/info_peer_gifts_widget.cpp +++ b/Telegram/SourceFiles/info/peer_gifts/info_peer_gifts_widget.cpp @@ -24,9 +24,14 @@ For license and copyright information please follow this link: #include "styles/style_info.h" #include "styles/style_credits.h" // giftBoxPadding +#include "tdb/tdb_tl_scheme.h" +#include "tdb/tdb_sender.h" + namespace Info::PeerGifts { namespace { +using namespace Tdb; + constexpr auto kPreloadPages = 2; constexpr auto kPerPage = 50; @@ -208,13 +213,28 @@ void InnerWidget::loadMore() { if (_allLoaded || _loadMoreRequestId) { return; } +#if 0 // mtp _loadMoreRequestId = _api.request(MTPpayments_GetUserStarGifts( _user->inputUser, MTP_string(_offset), MTP_int(kPerPage) )).done([=](const MTPpayments_UserStarGifts &result) { +#endif + _loadMoreRequestId = _api.request(TLgetUserGifts( + tl_int53(peerToUser(_user->id).bare), + tl_string(_offset), + tl_int32(kPerPage) + )).done([=](const TLuserGifts &result) { _loadMoreRequestId = 0; const auto &data = result.data(); + const auto offset = data.vnext_offset().v; + if (offset.isEmpty()) { + _allLoaded = true; + } else { + _offset = offset; + } + _totalCount = data.vtotal_count().v; +#if 0 // mtp if (const auto next = data.vnext_offset()) { _offset = qs(*next); } else { @@ -224,6 +244,7 @@ void InnerWidget::loadMore() { const auto owner = &_user->owner(); owner->processUsers(data.vusers()); +#endif _entries.reserve(_entries.size() + data.vgifts().v.size()); for (const auto &gift : data.vgifts().v) { diff --git a/Telegram/SourceFiles/info/statistics/info_statistics_list_controllers.cpp b/Telegram/SourceFiles/info/statistics/info_statistics_list_controllers.cpp index 0dc51cb076eccb..947ae0292d0ab7 100644 --- a/Telegram/SourceFiles/info/statistics/info_statistics_list_controllers.cpp +++ b/Telegram/SourceFiles/info/statistics/info_statistics_list_controllers.cpp @@ -1085,10 +1085,12 @@ void CreditsController::applySlice(const Data::CreditsStatusSlice &slice) { auto giftPacksRequested = false; for (const auto &item : slice.list) { +#if 0 // mtp if (item.bareGiveawayMsgId && !giftPacksRequested) { giftPacksRequested = true; session().giftBoxStickersPacks().load(); } +#endif delegate()->peerListAppendRow(create(item, {})); } for (const auto &item : slice.subscriptions) { diff --git a/Telegram/SourceFiles/inline_bots/bot_attach_web_view.cpp b/Telegram/SourceFiles/inline_bots/bot_attach_web_view.cpp index 9225cb350e7f2c..fb608577e33924 100644 --- a/Telegram/SourceFiles/inline_bots/bot_attach_web_view.cpp +++ b/Telegram/SourceFiles/inline_bots/bot_attach_web_view.cpp @@ -1075,6 +1075,19 @@ void WebViewInstance::requestSimple() { } void WebViewInstance::requestMain() { + _requestId = _session->sender().request(TLgetMainWebApp( + peerToTdbChat(_context.action->history->peer->id), + tl_int53(peerToUser(_bot->id).bare), + tl_string(_button.startCommand), + Window::Theme::WebViewTheme(), + tl_string("tdesktop") + )).done([=](const TLmainWebApp &result) { + show(qs(result.data().vurl())); + }).fail([=](const Error &error) { + _parentShow->showToast(error.message); + close(); + }).send(); +#if 0 // mtp using Flag = MTPmessages_RequestMainWebView::Flag; _requestId = _session->api().request(MTPmessages_RequestMainWebView( MTP_flags(Flag::f_theme_params @@ -1097,6 +1110,7 @@ void WebViewInstance::requestMain() { _parentShow->showToast(error.type()); close(); }).send(); +#endif } void WebViewInstance::requestApp(bool allowWrite) { @@ -1765,7 +1779,10 @@ AttachWebView::AttachWebView(not_null session) AttachWebView::~AttachWebView() { closeAll(); +#if 0 // mtp _session->api().request(_popularAppBotsRequestId).cancel(); +#endif + _session->sender().request(_popularAppBotsRequestId).cancel(); } void AttachWebView::openByUsername( @@ -1827,18 +1844,31 @@ void AttachWebView::loadPopularAppBots() { if (_popularAppBotsLoaded.current() || _popularAppBotsRequestId) { return; } +#if 0 // mtp _popularAppBotsRequestId = _session->api().request( MTPbots_GetPopularAppBots( MTP_string(), MTP_int(kPopularAppBotsLimit)) ).done([=](const MTPbots_PopularAppBots &result) { +#endif + _popularAppBotsRequestId = _session->sender().request( + TLgetGrossingWebAppBots( + tl_string(), // offset + tl_int32(kPopularAppBotsLimit)) + ).done([=](const TLfoundUsers &result) { _popularAppBotsRequestId = 0; +#if 0 // mtp const auto &list = result.data().vusers().v; +#endif + const auto &list = result.data().vuser_ids().v; auto parsed = std::vector>(); parsed.reserve(list.size()); for (const auto &user : list) { +#if 0 // mtp const auto bot = _session->data().processUser(user); +#endif + const auto bot = _session->data().user(UserId(user.v)); if (bot->isBot()) { parsed.push_back(bot); } diff --git a/Telegram/SourceFiles/main/main_app_config.cpp b/Telegram/SourceFiles/main/main_app_config.cpp index e1f594d0eed4e6..4a0de8961a8590 100644 --- a/Telegram/SourceFiles/main/main_app_config.cpp +++ b/Telegram/SourceFiles/main/main_app_config.cpp @@ -103,7 +103,7 @@ void AppConfig::refresh(bool force) { } #endif -void AppConfig::refresh() { +void AppConfig::refresh(bool force) { if (_requestId || !_api) { return; } diff --git a/Telegram/SourceFiles/main/main_session.cpp b/Telegram/SourceFiles/main/main_session.cpp index 058fd4150284bd..76f54efc7b6ddd 100644 --- a/Telegram/SourceFiles/main/main_session.cpp +++ b/Telegram/SourceFiles/main/main_session.cpp @@ -117,9 +117,7 @@ Session::Session( , _user(_data->processUser(user)) , _emojiStickersPack(std::make_unique(this)) , _diceStickersPacks(std::make_unique(this)) -#if 0 // mtp , _giftBoxStickersPacks(std::make_unique(this)) -#endif , _sendAsPeers(std::make_unique(this)) , _attachWebView(std::make_unique(this)) , _recentPeers(std::make_unique(this)) diff --git a/Telegram/SourceFiles/main/main_session.h b/Telegram/SourceFiles/main/main_session.h index 38c7df1f5ca18b..e99d51ec7ce943 100644 --- a/Telegram/SourceFiles/main/main_session.h +++ b/Telegram/SourceFiles/main/main_session.h @@ -189,11 +189,9 @@ class Session final : public base::has_weak_ptr { [[nodiscard]] Stickers::DicePacks &diceStickersPacks() const { return *_diceStickersPacks; } -#if 0 // mtp [[nodiscard]] Stickers::GiftBoxPack &giftBoxStickersPacks() const { return *_giftBoxStickersPacks; } -#endif [[nodiscard]] Data::Session &data() const { return *_data; } @@ -299,9 +297,7 @@ class Session final : public base::has_weak_ptr { // _emojiStickersPack depends on _data. const std::unique_ptr _emojiStickersPack; const std::unique_ptr _diceStickersPacks; -#if 0 // mtp const std::unique_ptr _giftBoxStickersPacks; -#endif const std::unique_ptr _sendAsPeers; const std::unique_ptr _attachWebView; const std::unique_ptr _recentPeers; diff --git a/Telegram/SourceFiles/payments/payments_form.cpp b/Telegram/SourceFiles/payments/payments_form.cpp index abb0477fe0bca0..774c661b17bd45 100644 --- a/Telegram/SourceFiles/payments/payments_form.cpp +++ b/Telegram/SourceFiles/payments/payments_form.cpp @@ -226,11 +226,11 @@ MTPinputStorePaymentPurpose InvoicePremiumGiftCodeGiveawayToTL( } #endif -Tdb::TLpremiumGiveawayParameters InvoiceGiftCodeGiveawayToTL( +Tdb::TLgiveawayParameters InvoiceGiftCodeGiveawayToTL( const InvoicePremiumGiftCode &invoice) { const auto &giveaway = v::get( invoice.purpose); - return Tdb::tl_premiumGiveawayParameters( + return Tdb::tl_giveawayParameters( peerToTdbChat(giveaway.boostPeer->id), Tdb::tl_vector(ranges::views::all( giveaway.additionalChannels @@ -536,9 +536,9 @@ TLinputInvoice Form::inputInvoice() const { if (users) { return Tdb::tl_inputInvoiceTelegram( Tdb::tl_telegramPaymentPurposePremiumGiftCodes( - users->boostPeer + (users->boostPeer ? peerToTdbChat(users->boostPeer->id) - : TLint53(), + : TLint53()), Tdb::tl_string(giftCode.currency), Tdb::tl_int53(giftCode.amount), Tdb::tl_vector(ranges::views::all( @@ -546,7 +546,8 @@ TLinputInvoice Form::inputInvoice() const { ) | ranges::views::transform([](not_null user) { return peerToTdbChat(user->id); }) | ranges::to>), - Tdb::tl_int32(giftCode.months))); + Tdb::tl_int32(giftCode.months), + Api::FormattedTextToTdb(users->message))); } else { return Tdb::tl_inputInvoiceTelegram( Tdb::tl_telegramPaymentPurposePremiumGiveaway( diff --git a/Telegram/SourceFiles/payments/payments_form.h b/Telegram/SourceFiles/payments/payments_form.h index ab819ba12dd0e0..b545f456594994 100644 --- a/Telegram/SourceFiles/payments/payments_form.h +++ b/Telegram/SourceFiles/payments/payments_form.h @@ -24,7 +24,7 @@ class TLsavedCredentials; class TLshippingOption; class TLDpaymentProviderStripe; class TLDpaymentProviderSmartGlocal; -class TLpremiumGiveawayParameters; +class TLgiveawayParameters; } // namespace Tdb class Image; @@ -310,7 +310,7 @@ struct FormUpdate : std::variant< [[nodiscard]] MTPinputStorePaymentPurpose InvoiceCreditsGiveawayToTL( const InvoicePremiumGiftCode &invoice); #endif -[[nodiscard]] Tdb::TLpremiumGiveawayParameters InvoiceGiftCodeGiveawayToTL( +[[nodiscard]] Tdb::TLgiveawayParameters InvoiceGiftCodeGiveawayToTL( const InvoicePremiumGiftCode &invoice); class Form final : public base::has_weak_ptr { diff --git a/Telegram/SourceFiles/settings/settings_credits_graphics.cpp b/Telegram/SourceFiles/settings/settings_credits_graphics.cpp index e25e6d9063964a..8e72c205517730 100644 --- a/Telegram/SourceFiles/settings/settings_credits_graphics.cpp +++ b/Telegram/SourceFiles/settings/settings_credits_graphics.cpp @@ -86,6 +86,9 @@ For license and copyright information please follow this link: #include "styles/style_settings.h" #include "styles/style_statistics.h" +#include "tdb/tdb_tl_scheme.h" +#include "tdb/tdb_sender.h" + #include // XXH64. #include @@ -93,6 +96,8 @@ For license and copyright information please follow this link: namespace Settings { namespace { +using namespace Tdb; + const auto kTopUpPrefix = "cloud_lng_topup_purpose_"; [[nodiscard]] uint64 UniqueIdFromOption( @@ -167,6 +172,7 @@ void ToggleStarGiftSaved( using Flag = MTPpayments_SaveStarGift::Flag; const auto api = &window->session().api(); const auto weak = base::make_weak(window); +#if 0 // mtp api->request(MTPpayments_SaveStarGift( MTP_flags(save ? Flag(0) : Flag::f_unsave), sender->inputUser, @@ -184,6 +190,24 @@ void ToggleStarGiftSaved( } done(false); }).send(); +#endif + window->session().sender().request(TLtoggleGiftIsSaved( + tl_int53(peerToUser(sender->id).bare), + tl_int53(itemId.bare), + tl_bool(save) + )).done([=] { + if (const auto strong = weak.get()) { + strong->showToast((save + ? tr::lng_gift_display_done + : tr::lng_gift_display_done_hide)(tr::now)); + } + done(true); + }).fail([=](const Error &error) { + if (const auto strong = weak.get()) { + strong->showToast(error.message); + } + done(false); + }).send(); } void ConfirmConvertStarGift( @@ -212,6 +236,7 @@ void ConvertStarGift( Fn done) { const auto api = &window->session().api(); const auto weak = base::make_weak(window); +#if 0 // mtp api->request(MTPpayments_ConvertStarGift( sender->inputUser, MTP_int(itemId) @@ -231,6 +256,26 @@ void ConvertStarGift( } done(false); }).send(); +#endif + window->session().sender().request(TLsellGift( + tl_int53(peerToUser(sender->id).bare), + tl_int53(itemId.bare) + )).done([=] { + if (const auto strong = weak.get()) { + strong->showSettings(Settings::CreditsId()); + strong->showToast(tr::lng_gift_got_stars( + tr::now, + lt_count, + stars, + Ui::Text::RichLangValue)); + } + done(true); + }).fail([=](const Error &error) { + if (const auto strong = weak.get()) { + strong->showToast(error.message); + } + done(false); + }).send(); } void AddViewMediaHandler( @@ -1229,6 +1274,7 @@ void ReceiptCreditsBox( } }); } else { +#if 0 // mtp using Flag = MTPpayments_ChangeStarsSubscription::Flag; session->api().request( MTPpayments_ChangeStarsSubscription( @@ -1246,6 +1292,20 @@ void ReceiptCreditsBox( } show->showToast(error.type()); }).send(); +#endif + session->sender().request(TLeditStarSubscription( + tl_string(s.id), + tl_bool(toCancel) + )).done([=] { + if (const auto strong = weak.data()) { + strong->closeBox(); + } + }).fail([=, show = box->uiShow()](const Error &error) { + if (const auto strong = weak.data()) { + state->confirmButtonBusy = false; + } + show->showToast(error.message); + }).send(); } }; diff --git a/Telegram/SourceFiles/settings/settings_privacy_controllers.cpp b/Telegram/SourceFiles/settings/settings_privacy_controllers.cpp index 4978a3fd163348..3d473bf509ae6e 100644 --- a/Telegram/SourceFiles/settings/settings_privacy_controllers.cpp +++ b/Telegram/SourceFiles/settings/settings_privacy_controllers.cpp @@ -175,19 +175,7 @@ AdminLog::OwnedItem GenerateForwardedItem( tl_bool(false), // is_outgoing tl_bool(false), // is_pinned tl_bool(false), // is_from_offline - tl_bool(false), // can_be_edited - tl_bool(false), // can_be_forwarded - tl_bool(false), // can_be_replied_in_another_chat tl_bool(true), // can_be_saved - tl_bool(true), // can_be_deleted_only_for_self - tl_bool(false), // can_be_deleted_for_all_users - tl_bool(false), // can_get_added_reactions - tl_bool(false), // can_get_statistics - tl_bool(false), // can_get_message_thread - tl_bool(false), // can_get_read_date - tl_bool(false), // can_get_viewers - tl_bool(false), // can_get_media_timestamp_links - tl_bool(false), // can_report_reactions tl_bool(false), // has_timestamped_media tl_bool(false), // is_channel_post tl_bool(false), // is_topic_message @@ -216,6 +204,7 @@ AdminLog::OwnedItem GenerateForwardedItem( tl_string(), // author_signature tl_int64(0), // media_album_id tl_int64(0), // effect_id + tl_bool(false), // has_sensitive_content tl_string(), // restriction_reason tl_messageText( tl_formattedText(tl_string(text), tl_vector()), diff --git a/Telegram/SourceFiles/support/support_autocomplete.cpp b/Telegram/SourceFiles/support/support_autocomplete.cpp index d9c3b8b06e5575..1ad807f5a85f61 100644 --- a/Telegram/SourceFiles/support/support_autocomplete.cpp +++ b/Telegram/SourceFiles/support/support_autocomplete.cpp @@ -320,19 +320,7 @@ AdminLog::OwnedItem GenerateContactItem( tl_bool(true), // is_outgoing tl_bool(false), // is_pinned tl_bool(false), // is_from_offline - tl_bool(false), // can_be_edited - tl_bool(false), // can_be_forwarded - tl_bool(false), // can_be_replied_in_another_chat tl_bool(true), // can_be_saved - tl_bool(true), // can_be_deleted_only_for_self - tl_bool(false), // can_be_deleted_for_all_users - tl_bool(false), // can_get_added_reactions - tl_bool(false), // can_get_statistics - tl_bool(false), // can_get_message_thread - tl_bool(false), // can_get_read_date - tl_bool(false), // can_get_viewers - tl_bool(false), // can_get_media_timestamp_links - tl_bool(false), // can_report_reactions tl_bool(false), // has_timestamped_media tl_bool(false), // is_channel_post tl_bool(false), // is_topic_message @@ -361,6 +349,7 @@ AdminLog::OwnedItem GenerateContactItem( tl_string(), // author_signature tl_int64(0), // media_album_id tl_int64(0), // effect_id + tl_bool(false), // has_sensitive_content tl_string(), // restriction_reason tl_messageContact( tl_contact( diff --git a/Telegram/SourceFiles/window/themes/window_theme.cpp b/Telegram/SourceFiles/window/themes/window_theme.cpp index cbe435556818cf..371a9fa8576696 100644 --- a/Telegram/SourceFiles/window/themes/window_theme.cpp +++ b/Telegram/SourceFiles/window/themes/window_theme.cpp @@ -1703,6 +1703,7 @@ TLthemeParameters WebViewTheme() { colorToInt(st::windowBg), // background_color colorToInt(st::boxDividerBg), // secondary_background_color colorToInt(st::windowBg), // header_background_color + colorToInt(st::windowBg), // bottom_bar_background_color colorToInt(st::lightButtonBg), // section_background_color section_separator_color, colorToInt(st::windowFg), // text_color diff --git a/Telegram/SourceFiles/window/window_main_menu_helpers.cpp b/Telegram/SourceFiles/window/window_main_menu_helpers.cpp index 3ce4e22ec27f8c..d620b8c4ab66b3 100644 --- a/Telegram/SourceFiles/window/window_main_menu_helpers.cpp +++ b/Telegram/SourceFiles/window/window_main_menu_helpers.cpp @@ -100,7 +100,8 @@ not_null AddMyChannelsBox( const auto api = box->lifetime().make_state( &session->mtp()); api->request(TLsearchStickerSet( - tl_string(u"tg_placeholders_android"_q) + tl_string(u"tg_placeholders_android"_q), + tl_bool(false) )).done([=](const TLstickerSet &result) { const auto &v = result.data().vstickers().v; if (v.size() > 1) { diff --git a/Telegram/SourceFiles/window/window_peer_menu.cpp b/Telegram/SourceFiles/window/window_peer_menu.cpp index 6aa4cbff253639..dbc33e7fd05cdc 100644 --- a/Telegram/SourceFiles/window/window_peer_menu.cpp +++ b/Telegram/SourceFiles/window/window_peer_menu.cpp @@ -1964,9 +1964,9 @@ void PeerMenuBlockUserBox( #endif peer->session().sender().request(TLreportChat( peerToTdbChat(peer->id), - tl_vector(), - tl_reportReasonSpam(), - tl_string() + tl_bytes(), // option_id + tl_vector(), // messages_ids + tl_string() // text )).send(); } if (clearChecked) {