From a333615e539dbbcd4417b8015217c46b7eb8f67f Mon Sep 17 00:00:00 2001 From: John Preston Date: Fri, 1 Nov 2024 16:43:36 +0400 Subject: [PATCH] Add message link to channel star transaction info. --- Telegram/Resources/langs/lang.strings | 1 + Telegram/SourceFiles/api/api_credits.cpp | 5 ++++- Telegram/SourceFiles/boxes/gift_premium_box.cpp | 4 +++- Telegram/SourceFiles/data/data_credits.h | 1 + .../info/statistics/info_statistics_list_controllers.cpp | 5 ++++- Telegram/SourceFiles/settings/settings_credits_graphics.cpp | 2 ++ 6 files changed, 15 insertions(+), 3 deletions(-) diff --git a/Telegram/Resources/langs/lang.strings b/Telegram/Resources/langs/lang.strings index 1da6e2be3..330f90d70 100644 --- a/Telegram/Resources/langs/lang.strings +++ b/Telegram/Resources/langs/lang.strings @@ -2467,6 +2467,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL "lng_credits_box_history_entry_success_date" = "Transaction date"; "lng_credits_box_history_entry_success_url" = "Transaction link"; "lng_credits_box_history_entry_media" = "Media"; +"lng_credits_box_history_entry_message" = "Message"; "lng_credits_box_history_entry_about" = "You can dispute this transaction {link}."; "lng_credits_box_history_entry_about_link" = "here"; "lng_credits_box_history_entry_reaction_name" = "Star Reaction"; diff --git a/Telegram/SourceFiles/api/api_credits.cpp b/Telegram/SourceFiles/api/api_credits.cpp index 6c0a7324a..ddff600b5 100644 --- a/Telegram/SourceFiles/api/api_credits.cpp +++ b/Telegram/SourceFiles/api/api_credits.cpp @@ -73,7 +73,9 @@ constexpr auto kTransactionsLimit = 100; return PeerId(0); }).value; const auto stargift = tl.data().vstargift(); + const auto reaction = tl.data().is_reaction(); const auto incoming = (int64(tl.data().vstars().v) >= 0); + const auto saveActorId = (reaction || !extended.empty()) && incoming; return Data::CreditsHistoryEntry{ .id = qs(tl.data().vid()), .title = qs(tl.data().vtitle().value_or_empty()), @@ -83,12 +85,13 @@ constexpr auto kTransactionsLimit = 100; .extended = std::move(extended), .credits = tl.data().vstars().v, .bareMsgId = uint64(tl.data().vmsg_id().value_or_empty()), - .barePeerId = barePeerId, + .barePeerId = saveActorId ? peer->id.value : barePeerId, .bareGiveawayMsgId = uint64( tl.data().vgiveaway_post_id().value_or_empty()), .bareGiftStickerId = (stargift ? owner->processDocument(stargift->data().vsticker())->id : 0), + .bareActorId = saveActorId ? barePeerId : uint64(0), .peerType = tl.data().vpeer().match([](const HistoryPeerTL &) { return Data::CreditsHistoryEntry::PeerType::Peer; }, [](const MTPDstarsTransactionPeerPlayMarket &) { diff --git a/Telegram/SourceFiles/boxes/gift_premium_box.cpp b/Telegram/SourceFiles/boxes/gift_premium_box.cpp index d1bdd9bf1..d0cc2c746 100644 --- a/Telegram/SourceFiles/boxes/gift_premium_box.cpp +++ b/Telegram/SourceFiles/boxes/gift_premium_box.cpp @@ -1168,7 +1168,9 @@ void AddCreditsHistoryEntryTable( }); AddTableRow( table, - tr::lng_credits_box_history_entry_media(), + (entry.reaction + ? tr::lng_credits_box_history_entry_message + : tr::lng_credits_box_history_entry_media)(), std::move(label), st::giveawayGiftCodeValueMargin); } diff --git a/Telegram/SourceFiles/data/data_credits.h b/Telegram/SourceFiles/data/data_credits.h index 3b99031f8..28817376c 100644 --- a/Telegram/SourceFiles/data/data_credits.h +++ b/Telegram/SourceFiles/data/data_credits.h @@ -62,6 +62,7 @@ struct CreditsHistoryEntry final { uint64 barePeerId = 0; uint64 bareGiveawayMsgId = 0; uint64 bareGiftStickerId = 0; + uint64 bareActorId = 0; PeerType peerType; QDateTime subscriptionUntil; QDateTime successDate; diff --git a/Telegram/SourceFiles/info/statistics/info_statistics_list_controllers.cpp b/Telegram/SourceFiles/info/statistics/info_statistics_list_controllers.cpp index 962096502..b342ad077 100644 --- a/Telegram/SourceFiles/info/statistics/info_statistics_list_controllers.cpp +++ b/Telegram/SourceFiles/info/statistics/info_statistics_list_controllers.cpp @@ -1080,7 +1080,10 @@ void CreditsController::applySlice(const Data::CreditsStatusSlice &slice) { delegate()->peerListUpdateRow(row); }, }; - if (const auto peerId = PeerId(i.barePeerId + s.barePeerId)) { + if (i.bareActorId) { + const auto peer = session().data().peer(PeerId(i.bareActorId)); + return std::make_unique(peer, descriptor); + } else if (const auto peerId = PeerId(i.barePeerId + s.barePeerId)) { const auto peer = session().data().peer(peerId); return std::make_unique(peer, descriptor); } else { diff --git a/Telegram/SourceFiles/settings/settings_credits_graphics.cpp b/Telegram/SourceFiles/settings/settings_credits_graphics.cpp index 6d0677348..6f50c871f 100644 --- a/Telegram/SourceFiles/settings/settings_credits_graphics.cpp +++ b/Telegram/SourceFiles/settings/settings_credits_graphics.cpp @@ -786,6 +786,8 @@ void ReceiptCreditsBox( ? session->data().peer(PeerId(s.barePeerId)).get() : (e.peerType == Type::PremiumBot) ? nullptr + : e.bareActorId + ? session->data().peer(PeerId(e.bareActorId)).get() : e.barePeerId ? session->data().peer(PeerId(e.barePeerId)).get() : nullptr;