From a7d8d28895f5312ea134f5db291f3828275e9253 Mon Sep 17 00:00:00 2001 From: levlam Date: Thu, 22 Sep 2022 01:46:12 +0300 Subject: [PATCH] Add td_api::messageExtendedMedia. --- CMakeLists.txt | 3 + td/generate/scheme/td_api.tl | 27 ++++- td/telegram/MessageContent.cpp | 11 +- td/telegram/MessageExtendedMedia.cpp | 164 +++++++++++++++++++++++++++ td/telegram/MessageExtendedMedia.h | 65 +++++++++++ td/telegram/MessageExtendedMedia.hpp | 110 ++++++++++++++++++ td/telegram/Payments.cpp | 23 +++- td/telegram/Payments.h | 9 +- td/telegram/Payments.hpp | 12 ++ 9 files changed, 408 insertions(+), 16 deletions(-) create mode 100644 td/telegram/MessageExtendedMedia.cpp create mode 100644 td/telegram/MessageExtendedMedia.h create mode 100644 td/telegram/MessageExtendedMedia.hpp diff --git a/CMakeLists.txt b/CMakeLists.txt index e8b8af387..ec69d6f9e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -372,6 +372,7 @@ set(TDLIB_SOURCE td/telegram/MessageContent.cpp td/telegram/MessageContentType.cpp td/telegram/MessageEntity.cpp + td/telegram/MessageExtendedMedia.cpp td/telegram/MessageId.cpp td/telegram/MessageReaction.cpp td/telegram/MessageReplyInfo.cpp @@ -598,6 +599,7 @@ set(TDLIB_SOURCE td/telegram/MessageContentType.h td/telegram/MessageCopyOptions.h td/telegram/MessageEntity.h + td/telegram/MessageExtendedMedia.h td/telegram/MessageId.h td/telegram/MessageLinkInfo.h td/telegram/MessageReaction.h @@ -729,6 +731,7 @@ set(TDLIB_SOURCE td/telegram/Game.hpp td/telegram/InputMessageText.hpp td/telegram/MessageEntity.hpp + td/telegram/MessageExtendedMedia.hpp td/telegram/MessageReaction.hpp td/telegram/MessageReplyInfo.hpp td/telegram/MinChannel.hpp diff --git a/td/generate/scheme/td_api.tl b/td/generate/scheme/td_api.tl index 524c6e9d0..924aa39fa 100644 --- a/td/generate/scheme/td_api.tl +++ b/td/generate/scheme/td_api.tl @@ -479,6 +479,7 @@ chatAdministratorRights can_manage_chat:Bool can_change_info:Bool can_post_messa //@payment_link An internal link to be opened for buying Telegram Premium to the user if store payment isn't possible; may be null if direct payment isn't available premiumPaymentOption currency:string amount:int53 discount_percentage:int32 month_count:int32 store_product_id:string payment_link:InternalLinkType = PremiumPaymentOption; + //@description Describes a custom emoji to be shown instead of the Telegram Premium badge @custom_emoji_id Identifier of the custom emoji in stickerFormatTgs format. If the custom emoji belongs to the sticker set GetOption("themed_emoji_statuses_sticker_set_id"), then it's color must be changed to the color of the Telegram Premium badge emojiStatus custom_emoji_id:int64 = EmojiStatus; @@ -1634,7 +1635,7 @@ paymentResult success:Bool verification_url:string = PaymentResult; paymentReceipt title:string description:formattedText photo:photo date:int32 seller_bot_user_id:int53 payment_provider_user_id:int53 invoice:invoice order_info:orderInfo shipping_option:shippingOption credentials_title:string tip_amount:int53 = PaymentReceipt; -//@class InputInvoice @description Describe an invoice to process +//@class InputInvoice @description Describes an invoice to process //@description An invoice from a message of the type messageInvoice @chat_id Chat identifier of the message @message_id Message identifier inputInvoiceMessage chat_id:int53 message_id:int53 = InputInvoice; @@ -1643,6 +1644,27 @@ inputInvoiceMessage chat_id:int53 message_id:int53 = InputInvoice; inputInvoiceName name:string = InputInvoice; +//@class MessageExtendedMedia @description Describes a media, which is attached to an invoice + +//@description The media is hidden until the invoice is paid +//@width Media width; 0 if unknown +//@height Media height; 0 if unknown +//@duration Media duration; 0 if unknown +//@minithumbnail Media minithumbnail; may be null +//@caption Media caption +messageExtendedMediaPreview width:int32 height:int32 duration:int32 minithumbnail:minithumbnail caption:formattedText = MessageExtendedMedia; + +//@description The media is a photo @photo The photo @caption Photo caption +messageExtendedMediaPhoto photo:photo caption:formattedText = MessageExtendedMedia; + +//@description The media is a video @video The video @caption Photo caption +messageExtendedMediaVideo video:video caption:formattedText = MessageExtendedMedia; + +//@description The media is unuspported @caption Media caption +messageExtendedMediaUnsupported caption:formattedText = MessageExtendedMedia; + + + //@description File with the date it was uploaded @file The file @date Point in time (Unix timestamp) when the file was uploaded datedFile file:file date:int32 = DatedFile; @@ -1960,7 +1982,8 @@ messagePoll poll:poll = MessageContent; //@description A message with an invoice from a bot @title Product title @param_description Product description @photo Product photo; may be null @currency Currency for the product price @total_amount Product total price in the smallest units of the currency //@start_parameter Unique invoice bot start_parameter. To share an invoice use the URL https://t.me/{bot_username}?start={start_parameter} @is_test True, if the invoice is a test invoice //@need_shipping_address True, if the shipping address must be specified @receipt_message_id The identifier of the message with the receipt, after the product has been purchased -messageInvoice title:string description:formattedText photo:photo currency:string total_amount:int53 start_parameter:string is_test:Bool need_shipping_address:Bool receipt_message_id:int53 = MessageContent; +//@extended_media Extended media attached to the invoice; may be null +messageInvoice title:string description:formattedText photo:photo currency:string total_amount:int53 start_parameter:string is_test:Bool need_shipping_address:Bool receipt_message_id:int53 extended_media:MessageExtendedMedia = MessageContent; //@description A message with information about an ended call @is_video True, if the call was a video call @discard_reason Reason why the call was discarded @duration Call duration, in seconds messageCall is_video:Bool discard_reason:CallDiscardReason duration:int32 = MessageContent; diff --git a/td/telegram/MessageContent.cpp b/td/telegram/MessageContent.cpp index 028a8db73..7aaa81740 100644 --- a/td/telegram/MessageContent.cpp +++ b/td/telegram/MessageContent.cpp @@ -4465,15 +4465,16 @@ unique_ptr get_message_content(Td *td, FormattedText message, case telegram_api::messageMediaGame::ID: { auto media = move_tl_object_as(media_ptr); - auto m = make_unique(Game(td, via_bot_user_id, std::move(media->game_), message, owner_dialog_id)); + auto m = make_unique( + Game(td, via_bot_user_id, std::move(media->game_), std::move(message), owner_dialog_id)); if (m->game.is_empty()) { break; } return std::move(m); } case telegram_api::messageMediaInvoice::ID: - return td::make_unique( - get_input_invoice(move_tl_object_as(media_ptr), td, owner_dialog_id)); + return td::make_unique(get_input_invoice( + move_tl_object_as(media_ptr), td, owner_dialog_id, std::move(message))); case telegram_api::messageMediaWebPage::ID: { auto media = move_tl_object_as(media_ptr); if (disable_web_page_preview != nullptr) { @@ -5093,7 +5094,7 @@ tl_object_ptr get_message_content_object(const MessageCo } case MessageContentType::Invoice: { const auto *m = static_cast(content); - return get_message_invoice_object(m->input_invoice, td); + return get_message_invoice_object(m->input_invoice, td, skip_bot_commands, max_media_timestamp); } case MessageContentType::LiveLocation: { const auto *m = static_cast(content); @@ -5565,7 +5566,7 @@ vector get_message_content_file_ids(const MessageContent *content, const case MessageContentType::Game: return static_cast(content)->game.get_file_ids(td); case MessageContentType::Invoice: - return get_input_invoice_file_ids(static_cast(content)->input_invoice); + return get_input_invoice_file_ids(td, static_cast(content)->input_invoice); case MessageContentType::ChatChangePhoto: return photo_get_file_ids(static_cast(content)->photo); case MessageContentType::PassportDataReceived: { diff --git a/td/telegram/MessageExtendedMedia.cpp b/td/telegram/MessageExtendedMedia.cpp new file mode 100644 index 000000000..f85cf1d24 --- /dev/null +++ b/td/telegram/MessageExtendedMedia.cpp @@ -0,0 +1,164 @@ +// +// Copyright Aliaksei Levin (levlam@telegram.org), Arseny Smirnov (arseny30@gmail.com) 2014-2022 +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +#include "td/telegram/MessageExtendedMedia.h" + +#include "td/telegram/Document.h" +#include "td/telegram/DocumentsManager.h" +#include "td/telegram/Td.h" +#include "td/telegram/VideosManager.h" + +#include "td/utils/algorithm.h" + +namespace td { + +MessageExtendedMedia::MessageExtendedMedia( + Td *td, telegram_api::object_ptr &&extended_media, FormattedText &&caption, + DialogId owner_dialog_id) { + if (extended_media == nullptr) { + return; + } + caption_ = std::move(caption); + + switch (extended_media->get_id()) { + case telegram_api::messageExtendedMediaPreview::ID: { + auto media = move_tl_object_as(extended_media); + type_ = Type::Preview; + duration_ = media->video_duration_; + dimensions_ = get_dimensions(media->w_, media->h_, "MessageExtendedMedia"); + if (media->thumb_ != nullptr) { + if (media->thumb_->get_id() == telegram_api::photoStrippedSize::ID) { + auto thumb = move_tl_object_as(media->thumb_); + minithumbnail_ = thumb->bytes_.as_slice().str(); + } else { + LOG(ERROR) << "Receive " << to_string(media->thumb_); + } + } + break; + } + case telegram_api::messageExtendedMedia::ID: { + auto media = move_tl_object_as(extended_media); + type_ = Type::Unsupported; + switch (media->media_->get_id()) { + case telegram_api::messageMediaPhoto::ID: { + auto photo = move_tl_object_as(media->media_); + if (photo->photo_ == nullptr) { + break; + } + + photo_ = get_photo(td->file_manager_.get(), std::move(photo->photo_), owner_dialog_id); + if (photo_.is_empty()) { + break; + } + type_ = Type::Photo; + break; + } + case telegram_api::messageMediaDocument::ID: { + auto document = move_tl_object_as(media->media_); + if (document->document_ == nullptr) { + break; + } + + auto document_ptr = std::move(document->document_); + int32 document_id = document_ptr->get_id(); + if (document_id == telegram_api::documentEmpty::ID) { + break; + } + CHECK(document_id == telegram_api::document::ID); + + auto parsed_document = td->documents_manager_->on_get_document( + move_tl_object_as(document_ptr), owner_dialog_id, nullptr); + if (parsed_document.empty() || parsed_document.type != Document::Type::Video) { + break; + } + CHECK(parsed_document.file_id.is_valid()); + video_file_id_ = parsed_document.file_id; + type_ = Type::Video; + break; + } + default: + break; + } + break; + } + default: + UNREACHABLE(); + } +} + +td_api::object_ptr MessageExtendedMedia::get_message_extended_media_object( + Td *td, bool skip_bot_commands, int32 max_media_timestamp) const { + if (type_ == Type::Empty) { + return nullptr; + } + + auto caption = get_formatted_text_object(caption_, skip_bot_commands, max_media_timestamp); + switch (type_) { + case Type::Unsupported: + return td_api::make_object(std::move(caption)); + case Type::Preview: + return td_api::make_object(dimensions_.width, dimensions_.height, duration_, + get_minithumbnail_object(minithumbnail_), + std::move(caption)); + case Type::Photo: { + auto photo = get_photo_object(td->file_manager_.get(), photo_); + CHECK(photo != nullptr); + return td_api::make_object(std::move(photo), std::move(caption)); + } + case Type::Video: + return td_api::make_object( + td->videos_manager_->get_video_object(video_file_id_), std::move(caption)); + default: + UNREACHABLE(); + return nullptr; + } +} + +void MessageExtendedMedia::append_file_ids(const Td *td, vector &file_ids) const { + switch (type_) { + case Type::Empty: + case Type::Unsupported: + case Type::Preview: + break; + case Type::Photo: + append(file_ids, photo_get_file_ids(photo_)); + break; + case Type::Video: + Document(Document::Type::Video, video_file_id_).append_file_ids(td, file_ids); + break; + default: + UNREACHABLE(); + break; + } +} + +bool operator==(const MessageExtendedMedia &lhs, const MessageExtendedMedia &rhs) { + if (lhs.type_ != rhs.type_ || lhs.caption_ != rhs.caption_) { + return false; + } + switch (lhs.type_) { + case MessageExtendedMedia::Type::Empty: + return true; + case MessageExtendedMedia::Type::Unsupported: + return true; + case MessageExtendedMedia::Type::Preview: + return lhs.duration_ == rhs.duration_ && lhs.dimensions_ == rhs.dimensions_ && + lhs.minithumbnail_ == rhs.minithumbnail_; + case MessageExtendedMedia::Type::Photo: + return lhs.photo_ == rhs.photo_; + case MessageExtendedMedia::Type::Video: + return lhs.video_file_id_ == rhs.video_file_id_; + default: + UNREACHABLE(); + return true; + } +} + +bool operator!=(const MessageExtendedMedia &lhs, const MessageExtendedMedia &rhs) { + return !(lhs == rhs); +} + +} // namespace td diff --git a/td/telegram/MessageExtendedMedia.h b/td/telegram/MessageExtendedMedia.h new file mode 100644 index 000000000..1ce17d670 --- /dev/null +++ b/td/telegram/MessageExtendedMedia.h @@ -0,0 +1,65 @@ +// +// Copyright Aliaksei Levin (levlam@telegram.org), Arseny Smirnov (arseny30@gmail.com) 2014-2022 +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +#pragma once + +#include "td/telegram/Dimensions.h" +#include "td/telegram/files/FileId.h" +#include "td/telegram/MessageEntity.h" +#include "td/telegram/Photo.h" + +#include "td/utils/common.h" + +namespace td { + +class Dependencies; +class Td; + +class MessageExtendedMedia { + enum class Type : int32 { Empty, Unsupported, Preview, Photo, Video }; + Type type_ = Type::Empty; + FormattedText caption_; + + // for Preview + int32 duration_ = 0; + Dimensions dimensions_; + string minithumbnail_; + + // for Photo + Photo photo_; + + // for Video + FileId video_file_id_; + + friend bool operator==(const MessageExtendedMedia &lhs, const MessageExtendedMedia &rhs); + + public: + MessageExtendedMedia() = default; + + MessageExtendedMedia(Td *td, telegram_api::object_ptr &&extended_media, + FormattedText &&caption, DialogId owner_dialog_id); + + bool is_empty() const { + return type_ == Type::Empty; + } + + td_api::object_ptr get_message_extended_media_object(Td *td, bool skip_bot_commands, + int32 max_media_timestamp) const; + + void append_file_ids(const Td *td, vector &file_ids) const; + + template + void store(StorerT &storer) const; + + template + void parse(ParserT &parser); +}; + +bool operator==(const MessageExtendedMedia &lhs, const MessageExtendedMedia &rhs); + +bool operator!=(const MessageExtendedMedia &lhs, const MessageExtendedMedia &rhs); + +} // namespace td diff --git a/td/telegram/MessageExtendedMedia.hpp b/td/telegram/MessageExtendedMedia.hpp new file mode 100644 index 000000000..d2b774cf4 --- /dev/null +++ b/td/telegram/MessageExtendedMedia.hpp @@ -0,0 +1,110 @@ +// +// Copyright Aliaksei Levin (levlam@telegram.org), Arseny Smirnov (arseny30@gmail.com) 2014-2022 +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +#pragma once + +#include "td/telegram/MessageExtendedMedia.h" +#include "td/telegram/Photo.hpp" +#include "td/telegram/Td.h" +#include "td/telegram/VideosManager.h" + +#include "td/utils/tl_helpers.h" + +namespace td { + +template +void MessageExtendedMedia::store(StorerT &storer) const { + bool has_caption = !caption_.text.empty(); + bool has_duration = duration_ != 0; + bool has_dimensions = dimensions_.width != 0 || dimensions_.height != 0; + bool has_minithumbnail = !minithumbnail_.empty(); + bool has_photo = !photo_.is_empty(); + bool has_video = video_file_id_.is_valid(); + BEGIN_STORE_FLAGS(); + STORE_FLAG(has_caption); + STORE_FLAG(has_duration); + STORE_FLAG(has_dimensions); + STORE_FLAG(has_minithumbnail); + STORE_FLAG(has_photo); + STORE_FLAG(has_video); + END_STORE_FLAGS(); + td::store(type_, storer); + if (has_caption) { + td::store(caption_, storer); + } + if (has_duration) { + td::store(duration_, storer); + } + if (has_dimensions) { + td::store(dimensions_, storer); + } + if (has_minithumbnail) { + td::store(minithumbnail_, storer); + } + if (has_photo) { + td::store(photo_, storer); + } + if (has_video) { + Td *td = storer.context()->td().get_actor_unsafe(); + td->videos_manager_->store_video(video_file_id_, storer); + } +} + +template +void MessageExtendedMedia::parse(ParserT &parser) { + bool has_caption; + bool has_duration; + bool has_dimensions; + bool has_minithumbnail; + bool has_photo; + bool has_video; + BEGIN_PARSE_FLAGS(); + PARSE_FLAG(has_caption); + PARSE_FLAG(has_duration); + PARSE_FLAG(has_dimensions); + PARSE_FLAG(has_minithumbnail); + PARSE_FLAG(has_photo); + PARSE_FLAG(has_video); + END_PARSE_FLAGS(); + td::parse(type_, parser); + if (has_caption) { + td::parse(caption_, parser); + } + if (has_duration) { + td::parse(duration_, parser); + } + if (has_dimensions) { + td::parse(dimensions_, parser); + } + if (has_minithumbnail) { + td::parse(minithumbnail_, parser); + } + bool is_bad = false; + if (has_photo) { + td::parse(photo_, parser); + for (auto &photo_size : photo_.photos) { + if (!photo_size.file_id.is_valid()) { + is_bad = true; + } + } + if (photo_.is_empty()) { + is_bad = true; + } + } + if (has_video) { + Td *td = parser.context()->td().get_actor_unsafe(); + video_file_id_ = td->videos_manager_->parse_video(parser); + is_bad = !video_file_id_.is_valid(); + } + if (is_bad) { + LOG(ERROR) << "Failed to parse MessageExtendedMedia"; + photo_ = Photo(); + video_file_id_ = FileId(); + type_ = Type::Unsupported; + } +} + +} // namespace td diff --git a/td/telegram/Payments.cpp b/td/telegram/Payments.cpp index b869b7ea5..5e54e8f76 100644 --- a/td/telegram/Payments.cpp +++ b/td/telegram/Payments.cpp @@ -756,7 +756,7 @@ bool operator==(const InputInvoice &lhs, const InputInvoice &rhs) { lhs.start_parameter == rhs.start_parameter && lhs.invoice == rhs.invoice && lhs.total_amount == rhs.total_amount && lhs.receipt_message_id == rhs.receipt_message_id && lhs.payload == rhs.payload && lhs.provider_token == rhs.provider_token && - lhs.provider_data == rhs.provider_data; + lhs.provider_data == rhs.provider_data && lhs.extended_media == rhs.extended_media; } bool operator!=(const InputInvoice &lhs, const InputInvoice &rhs) { @@ -764,7 +764,7 @@ bool operator!=(const InputInvoice &lhs, const InputInvoice &rhs) { } InputInvoice get_input_invoice(tl_object_ptr &&message_invoice, Td *td, - DialogId owner_dialog_id) { + DialogId owner_dialog_id, FormattedText &&message) { InputInvoice result; result.title = std::move(message_invoice->title_); result.description = std::move(message_invoice->description_); @@ -776,6 +776,8 @@ InputInvoice get_input_invoice(tl_object_ptr // result.payload = string(); // result.provider_token = string(); // result.provider_data = string(); + result.extended_media = + MessageExtendedMedia(td, std::move(message_invoice->extended_media_), std::move(message), owner_dialog_id); if (message_invoice->total_amount_ <= 0 || !check_currency_amount(message_invoice->total_amount_)) { LOG(ERROR) << "Receive invalid total amount " << message_invoice->total_amount_; message_invoice->total_amount_ = 0; @@ -804,6 +806,7 @@ InputInvoice get_input_invoice(tl_object_ptrtotal_amount_ <= 0 || !check_currency_amount(message_invoice->total_amount_)) { LOG(ERROR) << "Receive invalid total amount " << message_invoice->total_amount_; message_invoice->total_amount_ = 0; @@ -935,15 +938,21 @@ Result process_input_message_invoice( result.payload = std::move(input_invoice->payload_); result.provider_token = std::move(input_invoice->provider_token_); result.provider_data = std::move(input_invoice->provider_data_); + + // TRY_RESULT(extended_media, MessageExtendedMedia::get_message_extended_media(td, std::move(input_invoice->extended_media_))); + // result.extended_media = std::move(extended_media); + return result; } -tl_object_ptr get_message_invoice_object(const InputInvoice &input_invoice, Td *td) { +tl_object_ptr get_message_invoice_object(const InputInvoice &input_invoice, Td *td, + bool skip_bot_commands, int32 max_media_timestamp) { return make_tl_object( input_invoice.title, get_product_description_object(input_invoice.description), get_photo_object(td->file_manager_.get(), input_invoice.photo), input_invoice.invoice.currency, input_invoice.total_amount, input_invoice.start_parameter, input_invoice.invoice.is_test, - input_invoice.invoice.need_shipping_address, input_invoice.receipt_message_id.get()); + input_invoice.invoice.need_shipping_address, input_invoice.receipt_message_id.get(), + input_invoice.extended_media.get_message_extended_media_object(td, skip_bot_commands, max_media_timestamp)); } static tl_object_ptr get_input_invoice(const Invoice &invoice) { @@ -1050,8 +1059,10 @@ tl_object_ptr get_input_bot_inl std::move(reply_markup)); } -vector get_input_invoice_file_ids(const InputInvoice &input_invoice) { - return photo_get_file_ids(input_invoice.photo); +vector get_input_invoice_file_ids(const Td *td, const InputInvoice &input_invoice) { + auto file_ids = photo_get_file_ids(input_invoice.photo); + input_invoice.extended_media.append_file_ids(td, file_ids); + return file_ids; } bool operator==(const Address &lhs, const Address &rhs) { diff --git a/td/telegram/Payments.h b/td/telegram/Payments.h index 66ffe1748..c60776d40 100644 --- a/td/telegram/Payments.h +++ b/td/telegram/Payments.h @@ -9,6 +9,7 @@ #include "td/telegram/DialogId.h" #include "td/telegram/files/FileId.h" #include "td/telegram/FullMessageId.h" +#include "td/telegram/MessageExtendedMedia.h" #include "td/telegram/MessageId.h" #include "td/telegram/Photo.h" #include "td/telegram/td_api.h" @@ -63,6 +64,7 @@ struct InputInvoice { string payload; string provider_token; string provider_data; + MessageExtendedMedia extended_media; int64 total_amount = 0; MessageId receipt_message_id; @@ -123,7 +125,7 @@ bool operator==(const InputInvoice &lhs, const InputInvoice &rhs); bool operator!=(const InputInvoice &lhs, const InputInvoice &rhs); InputInvoice get_input_invoice(tl_object_ptr &&message_invoice, Td *td, - DialogId owner_dialog_id); + DialogId owner_dialog_id, FormattedText &&message); InputInvoice get_input_invoice(tl_object_ptr &&message_invoice, Td *td, DialogId owner_dialog_id); @@ -131,14 +133,15 @@ InputInvoice get_input_invoice(tl_object_ptr process_input_message_invoice( td_api::object_ptr &&input_message_content, Td *td); -tl_object_ptr get_message_invoice_object(const InputInvoice &input_invoice, Td *td); +tl_object_ptr get_message_invoice_object(const InputInvoice &input_invoice, Td *td, + bool skip_bot_commands, int32 max_media_timestamp); tl_object_ptr get_input_media_invoice(const InputInvoice &input_invoice, Td *td); tl_object_ptr get_input_bot_inline_message_media_invoice( const InputInvoice &input_invoice, tl_object_ptr &&reply_markup, Td *td); -vector get_input_invoice_file_ids(const InputInvoice &input_invoice); +vector get_input_invoice_file_ids(const Td *td, const InputInvoice &input_invoice); bool operator==(const Address &lhs, const Address &rhs); bool operator!=(const Address &lhs, const Address &rhs); diff --git a/td/telegram/Payments.hpp b/td/telegram/Payments.hpp index 5aba1770e..20c978779 100644 --- a/td/telegram/Payments.hpp +++ b/td/telegram/Payments.hpp @@ -8,6 +8,7 @@ #include "td/telegram/Payments.h" +#include "td/telegram/MessageExtendedMedia.hpp" #include "td/telegram/Photo.hpp" #include "td/telegram/Version.h" @@ -91,6 +92,7 @@ void store(const InputInvoice &input_invoice, StorerT &storer) { bool has_provider_data = !input_invoice.provider_data.empty(); bool has_total_amount = input_invoice.total_amount != 0; bool has_receipt_message_id = input_invoice.receipt_message_id.is_valid(); + bool has_extended_media = input_invoice.extended_media.is_empty(); BEGIN_STORE_FLAGS(); STORE_FLAG(has_description); STORE_FLAG(has_photo); @@ -100,6 +102,7 @@ void store(const InputInvoice &input_invoice, StorerT &storer) { STORE_FLAG(has_provider_data); STORE_FLAG(has_total_amount); STORE_FLAG(has_receipt_message_id); + STORE_FLAG(has_extended_media); END_STORE_FLAGS(); store(input_invoice.title, storer); if (has_description) { @@ -127,6 +130,9 @@ void store(const InputInvoice &input_invoice, StorerT &storer) { if (has_receipt_message_id) { store(input_invoice.receipt_message_id, storer); } + if (has_extended_media) { + store(input_invoice.extended_media, storer); + } } template @@ -139,6 +145,7 @@ void parse(InputInvoice &input_invoice, ParserT &parser) { bool has_provider_data; bool has_total_amount; bool has_receipt_message_id; + bool has_extended_media; if (parser.version() >= static_cast(Version::AddInputInvoiceFlags)) { BEGIN_PARSE_FLAGS(); PARSE_FLAG(has_description); @@ -149,6 +156,7 @@ void parse(InputInvoice &input_invoice, ParserT &parser) { PARSE_FLAG(has_provider_data); PARSE_FLAG(has_total_amount); PARSE_FLAG(has_receipt_message_id); + PARSE_FLAG(has_extended_media); END_PARSE_FLAGS(); } else { has_description = true; @@ -159,6 +167,7 @@ void parse(InputInvoice &input_invoice, ParserT &parser) { has_provider_data = parser.version() >= static_cast(Version::AddMessageInvoiceProviderData); has_total_amount = true; has_receipt_message_id = true; + has_extended_media = false; } parse(input_invoice.title, parser); if (has_description) { @@ -186,6 +195,9 @@ void parse(InputInvoice &input_invoice, ParserT &parser) { if (has_receipt_message_id) { parse(input_invoice.receipt_message_id, parser); } + if (has_extended_media) { + parse(input_invoice.extended_media, parser); + } } template