From f8e913c67549e9ea3906a6ada1f08d464ae29232 Mon Sep 17 00:00:00 2001 From: John Preston Date: Wed, 23 Oct 2024 18:36:52 +0400 Subject: [PATCH] wip --- .../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 +- 39 files changed, 516 insertions(+), 172 deletions(-) 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) {