Update API scheme to layer 184.
This commit is contained in:
parent
5b9278eced
commit
c6e1cf639e
|
@ -1889,6 +1889,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
"lng_action_boost_apply#one" = "{from} boosted the group";
|
||||
"lng_action_boost_apply#other" = "{from} boosted the group {count} times";
|
||||
"lng_action_set_chat_intro" = "{from} added the message below for all empty chats. How?";
|
||||
"lng_action_payment_refunded" = "{peer} refunded back {amount}";
|
||||
|
||||
"lng_similar_channels_title" = "Similar channels";
|
||||
"lng_similar_channels_view_all" = "View all";
|
||||
|
|
|
@ -1515,6 +1515,13 @@ ServiceAction ParseServiceAction(
|
|||
result.content = content;
|
||||
}, [&](const MTPDmessageActionRequestedPeerSentMe &data) {
|
||||
// Should not be in user inbox.
|
||||
}, [&](const MTPDmessageActionPaymentRefunded &data) {
|
||||
auto content = ActionPaymentRefunded();
|
||||
content.currency = ParseString(data.vcurrency());
|
||||
content.amount = data.vtotal_amount().v;
|
||||
content.peerId = ParsePeerId(data.vpeer());
|
||||
content.transactionId = data.vcharge().data().vid().v;
|
||||
result.content = content;
|
||||
}, [](const MTPDmessageActionEmpty &data) {});
|
||||
return result;
|
||||
}
|
||||
|
|
|
@ -576,6 +576,13 @@ struct ActionBoostApply {
|
|||
int boosts = 0;
|
||||
};
|
||||
|
||||
struct ActionPaymentRefunded {
|
||||
PeerId peerId = 0;
|
||||
Utf8String currency;
|
||||
uint64 amount = 0;
|
||||
Utf8String transactionId;
|
||||
};
|
||||
|
||||
struct ServiceAction {
|
||||
std::variant<
|
||||
v::null_t,
|
||||
|
@ -617,7 +624,8 @@ struct ServiceAction {
|
|||
ActionGiftCode,
|
||||
ActionGiveawayLaunch,
|
||||
ActionGiveawayResults,
|
||||
ActionBoostApply> content;
|
||||
ActionBoostApply,
|
||||
ActionPaymentRefunded> content;
|
||||
};
|
||||
|
||||
ServiceAction ParseServiceAction(
|
||||
|
|
|
@ -1315,6 +1315,12 @@ auto HtmlWriter::Wrap::pushMessage(
|
|||
+ " boosted the group "
|
||||
+ QByteArray::number(data.boosts)
|
||||
+ (data.boosts > 1 ? " times" : " time");
|
||||
}, [&](const ActionPaymentRefunded &data) {
|
||||
const auto amount = FormatMoneyAmount(data.amount, data.currency);
|
||||
auto result = peers.wrapPeerName(data.peerId)
|
||||
+ " refunded back "
|
||||
+ amount;
|
||||
return result;
|
||||
}, [](v::null_t) { return QByteArray(); });
|
||||
|
||||
if (!serviceText.isEmpty()) {
|
||||
|
|
|
@ -625,6 +625,13 @@ QByteArray SerializeMessage(
|
|||
pushActor();
|
||||
pushAction("boost_apply");
|
||||
push("boosts", data.boosts);
|
||||
}, [&](const ActionPaymentRefunded &data) {
|
||||
pushAction("refunded_payment");
|
||||
push("amount", data.amount);
|
||||
push("currency", data.currency);
|
||||
pushBare("peer_name", wrapPeerName(data.peerId));
|
||||
push("peer_id", data.peerId);
|
||||
push("charge_id", data.transactionId);
|
||||
}, [](v::null_t) {});
|
||||
|
||||
if (v::is_null(message.action.content)) {
|
||||
|
|
|
@ -23,6 +23,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
#include "ui/text/format_values.h"
|
||||
#include "ui/text/text_isolated_emoji.h"
|
||||
#include "ui/text/text_utilities.h"
|
||||
#include "settings/settings_credits_graphics.h" // ShowRefundInfoBox.
|
||||
#include "storage/file_upload.h"
|
||||
#include "storage/storage_shared_media.h"
|
||||
#include "main/main_account.h"
|
||||
|
@ -4028,6 +4029,22 @@ void HistoryItem::createServiceFromMtp(const MTPDmessageService &message) {
|
|||
}
|
||||
} else if (type == mtpc_messageActionGiveawayResults) {
|
||||
UpdateComponents(HistoryServiceGiveawayResults::Bit());
|
||||
} else if (type == mtpc_messageActionPaymentRefunded) {
|
||||
const auto &data = action.c_messageActionPaymentRefunded();
|
||||
UpdateComponents(HistoryServicePaymentRefund::Bit());
|
||||
const auto refund = Get<HistoryServicePaymentRefund>();
|
||||
refund->peer = _history->owner().peer(peerFromMTP(data.vpeer()));
|
||||
refund->amount = data.vtotal_amount().v;
|
||||
refund->currency = qs(data.vcurrency());
|
||||
refund->transactionId = qs(data.vcharge().data().vid());
|
||||
const auto id = fullId();
|
||||
refund->link = std::make_shared<LambdaClickHandler>([=](
|
||||
ClickContext context) {
|
||||
const auto my = context.other.value<ClickHandlerContext>();
|
||||
if (const auto window = my.sessionWindow.get()) {
|
||||
Settings::ShowRefundInfoBox(window, id);
|
||||
}
|
||||
});
|
||||
}
|
||||
if (const auto replyTo = message.vreply_to()) {
|
||||
replyTo->match([&](const MTPDmessageReplyHeader &data) {
|
||||
|
@ -4941,6 +4958,25 @@ void HistoryItem::setServiceMessageByAction(const MTPmessageAction &action) {
|
|||
return result;
|
||||
};
|
||||
|
||||
auto preparePaymentRefunded = [&](const MTPDmessageActionPaymentRefunded &action) {
|
||||
auto result = PreparedServiceText();
|
||||
const auto refund = Get<HistoryServicePaymentRefund>();
|
||||
Assert(refund != nullptr);
|
||||
Assert(refund->peer != nullptr);
|
||||
|
||||
const auto amount = refund->amount;
|
||||
const auto currency = refund->currency;
|
||||
result.links.push_back(refund->peer->createOpenLink());
|
||||
result.text = tr::lng_action_payment_refunded(
|
||||
tr::now,
|
||||
lt_peer,
|
||||
Ui::Text::Link(refund->peer->name(), 1), // Link 1.
|
||||
lt_amount,
|
||||
{ Ui::FillAmountAndCurrency(amount, currency) },
|
||||
Ui::Text::WithEntities);
|
||||
return result;
|
||||
};
|
||||
|
||||
setServiceText(action.match(
|
||||
prepareChatAddUserText,
|
||||
prepareChatJoinedByLink,
|
||||
|
@ -4983,6 +5019,7 @@ void HistoryItem::setServiceMessageByAction(const MTPmessageAction &action) {
|
|||
prepareGiveawayLaunch,
|
||||
prepareGiveawayResults,
|
||||
prepareBoostApply,
|
||||
preparePaymentRefunded,
|
||||
PrepareEmptyText<MTPDmessageActionRequestedPeerSentMe>,
|
||||
PrepareErrorText<MTPDmessageActionEmpty>));
|
||||
|
||||
|
|
|
@ -671,6 +671,15 @@ struct HistoryServiceCustomLink
|
|||
ClickHandlerPtr link;
|
||||
};
|
||||
|
||||
struct HistoryServicePaymentRefund
|
||||
: public RuntimeComponent<HistoryServicePaymentRefund, HistoryItem> {
|
||||
ClickHandlerPtr link;
|
||||
PeerData *peer = nullptr;
|
||||
QString transactionId;
|
||||
QString currency;
|
||||
uint64 amount = 0;
|
||||
};
|
||||
|
||||
enum class HistorySelfDestructType {
|
||||
Photo,
|
||||
Video,
|
||||
|
|
|
@ -679,6 +679,8 @@ TextState Service::textState(QPoint point, StateRequest request) const {
|
|||
result.link = results->lnk;
|
||||
} else if (const auto custom = item->Get<HistoryServiceCustomLink>()) {
|
||||
result.link = custom->link;
|
||||
} else if (const auto payment = item->Get<HistoryServicePaymentRefund>()) {
|
||||
result.link = payment->link;
|
||||
} else if (media && data()->showSimilarChannels()) {
|
||||
result = media->textState(mediaPoint, request);
|
||||
}
|
||||
|
|
|
@ -102,7 +102,7 @@ channel#aadfc8f flags:# creator:flags.0?true left:flags.2?true broadcast:flags.5
|
|||
channelForbidden#17d493d5 flags:# broadcast:flags.5?true megagroup:flags.8?true id:long access_hash:long title:string until_date:flags.16?int = Chat;
|
||||
|
||||
chatFull#2633421b flags:# can_set_username:flags.7?true has_scheduled:flags.8?true translations_disabled:flags.19?true id:long about:string participants:ChatParticipants chat_photo:flags.2?Photo notify_settings:PeerNotifySettings exported_invite:flags.13?ExportedChatInvite bot_info:flags.3?Vector<BotInfo> pinned_msg_id:flags.6?int folder_id:flags.11?int call:flags.12?InputGroupCall ttl_period:flags.14?int groupcall_default_join_as:flags.15?Peer theme_emoticon:flags.16?string requests_pending:flags.17?int recent_requesters:flags.17?Vector<long> available_reactions:flags.18?ChatReactions reactions_limit:flags.20?int = ChatFull;
|
||||
channelFull#bbab348d flags:# can_view_participants:flags.3?true can_set_username:flags.6?true can_set_stickers:flags.7?true hidden_prehistory:flags.10?true can_set_location:flags.16?true has_scheduled:flags.19?true can_view_stats:flags.20?true blocked:flags.22?true flags2:# can_delete_channel:flags2.0?true antispam:flags2.1?true participants_hidden:flags2.2?true translations_disabled:flags2.3?true stories_pinned_available:flags2.5?true view_forum_as_messages:flags2.6?true restricted_sponsored:flags2.11?true can_view_revenue:flags2.12?true paid_media_allowed:flags2.14?true id:long about:string participants_count:flags.0?int admins_count:flags.1?int kicked_count:flags.2?int banned_count:flags.2?int online_count:flags.13?int read_inbox_max_id:int read_outbox_max_id:int unread_count:int chat_photo:Photo notify_settings:PeerNotifySettings exported_invite:flags.23?ExportedChatInvite bot_info:Vector<BotInfo> migrated_from_chat_id:flags.4?long migrated_from_max_id:flags.4?int pinned_msg_id:flags.5?int stickerset:flags.8?StickerSet available_min_id:flags.9?int folder_id:flags.11?int linked_chat_id:flags.14?long location:flags.15?ChannelLocation slowmode_seconds:flags.17?int slowmode_next_send_date:flags.18?int stats_dc:flags.12?int pts:int call:flags.21?InputGroupCall ttl_period:flags.24?int pending_suggestions:flags.25?Vector<string> groupcall_default_join_as:flags.26?Peer theme_emoticon:flags.27?string requests_pending:flags.28?int recent_requesters:flags.28?Vector<long> default_send_as:flags.29?Peer available_reactions:flags.30?ChatReactions reactions_limit:flags2.13?int stories:flags2.4?PeerStories wallpaper:flags2.7?WallPaper boosts_applied:flags2.8?int boosts_unrestrict:flags2.9?int emojiset:flags2.10?StickerSet = ChatFull;
|
||||
channelFull#bbab348d flags:# can_view_participants:flags.3?true can_set_username:flags.6?true can_set_stickers:flags.7?true hidden_prehistory:flags.10?true can_set_location:flags.16?true has_scheduled:flags.19?true can_view_stats:flags.20?true blocked:flags.22?true flags2:# can_delete_channel:flags2.0?true antispam:flags2.1?true participants_hidden:flags2.2?true translations_disabled:flags2.3?true stories_pinned_available:flags2.5?true view_forum_as_messages:flags2.6?true restricted_sponsored:flags2.11?true can_view_revenue:flags2.12?true paid_media_allowed:flags2.14?true can_view_stars_revenue:flags2.15?true id:long about:string participants_count:flags.0?int admins_count:flags.1?int kicked_count:flags.2?int banned_count:flags.2?int online_count:flags.13?int read_inbox_max_id:int read_outbox_max_id:int unread_count:int chat_photo:Photo notify_settings:PeerNotifySettings exported_invite:flags.23?ExportedChatInvite bot_info:Vector<BotInfo> migrated_from_chat_id:flags.4?long migrated_from_max_id:flags.4?int pinned_msg_id:flags.5?int stickerset:flags.8?StickerSet available_min_id:flags.9?int folder_id:flags.11?int linked_chat_id:flags.14?long location:flags.15?ChannelLocation slowmode_seconds:flags.17?int slowmode_next_send_date:flags.18?int stats_dc:flags.12?int pts:int call:flags.21?InputGroupCall ttl_period:flags.24?int pending_suggestions:flags.25?Vector<string> groupcall_default_join_as:flags.26?Peer theme_emoticon:flags.27?string requests_pending:flags.28?int recent_requesters:flags.28?Vector<long> default_send_as:flags.29?Peer available_reactions:flags.30?ChatReactions reactions_limit:flags2.13?int stories:flags2.4?PeerStories wallpaper:flags2.7?WallPaper boosts_applied:flags2.8?int boosts_unrestrict:flags2.9?int emojiset:flags2.10?StickerSet = ChatFull;
|
||||
|
||||
chatParticipant#c02d4007 user_id:long inviter_id:long date:int = ChatParticipant;
|
||||
chatParticipantCreator#e46bcee4 user_id:long = ChatParticipant;
|
||||
|
@ -179,6 +179,7 @@ messageActionGiveawayLaunch#332ba9ed = MessageAction;
|
|||
messageActionGiveawayResults#2a9fadc5 winners_count:int unclaimed_count:int = MessageAction;
|
||||
messageActionBoostApply#cc02aa6d boosts:int = MessageAction;
|
||||
messageActionRequestedPeerSentMe#93b31848 button_id:int peers:Vector<RequestedPeer> = MessageAction;
|
||||
messageActionPaymentRefunded#41b3e202 flags:# peer:Peer currency:string total_amount:long payload:flags.0?bytes charge:PaymentCharge = MessageAction;
|
||||
|
||||
dialog#d58a08c6 flags:# pinned:flags.2?true unread_mark:flags.3?true view_forum_as_messages:flags.6?true peer:Peer top_message:int read_inbox_max_id:int read_outbox_max_id:int unread_count:int unread_mentions_count:int unread_reactions_count:int notify_settings:PeerNotifySettings pts:flags.0?int draft:flags.1?DraftMessage folder_id:flags.4?int ttl_period:flags.5?int = Dialog;
|
||||
dialogFolder#71bd134c flags:# pinned:flags.2?true folder:Folder peer:Peer top_message:int unread_muted_peers_count:int unread_unmuted_peers_count:int unread_muted_messages_count:int unread_unmuted_messages_count:int = Dialog;
|
||||
|
@ -2493,4 +2494,4 @@ smsjobs.finishJob#4f1ebf24 flags:# job_id:string error:flags.0?string = Bool;
|
|||
|
||||
fragment.getCollectibleInfo#be1e85ba collectible:InputCollectible = fragment.CollectibleInfo;
|
||||
|
||||
// LAYER 183
|
||||
// LAYER 184
|
||||
|
|
|
@ -23,6 +23,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
#include "data/stickers/data_custom_emoji.h"
|
||||
#include "history/history.h"
|
||||
#include "history/history_item.h"
|
||||
#include "history/history_item_components.h" // HistoryServicePaymentRefund.
|
||||
#include "info/settings/info_settings_widget.h" // SectionCustomTopBarData.
|
||||
#include "info/statistics/info_statistics_list_controllers.h"
|
||||
#include "lang/lang_keys.h"
|
||||
|
@ -633,6 +634,33 @@ void ReceiptCreditsBox(
|
|||
}, button->lifetime());
|
||||
}
|
||||
|
||||
void ShowRefundInfoBox(
|
||||
not_null<Window::SessionController*> controller,
|
||||
FullMsgId refundItemId) {
|
||||
const auto owner = &controller->session().data();
|
||||
const auto item = owner->message(refundItemId);
|
||||
const auto refund = item
|
||||
? item->Get<HistoryServicePaymentRefund>()
|
||||
: nullptr;
|
||||
if (!refund) {
|
||||
return;
|
||||
}
|
||||
Assert(refund->peer != nullptr);
|
||||
auto info = Data::CreditsHistoryEntry();
|
||||
info.id = refund->transactionId;
|
||||
info.date = base::unixtime::parse(item->date());
|
||||
info.credits = refund->amount;
|
||||
info.barePeerId = refund->peer->id.value;
|
||||
info.peerType = Data::CreditsHistoryEntry::PeerType::Peer;
|
||||
info.refunded = true;
|
||||
info.in = true;
|
||||
controller->show(Box(
|
||||
::Settings::ReceiptCreditsBox,
|
||||
controller,
|
||||
nullptr, // premiumBot
|
||||
info));
|
||||
}
|
||||
|
||||
object_ptr<Ui::RpWidget> GenericEntryPhoto(
|
||||
not_null<Ui::RpWidget*> parent,
|
||||
Fn<Fn<void(Painter &, int, int, int, int)>(Fn<void()>)> callback,
|
||||
|
|
|
@ -54,6 +54,9 @@ void ReceiptCreditsBox(
|
|||
not_null<Window::SessionController*> controller,
|
||||
PeerData *premiumBot,
|
||||
const Data::CreditsHistoryEntry &e);
|
||||
void ShowRefundInfoBox(
|
||||
not_null<Window::SessionController*> controller,
|
||||
FullMsgId refundItemId);
|
||||
|
||||
[[nodiscard]] object_ptr<Ui::RpWidget> GenericEntryPhoto(
|
||||
not_null<Ui::RpWidget*> parent,
|
||||
|
|
Loading…
Reference in New Issue