Add message link to channel star transaction info.

This commit is contained in:
John Preston 2024-11-01 16:43:36 +04:00
parent e1b33fbc40
commit a333615e53
6 changed files with 15 additions and 3 deletions

View File

@ -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_date" = "Transaction date";
"lng_credits_box_history_entry_success_url" = "Transaction link"; "lng_credits_box_history_entry_success_url" = "Transaction link";
"lng_credits_box_history_entry_media" = "Media"; "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" = "You can dispute this transaction {link}.";
"lng_credits_box_history_entry_about_link" = "here"; "lng_credits_box_history_entry_about_link" = "here";
"lng_credits_box_history_entry_reaction_name" = "Star Reaction"; "lng_credits_box_history_entry_reaction_name" = "Star Reaction";

View File

@ -73,7 +73,9 @@ constexpr auto kTransactionsLimit = 100;
return PeerId(0); return PeerId(0);
}).value; }).value;
const auto stargift = tl.data().vstargift(); const auto stargift = tl.data().vstargift();
const auto reaction = tl.data().is_reaction();
const auto incoming = (int64(tl.data().vstars().v) >= 0); const auto incoming = (int64(tl.data().vstars().v) >= 0);
const auto saveActorId = (reaction || !extended.empty()) && incoming;
return Data::CreditsHistoryEntry{ return Data::CreditsHistoryEntry{
.id = qs(tl.data().vid()), .id = qs(tl.data().vid()),
.title = qs(tl.data().vtitle().value_or_empty()), .title = qs(tl.data().vtitle().value_or_empty()),
@ -83,12 +85,13 @@ constexpr auto kTransactionsLimit = 100;
.extended = std::move(extended), .extended = std::move(extended),
.credits = tl.data().vstars().v, .credits = tl.data().vstars().v,
.bareMsgId = uint64(tl.data().vmsg_id().value_or_empty()), .bareMsgId = uint64(tl.data().vmsg_id().value_or_empty()),
.barePeerId = barePeerId, .barePeerId = saveActorId ? peer->id.value : barePeerId,
.bareGiveawayMsgId = uint64( .bareGiveawayMsgId = uint64(
tl.data().vgiveaway_post_id().value_or_empty()), tl.data().vgiveaway_post_id().value_or_empty()),
.bareGiftStickerId = (stargift .bareGiftStickerId = (stargift
? owner->processDocument(stargift->data().vsticker())->id ? owner->processDocument(stargift->data().vsticker())->id
: 0), : 0),
.bareActorId = saveActorId ? barePeerId : uint64(0),
.peerType = tl.data().vpeer().match([](const HistoryPeerTL &) { .peerType = tl.data().vpeer().match([](const HistoryPeerTL &) {
return Data::CreditsHistoryEntry::PeerType::Peer; return Data::CreditsHistoryEntry::PeerType::Peer;
}, [](const MTPDstarsTransactionPeerPlayMarket &) { }, [](const MTPDstarsTransactionPeerPlayMarket &) {

View File

@ -1168,7 +1168,9 @@ void AddCreditsHistoryEntryTable(
}); });
AddTableRow( AddTableRow(
table, 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), std::move(label),
st::giveawayGiftCodeValueMargin); st::giveawayGiftCodeValueMargin);
} }

View File

@ -62,6 +62,7 @@ struct CreditsHistoryEntry final {
uint64 barePeerId = 0; uint64 barePeerId = 0;
uint64 bareGiveawayMsgId = 0; uint64 bareGiveawayMsgId = 0;
uint64 bareGiftStickerId = 0; uint64 bareGiftStickerId = 0;
uint64 bareActorId = 0;
PeerType peerType; PeerType peerType;
QDateTime subscriptionUntil; QDateTime subscriptionUntil;
QDateTime successDate; QDateTime successDate;

View File

@ -1080,7 +1080,10 @@ void CreditsController::applySlice(const Data::CreditsStatusSlice &slice) {
delegate()->peerListUpdateRow(row); 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<CreditsRow>(peer, descriptor);
} else if (const auto peerId = PeerId(i.barePeerId + s.barePeerId)) {
const auto peer = session().data().peer(peerId); const auto peer = session().data().peer(peerId);
return std::make_unique<CreditsRow>(peer, descriptor); return std::make_unique<CreditsRow>(peer, descriptor);
} else { } else {

View File

@ -786,6 +786,8 @@ void ReceiptCreditsBox(
? session->data().peer(PeerId(s.barePeerId)).get() ? session->data().peer(PeerId(s.barePeerId)).get()
: (e.peerType == Type::PremiumBot) : (e.peerType == Type::PremiumBot)
? nullptr ? nullptr
: e.bareActorId
? session->data().peer(PeerId(e.bareActorId)).get()
: e.barePeerId : e.barePeerId
? session->data().peer(PeerId(e.barePeerId)).get() ? session->data().peer(PeerId(e.barePeerId)).get()
: nullptr; : nullptr;