From 7cf1bbb07b5ee893c482291f1a2f015bc68c9221 Mon Sep 17 00:00:00 2001 From: John Preston Date: Wed, 23 Oct 2024 15:02:33 +0400 Subject: [PATCH] wip --- Telegram/SourceFiles/api/api_chat_invite.cpp | 59 ++++- .../SourceFiles/api/api_chat_participants.cpp | 3 +- Telegram/SourceFiles/api/api_credits.cpp | 222 ++++++++++++++---- .../SourceFiles/api/api_global_privacy.cpp | 10 + Telegram/SourceFiles/api/api_invite_links.cpp | 10 +- Telegram/SourceFiles/api/api_premium.cpp | 94 ++++++-- Telegram/SourceFiles/api/api_premium.h | 10 + Telegram/SourceFiles/api/api_report.cpp | 106 +++++++-- Telegram/SourceFiles/api/api_sending.cpp | 4 +- .../SourceFiles/api/api_sensitive_content.cpp | 2 +- Telegram/SourceFiles/api/api_statistics.cpp | 53 +++-- Telegram/SourceFiles/api/api_updates.cpp | 6 +- .../boxes/peers/edit_participants_box.cpp | 2 +- .../boxes/peers/edit_peer_info_box.cpp | 3 +- .../boxes/peers/edit_peer_invite_link.cpp | 1 + .../SourceFiles/boxes/send_credits_box.cpp | 14 ++ .../SourceFiles/boxes/sticker_set_box.cpp | 93 +++++++- Telegram/SourceFiles/boxes/stickers_box.cpp | 3 +- .../chat_helpers/stickers_emoji_pack.cpp | 20 +- .../chat_helpers/stickers_emoji_pack.h | 9 +- .../chat_helpers/stickers_gift_box_pack.cpp | 28 ++- .../chat_helpers/stickers_gift_box_pack.h | 10 +- .../chat_helpers/stickers_lottie.cpp | 2 +- .../SourceFiles/core/local_url_handlers.cpp | 48 +++- .../SourceFiles/data/components/credits.cpp | 7 + .../SourceFiles/data/components/credits.h | 7 + .../data/components/sponsored_messages.cpp | 4 +- .../SourceFiles/data/data_media_preload.cpp | 15 +- .../SourceFiles/data/data_media_preload.h | 21 +- .../SourceFiles/data/data_media_types.cpp | 21 +- Telegram/SourceFiles/data/data_media_types.h | 11 +- .../data/data_message_reaction_id.cpp | 2 + .../data/data_message_reactions.cpp | 48 +++- .../SourceFiles/data/data_message_reactions.h | 2 + Telegram/SourceFiles/data/data_peer.cpp | 2 +- Telegram/SourceFiles/data/data_session.cpp | 6 +- Telegram/SourceFiles/data/data_story.cpp | 30 +++ Telegram/SourceFiles/data/data_user.cpp | 8 +- Telegram/SourceFiles/data/data_web_page.cpp | 52 ++-- .../data/stickers/data_stickers.cpp | 5 +- .../admin_log/history_admin_log_inner.cpp | 51 ++-- .../admin_log/history_admin_log_item.cpp | 25 +- Telegram/SourceFiles/history/history_item.cpp | 177 ++++++++++++-- .../history/history_item_helpers.cpp | 7 - .../history/history_item_reply_markup.cpp | 2 + .../view/history_view_contact_status.cpp | 6 +- .../view/history_view_group_call_bar.cpp | 3 +- .../view/media/history_view_premium_gift.cpp | 2 +- .../peer_gifts/info_peer_gifts_common.cpp | 2 + .../peer_gifts/info_peer_gifts_widget.cpp | 21 ++ .../info_statistics_list_controllers.cpp | 2 + .../inline_bots/bot_attach_web_view.cpp | 30 +++ Telegram/SourceFiles/main/main_app_config.cpp | 2 +- Telegram/SourceFiles/main/main_session.cpp | 2 - Telegram/SourceFiles/main/main_session.h | 4 - .../SourceFiles/payments/payments_form.cpp | 11 +- Telegram/SourceFiles/payments/payments_form.h | 4 +- .../settings/settings_credits_graphics.cpp | 60 +++++ .../settings/settings_privacy_controllers.cpp | 13 +- .../support/support_autocomplete.cpp | 13 +- .../window/themes/window_theme.cpp | 1 + .../window/window_main_menu_helpers.cpp | 3 +- .../SourceFiles/window/window_peer_menu.cpp | 6 +- 63 files changed, 1180 insertions(+), 320 deletions(-) diff --git a/Telegram/SourceFiles/api/api_chat_invite.cpp b/Telegram/SourceFiles/api/api_chat_invite.cpp index bbb86c9bc4ae9e..a6c1b41166814d 100644 --- a/Telegram/SourceFiles/api/api_chat_invite.cpp +++ b/Telegram/SourceFiles/api/api_chat_invite.cpp @@ -138,13 +138,25 @@ void ConfirmSubscriptionBox( not_null box, not_null session, const QString &hash, +#if 0 // mtp const MTPDchatInvite *data) { +#endif + const TLDchatInviteLinkInfo *data) { box->setWidth(st::boxWideWidth); +#if 0 // mtp const auto amount = data->vsubscription_pricing()->data().vamount().v; const auto formId = data->vsubscription_form_id()->v; const auto name = qs(data->vtitle()); const auto maybePhoto = session->data().processPhoto(data->vphoto()); const auto photo = maybePhoto->isNull() ? nullptr : maybePhoto.get(); +#endif + const auto &pricing = data->vsubscription_info()->data().vpricing(); + const auto amount = pricing.data().vstar_count().v; + const auto formId = data->vsubscription_info()->data().vform_id().v; + const auto name = qs(data->vtitle()); + const auto photo = data->vphoto() + ? session->data().processSmallPhoto(*data->vphoto()).get() + : nullptr; struct State final { std::shared_ptr photoMedia; @@ -293,22 +305,40 @@ void ConfirmSubscriptionBox( const auto buttonWidth = state->saveButton ? state->saveButton->width() : 0; + state->api->request(TLsendPaymentForm( + tl_inputInvoiceTelegram( + tl_telegramPaymentPurposeJoinChat(tl_string(hash))), + tl_int64(formId), + tl_string(), // order_info_id + tl_string(), // shipping_option_id + null, // credentials + tl_int53(0) // tip_amount + )).done([=](const TLpaymentResult &result) { +#if 0 // mtp state->api->request( MTPpayments_SendStarsForm( MTP_long(formId), MTP_inputInvoiceChatInviteSubscription(MTP_string(hash))) ).done([=](const MTPpayments_PaymentResult &result) { +#endif state->api = std::nullopt; state->loading.force_assign(false); +#if 0 // mtp result.match([&](const MTPDpayments_paymentResult &data) { session->api().applyUpdates(data.vupdates()); }, [](const MTPDpayments_paymentVerificationNeeded &data) { }); +#endif if (weak) { box->closeBox(); } +#if 0 // mtp }).fail([=](const MTP::Error &error) { const auto id = error.type(); +#endif + + }).fail([=](const Error &error) { + const auto id = error.message; if (weak) { state->api = std::nullopt; } @@ -400,11 +430,30 @@ void CheckChatInvite( }, [](const TLDinviteLinkChatTypeChannel&) { return false; }); - const auto box = strong->show(Box( - session, - data, - invitePeekChannel, - [=] { SubmitChatInvite(weak, session, hash, isGroup); })); + const auto hasPricing = data.vsubscription_info().has_value(); + const auto canRefulfill = hasPricing + && data.vsubscription_info()->data().vcan_reuse().v; + const auto formId = hasPricing + ? data.vsubscription_info()->data().vform_id().v + : 0; + if (hasPricing + && !canRefulfill + && !formId) { + strong->uiShow()->showToast( + tr::lng_confirm_phone_link_invalid(tr::now)); + return; + } + const auto box = (hasPricing && !canRefulfill) + ? strong->show(Box( + ConfirmSubscriptionBox, + session, + hash, + &data)) + : strong->show(Box( + session, + data, + invitePeekChannel, + [=] { SubmitChatInvite(weak, session, hash, isGroup); })); if (invitePeekChannel) { box->boxClosing( ) | rpl::filter([=] { diff --git a/Telegram/SourceFiles/api/api_chat_participants.cpp b/Telegram/SourceFiles/api/api_chat_participants.cpp index b159676aff893e..8ddb771aba8877 100644 --- a/Telegram/SourceFiles/api/api_chat_participants.cpp +++ b/Telegram/SourceFiles/api/api_chat_participants.cpp @@ -354,6 +354,7 @@ ChatParticipant::ChatParticipant( _rank = data.vcustom_title().v; }, [&](const TLDchatMemberStatusMember &data) { _type = Type::Member; + _subscriptionDate = data.vmember_until_date().v; }, [&](const TLDchatMemberStatusBanned &data) { _type = Type::Banned; }, [&](const TLDchatMemberStatusRestricted &data) { @@ -1018,7 +1019,7 @@ void ChatParticipants::unblock( const auto requestId = _api.request(TLsetChatMemberStatus( peerToTdbChat(channel->id), peerToSender(participant->id), - tl_chatMemberStatusMember() + tl_chatMemberStatusMember(tl_int32(0)) // member_until_date )).done([=] { _kickRequests.remove(KickRequest(channel, participant)); if (channel->kickedCount() > 0) { diff --git a/Telegram/SourceFiles/api/api_credits.cpp b/Telegram/SourceFiles/api/api_credits.cpp index 971e5f490d33b7..1b529a66c850c3 100644 --- a/Telegram/SourceFiles/api/api_credits.cpp +++ b/Telegram/SourceFiles/api/api_credits.cpp @@ -23,6 +23,7 @@ For license and copyright information please follow this link: #include "tdb/tdb_tl_scheme.h" #include "api/api_text_entities.h" +#include "data/data_credits.h" namespace Api { namespace { @@ -193,6 +194,38 @@ constexpr auto kTransactionsPerPage = 50; .refunded = data.vis_refund().v, .in = (int64(data.vstar_count().v) >= 0), }; + const auto fillPaidMedia = [&](const TLvector &media) { + const auto list = media.v; + if (list.empty()) { + return; + } + using namespace Data; + const auto owner = &peer->owner(); + result.extended.reserve(list.size()); + for (const auto &media : list) { + media.match([&](const TLDpaidMediaPhoto &data) { + const auto photo = owner->processPhoto(data.vphoto()); + if (!photo->isNull()) { + result.extended.push_back(Data::CreditsHistoryMedia{ + .type = Data::CreditsHistoryMediaType::Photo, + .id = photo->id, + }); + } + }, [&](const TLDpaidMediaVideo &data) { + const auto document = owner->processDocument( + data.vvideo()); + if (document->isAnimation() + || document->isVideoFile() + || document->isGifv()) { + result.extended.push_back(Data::CreditsHistoryMedia{ + .type = Data::CreditsHistoryMediaType::Video, + .id = document->id, + }); + } + }, [&](const auto &) {}); + } + }; + using Type = Data::CreditsHistoryEntry::PeerType; data.vpartner().match([&](const TLDstarTransactionPartnerTelegram &) { result.peerType = Type::PremiumBot; @@ -215,56 +248,85 @@ constexpr auto kTransactionsPerPage = 50; }, [&](const TLDstarTransactionPartnerTelegramAds &data) { result.peerType = Type::Ads; }, [&](const TLDstarTransactionPartnerBot &data) { - if (const auto product = data.vproduct_info()) { - const auto &data = product->data(); - result.title = data.vtitle().v; - result.description = Api::FormattedTextFromTdb( - data.vdescription() - ).text; - if (const auto photo = data.vphoto()) { - result.photoId = peer->owner().processPhoto(*photo)->id; + data.vpurpose().match([&]( + const TLDbotTransactionPurposePaidMedia &data) { + fillPaidMedia(data.vmedia()); + }, [&](const TLDbotTransactionPurposeInvoicePayment &data) { + if (const auto product = data.vproduct_info()) { + const auto &data = product->data(); + result.title = data.vtitle().v; + result.description = Api::FormattedTextFromTdb( + data.vdescription()); + if (const auto photo = data.vphoto()) { + result.photoId = peer->owner().processPhoto(*photo)->id; + } } - } - result.barePeerId = peerFromUser(data.vbot_user_id().v).value; + }); + result.barePeerId = peerFromUser(data.vuser_id().v).value; result.peerType = Type::Peer; - }, [&](const TLDstarTransactionPartnerChannel &data) { + }, [&](const TLDstarTransactionPartnerBusiness &data) { + fillPaidMedia(data.vmedia()); + result.barePeerId = peerFromUser(data.vuser_id().v).value; + result.peerType = Type::Peer; + }, [&](const TLDstarTransactionPartnerChat &data) { using namespace Data; result.barePeerId = peerFromTdbChat(data.vchat_id()).value; - result.bareMsgId = data.vpaid_media_message_id().v; + data.vpurpose().match([&]( + const TLDchatTransactionPurposeJoin &data) { + result.subscriptionUntil = base::unixtime::parse( + base::unixtime::now() + data.vperiod().v); + }, [&](const TLDchatTransactionPurposePaidMedia &data) { + result.bareMsgId = data.vmessage_id().v; + fillPaidMedia(data.vmedia()); + }, [&](const TLDchatTransactionPurposeReaction &data) { + result.bareMsgId = data.vmessage_id().v; + result.reaction = true; + }, [&](const TLDchatTransactionPurposeGiveaway &data) { + result.bareGiveawayMsgId = uint64(data.vgiveaway_message_id().v); + }); + result.peerType = Type::Peer; + }, [&](const TLDstarTransactionPartnerUser &data) { + using namespace Data; + result.barePeerId = peerFromUser(data.vuser_id()).value; + data.vpurpose().match([&]( + const TLDuserTransactionPurposeGiftSell &data) { + const auto &gift = data.vgift().data(); + result.convertStars = gift.vdefault_sell_star_count().v; + result.converted = true; + }, [&](const TLDuserTransactionPurposeGiftSend &data) { + const auto &gift = data.vgift().data(); + result.convertStars = gift.vdefault_sell_star_count().v; + }, [&](const TLDuserTransactionPurposeGiftedStars &data) { + result.bareGiftStickerId = data.vsticker() + ? peer->owner().processDocument(*data.vsticker())->id + : 0; + }); + result.gift = true; result.peerType = Type::Peer; - const auto list = data.vmedia().v; - if (!list.empty()) { - const auto owner = &peer->owner(); - result.extended.reserve(list.size()); - for (const auto &media : list) { - media.match([&](const TLDpaidMediaPhoto &data) { - const auto photo = owner->processPhoto(data.vphoto()); - if (!photo->isNull()) { - result.extended.push_back(CreditsHistoryMedia{ - .type = CreditsHistoryMediaType::Photo, - .id = photo->id, - }); - } - }, [&](const TLDpaidMediaVideo &data) { - const auto document = owner->processDocument( - data.vvideo()); - if (document->isAnimation() - || document->isVideoFile() - || document->isGifv()) { - result.extended.push_back(CreditsHistoryMedia{ - .type = CreditsHistoryMediaType::Video, - .id = document->id, - }); - } - }, [&](const auto &) {}); - } - } }, [&](const TLDstarTransactionPartnerUnsupported &) { result.peerType = Type::Unsupported; }); return result; } +[[nodiscard]] Data::SubscriptionEntry SubscriptionFromTL( + const TLstarSubscription &tl) { + const auto &data = tl.data(); + return Data::SubscriptionEntry{ + .id = data.vid().v, + .inviteHash = data.vinvite_link().v, + .until = base::unixtime::parse(data.vexpiration_date().v), + .subscription = Data::PeerSubscription{ + .credits = uint64(data.vpricing().data().vstar_count().v), + .period = data.vpricing().data().vperiod().v, + }, + .barePeerId = peerFromTdbChat(data.vchat_id()).value, + .cancelled = data.vis_canceled().v, + .expired = (base::unixtime::now() > data.vexpiration_date().v), + .canRefulfill = data.vcan_reuse().v, + }; +} + [[nodiscard]] Data::CreditsStatusSlice StatusFromTL( const TLstarTransactions &status, not_null peer) { @@ -281,6 +343,22 @@ constexpr auto kTransactionsPerPage = 50; }; } +[[nodiscard]] Data::CreditsStatusSlice StatusFromTL( + const TLstarSubscriptions &status, + not_null peer) { + const auto &data = status.data(); + return Data::CreditsStatusSlice{ + .subscriptions = ranges::views::all( + data.vsubscriptions().v + ) | ranges::views::transform([&](const TLstarSubscription &tl) { + return SubscriptionFromTL(tl); + }) | ranges::to_vector, + .balance = uint64(data.vstar_count().v), + .allLoaded = data.vnext_offset().v.isEmpty(), + .token = data.vnext_offset().v, + }; +} + } // namespace CreditsTopupOptions::CreditsTopupOptions(not_null peer) @@ -340,14 +418,23 @@ rpl::producer CreditsTopupOptions::request() { }).fail(fail).send(); } #endif - _api.request(TLgetStarPaymentOptions( // todo - )).done([=](const TLDstarPaymentOptions &result) { - _options = OptionsFromTL(result.voptions().v); - consumer.put_done(); - }).fail([=](const Error &error) { - consumer.put_error_copy(error.message); - }).send(); - + const auto send = [&](auto &&request) { + _api.request( + std::move(request) + ).done([=](const TLDstarPaymentOptions &result) { + _options = optionsFromTL(result.voptions().v); + consumer.put_done(); + }).fail([=](const Error &error) { + consumer.put_error_copy(error.message); + }).send(); + }; + if (_peer->isSelf()) { + send(TLgetStarPaymentOptions()); + } else if (const auto user = _peer->asUser()) { + send(TLgetStarGiftPaymentOptions( + tl_int53(peerToUser(user->id).bare) + )); + } return lifetime; }; } @@ -377,12 +464,16 @@ void CreditsStatus::request( using TLResult = TLstarTransactions; _requestId = _api.request(TLgetStarTransactions( peerToSender(_peer->id), + tl_string(), // subscription_id null, tl_string(), tl_int32(kTransactionsPerStatus) )).done([=](const TLResult &result) { _requestId = 0; +#if 0 // mtp const auto balance = result.data().vbalance().v; +#endif + const auto balance = result.data().vstar_count().v; _peer->session().credits().apply(_peer->id, balance); if (const auto onstack = done) { onstack(StatusFromTL(result, _peer)); @@ -426,6 +517,7 @@ void CreditsHistory::request( #endif _requestId = _api.request(TLgetStarTransactions( peerToSender(_peer->id), + tl_string(), // subscription_id ((_in == _out) ? std::optional() : _in @@ -448,11 +540,18 @@ void CreditsHistory::requestSubscriptions( if (_requestId) { return; } +#if 0 // mtp _requestId = _api.request(MTPpayments_GetStarsSubscriptions( MTP_flags(0), _peer->isSelf() ? MTP_inputPeerSelf() : _peer->input, MTP_string(token) )).done([=](const MTPpayments_StarsStatus &result) { +#endif + Assert(_peer->isSelf()); + _requestId = _api.request(TLgetStarSubscriptions( + tl_bool(false), // only_expiring + tl_string(token) + )).done([=](const TLstarSubscriptions &result) { _requestId = 0; done(StatusFromTL(result, _peer)); }).fail([=] { @@ -595,22 +694,35 @@ rpl::producer CreditsGiveawayOptions::request() { return [=](auto consumer) { auto lifetime = rpl::lifetime(); +#if 0 // mtp using TLOption = MTPStarsGiveawayOption; +#endif const auto optionsFromTL = [=](const auto &options) { return ranges::views::all( options ) | ranges::views::transform([=](const auto &option) { + const TLDstarGiveawayPaymentOption &data = option.data(); return Data::CreditsGiveawayOption{ .winners = ranges::views::all( +#if 0 // mtp option.data().vwinners().v +#endif + option.data().vwinner_options().v ) | ranges::views::transform([](const auto &winner) { return Data::CreditsGiveawayOption::Winner{ +#if 0 // mtp .users = winner.data().vusers().v, .perUserStars = winner.data().vper_user_stars().v, .isDefault = winner.data().is_default(), +#endif + .users = winner.data().vwinner_count().v, + .perUserStars = uint64( + winner.data().vwon_star_count().v), + .isDefault = winner.data().vis_default().v, }; }) | ranges::to_vector, +#if 0 // mtp .storeProduct = qs( option.data().vstore_product().value_or_empty()), .currency = qs(option.data().vcurrency()), @@ -619,15 +731,31 @@ rpl::producer CreditsGiveawayOptions::request() { .yearlyBoosts = option.data().vyearly_boosts().v, .isExtended = option.data().is_extended(), .isDefault = option.data().is_default(), +#endif + .storeProduct = data.vstore_product_id().v, + .currency = data.vcurrency().v, + .amount = uint64(data.vamount().v), + .credits = uint64(data.vstar_count().v), + .yearlyBoosts = data.vyearly_boost_count().v, + .isExtended = data.vis_additional().v, + .isDefault = data.vis_default().v, }; }) | ranges::to_vector; }; +#if 0 // mtp const auto fail = [=](const MTP::Error &error) { consumer.put_error_copy(error.type()); }; _api.request(MTPpayments_GetStarsGiveawayOptions( )).done([=](const MTPVector &result) { +#endif + const auto fail = [=](const Error &error) { + consumer.put_error_copy(error.message); + }; + _api.request(TLgetStarGiveawayPaymentOptions( + )).done([=](const TLstarGiveawayPaymentOptions &got) { + const auto &result = got.data().voptions(); _options = optionsFromTL(result.v); consumer.put_done(); }).fail(fail).send(); diff --git a/Telegram/SourceFiles/api/api_global_privacy.cpp b/Telegram/SourceFiles/api/api_global_privacy.cpp index bf2b0baf36b87a..1f00931bf4ab26 100644 --- a/Telegram/SourceFiles/api/api_global_privacy.cpp +++ b/Telegram/SourceFiles/api/api_global_privacy.cpp @@ -30,6 +30,14 @@ bool GlobalPrivacy::apply(const Tdb::TLDupdateOption &option) { return false; }); return true; + } else if (option.vname().v == u"is_paid_reaction_anonymous"_q) { + _paidReactionAnonymous = option.vvalue().match([]( + const Tdb::TLDoptionValueBoolean &data) { + return data.vvalue().v; + }, [](const auto &) { + return false; + }); + return true; } return false; } @@ -179,10 +187,12 @@ void GlobalPrivacy::loadPaidReactionAnonymous() { return; } _paidReactionAnonymousLoaded = true; +#if 0 // mtp _api.request(MTPmessages_GetPaidReactionPrivacy( )).done([=](const MTPUpdates &result) { _session->api().applyUpdates(result); }).send(); +#endif } void GlobalPrivacy::updatePaidReactionAnonymous(bool value) { diff --git a/Telegram/SourceFiles/api/api_invite_links.cpp b/Telegram/SourceFiles/api/api_invite_links.cpp index 43b84e2aa84109..53064c7d5e8fd8 100644 --- a/Telegram/SourceFiles/api/api_invite_links.cpp +++ b/Telegram/SourceFiles/api/api_invite_links.cpp @@ -151,12 +151,12 @@ void InviteLinks::performCreate( )).done([=, peer = args.peer](const MTPExportedChatInvite &result) { #endif _api->sender().request(TLcreateChatInviteLink( - peerToTdbChat(peer->id), - tl_string(label), - tl_int32(expireDate), - tl_int32(usageLimit), + peerToTdbChat(args.peer->id), + tl_string(args.label), + tl_int32(args.expireDate), + tl_int32(args.usageLimit), tl_bool(requestApproval) - )).done([=](const TLchatInviteLink &result) { + )).done([=, peer = args.peer](const TLchatInviteLink &result) { const auto callbacks = _createCallbacks.take(peer); const auto link = prepend(peer, peer->session().user(), result); if (link && callbacks) { diff --git a/Telegram/SourceFiles/api/api_premium.cpp b/Telegram/SourceFiles/api/api_premium.cpp index c6540740d5cace..385b2597b4dda5 100644 --- a/Telegram/SourceFiles/api/api_premium.cpp +++ b/Telegram/SourceFiles/api/api_premium.cpp @@ -76,14 +76,14 @@ using namespace Tdb; tlOption.vamount().v / float64(tlOption.vusers().v), qs(tlOption.vcurrency()), #endif - tlOption.vamount().v / float64(tlOption.vuser_count().v), + tlOption.vamount().v / float64(tlOption.vwinner_count().v), tlOption.vcurrency().v.toUtf8(), false); options[i].costPerMonth = perUserText + ' ' + QChar(0x00D7) + ' ' - + QString::number(tlOption.vuser_count().v); + + QString::number(tlOption.vwinner_count().v); #if 0 // mtp + QString::number(tlOption.vusers().v); #endif @@ -290,7 +290,7 @@ void Premium::reloadPromo() { return option.data().vpayment_option(); }) | ranges::to(); - _subscriptionOptions = SubscriptionOptionsFromTL(list); + _subscriptionOptions = PremiumSubscriptionOptionsFromTL(list); for (const auto &option : list) { if (option.data().vmonth_count().v == 1) { _monthlyAmount = option.data().vamount().v; @@ -612,25 +612,25 @@ void Premium::resolveGiveawayInfo( info.credits = data.vstars_prize().value_or_empty(); }); #endif - _giveawayInfoRequestId = _api.request(TLgetPremiumGiveawayInfo( + _giveawayInfoRequestId = _api.request(TLgetGiveawayInfo( peerToTdbChat(_giveawayInfoPeer->id), tl_int53(_giveawayInfoMessageId.bare) - )).done([=](const TLpremiumGiveawayInfo &result) { + )).done([=](const TLgiveawayInfo &result) { _giveawayInfoRequestId = 0; auto info = GiveawayInfo(); - result.match([&](const TLDpremiumGiveawayInfoOngoing &data) { + result.match([&](const TLDgiveawayInfoOngoing &data) { using AlreadyWasMember - = TLDpremiumGiveawayParticipantStatusAlreadyWasMember; + = TLDgiveawayParticipantStatusAlreadyWasMember; using Participating - = TLDpremiumGiveawayParticipantStatusParticipating; + = TLDgiveawayParticipantStatusParticipating; using Administrator - = TLDpremiumGiveawayParticipantStatusAdministrator; + = TLDgiveawayParticipantStatusAdministrator; using DisallowedCountry - = TLDpremiumGiveawayParticipantStatusDisallowedCountry; + = TLDgiveawayParticipantStatusDisallowedCountry; data.vstatus().match([&]( - const TLDpremiumGiveawayParticipantStatusEligible &) { + const TLDgiveawayParticipantStatusEligible &) { }, [&](const Participating &) { info.participating = true; }, [&](const AlreadyWasMember &data) { @@ -645,7 +645,7 @@ void Premium::resolveGiveawayInfo( ? GiveawayState::Preparing : GiveawayState::Running; info.startDate = data.vcreation_date().v; - }, [&](const TLDpremiumGiveawayInfoCompleted &data) { + }, [&](const TLDgiveawayInfoCompleted &data) { info.state = data.vwas_refunded().v ? GiveawayState::Refunded : GiveawayState::Finished; @@ -834,7 +834,7 @@ rpl::producer PremiumGiftCodeOptions::request() { auto tlMapOptions = base::flat_map>(); for (const auto &tlOption : data.voptions().v) { const auto &data = tlOption.data(); - const auto userCount = data.vuser_count().v; + const auto userCount = data.vwinner_count().v; tlMapOptions[userCount].push_back(tlOption); const auto token = Token{ userCount, data.vmonth_count().v }; @@ -893,9 +893,11 @@ rpl::producer PremiumGiftCodeOptions::applyPrepaid( consumer.put_error_copy(error.type()); }).send(); #endif - _api.request(Tdb::TLlaunchPrepaidPremiumGiveaway( + _api.request(Tdb::TLlaunchPrepaidGiveaway( Tdb::tl_int64(prepaidId), - Payments::InvoiceGiftCodeGiveawayToTL(invoice) + Payments::InvoiceGiftCodeGiveawayToTL(invoice), + tl_int32(invoice.users), + tl_int53(invoice.creditsAmount.value_or(0)) )).done([=](const Tdb::TLok &) { consumer.put_done(); }).fail([=](const Tdb::Error &error) { @@ -990,6 +992,7 @@ auto PremiumGiftCodeOptions::requestStarGifts() return [=](auto consumer) { auto lifetime = rpl::lifetime(); +#if 0 // mtp _api.request(MTPpayments_GetStarGifts( MTP_int(0) )).done([=](const MTPpayments_StarGifts &result) { @@ -1011,6 +1014,24 @@ auto PremiumGiftCodeOptions::requestStarGifts() }).fail([=](const MTP::Error &error) { consumer.put_error_copy(error.type()); }).send(); +#endif + _api.request(TLgetAvailableGifts( + )).done([=](const TLgifts &result) { + const auto &data = result.data(); + const auto &list = data.vgifts().v; + const auto session = &_peer->session(); + auto gifts = std::vector(); + gifts.reserve(list.size()); + for (const auto &gift : list) { + if (auto parsed = FromTL(session, gift)) { + gifts.push_back(std::move(*parsed)); + } + } + _gifts = std::move(gifts); + consumer.put_done(); + }).fail([=](const Error &error) { + consumer.put_error_copy(error.message); + }).send(); return lifetime; }; @@ -1173,6 +1194,7 @@ rpl::producer RandomHelloStickerValue( }) | rpl::take(1) | rpl::map(random)); } +#if 0 // mtp std::optional FromTL( not_null session, const MTPstarGift &gift) { @@ -1224,5 +1246,47 @@ std::optional FromTL( .mine = to->isSelf(), }; } +#endif + +std::optional FromTL( + not_null session, + const TLgift &gift) { + const auto &data = gift.data(); + const auto document = session->data().processDocument( + data.vsticker()); + if (!document->sticker()) { + return {}; + } + return StarGift{ + .id = uint64(data.vid().v), + .stars = int64(data.vstar_count().v), + .convertStars = int64(data.vdefault_sell_star_count().v), + .document = document, + .limitedLeft = data.vremaining_count().v, + .limitedCount = data.vtotal_count().v, + }; +} + +std::optional FromTL( + not_null to, + const TLuserGift &gift) { + const auto session = &to->session(); + const auto &data = gift.data(); + auto parsed = FromTL(session, data.vgift()); + if (!parsed) { + return {}; + } + return UserStarGift{ + .gift = std::move(*parsed), + .message = Api::FormattedTextFromTdb(data.vtext()), + .convertStars = data.vsell_star_count().v, + .fromId = peerFromUser(data.vsender_user_id()), + .messageId = data.vmessage_id().v, + .date = data.vdate().v, + .anonymous = data.vis_private().v, + .hidden = !data.vis_saved().v, + .mine = to->isSelf(), + }; +} } // namespace Api diff --git a/Telegram/SourceFiles/api/api_premium.h b/Telegram/SourceFiles/api/api_premium.h index b4d3f6acf8f7fb..c0113ebd010452 100644 --- a/Telegram/SourceFiles/api/api_premium.h +++ b/Telegram/SourceFiles/api/api_premium.h @@ -12,6 +12,8 @@ For license and copyright information please follow this link: namespace Tdb { class TLpremiumFeature; +class TLgift; +class TLuserGift; } // namespace Tdb enum class PremiumFeature; @@ -293,11 +295,19 @@ enum class RequirePremiumState { [[nodiscard]] rpl::producer RandomHelloStickerValue( not_null session); +#if 0 // mtp [[nodiscard]] std::optional FromTL( not_null session, const MTPstarGift &gift); [[nodiscard]] std::optional FromTL( not_null to, const MTPuserStarGift &gift); +#endif +[[nodiscard]] std::optional FromTL( + not_null session, + const Tdb::TLgift &gift); +[[nodiscard]] std::optional FromTL( + not_null to, + const Tdb::TLuserGift &gift); } // namespace Api diff --git a/Telegram/SourceFiles/api/api_report.cpp b/Telegram/SourceFiles/api/api_report.cpp index d9e69205ca3e17..47ba1e086c470c 100644 --- a/Telegram/SourceFiles/api/api_report.cpp +++ b/Telegram/SourceFiles/api/api_report.cpp @@ -18,6 +18,7 @@ For license and copyright information please follow this link: #include "ui/layers/show.h" #include "tdb/tdb_tl_scheme.h" +#include "tdb/tdb_sender.h" namespace Api { @@ -71,24 +72,7 @@ void SendReport( show->showToast(tr::lng_report_thanks(tr::now)); }; v::match(data, [&](v::null_t) { - peer->session().sender().request(TLreportChat( - peerToTdbChat(peer->id), - tl_vector(), - ReasonToTL(reason), - tl_string(comment) - )).done(std::move(done)).send(); - }, [&](const MessageIdsList &ids) { - auto list = QVector(); - list.reserve(ids.size()); - for (const auto &fullId : ids) { - list.push_back(tl_int53(fullId.msg.bare)); - } - peer->session().sender().request(TLreportChat( - peerToTdbChat(peer->id), - tl_vector(list), - ReasonToTL(reason), - tl_string(comment) - )).done(std::move(done)).send(); + Unexpected("This won't be here."); }, [&](not_null photo) { const auto tdb = std::get_if( &photo->location(Data::PhotoSize::Large).file().data); @@ -100,13 +84,6 @@ void SendReport( tl_string(comment) )).done(std::move(done)).send(); } - }, [&](StoryId id) { - peer->session().sender().request(TLreportStory( - peerToTdbChat(peer->id), - tl_int32(id), - ReasonToTL(reason), - tl_string(comment) - )).done(std::move(done)).send(); }); #if 0 // mtp v::match(data, [&](v::null_t) { @@ -148,6 +125,7 @@ auto CreateReportMessagesOrStoriesCallback( return [=]( Data::ReportInput reportInput, Fn done) { +#if 0 // mtp auto apiIds = QVector(); apiIds.reserve(reportInput.ids.size() + reportInput.stories.size()); for (const auto &id : reportInput.ids) { @@ -191,7 +169,6 @@ auto CreateReportMessagesOrStoriesCallback( state->requestId = 0; done({ .error = error.type() }); }; - if (!reportInput.stories.empty()) { state->requestId = peer->session().api().request( MTPstories_Report( @@ -209,6 +186,83 @@ auto CreateReportMessagesOrStoriesCallback( MTP_string(reportInput.comment)) ).done(received).fail(fail).send(); } +#endif + const auto fail = [=](const Error &error) { + state->requestId = 0; + done({ .error = error.message }); + }; + const auto optionRequired = [=](const auto &data) { + const auto t = data.vtitle().v; + auto list = Result::Options(); + list.reserve(data.voptions().v.size()); + for (const auto &tl : data.voptions().v) { + list.emplace_back(Result::Option{ + .id = tl.data().vid().v, + .text = tl.data().vtext().v, + }); + } + return Result{ .options = std::move(list), .title = t }; + }; + const auto textRequired = [=](const auto &data) { + return Result{ + .commentOption = ReportResult::CommentOption{ + .optional = data.vis_optional().v, + .id = data.voption_id().v, + }, + }; + }; + if (!reportInput.stories.empty()) { + Assert(reportInput.stories.size() == 1); + state->requestId = peer->session().sender().request( + TLreportStory( + peerToTdbChat(peer->id), + tl_int32(reportInput.stories.front()), + tl_bytes(reportInput.optionId), + tl_string(reportInput.comment)) + ).done([=]( + const TLreportStoryResult &result, + mtpRequestId requestId) { + if (state->requestId != requestId) { + return; + } + state->requestId = 0; + done(result.match([](const TLDreportStoryResultOk &) { + return Result{ .successful = true }; + }, [&](const TLDreportStoryResultOptionRequired &data) { + return optionRequired(data); + }, [&](const TLDreportStoryResultTextRequired &data) { + return textRequired(data); + })); + }).fail(fail).send(); + } else { + state->requestId = peer->session().sender().request( + TLreportChat( + peerToTdbChat(peer->id), + tl_bytes(reportInput.optionId), + tl_vector(ranges::views::all( + reportInput.ids + ) | ranges::views::transform([](MsgId id) { + return tl_int53(id.bare); + }) | ranges::to>()), + tl_string(reportInput.comment)) + ).done([=]( + const TLreportChatResult &result, + mtpRequestId requestId) { + if (state->requestId != requestId) { + return; + } + state->requestId = 0; + done(result.match([](const TLDreportChatResultOk &) { + return Result{ .successful = true }; + }, [&](const TLDreportChatResultOptionRequired &data) { + return optionRequired(data); + }, [&](const TLDreportChatResultTextRequired &data) { + return textRequired(data); + }, [&](const TLDreportChatResultMessagesRequired &) { + return Result{ .error = u"MESSAGE_ID_REQUIRED"_q }; + })); + }).fail(fail).send(); + } }; } diff --git a/Telegram/SourceFiles/api/api_sending.cpp b/Telegram/SourceFiles/api/api_sending.cpp index d84cdb93528a3f..c3f90a25bce872 100644 --- a/Telegram/SourceFiles/api/api_sending.cpp +++ b/Telegram/SourceFiles/api/api_sending.cpp @@ -567,7 +567,7 @@ void GenerateLocalMediaMessage( .flags = flags, .from = messageFromId, .replyTo = action.replyTo, - .date = HistoryItem::NewMessageDate(action.options.scheduled), + .date = NewMessageDate(action.options.scheduled), .viaBotId = viaBotId, .postAuthor = messagePostAuthor, }, media, caption); @@ -1188,7 +1188,7 @@ void TryGenerateLocalInlineResultMessage( .flags = flags, .from = messageFromId, .replyTo = action.replyTo, - .date = HistoryItem::NewMessageDate(action.options.scheduled), + .date = NewMessageDate(action.options.scheduled), .viaBotId = ((bot && !action.options.hideViaBot) ? peerToUser(bot->id) : 0), diff --git a/Telegram/SourceFiles/api/api_sensitive_content.cpp b/Telegram/SourceFiles/api/api_sensitive_content.cpp index 794271cee9fbfe..bd62a3d697b495 100644 --- a/Telegram/SourceFiles/api/api_sensitive_content.cpp +++ b/Telegram/SourceFiles/api/api_sensitive_content.cpp @@ -67,7 +67,7 @@ void SensitiveContent::reload(bool force) { } #endif -void SensitiveContent::reload() { +void SensitiveContent::reload(bool force) { using namespace Tdb; const auto getOption = [&]( diff --git a/Telegram/SourceFiles/api/api_statistics.cpp b/Telegram/SourceFiles/api/api_statistics.cpp index 4835515c871ced..372857491b2846 100644 --- a/Telegram/SourceFiles/api/api_statistics.cpp +++ b/Telegram/SourceFiles/api/api_statistics.cpp @@ -954,13 +954,23 @@ rpl::producer Boosts::request() { _boostStatus.prepaidGiveaway = ranges::views::all( data.vprepaid_giveaways().v ) | ranges::views::transform([]( - const TLprepaidPremiumGiveaway &r) { + const TLprepaidGiveaway &r) { + auto months = 0; + auto stars = uint64(); + r.data().vprize().match([&]( + const TLDgiveawayPrizePremium &data) { + months = data.vmonth_count().v; + }, [&](const TLDgiveawayPrizeStars &data) { + stars = data.vstar_count().v; + }); return Data::BoostPrepaidGiveaway{ - .months = r.data().vmonth_count().v, - .id = uint64(r.data().vid().v), - .quantity = r.data().vwinner_count().v, .date = QDateTime::fromSecsSinceEpoch( r.data().vpayment_date().v), + .id = uint64(r.data().vid().v), + .credits = stars, + .months = months, + .quantity = r.data().vwinner_count().v, + .boosts = r.data().vboost_count().v, }; }) | ranges::to_vector; @@ -1002,7 +1012,6 @@ void Boosts::requestBoosts( constexpr auto kMonthsDivider = int(30 * 86400); for (const auto &boost : data.vboosts().v) { const auto &data = boost.data(); - const auto userId = data.vsource().match([&](const auto &d) { return UserId(d.vuser_id().v); }); @@ -1032,19 +1041,29 @@ void Boosts::requestBoosts( }, [](const auto &) { return FullMsgId(); }); + + const auto stars = data.vsource().match([&]( + const TLDchatBoostSourceGiveaway &d) { + return d.vstar_count().v; + }, [&](const auto &) { + return int64(); + }); + list.push_back({ - !giftCodeLink.slug.isEmpty(), - (!!giveawayMessage), - isUnclaimed, - data.vid().v.toUtf8(), - userId, - giveawayMessage, - QDateTime::fromSecsSinceEpoch(data.vstart_date().v), - QDateTime::fromSecsSinceEpoch(data.vexpiration_date().v), - (data.vexpiration_date().v - data.vstart_date().v) - / kMonthsDivider, - std::move(giftCodeLink), - (data.vcount().v == 1 ? 0 : data.vcount().v), + .id = data.vid().v.toUtf8(), + .userId = userId, + .giveawayMessage = giveawayMessage, + .date = QDateTime::fromSecsSinceEpoch(data.vstart_date().v), + .expiresAt = QDateTime::fromSecsSinceEpoch(data.vexpiration_date().v), + .expiresAfterMonths = ((data.vexpiration_date().v - data.vstart_date().v) + / kMonthsDivider), + .giftCodeLink = std::move(giftCodeLink), + .multiplier = (data.vcount().v == 1 ? 0 : data.vcount().v), + .credits = uint64(stars), + + .isGift = !giftCodeLink.slug.isEmpty(), + .isGiveaway = (!!giveawayMessage), + .isUnclaimed = isUnclaimed, }); } done(Data::BoostsListSlice{ diff --git a/Telegram/SourceFiles/api/api_updates.cpp b/Telegram/SourceFiles/api/api_updates.cpp index 1499e455cdfeab..00686b87092f9f 100644 --- a/Telegram/SourceFiles/api/api_updates.cpp +++ b/Telegram/SourceFiles/api/api_updates.cpp @@ -2892,6 +2892,10 @@ void Updates::applyUpdate(const TLupdate &update) { }, [&](const TLDupdateMessageFactCheck &data) { _session->factchecks().apply(data); }, [&](const TLDupdateMessageLiveLocationViewed &data) { + }, [&](const TLDupdateActiveLiveLocationMessages &data) { + for (const auto &message : data.vmessages().v) { + owner.processMessage(message, NewMessageType::Existing); + } }, [&](const TLDupdateNewChat &data) { owner.processPeer(data.vchat()); }, [&](const TLDupdateChatTitle &data) { @@ -3298,7 +3302,7 @@ void Updates::applyUpdate(const TLupdate &update) { } } }, [&](const TLDupdateOwnedStarCount &data) { - session().setCredits(data.vstar_count().v); + session().credits().apply(data); }, [&](const TLDupdateSpeechRecognitionTrial &data) { session().api().transcribes().apply(data); }, [&](const TLDupdateSpeedLimitNotification &data) { diff --git a/Telegram/SourceFiles/boxes/peers/edit_participants_box.cpp b/Telegram/SourceFiles/boxes/peers/edit_participants_box.cpp index e63613ea2bf538..b172105436af2d 100644 --- a/Telegram/SourceFiles/boxes/peers/edit_participants_box.cpp +++ b/Telegram/SourceFiles/boxes/peers/edit_participants_box.cpp @@ -63,7 +63,7 @@ void RemoveAdmin( peer->session().sender().request(TLsetChatMemberStatus( peerToTdbChat(peer->id), peerToSender(user->id), - tl_chatMemberStatusMember() + tl_chatMemberStatusMember(tl_int32(0)) // member_until_date )).done([=] { if (const auto channel = peer->asChannel()) { channel->applyEditAdmin(user, oldRights, {}, {}); diff --git a/Telegram/SourceFiles/boxes/peers/edit_peer_info_box.cpp b/Telegram/SourceFiles/boxes/peers/edit_peer_info_box.cpp index 5dc93c7c24a09e..bcf680ad6d46dd 100644 --- a/Telegram/SourceFiles/boxes/peers/edit_peer_info_box.cpp +++ b/Telegram/SourceFiles/boxes/peers/edit_peer_info_box.cpp @@ -2461,7 +2461,8 @@ void Controller::saveSignatures() { #endif _api.request(TLtoggleSupergroupSignMessages( tl_int53(peerToChannel(channel->id).bare), - tl_bool(*_savingData.signatures) + tl_bool(*_savingData.signatures), + tl_bool(*_savingData.signatureProfiles) )).done([=] { // CHAT_NOT_MODIFIED is processed as TLok. continueSave(); diff --git a/Telegram/SourceFiles/boxes/peers/edit_peer_invite_link.cpp b/Telegram/SourceFiles/boxes/peers/edit_peer_invite_link.cpp index d6e00c63161a8e..4ca7c261a79733 100644 --- a/Telegram/SourceFiles/boxes/peers/edit_peer_invite_link.cpp +++ b/Telegram/SourceFiles/boxes/peers/edit_peer_invite_link.cpp @@ -946,6 +946,7 @@ void Controller::loadMoreRows() { _requestId = _api.request(TLgetChatInviteLinkMembers( peerToTdbChat(_peer->id), tl_string(_link), + tl_bool(false), // only_with_expired_subscription tl_chatInviteLinkMember( // Offset. tl_int53(_lastUser ? peerToUser(_lastUser->user->id).bare diff --git a/Telegram/SourceFiles/boxes/send_credits_box.cpp b/Telegram/SourceFiles/boxes/send_credits_box.cpp index fafdd1b6bcd09d..b5eba9ae56ca11 100644 --- a/Telegram/SourceFiles/boxes/send_credits_box.cpp +++ b/Telegram/SourceFiles/boxes/send_credits_box.cpp @@ -43,6 +43,7 @@ For license and copyright information please follow this link: #include "tdb/tdb_tl_scheme.h" #include "tdb/tdb_sender.h" +#include "api/api_text_entities.h" namespace Ui { namespace { @@ -470,6 +471,7 @@ void SendStarGift( not_null session, std::shared_ptr data, Fn)> done) { +#if 0 // mtp session->api().request(MTPpayments_SendStarsForm( MTP_long(data->formId), data->inputInvoice @@ -482,6 +484,18 @@ void SendStarGift( }).fail([=](const MTP::Error &error) { done(error.type()); }).send(); +#endif + const auto &gift = v::get(data->id.value); + session->sender().request(TLsendGift( + tl_int64(gift.giftId), + tl_int53(peerToUser(gift.user->id).bare), + Api::FormattedTextToTdb(gift.message), + tl_bool(gift.anonymous) + )).done([=] { + done(std::nullopt); + }).fail([=](const Error &error) { + done(error.message); + }).send(); } } // namespace Ui diff --git a/Telegram/SourceFiles/boxes/sticker_set_box.cpp b/Telegram/SourceFiles/boxes/sticker_set_box.cpp index 73d5e09a82f05d..9837435f5efb1c 100644 --- a/Telegram/SourceFiles/boxes/sticker_set_box.cpp +++ b/Telegram/SourceFiles/boxes/sticker_set_box.cpp @@ -84,7 +84,10 @@ constexpr auto kStickerMoveDuration = crl::time(200); using Data::StickersSet; using Data::StickersPack; using SetFlag = Data::StickersSetFlag; +#if 0 // mtp using TLStickerSet = MTPmessages_StickerSet; +#endif +using TLStickerSet = TLstickerSet; [[nodiscard]] std::optional ComputeImageColor( const style::icon &lockIcon, @@ -389,7 +392,6 @@ class StickerSetBox::Inner final : public Ui::RpWidget { #if 0 // mtp void installDone(const MTPmessages_StickerSetInstallResult &result); #endif - void gotSet(const TLstickerSet &set); void installDone(); void requestReorder(not_null document, int index); @@ -684,6 +686,7 @@ void ChangeSetNameBox( const auto buttonWidth = state->saveButton ? state->saveButton->width() : 0; +#if 0 // mtp state->requestId = data->session().api().request( MTPstickers_RenameStickerSet( Data::InputStickerSet(input), @@ -700,6 +703,31 @@ void ChangeSetNameBox( show->showToast(error.type()); close(); }).send(); +#endif + const auto &sets = data->stickers().sets(); + const auto it = sets.find(input.id); + if (it == sets.end()) { + show->showToast(u"Set not found!"_q); + return; + } + state->requestId = data->session().sender().request( + TLsetStickerSetTitle( + tl_string(it->second->shortName), + tl_string(text)) + ).done([=] { + state->requestId = data->session().sender().request( + TLgetStickerSet(tl_int64(input.id)) + ).done([=](const TLstickerSet &result) { + done(result); + close(); + }).fail([=](const Error &error) { + show->showToast(error.message); + close(); + }).send(); + }).fail([=](const Error &error) { + show->showToast(error.message); + close(); + }).send(); if (state->saveButton) { state->saveButton->resizeToWidth(buttonWidth); } @@ -722,7 +750,11 @@ void ChangeSetNameBox( state->requestId.value() | rpl::map(rpl::mappers::_1 > 0)); } box->addButton(tr::lng_cancel(), [=] { +#if 0 // mtp data->session().api().request(state->requestId.current()).cancel(); +#endif + data->session().sender().request( + state->requestId.current()).cancel(); close(); }); } @@ -927,16 +959,17 @@ StickerSetBox::Inner::Inner( _api.request(TLgetStickerSet( tl_int64(_input.id) )).done([=](const TLstickerSet &result) { - gotSet(result); + applySet(result); }).fail([=] { _loaded = true; _errors.fire(Error::NotFound); }).send(); } else { _api.request(TLsearchStickerSet( - tl_string(_input.shortName) + tl_string(_input.shortName), + tl_bool(true) )).done([=](const TLstickerSet &result) { - gotSet(result); + applySet(result); }).fail([=] { _loaded = true; _errors.fire(Error::NotFound); @@ -1091,8 +1124,8 @@ void StickerSetBox::Inner::applySet(const TLStickerSet &set) { set->emoji = _emoji; set->setThumbnail(_setThumbnail, _setThumbnailType); } - }; #if 0 // mtp + }; }, [&](const MTPDmessages_stickerSetNotModified &data) { LOG(("API Error: Unexpected messages.stickerSetNotModified.")); #endif @@ -1362,6 +1395,11 @@ void StickerSetBox::Inner::requestReorder( _apiReorder.emplace(&_session->mtp()); } _reorderRequests.emplace_back([document, index, this] { + _apiReorder->request(TLsetStickerPositionInSet( + tl_inputFileId(tl_int32(document->tdbFileId())), + tl_int32(index) + )).done([this, document] { +#if 0 // mtp _apiReorder->request( MTPstickers_ChangeStickerPosition( document->mtpInput(), @@ -1373,16 +1411,30 @@ void StickerSetBox::Inner::requestReorder( Data::StickersType::Stickers); }, [](const auto &) { }); +#endif if (!_reorderRequests.empty()) { _reorderRequests.pop_front(); } if (_reorderRequests.empty()) { + _apiReorder->request(TLgetStickerSet( + tl_int64(_setId) + )).done([this, document](const TLstickerSet &result) { + document->owner().stickers().feedSetFull(result); + document->owner().stickers().notifyUpdated( + Data::StickersType::Stickers); + }).fail([show = _show](const Tdb::Error &error) { + show->showToast(error.message); + }).send(); // applySet(result); // Causes stickers blink. } else { _reorderRequests.front()(); } +#if 0 // mtp }).fail([show = _show](const MTP::Error &error) { show->showToast(error.type()); +#endif + }).fail([show = _show](const Tdb::Error &error) { + show->showToast(error.message); }).send(); }); if (_reorderRequests.size() == 1) { @@ -1644,6 +1696,7 @@ void StickerSetBox::Inner::fillDeleteStickerBox( const auto buttonWidth = state->saveButton ? state->saveButton->width() : 0; +#if 0 // mtp state->requestId = document->owner().session().api().request( MTPstickers_RemoveStickerFromSet(document->mtpInput() )).done([=](const TLStickerSet &result) { @@ -1664,6 +1717,33 @@ void StickerSetBox::Inner::fillDeleteStickerBox( strongBox->uiShow()->showToast(error.type()); } }).send(); +#endif + state->requestId = document->owner().session().sender().request( + TLremoveStickerFromSet( + tl_inputFileId(tl_int32(document->tdbFileId()))) + ).done([=] { + document->owner().session().sender().request(TLgetStickerSet( + tl_int64(_setId) + )).done([=](const TLstickerSet &result) { + document->owner().stickers().feedSetFull(result); + document->owner().stickers().notifyUpdated( + Data::StickersType::Stickers); + if (const auto strong = weak.data()) { + applySet(result); + } + if (const auto strongBox = weakBox.data()) { + strongBox->closeBox(); + } + }).fail([=](const Tdb::Error &error) { + if (const auto strongBox = weakBox.data()) { + strongBox->uiShow()->showToast(error.message); + } + }).send(); + }).fail([=](const Tdb::Error &error) { + if (const auto strongBox = weakBox.data()) { + strongBox->uiShow()->showToast(error.message); + } + }).send(); if (state->saveButton) { state->saveButton->resizeToWidth(buttonWidth); } @@ -1686,7 +1766,10 @@ void StickerSetBox::Inner::fillDeleteStickerBox( state->requestId.value() | rpl::map(rpl::mappers::_1 > 0)); } box->addButton(tr::lng_close(), [=] { +#if 0 // mtp document->owner().session().api().request( +#endif + document->owner().session().sender().request( state->requestId.current()).cancel(); box->closeBox(); }); diff --git a/Telegram/SourceFiles/boxes/stickers_box.cpp b/Telegram/SourceFiles/boxes/stickers_box.cpp index c352eab49b54ad..bd1f3f632b7493 100644 --- a/Telegram/SourceFiles/boxes/stickers_box.cpp +++ b/Telegram/SourceFiles/boxes/stickers_box.cpp @@ -2282,7 +2282,8 @@ void StickersBox::Inner::handleMegagroupSetAddressChange() { } } else if (!_megagroupSetRequestId) { _megagroupSetRequestId = _api.request(TLsearchStickerSet( - tl_string(text) + tl_string(text), + tl_bool(true) )).done([=](const TLstickerSet &result) { _megagroupSetRequestId = 0; const auto set = session().data().stickers().feedSetFull(result); diff --git a/Telegram/SourceFiles/chat_helpers/stickers_emoji_pack.cpp b/Telegram/SourceFiles/chat_helpers/stickers_emoji_pack.cpp index 8fdbb947746bef..34f3f4e83f7feb 100644 --- a/Telegram/SourceFiles/chat_helpers/stickers_emoji_pack.cpp +++ b/Telegram/SourceFiles/chat_helpers/stickers_emoji_pack.cpp @@ -156,7 +156,6 @@ void EmojiPack::remove(not_null view) { } } -#if 0 // mtp auto EmojiPack::stickerForEmoji(EmojiPtr emoji) -> Sticker { Expects(emoji != nullptr); @@ -165,6 +164,7 @@ auto EmojiPack::stickerForEmoji(EmojiPtr emoji) -> Sticker { return { i->second.get(), nullptr }; } if (!emoji->colored()) { + request(emoji); return {}; } const auto j = _map.find(emoji->original()); @@ -172,9 +172,27 @@ auto EmojiPack::stickerForEmoji(EmojiPtr emoji) -> Sticker { const auto index = emoji->variantIndex(emoji); return { j->second.get(), ColorReplacements(index) }; } + request(emoji->original()); return {}; } +void EmojiPack::request(EmojiPtr emoji) { + if (!_requested.emplace(emoji).second) { + return; + } + _session->sender().request(TLgetAnimatedEmoji( + tl_string(emoji->id()) + )).done([=](const TLanimatedEmoji &result) { + const auto &data = result.data(); + if (const auto &sticker = data.vsticker()) { + const auto document = _session->data().processDocument(*sticker); + _map.emplace(emoji, document); + _refreshed.fire({}); + } + }).send(); +} + +#if 0 // mtp auto EmojiPack::stickerForEmoji(const IsolatedEmoji &emoji) -> Sticker { Expects(!emoji.empty()); diff --git a/Telegram/SourceFiles/chat_helpers/stickers_emoji_pack.h b/Telegram/SourceFiles/chat_helpers/stickers_emoji_pack.h index ed92162ddff69f..45ae9e219eafa1 100644 --- a/Telegram/SourceFiles/chat_helpers/stickers_emoji_pack.h +++ b/Telegram/SourceFiles/chat_helpers/stickers_emoji_pack.h @@ -82,8 +82,8 @@ class EmojiPack final { bool add(not_null view); void remove(not_null view); -#if 0 // mtp [[nodiscard]] Sticker stickerForEmoji(EmojiPtr emoji); +#if 0 // mtp [[nodiscard]] Sticker stickerForEmoji(const IsolatedEmoji &emoji); #endif [[nodiscard]] std::shared_ptr image(EmojiPtr emoji); @@ -100,10 +100,10 @@ class EmojiPack final { [[nodiscard]] int animationsVersion() const { return _animationsVersion; } +#endif [[nodiscard]] rpl::producer<> refreshed() const { return _refreshed.events(); } -#endif [[nodiscard]] std::unique_ptr effectPlayer( not_null document, @@ -160,10 +160,11 @@ class EmojiPack final { void refreshItems(const base::flat_set> &list); void refreshItems(const base::flat_set> &items); + void request(EmojiPtr emoji); + base::flat_set _requested; + const not_null _session; -#if 0 // mtp base::flat_map> _map; -#endif base::flat_map< IsolatedEmoji, base::flat_set>> _items; diff --git a/Telegram/SourceFiles/chat_helpers/stickers_gift_box_pack.cpp b/Telegram/SourceFiles/chat_helpers/stickers_gift_box_pack.cpp index b2686e6067e2b8..d684f6fa2959d3 100644 --- a/Telegram/SourceFiles/chat_helpers/stickers_gift_box_pack.cpp +++ b/Telegram/SourceFiles/chat_helpers/stickers_gift_box_pack.cpp @@ -7,16 +7,19 @@ For license and copyright information please follow this link: */ #include "chat_helpers/stickers_gift_box_pack.h" -#if 0 // mtp - #include "apiwrap.h" #include "data/data_document.h" #include "data/data_file_origin.h" #include "data/data_session.h" #include "main/main_session.h" +#include "tdb/tdb_tl_scheme.h" +#include "tdb/tdb_sender.h" + namespace Stickers { +using namespace Tdb; + GiftBoxPack::GiftBoxPack(not_null session) : _session(session) , _localMonths({ 1, 3, 6, 12, 24 }) { @@ -39,6 +42,7 @@ int GiftBoxPack::monthsForStars(int stars) const { } DocumentData *GiftBoxPack::lookup(int months) const { +#if 0 // mtp const auto it = ranges::lower_bound(_localMonths, months); const auto fallback = _documents.empty() ? nullptr : _documents[0]; if (it == begin(_localMonths)) { @@ -53,12 +57,29 @@ DocumentData *GiftBoxPack::lookup(int months) const { : 0; const auto index = int(std::distance(begin(_localMonths), it - shift)); return (index >= _documents.size()) ? fallback : _documents[index]; +#endif + const auto i = _months.find(months); + if (i == end(_months)) { + _months.emplace(months, nullptr); + _session->sender().request(TLgetPremiumInfoSticker( + tl_int32(months) + )).done([=](const TLsticker &result) { + const auto document = _session->data().processDocument(result); + if (document->sticker()) { + _months[months] = document; + _updated.fire({}); + } + }).send(); + return nullptr; + } + return i->second; } Data::FileOrigin GiftBoxPack::origin() const { return Data::FileOriginStickerSet(_setId, _accessHash); } +#if 0 // mtp void GiftBoxPack::load() { if (_requestId || !_documents.empty()) { return; @@ -120,7 +141,6 @@ void GiftBoxPack::applySet(const MTPDmessages_stickerSet &data) { } _updated.fire({}); } +#endif } // namespace Stickers - -#endif diff --git a/Telegram/SourceFiles/chat_helpers/stickers_gift_box_pack.h b/Telegram/SourceFiles/chat_helpers/stickers_gift_box_pack.h index 8ce4345b8de358..8913dc85702965 100644 --- a/Telegram/SourceFiles/chat_helpers/stickers_gift_box_pack.h +++ b/Telegram/SourceFiles/chat_helpers/stickers_gift_box_pack.h @@ -7,8 +7,6 @@ For license and copyright information please follow this link: */ #pragma once -#if 0 // mtp - class DocumentData; namespace Data { @@ -26,7 +24,9 @@ class GiftBoxPack final { explicit GiftBoxPack(not_null session); ~GiftBoxPack(); +#if 0 // mtp void load(); +#endif [[nodiscard]] int monthsForStars(int stars) const; [[nodiscard]] DocumentData *lookup(int months) const; [[nodiscard]] Data::FileOrigin origin() const; @@ -34,7 +34,11 @@ class GiftBoxPack final { private: using SetId = uint64; +#if 0 // mtp void applySet(const MTPDmessages_stickerSet &data); +#endif + + mutable base::flat_map _months; const not_null _session; const std::vector _localMonths; @@ -48,5 +52,3 @@ class GiftBoxPack final { }; } // namespace Stickers - -#endif diff --git a/Telegram/SourceFiles/chat_helpers/stickers_lottie.cpp b/Telegram/SourceFiles/chat_helpers/stickers_lottie.cpp index 73b8d028a66784..6c6635d45af3d2 100644 --- a/Telegram/SourceFiles/chat_helpers/stickers_lottie.cpp +++ b/Telegram/SourceFiles/chat_helpers/stickers_lottie.cpp @@ -349,7 +349,7 @@ not_null GenerateLocalTgsSticker( "WEBP", result->thumbbytes)); #endif - const auto document = _session->data().processDocument(result->document); + const auto document = session->data().processDocument(result->document); document->setLocation(Core::FileLocation(path)); Ensures(document->sticker()); diff --git a/Telegram/SourceFiles/core/local_url_handlers.cpp b/Telegram/SourceFiles/core/local_url_handlers.cpp index 589944af7d397e..25ff024ecaa023 100644 --- a/Telegram/SourceFiles/core/local_url_handlers.cpp +++ b/Telegram/SourceFiles/core/local_url_handlers.cpp @@ -1728,15 +1728,15 @@ bool HandleLocalUrl( .openWebAppUrl = openWebAppUrl, })); }); - }, [&](const TLDinternalLinkTypeSideMenuBot &data) { + }, [&](const TLDinternalLinkTypeMainWebApp &data) { if (!controller) { return false; } - // todo controller->showPeerByLink(Window::PeerByLinkInfo{ .usernameOrId = data.vbot_username().v, - .attachBotToggleCommand = data.vurl().v, - //.attachBotMenuOpen = true, + .attachBotToggleCommand = data.vstart_parameter().v, + .attachBotMainOpen = true, + .attachBotMainCompact = data.vis_compact().v, .clickFromMessageId = my.itemId, }); controller->window().activate(); @@ -2145,10 +2145,46 @@ bool HandleLocalUrl( if (!controller) { return false; } - const auto ref = data.vreferrer().v; - controller->showGiftPremiumsBox(ref.isEmpty() ? u"gift_url"_q : ref); + Ui::ChooseStarGiftRecipient(controller); controller->window().activate(); return true; + }, [&](const TLDinternalLinkTypeBuyStars &data) { + if (!controller) { + return false; + } + const auto amount = std::clamp( + data.vstar_count().v, + int64(1), + int64(1'000'000)); + const auto purpose = data.vpurpose().v; + const auto weak = base::make_weak(controller); + const auto done = [=](::Settings::SmallBalanceResult result) { + if (result == ::Settings::SmallBalanceResult::Already) { + if (const auto strong = weak.get()) { + const auto filter = [=](const auto &...) { + strong->showSettings(::Settings::CreditsId()); + return false; + }; + strong->showToast(Ui::Toast::Config{ + .text = tr::lng_credits_enough( + tr::now, + lt_link, + Ui::Text::Link( + Ui::Text::Bold( + tr::lng_credits_enough_link(tr::now))), + Ui::Text::RichLangValue), + .filter = filter, + .duration = 4 * crl::time(1000), + }); + } + } + }; + ::Settings::MaybeRequestBalanceIncrease( + controller->uiShow(), + amount, + ::Settings::SmallBalanceDeepLink{ .purpose = purpose }, + done); + return true; }); } diff --git a/Telegram/SourceFiles/data/components/credits.cpp b/Telegram/SourceFiles/data/components/credits.cpp index 4c2379a9501da2..6f9557164f2d10 100644 --- a/Telegram/SourceFiles/data/components/credits.cpp +++ b/Telegram/SourceFiles/data/components/credits.cpp @@ -12,6 +12,8 @@ For license and copyright information please follow this link: #include "main/main_app_config.h" #include "main/main_session.h" +#include "tdb/tdb_tl_scheme.h" + namespace Data { namespace { @@ -26,9 +28,14 @@ Credits::Credits(not_null session) Credits::~Credits() = default; +#if 0 // mtp void Credits::apply(const MTPDupdateStarsBalance &data) { apply(data.vbalance().v); } +#endif +void Credits::apply(const Tdb::TLDupdateOwnedStarCount &data) { + apply(data.vstar_count().v); +} rpl::producer Credits::rateValue( not_null ownedBotOrChannel) { diff --git a/Telegram/SourceFiles/data/components/credits.h b/Telegram/SourceFiles/data/components/credits.h index 62fefcc3c7b1b2..ee39a50e4aa9e7 100644 --- a/Telegram/SourceFiles/data/components/credits.h +++ b/Telegram/SourceFiles/data/components/credits.h @@ -15,6 +15,10 @@ namespace Main { class Session; } // namespace Main +namespace Tdb { +class TLDupdateOwnedStarCount; +} // namespace Tdb + namespace Data { class Credits final { @@ -40,7 +44,10 @@ class Credits final { void withdrawLocked(int count); void invalidate(); +#if 0 // mtp void apply(const MTPDupdateStarsBalance &data); +#endif + void apply(const Tdb::TLDupdateOwnedStarCount &data); private: void updateNonLockedValue(); diff --git a/Telegram/SourceFiles/data/components/sponsored_messages.cpp b/Telegram/SourceFiles/data/components/sponsored_messages.cpp index 85c5e6d03fe885..84e1ff6c85ec93 100644 --- a/Telegram/SourceFiles/data/components/sponsored_messages.cpp +++ b/Telegram/SourceFiles/data/components/sponsored_messages.cpp @@ -593,7 +593,9 @@ void SponsoredMessages::clicked( const auto id = DeserializeRandomId(entryPtr->sponsored.randomId); _session->sender().request(TLclickChatSponsoredMessage( peerToTdbChat(id.peer), - tl_int53(id.msg.bare) + tl_int53(id.msg.bare), + tl_bool(isMedia), + tl_bool(isFullscreen) )).send(); #if 0 // mtp const auto randomId = entryPtr->sponsored.randomId; diff --git a/Telegram/SourceFiles/data/data_media_preload.cpp b/Telegram/SourceFiles/data/data_media_preload.cpp index b6daed91b49803..d75384f8bd07c8 100644 --- a/Telegram/SourceFiles/data/data_media_preload.cpp +++ b/Telegram/SourceFiles/data/data_media_preload.cpp @@ -18,9 +18,14 @@ For license and copyright information please follow this link: #include "media/streaming/media_streaming_reader.h" #include "storage/file_download.h" // kMaxFileInMemory. +#include "tdb/tdb_account.h" +#include "tdb/tdb_tl_scheme.h" + namespace Data { namespace { +using namespace Tdb; + constexpr auto kDefaultPreloadPrefix = 4 * 1024 * 1024; [[nodiscard]] int64 ChoosePreloadPrefix(not_null video) { @@ -208,13 +213,6 @@ bool VideoPreload::setWebFileSizeHook(int64 size) { } #endif -[[nodiscard]] int ChoosePreloadPrefix(not_null document) { - const auto prefix = document->videoPreloadPrefix(); - const auto part = Storage::kDownloadPartSize; - const auto parts = (prefix + part - 1) / part; - return std::min(int64(parts) * part, document->size); -} - [[nodiscard]] QByteArray PackPreload(const QByteArray &bytes, int64 full) { if (bytes.isEmpty()) { return {}; @@ -244,6 +242,7 @@ VideoPreload::VideoPreload( not_null video, Fn done) : MediaPreload(std::move(done)) +, _video(video) , _session(&video->session()) , _sender(&_session->sender()) , _full(video->size) @@ -334,7 +333,7 @@ void VideoPreload::startWith(const TLDlocalFile &data) { }); } }).fail([=] { - done(); + done({}); }).send(); } } diff --git a/Telegram/SourceFiles/data/data_media_preload.h b/Telegram/SourceFiles/data/data_media_preload.h index 6151f75fa533f0..09eb74eff6a747 100644 --- a/Telegram/SourceFiles/data/data_media_preload.h +++ b/Telegram/SourceFiles/data/data_media_preload.h @@ -9,6 +9,16 @@ For license and copyright information please follow this link: #include "storage/download_manager_mtproto.h" +#include "tdb/tdb_sender.h" + +namespace Tdb { +class TLDlocalFile; +} // namespace Tdb + +namespace Main { +class Session; +} // namespace Main + namespace Data { class PhotoMedia; @@ -98,15 +108,16 @@ class VideoPreload final void load(); void done(QByteArray result); - void startWith(const TLDlocalFile &data); - bool continueWith(const TLDlocalFile &data); - void finishWith(const TLDlocalFile &data); + void startWith(const Tdb::TLDlocalFile &data); + bool continueWith(const Tdb::TLDlocalFile &data); + void finishWith(const Tdb::TLDlocalFile &data); + const not_null _video; const not_null _session; - Sender _sender; + Tdb::Sender _sender; int64 _full = 0; FileId _fileId = 0; - int _prefix = 0; + int64 _prefix = 0; rpl::lifetime _downloadLifetime; diff --git a/Telegram/SourceFiles/data/data_media_types.cpp b/Telegram/SourceFiles/data/data_media_types.cpp index 89c15c47342518..207fa4c0643095 100644 --- a/Telegram/SourceFiles/data/data_media_types.cpp +++ b/Telegram/SourceFiles/data/data_media_types.cpp @@ -628,14 +628,18 @@ bool IsFirstVideo(const Invoice &invoice) { GiveawayStart ComputeGiveawayStartData( not_null item, - const TLDmessagePremiumGiveaway &data) { + const TLDmessageGiveaway &data) { const auto &fields = data.vparameters().data(); auto result = GiveawayStart{ .untilDate = fields.vwinners_selection_date().v, .quantity = data.vwinner_count().v, - .months = data.vmonth_count().v, .all = !fields.vonly_new_members().v, }; + data.vprize().match([&](const TLDgiveawayPrizePremium &data) { + result.months = data.vmonth_count().v; + }, [&](const TLDgiveawayPrizeStars &data) { + result.credits = data.vstar_count().v; + }); const auto &list = fields.vadditional_chat_ids().v; result.channels.reserve(1 + list.size()); const auto owner = &item->history()->owner(); @@ -658,7 +662,7 @@ GiveawayStart ComputeGiveawayStartData( GiveawayResults ComputeGiveawayResultsData( not_null item, - const TLDmessagePremiumGiveawayWinners &data) { + const TLDmessageGiveawayWinners &data) { auto result = GiveawayResults{ .channel = item->history()->owner().channel( peerToChannel(peerFromTdbChat(data.vboosted_chat_id()))), @@ -667,10 +671,14 @@ GiveawayResults ComputeGiveawayResultsData( .additionalPeersCount = data.vadditional_chat_count().v, .winnersCount = data.vwinner_count().v, .unclaimedCount = data.vunclaimed_prize_count().v, - .months = data.vmonth_count().v, .refunded = data.vwas_refunded().v, .all = !data.vonly_new_members().v, }; + data.vprize().match([&](const TLDgiveawayPrizePremium &data) { + result.months = data.vmonth_count().v; + }, [&](const TLDgiveawayPrizeStars &data) { + result.credits = data.vstar_count().v; + }); result.winners.reserve(data.vwinner_user_ids().v.size()); const auto owner = &item->history()->owner(); for (const auto &id : data.vwinner_user_ids().v) { @@ -2517,9 +2525,10 @@ MediaGiftBox::MediaGiftBox( MediaGiftBox::MediaGiftBox( not_null parent, not_null from, - int months, + GiftType type, + int count, DocumentData *sticker) -: MediaGiftBox(parent, from, GiftCode{ .months = months }, sticker) { +: MediaGiftBox(parent, from, { .count = count, .type = type }, sticker) { } MediaGiftBox::MediaGiftBox( diff --git a/Telegram/SourceFiles/data/data_media_types.h b/Telegram/SourceFiles/data/data_media_types.h index f18cce8d8ec481..93b78bfa5741ed 100644 --- a/Telegram/SourceFiles/data/data_media_types.h +++ b/Telegram/SourceFiles/data/data_media_types.h @@ -16,8 +16,8 @@ class TLDmessageInvoice; class TLDmessageCall; class TLDmessageDice; class TLmessageContent; -class TLDmessagePremiumGiveaway; -class TLDmessagePremiumGiveawayWinners; +class TLDmessageGiveaway; +class TLDmessageGiveawayWinners; } // namespace Tdb class Image; @@ -661,7 +661,8 @@ class MediaGiftBox final : public Media { MediaGiftBox( not_null parent, not_null from, - int months, + GiftType type, + int count, DocumentData *sticker); MediaGiftBox( not_null parent, @@ -857,10 +858,10 @@ class MediaGiveawayResults final : public Media { [[nodiscard]] GiveawayStart ComputeGiveawayStartData( not_null item, - const Tdb::TLDmessagePremiumGiveaway &data); + const Tdb::TLDmessageGiveaway &data); [[nodiscard]] GiveawayResults ComputeGiveawayResultsData( not_null item, - const Tdb::TLDmessagePremiumGiveawayWinners &data); + const Tdb::TLDmessageGiveawayWinners &data); } // namespace Data diff --git a/Telegram/SourceFiles/data/data_message_reaction_id.cpp b/Telegram/SourceFiles/data/data_message_reaction_id.cpp index 5ec2bd7b84ac33..c8fd8e69a13415 100644 --- a/Telegram/SourceFiles/data/data_message_reaction_id.cpp +++ b/Telegram/SourceFiles/data/data_message_reaction_id.cpp @@ -87,6 +87,8 @@ ReactionId ReactionFromTL(const TLreactionType &reaction) { return ReactionId{ data.vemoji().v }; }, [&](const TLDreactionTypeCustomEmoji &data) { return ReactionId{ DocumentId(data.vcustom_emoji_id().v) }; + }, [](const TLDreactionTypePaid &) { + return ReactionId::Paid(); }); } diff --git a/Telegram/SourceFiles/data/data_message_reactions.cpp b/Telegram/SourceFiles/data/data_message_reactions.cpp index 8dee91c96c2d5f..3eacc90470773d 100644 --- a/Telegram/SourceFiles/data/data_message_reactions.cpp +++ b/Telegram/SourceFiles/data/data_message_reactions.cpp @@ -418,7 +418,6 @@ Reactions::Reactions(not_null owner) }, _lifetime); }); #endif -{ } Reactions::~Reactions() = default; @@ -2233,12 +2232,19 @@ void Reactions::sendPaidPrivacyRequest( Expects(!send.count); const auto id = item->fullId(); +#if 0 // mtp auto &api = _owner->session().api(); const auto requestId = api.request( MTPmessages_TogglePaidReactionPrivacy( item->history()->peer->input, MTP_int(id.msg), MTP_bool(*send.anonymous)) +#endif + const auto requestId = _owner->session().sender().request( + TLtogglePaidMessageReactionIsAnonymous( + peerToTdbChat(item->history()->peer->id), + tl_int53(id.msg.bare), + tl_bool(*send.anonymous)) ).done([=] { if (const auto item = _owner->message(id)) { if (_sendingPaid.remove(item)) { @@ -2246,7 +2252,10 @@ void Reactions::sendPaidPrivacyRequest( } } checkQuitPreventFinished(); +#if 0 // mtp }).fail([=](const MTP::Error &error) { +#endif + }).fail([=](const Error &error) { if (const auto item = _owner->message(id)) { if (_sendingPaid.remove(item)) { sendPaidFinish(item, send, false); @@ -2268,6 +2277,7 @@ void Reactions::sendPaidRequest( } const auto id = item->fullId(); +#if 0 // mtp const auto randomId = base::unixtime::mtproto_msg_id(); auto &api = _owner->session().api(); using Flag = MTPmessages_SendPaidReaction::Flag; @@ -2279,19 +2289,55 @@ void Reactions::sendPaidRequest( MTP_long(randomId), MTP_bool(send.anonymous.value_or(false)) )).done([=](const MTPUpdates &result) { +#endif + const auto requestId = _owner->session().sender().request( + TLaddPendingPaidMessageReaction( + peerToTdbChat(id.peer), + tl_int53(id.msg.bare), + tl_int53(send.count), + tl_bool(!send.anonymous.has_value()), + tl_bool(send.anonymous.value_or(false))) + ).done([=] { + const auto item = _owner->message(id); + if (!item) { + checkQuitPreventFinished(); + return; + } + _sendingPaid[item] = _owner->session().sender().request( + TLcommitPendingPaidMessageReactions( + peerToTdbChat(id.peer), + tl_int53(id.msg.bare)) + ).done([=] { + if (const auto item = _owner->message(id)) { if (_sendingPaid.remove(item)) { sendPaidFinish(item, send, true); } } +#if 0 // mtp _owner->session().api().applyUpdates(result); +#endif checkQuitPreventFinished(); + + }).fail([=] { + if (const auto item = _owner->message(id)) { + _sendingPaid.remove(item); + sendPaidFinish(item, send, false); + } + checkQuitPreventFinished(); + }).send(); +#if 0 // mtp }).fail([=](const MTP::Error &error) { +#endif + }).fail([=] { if (const auto item = _owner->message(id)) { _sendingPaid.remove(item); +#if 0 // mtp if (error.type() == u"RANDOM_ID_EXPIRED"_q) { sendPaidRequest(item, send); } else { +#endif + { sendPaidFinish(item, send, false); } } diff --git a/Telegram/SourceFiles/data/data_message_reactions.h b/Telegram/SourceFiles/data/data_message_reactions.h index 351b5d1ab57d90..8212ac32abc334 100644 --- a/Telegram/SourceFiles/data/data_message_reactions.h +++ b/Telegram/SourceFiles/data/data_message_reactions.h @@ -423,11 +423,13 @@ class Reactions final : private CustomEmojiManager::Listener { base::flat_set> _pollItems; base::flat_set> _pollingItems; mtpRequestId _pollRequestId = 0; +#endif base::flat_map, crl::time> _sendPaidItems; base::flat_map, mtpRequestId> _sendingPaid; base::Timer _sendPaidTimer; +#if 0 // mtp mtpRequestId _saveFaveRequestId = 0; #endif diff --git a/Telegram/SourceFiles/data/data_peer.cpp b/Telegram/SourceFiles/data/data_peer.cpp index c403d13123acdd..8b5a34e7bff4ab 100644 --- a/Telegram/SourceFiles/data/data_peer.cpp +++ b/Telegram/SourceFiles/data/data_peer.cpp @@ -535,7 +535,7 @@ QImage PeerData::GenerateUserpicImage( int size, std::optional radius) { if (const auto user = peer->secretChatUser()) { - return user->generateUserpicImage(view, size, radius); + return GenerateUserpicImage(user, view, size, radius); } if (const auto userpic = peer->userpicCloudImage(view)) { auto image = userpic->scaled( diff --git a/Telegram/SourceFiles/data/data_session.cpp b/Telegram/SourceFiles/data/data_session.cpp index f74c344383d5f4..7e398899b88aaa 100644 --- a/Telegram/SourceFiles/data/data_session.cpp +++ b/Telegram/SourceFiles/data/data_session.cpp @@ -137,6 +137,7 @@ void CheckForSwitchInlineButton(not_null item) { return AdminRightsFromChatAdministratorRights(data.vrights()); } +#if 0 // mtp [[nodiscard]] InlineImageLocation FindInlineThumbnail( const QVector &sizes) { const auto i = ranges::find( @@ -1141,7 +1142,7 @@ not_null Session::processUser(const TLuser &user) { result->clearPhoto(); } result->setUnavailableReasons( - ExtractUnavailableReasons(data.vrestriction_reason())); + Data::UnavailableReason::Extract(data.vrestriction_reason())); data.vtype().match([&](const TLDuserTypeRegular &) { result->setFlags(result->flags() & ~UserDataFlag::Deleted); @@ -1169,6 +1170,7 @@ not_null Session::processUser(const TLuser &user) { result->botInfo->supportsAttachMenu = data.vcan_be_added_to_attachment_menu().v; result->botInfo->canEditInformation = data.vcan_be_edited().v; + result->botInfo->hasMainApp = data.vhas_main_web_app().v; }, [&](const TLDuserTypeUnknown) { result->setFlags(result->flags() | UserDataFlag::Deleted); result->setBotInfoVersion(-1); @@ -1490,7 +1492,7 @@ not_null Session::processChannel( | (data.vis_forum().v ? Flag::Forum : Flag()); result->setUnavailableReasons( - ExtractUnavailableReasons(data.vrestriction_reason())); + Data::UnavailableReason::Extract(data.vrestriction_reason())); data.vstatus().match([&](const TLDchatMemberStatusCreator &data) { if (!data.vis_member().v) { diff --git a/Telegram/SourceFiles/data/data_story.cpp b/Telegram/SourceFiles/data/data_story.cpp index 8445a5cec24527..bf577a15aa45ba 100644 --- a/Telegram/SourceFiles/data/data_story.cpp +++ b/Telegram/SourceFiles/data/data_story.cpp @@ -165,6 +165,7 @@ using UpdateFlag = StoryUpdate::Flag; }, [](const TLDstoryAreaTypeSuggestedReaction &) { }, [](const TLDstoryAreaTypeMessage &) { }, [](const TLDstoryAreaTypeLink &) { + }, [](const TLDstoryAreaTypeWeather &) { }); return result; } @@ -186,6 +187,7 @@ using UpdateFlag = StoryUpdate::Flag; }); }, [](const TLDstoryAreaTypeMessage &) { }, [](const TLDstoryAreaTypeLink &) { + }, [](const TLDstoryAreaTypeWeather &) { }); return result; } @@ -278,6 +280,7 @@ using UpdateFlag = StoryUpdate::Flag; data.vmessage_id().v), }); }, [](const TLDstoryAreaTypeLink &) { + }, [](const TLDstoryAreaTypeWeather &) { }); return result; } @@ -296,6 +299,31 @@ using UpdateFlag = StoryUpdate::Flag; .area = ParseArea(position), .url = data.vurl().v, }); + }, [](const TLDstoryAreaTypeWeather &) { + }); + return result; +} + +[[nodiscard]] auto ParseWeatherArea(const TLstoryArea &area) +-> std::optional { + auto result = std::optional(); + const auto &data = area.data(); + const auto &position = data.vposition(); + data.vtype().match([](const TLDstoryAreaTypeLocation &) { + }, [](const TLDstoryAreaTypeVenue &) { + }, [](const TLDstoryAreaTypeSuggestedReaction &) { + }, [](const TLDstoryAreaTypeMessage &) { + }, [](const TLDstoryAreaTypeLink &) { + }, [&](const TLDstoryAreaTypeWeather &data) { + result.emplace(WeatherArea{ + .area = ParseArea(position), + .emoji = data.vemoji().v, + .color = Ui::Color32FromSerialized(data.vbackground_color().v), + .millicelsius = int(1000. * std::clamp( + data.vtemperature().v, + -274., + 1'000'000.)), + }); }); return result; } @@ -1172,7 +1200,9 @@ StoryPreload::StoryPreload(not_null story, Fn done) if (VideoPreload::Can(video)) { _task = std::make_unique( video, +#if 0 // mtp story->fullId(), +#endif std::move(done)); } else { done(); diff --git a/Telegram/SourceFiles/data/data_user.cpp b/Telegram/SourceFiles/data/data_user.cpp index 4b25a41b86bcfb..f8370a48a69c4c 100644 --- a/Telegram/SourceFiles/data/data_user.cpp +++ b/Telegram/SourceFiles/data/data_user.cpp @@ -837,7 +837,7 @@ void ApplyUserUpdate( const auto mask = Flag::Blocked // | Flag::HasPhoneCalls // Unused. | Flag::PhoneCallsPrivate - | Flag::CanReceiveGifts + // | Flag::CanReceiveGifts | Flag::CanPinMessages | Flag::VoiceMessagesForbidden; const auto blocked = update.vblock_list() @@ -845,9 +845,9 @@ void ApplyUserUpdate( user->setFlags((user->flags() & ~mask) | (update.vhas_private_calls().v ? Flag::PhoneCallsPrivate : Flag()) // | (update.is_phone_calls_available() ? Flag::HasPhoneCalls : Flag()) - | (!update.vpremium_gift_options().v.empty() - ? Flag::CanReceiveGifts - : Flag()) + //| (!update.vpremium_gift_options().v.empty() + // ? Flag::CanReceiveGifts + // : Flag()) | (true /* Always true from TDLib. */ ? Flag::CanPinMessages : Flag()) | (blocked ? Flag::Blocked : Flag()) | (update.vhas_restricted_voice_and_video_note_messages().v diff --git a/Telegram/SourceFiles/data/data_web_page.cpp b/Telegram/SourceFiles/data/data_web_page.cpp index cc74064bd8e45b..cfb4b4df53e7c3 100644 --- a/Telegram/SourceFiles/data/data_web_page.cpp +++ b/Telegram/SourceFiles/data/data_web_page.cpp @@ -231,10 +231,16 @@ WebPageType ParseWebPageType(const TLlinkPreviewType &type, bool hasIV) { }); }, [&](const TLDlinkPreviewTypeDocument &data) { return WebPageType::Document; - }, [&](const TLDlinkPreviewTypeEmbeddedAudioPlayer &data) { + }, [&](const TLDlinkPreviewTypeEmbeddedAnimationPlayer &data) { return WebPageType::Video; + }, [&](const TLDlinkPreviewTypeEmbeddedAudioPlayer &data) { + return article; }, [&](const TLDlinkPreviewTypeEmbeddedVideoPlayer &data) { return WebPageType::Video; + }, [&](const TLDlinkPreviewTypeExternalAudio &data) { + return article; + }, [&](const TLDlinkPreviewTypeExternalVideo &data) { + return WebPageType::Video; }, [&](const TLDlinkPreviewTypeInvoice &data) { return article; }, [&](const TLDlinkPreviewTypeMessage &data) { @@ -317,10 +323,16 @@ WebPageType ParseWebPageType(const TLlinkPreviewType &type, bool hasIV) { return photo(data); }, [&](const TLDlinkPreviewTypeDocument &data) { return null; + }, [&](const TLDlinkPreviewTypeEmbeddedAnimationPlayer &data) { + return null; }, [&](const TLDlinkPreviewTypeEmbeddedAudioPlayer &data) { return null; }, [&](const TLDlinkPreviewTypeEmbeddedVideoPlayer &data) { return null; + }, [&](const TLDlinkPreviewTypeExternalAudio &data) { + return null; + }, [&](const TLDlinkPreviewTypeExternalVideo &data) { + return null; }, [&](const TLDlinkPreviewTypeInvoice &data) { return null; }, [&](const TLDlinkPreviewTypeMessage &data) { @@ -374,7 +386,7 @@ WebPageType ParseWebPageType(const TLlinkPreviewType &type, bool hasIV) { }, [&](const TLDlinkPreviewTypeArticle &data) { return null; }, [&](const TLDlinkPreviewTypeAudio &data) { - return data.vaudio() ? document(*data.vaudio()) : null; + return document(data.vaudio()); }, [&](const TLDlinkPreviewTypeBackground &data) { return data.vdocument() ? document(*data.vdocument()) : null; }, [&](const TLDlinkPreviewTypeChannelBoost &data) { @@ -383,10 +395,16 @@ WebPageType ParseWebPageType(const TLlinkPreviewType &type, bool hasIV) { return null; }, [&](const TLDlinkPreviewTypeDocument &data) { return document(data.vdocument()); + }, [&](const TLDlinkPreviewTypeEmbeddedAnimationPlayer &data) { + return null; }, [&](const TLDlinkPreviewTypeEmbeddedAudioPlayer &data) { return null; }, [&](const TLDlinkPreviewTypeEmbeddedVideoPlayer &data) { return null; + }, [&](const TLDlinkPreviewTypeExternalAudio &data) { + return null; + }, [&](const TLDlinkPreviewTypeExternalVideo &data) { + return null; }, [&](const TLDlinkPreviewTypeInvoice &data) { return null; }, [&](const TLDlinkPreviewTypeMessage &data) { @@ -412,7 +430,7 @@ WebPageType ParseWebPageType(const TLlinkPreviewType &type, bool hasIV) { }, [&](const TLDlinkPreviewTypeUser &data) { return null; }, [&](const TLDlinkPreviewTypeVideo &data) { - return data.vvideo() ? document(*data.vvideo()) : null; + return document(data.vvideo()); }, [&](const TLDlinkPreviewTypeVideoChat &data) { return null; }, [&](const TLDlinkPreviewTypeVideoNote &data) { @@ -454,11 +472,11 @@ WebPageType ParseWebPageType(const TLlinkPreviewType &type, bool hasIV) { return type.match([&](const TLDlinkPreviewTypeAnimation &data) { return data.vanimation().data().vduration().v; }, [&](const TLDlinkPreviewTypeAudio &data) { - return data.vduration().v; + return data.vaudio().data().vduration().v; }, [&](const TLDlinkPreviewTypeEmbeddedVideoPlayer &data) { return data.vduration().v; }, [&](const TLDlinkPreviewTypeVideo &data) { - return data.vduration().v; + return data.vvideo().data().vduration().v; }, [&](const TLDlinkPreviewTypeVideoNote &data) { return data.vvideo_note().data().vduration().v; }, [&](const TLDlinkPreviewTypeVoiceNote &data) { @@ -468,28 +486,6 @@ WebPageType ParseWebPageType(const TLlinkPreviewType &type, bool hasIV) { }); } -[[nodiscard]] QString ExtractAuthor(const TLlinkPreviewType &type) { - return type.match([&](const TLDlinkPreviewTypeAnimation &data) { - return data.vauthor().v; - }, [&](const TLDlinkPreviewTypeApp &data) { - return data.vauthor().v; - }, [&](const TLDlinkPreviewTypeArticle &data) { - return data.vauthor().v; - }, [&](const TLDlinkPreviewTypeAudio &data) { - return data.vauthor().v; - }, [&](const TLDlinkPreviewTypeDocument &data) { - return data.vauthor().v; - }, [&](const TLDlinkPreviewTypeEmbeddedAudioPlayer &data) { - return data.vauthor().v; - }, [&](const TLDlinkPreviewTypeEmbeddedVideoPlayer &data) { - return data.vauthor().v; - }, [&](const TLDlinkPreviewTypePhoto &data) { - return data.vauthor().v; - }, [&](const auto &) { - return QString(); - }); -} - } // namespace #if 0 // mtp @@ -600,7 +596,7 @@ void WebPageData::setFromTdb(const TLlinkPreview &data) { ExtractDocument(_owner, fields.vtype()), ExtractStickerSet(_owner, fields.vtype()), ExtractDuration(fields.vtype()), - ExtractAuthor(fields.vtype()), + fields.vauthor().v, fields.vhas_large_media().v, 0); diff --git a/Telegram/SourceFiles/data/stickers/data_stickers.cpp b/Telegram/SourceFiles/data/stickers/data_stickers.cpp index 151689f64991bc..a47488a4be4d2c 100644 --- a/Telegram/SourceFiles/data/stickers/data_stickers.cpp +++ b/Telegram/SourceFiles/data/stickers/data_stickers.cpp @@ -770,7 +770,10 @@ void Stickers::apply(const TLDupdateRecentStickers &data) { // : Data::Stickers::CloudRecentSetId), // tr::lng_recent_stickers(tr::now), // data.vsticker_ids().v); - session().api().requestRecentStickersForce(data.vis_attached().v); + session().api().requestSpecialStickersForce( + false, + true, + data.vis_attached().v); } void Stickers::apply(const TLDupdateFavoriteStickers &data) { diff --git a/Telegram/SourceFiles/history/admin_log/history_admin_log_inner.cpp b/Telegram/SourceFiles/history/admin_log/history_admin_log_inner.cpp index 2dcfd6eaf8c589..4074f104a92f39 100644 --- a/Telegram/SourceFiles/history/admin_log/history_admin_log_inner.cpp +++ b/Telegram/SourceFiles/history/admin_log/history_admin_log_inner.cpp @@ -834,25 +834,28 @@ void InnerWidget::preloadMore(Direction direction) { // const auto minId = (direction == Direction::Up) ? 0 : _maxId; const auto perPage = _items.empty() ? kEventsFirstPage : kEventsPerPage; + using LocalFlag = FilterValue::Flag; + const auto f = _filter.flags.value_or(LocalFlag()); auto filter = tl_chatEventLogFilters( - tl_bool(_filter.flags & FilterValue::Flag::Edit), - tl_bool(_filter.flags & FilterValue::Flag::Delete), - tl_bool(_filter.flags & FilterValue::Flag::Pinned), - tl_bool(_filter.flags & FilterValue::Flag::Join), - tl_bool(_filter.flags & FilterValue::Flag::Leave), - tl_bool(_filter.flags & FilterValue::Flag::Invites), - tl_bool(_filter.flags & FilterValue::Flag::Promote), - tl_bool(_filter.flags & FilterValue::Flag::Demote), - tl_bool(_filter.flags & FilterValue::Flag::Info), - tl_bool(_filter.flags & FilterValue::Flag::Settings), - tl_bool(_filter.flags & FilterValue::Flag::Invite), - tl_bool(_filter.flags & FilterValue::Flag::GroupCall), - tl_bool(_filter.flags & FilterValue::Flag::Topics)); - - auto admins = _filter.allUsers + tl_bool(f & LocalFlag::Edit), + tl_bool(f & LocalFlag::Delete), + tl_bool(f & LocalFlag::Pinned), + tl_bool(f & LocalFlag::Join), + tl_bool(f & LocalFlag::Leave), + tl_bool(f & LocalFlag::Invites), + tl_bool(f & LocalFlag::Promote), + tl_bool(f & LocalFlag::Demote), + tl_bool(f & LocalFlag::Info), + tl_bool(f & LocalFlag::Settings), + tl_bool(f & LocalFlag::Invite), + tl_bool(f & LocalFlag::GroupCall), + tl_bool(f & LocalFlag::Topics), + tl_bool(f & LocalFlag::SubExtend)); + + auto admins = !_filter.admins ? QVector() : ranges::views::all( - _filter.admins + *_filter.admins ) | ranges::views::transform([](not_null user) { return tl_int53(peerToUser(user->id).bare); }) | ranges::to>(); @@ -1635,15 +1638,25 @@ void InnerWidget::suggestRestrictParticipant( if (type == id_chatMemberStatusBanned) { editRestrictions( false, - ChatRestrictionsInfo(data.vstatus())); + ChatRestrictionsInfo(data.vstatus()), + user->owner().userLoaded( + UserId(data.vinviter_user_id())), + data.vjoined_chat_date().v); } else { const auto hasAdminRights = (type == id_chatMemberStatusAdministrator) || (type == id_chatMemberStatusCreator); - editRestrictions(hasAdminRights, ChatRestrictionsInfo()); + editRestrictions( + hasAdminRights, + ChatRestrictionsInfo(), + (hasAdminRights + ? nullptr + : user->owner().userLoaded( + UserId(data.vinviter_user_id()))), + hasAdminRights ? 0 : data.vjoined_chat_date().v); } }).fail([=] { - editRestrictions(false, ChatRestrictionsInfo()); + editRestrictions(false, {}, nullptr, 0); }).send(); #if 0 // goodToRemove _api.request(MTPchannels_GetParticipant( diff --git a/Telegram/SourceFiles/history/admin_log/history_admin_log_item.cpp b/Telegram/SourceFiles/history/admin_log/history_admin_log_item.cpp index 6fd5b0ebb9f090..2d8cd8bfdd6c35 100644 --- a/Telegram/SourceFiles/history/admin_log/history_admin_log_item.cpp +++ b/Telegram/SourceFiles/history/admin_log/history_admin_log_item.cpp @@ -202,19 +202,7 @@ Tdb::TLmessage PrepareLogMessage( Tdb::tl_bool(false), // is_outgoing message.data().vis_pinned(), Tdb::tl_bool(false), // is_from_offline - Tdb::tl_bool(false), // can_be_edited - Tdb::tl_bool(false), // can_be_forwarded - Tdb::tl_bool(false), // can_be_replied_in_another_chat Tdb::tl_bool(false), // can_be_saved - Tdb::tl_bool(false), // can_be_deleted_only_for_self - Tdb::tl_bool(false), // can_be_deleted_for_all_users - Tdb::tl_bool(false), // can_get_added_reactions - Tdb::tl_bool(false), // can_get_statistics - Tdb::tl_bool(false), // can_get_message_thread - Tdb::tl_bool(false), // can_get_read_date - Tdb::tl_bool(false), // can_get_viewers - message.data().vcan_get_media_timestamp_links(), - Tdb::tl_bool(false), // can_report_reactions message.data().vhas_timestamped_media(), Tdb::tl_bool(false), // is_channel_post Tdb::tl_bool(false), // is_topic_message @@ -240,6 +228,7 @@ Tdb::TLmessage PrepareLogMessage( message.data().vauthor_signature(), Tdb::tl_int64(0), // media_album_id Tdb::tl_int64(0), // effect_id + message.data().vhas_sensitive_content(), Tdb::tl_string(), // restriction_reason message.data().vcontent(), message.data().vreply_markup() @@ -1022,6 +1011,8 @@ void GenerateItems( using LogChangeProfilePeerColor = TLDchatEventProfileAccentColorChanged; using LogChangeWallpaper = TLDchatEventBackgroundChanged; using LogChangeEmojiStatus = TLDchatEventEmojiStatusChanged; + using LogToggleSignatureProfiles = TLDchatEventShowMessageSenderToggled; + using LogParticipantSubExtend = TLDchatEventMemberSubscriptionExtended; const auto session = &history->session(); const auto id = event.vid().v; @@ -2618,7 +2609,10 @@ void GenerateItems( }; const auto createToggleSignatureProfiles = [&](const LogToggleSignatureProfiles &action) { + const auto enabled = action.vshow_message_sender().v; +#if 0 // mtp const auto enabled = (action.vnew_value().type() == mtpc_boolTrue); +#endif const auto text = (enabled ? tr::lng_admin_log_signature_profiles_enabled : tr::lng_admin_log_signature_profiles_disabled)( @@ -2631,7 +2625,14 @@ void GenerateItems( const auto createParticipantSubExtend = [&](const LogParticipantSubExtend &action) { const auto participant = Api::ChatParticipant( +#if 0 // mtp action.vnew_participant(), +#endif + tl_chatMember( + peerToSender(peerFromUser(action.vuser_id())), + tl_int53(0), // inviter_user_id + tl_int32(0), // joined_chat_date + action.vnew_status()), channel); if (!participant.subscriptionDate()) { return; diff --git a/Telegram/SourceFiles/history/history_item.cpp b/Telegram/SourceFiles/history/history_item.cpp index eee03f5468d593..12f07d25bb12dd 100644 --- a/Telegram/SourceFiles/history/history_item.cpp +++ b/Telegram/SourceFiles/history/history_item.cpp @@ -4293,7 +4293,10 @@ void HistoryItem::createServiceFromTdb(const TLmessageContent &content) { const auto payment = Get(); const auto id = fullId(); const auto owner = &history()->owner(); - payment->amount = Ui::FillAmountAndCurrency(amount, currency); + payment->amount = AmountAndStarCurrency( + &_history->session(), + amount, + currency); payment->invoiceLink = std::make_shared([=]( ClickContext context) { using namespace Payments; @@ -4989,16 +4992,82 @@ void HistoryItem::setServiceMessageByContent( const auto peer = isSelf ? history()->peer : _from; const auto amount = data.vamount().v; const auto currency = data.vcurrency().v; + const auto session = &history()->session(); + const auto cost = AmountAndStarCurrency(session, amount, currency); prepared.links.push_back(peer->createOpenLink()); - prepared.text = (isSelf - ? tr::lng_action_gift_received_me - : tr::lng_action_gift_received)( + prepared.text = isSelf + ? tr::lng_action_gift_sent( + tr::now, + lt_cost, + cost, + Ui::Text::WithEntities) + : tr::lng_action_gift_received( tr::now, lt_user, - Ui::Text::Link(peer->name(), 1), // Link 1. + Ui::Text::Link(peer->shortName(), 1), // Link 1. lt_cost, - { Ui::FillAmountAndCurrency(amount, currency) }, + cost, Ui::Text::WithEntities); + }, [&](const TLDmessageGiftedStars &data) { + const auto isSelf = (_from->id == _from->session().userPeerId()); + const auto peer = isSelf ? history()->peer : _from; + const auto amount = data.vamount().v; + const auto currency = data.vcurrency().v; + const auto session = &history()->session(); + const auto cost = AmountAndStarCurrency(session, amount, currency); + prepared.links.push_back(peer->createOpenLink()); + prepared.text = isSelf + ? tr::lng_action_gift_sent( + tr::now, + lt_cost, + cost, + Ui::Text::WithEntities) + : tr::lng_action_gift_received( + tr::now, + lt_user, + Ui::Text::Link(peer->shortName(), 1), // Link 1. + lt_cost, + cost, + Ui::Text::WithEntities); + }, [&](const TLDmessageGiveawayPrizeStars &action) { + prepared.text = { + (action.vis_unclaimed().v + ? tr::lng_prize_unclaimed_about + : tr::lng_prize_about)( + tr::now, + lt_channel, + _from->owner().peer( + peerFromChat(action.vboosted_chat_id()))->name()), + }; + }, [&](const TLDmessageGift &action) { + const auto isSelf = _from->isSelf(); + const auto peer = isSelf ? _history->peer : _from; + const auto stars = action.vgift().data().vstar_count().v; + const auto cost = TextWithEntities{ + tr::lng_action_gift_for_stars(tr::now, lt_count, stars), + }; + const auto anonymous = _from->isServiceUser(); + if (anonymous) { + prepared.text = tr::lng_action_gift_received_anonymous( + tr::now, + lt_cost, + cost, + Ui::Text::WithEntities); + } else { + prepared.links.push_back(peer->createOpenLink()); + prepared.text = isSelf + ? tr::lng_action_gift_sent(tr::now, + lt_cost, + cost, + Ui::Text::WithEntities) + : tr::lng_action_gift_received( + tr::now, + lt_user, + Ui::Text::Link(peer->shortName(), 1), // Link 1. + lt_cost, + cost, + Ui::Text::WithEntities); + } }, [&](const TLDmessagePremiumGiftCode &action) { if (const auto creator = action.vcreator_id()) { prepared.text = { @@ -5015,21 +5084,27 @@ void HistoryItem::setServiceMessageByContent( } else { const auto isSelf = (_from->id == _from->session().userPeerId()); const auto peer = isSelf ? _history->peer : _from; + const auto session = &history()->session(); + const auto cost = AmountAndStarCurrency( + session, + action.vamount().v, + action.vcurrency().v); prepared.links.push_back(peer->createOpenLink()); - prepared.text = (isSelf - ? tr::lng_action_gift_received_me - : tr::lng_action_gift_received)( + prepared.text = isSelf + ? tr::lng_action_gift_sent( + tr::now, + lt_cost, + cost, + Ui::Text::WithEntities) + : tr::lng_action_gift_received( tr::now, lt_user, - Ui::Text::Link(peer->name(), 1), // Link 1. + Ui::Text::Link(peer->shortName(), 1), // Link 1. lt_cost, - { Ui::FillAmountAndCurrency( - action.vamount().v, - action.vcurrency().v) }, + cost, Ui::Text::WithEntities); - } - }, [&](const TLDmessagePremiumGiveawayCreated &data) { + }, [&](const TLDmessageGiveawayCreated &data) { prepared.links.push_back(fromLink()); prepared.text = tr::lng_action_giveaway_started( tr::now, @@ -5195,10 +5270,57 @@ void HistoryItem::applyContent(const TLmessageContent &content) { _media = std::make_unique( this, _from, - data.vmonth_count().v, + Data::GiftCode{ + .message = Api::FormattedTextFromTdb(data.vtext()), + .count = data.vmonth_count().v, + .type = Data::GiftType::Premium, + }, + (data.vsticker() + ? _history->owner().processDocument(*data.vsticker()).get() + : nullptr)); + }, [&](const TLDmessageGiftedStars &data) { + _media = std::make_unique( + this, + _from, + Data::GiftType::Credits, + data.vstar_count().v, + (data.vsticker() + ? _history->owner().processDocument(*data.vsticker()).get() + : nullptr)); + }, [&](const TLDmessageGiveawayPrizeStars &data) { + _media = std::make_unique( + this, + _from, + Data::GiftCode{ + .slug = data.vtransaction_id().v, + .channel = history()->owner().channel( + peerToChannel(peerFromTdbChat(data.vboosted_chat_id()))), + .giveawayMsgId = data.vgiveaway_message_id().v, + .count = int(data.vstar_count().v), + .type = Data::GiftType::Credits, + .viaGiveaway = true, + .unclaimed = data.vis_unclaimed().v, + }, (data.vsticker() ? _history->owner().processDocument(*data.vsticker()).get() : nullptr)); + }, [&](const TLDmessageGift &data) { + const auto &gift = data.vgift().data(); + const auto document = history()->owner().processDocument( + gift.vsticker()); + using Fields = Data::GiftCode; + _media = std::make_unique(this, _from, Fields{ + .document = document->sticker() ? document.get() : nullptr, + .message = Api::FormattedTextFromTdb(data.vtext()), + .convertStars = int(data.vsell_star_count().v), + .limitedCount = gift.vtotal_count().v, + .limitedLeft = gift.vremaining_count().v, + .count = int(gift.vstar_count().v), + .type = Data::GiftType::StarGift, + .anonymous = data.vis_private().v, + .converted = data.vwas_converted().v, + .saved = data.vis_saved().v, + }, _history->owner().processDocument(gift.vsticker())); }, [&](const TLDmessagePremiumGiftCode &data) { const auto boostedId = data.vcreator_id() ? peerToChannel(peerFromSender(*data.vcreator_id())) @@ -5208,10 +5330,12 @@ void HistoryItem::applyContent(const TLmessageContent &content) { _from, Data::GiftCode{ .slug = data.vcode().v, + .message = Api::FormattedTextFromTdb(data.vtext()), .channel = (boostedId ? _history->owner().channel(boostedId).get() : nullptr), - .months = data.vmonth_count().v, + .count = data.vmonth_count().v, + .type = Data::GiftType::Premium, .viaGiveaway = data.vis_from_giveaway().v, .unclaimed = data.vis_unclaimed().v, }, @@ -5311,8 +5435,8 @@ void HistoryItem::setContent(const TLmessageContent &content) { || TLDmessageDice::Is() || TLDmessagePoll::Is() || TLDmessageCall::Is() - || TLDmessagePremiumGiveaway::Is() - || TLDmessagePremiumGiveawayWinners::Is()) { + || TLDmessageGiveaway::Is() + || TLDmessageGiveawayWinners::Is()) { setMedia(content); } else if constexpr (TLDmessageInvoice::Is()) { setMedia(content); @@ -5355,8 +5479,11 @@ void HistoryItem::setContent(const TLmessageContent &content) { || TLDmessageProximityAlertTriggered::Is() || TLDmessageChatJoinByRequest::Is() || TLDmessageGiftedPremium::Is() - || TLDmessagePremiumGiveawayCreated::Is() - || TLDmessagePremiumGiveawayCompleted::Is() + || TLDmessageGiftedStars::Is() + || TLDmessageGiveawayPrizeStars::Is() + || TLDmessageGift::Is() + || TLDmessageGiveawayCreated::Is() + || TLDmessageGiveawayCompleted::Is() || TLDmessagePremiumGiftCode::Is() || TLDmessageForumTopicCreated::Is() || TLDmessageForumTopicEdited::Is() @@ -5553,18 +5680,18 @@ std::unique_ptr HistoryItem::CreateMedia( peerFromTdbChat(data.vstory_sender_chat_id()), data.vstory_id().v, }, data.vvia_mention().v); - }, [&](const TLDmessagePremiumGiveawayCreated &data) -> Result { + }, [&](const TLDmessageGiveawayCreated &data) -> Result { return Result(); - }, [&](const TLDmessagePremiumGiveaway &data) -> Result { + }, [&](const TLDmessageGiveaway &data) -> Result { return std::make_unique( item, Data::ComputeGiveawayStartData(item, data), (data.vsticker() ? owner.processDocument(*data.vsticker()).get() : nullptr)); - }, [&](const TLDmessagePremiumGiveawayCompleted &data) -> Result { + }, [&](const TLDmessageGiveawayCompleted &data) -> Result { return Result(); - }, [&](const TLDmessagePremiumGiveawayWinners &data) -> Result { + }, [&](const TLDmessageGiveawayWinners &data) -> Result { return std::make_unique( item, Data::ComputeGiveawayResultsData(item, data)); diff --git a/Telegram/SourceFiles/history/history_item_helpers.cpp b/Telegram/SourceFiles/history/history_item_helpers.cpp index dfe255dd7c236b..7fd5d3226889a0 100644 --- a/Telegram/SourceFiles/history/history_item_helpers.cpp +++ b/Telegram/SourceFiles/history/history_item_helpers.cpp @@ -110,16 +110,9 @@ MessageFlags FlagsFromTdb(const TLDmessage &data) { : Flag()) | (mediaUnread ? Flag::MediaIsUnread : Flag()) | (data.vis_channel_post().v ? Flag::Post : Flag()) - | (data.vcan_be_deleted_for_all_users().v - ? Flag::CanDeleteForAll - : Flag()) - | (data.vcan_be_edited().v ? Flag::CanEdit : Flag()) | (data.vis_pinned().v ? Flag::Pinned : Flag()) | (data.vreply_to() ? Flag::HasReplyInfo : Flag()) | (data.vreply_markup() ? Flag::HasReplyMarkup : Flag()) - | (data.vcan_get_added_reactions().v - ? Flag::CanViewReactions - : Flag()) | (views ? Flag::HasViews : Flag()) | (invertMedia ? Flag::InvertMedia : Flag()); } diff --git a/Telegram/SourceFiles/history/history_item_reply_markup.cpp b/Telegram/SourceFiles/history/history_item_reply_markup.cpp index a22cee3eff949f..10ab021864cd5e 100644 --- a/Telegram/SourceFiles/history/history_item_reply_markup.cpp +++ b/Telegram/SourceFiles/history/history_item_reply_markup.cpp @@ -405,6 +405,8 @@ auto HistoryMessageMarkupData::buttonData( }; }, [&](const TLDinlineKeyboardButtonTypeWebApp &data) { return ButtonData{ Type::WebView, data.vurl().v.toUtf8() }; + }, [&](const TLDinlineKeyboardButtonTypeCopyText &data) { + return ButtonData{ Type::CopyText, data.vtext().v.toUtf8() }; }); } diff --git a/Telegram/SourceFiles/history/view/history_view_contact_status.cpp b/Telegram/SourceFiles/history/view/history_view_contact_status.cpp index 46ed4156a20776..b5924ced44434a 100644 --- a/Telegram/SourceFiles/history/view/history_view_contact_status.cpp +++ b/Telegram/SourceFiles/history/view/history_view_contact_status.cpp @@ -760,9 +760,9 @@ void ContactStatus::setupReportHandler(not_null peer) { #endif peer->session().sender().request(TLreportChat( peerToTdbChat(peer->id), - tl_vector(), - tl_reportReasonSpam(), - tl_string() + tl_bytes(), // option_id + tl_vector(), // message_ids + tl_string() // text )).send(); crl::on_main(&peer->session(), [=] { diff --git a/Telegram/SourceFiles/history/view/history_view_group_call_bar.cpp b/Telegram/SourceFiles/history/view/history_view_group_call_bar.cpp index 50f5bea8c7ad6d..152937a6405cbd 100644 --- a/Telegram/SourceFiles/history/view/history_view_group_call_bar.cpp +++ b/Telegram/SourceFiles/history/view/history_view_group_call_bar.cpp @@ -353,7 +353,8 @@ rpl::producer GroupCallBarContentByCall( .speaking = speaker.speaking, }; userpic.peer->loadUserpic(); - auto image = userpic.peer->generateUserpicImage( + auto image = PeerData::GenerateUserpicImage( + userpic.peer, userpic.view, userpicSize); userpic.uniqueKey = userpic.peer->userpicUniqueKey( 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 e0b8eb860e72d3..b0330a02fb7e8a 100644 --- a/Telegram/SourceFiles/history/view/media/history_view_premium_gift.cpp +++ b/Telegram/SourceFiles/history/view/media/history_view_premium_gift.cpp @@ -47,7 +47,7 @@ PremiumGift::PremiumGift( DocumentData *document) : _parent(parent) , _gift(gift) -, _data(gift->data()) +, _data(*gift->gift()) , _document(document) { } 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) {