Unify field naming in Invoice/InputInvoice classes.
This commit is contained in:
parent
7f353cd064
commit
87e2e107bb
@ -21,14 +21,15 @@
|
||||
namespace td {
|
||||
|
||||
bool operator==(const Invoice &lhs, const Invoice &rhs) {
|
||||
return lhs.is_test == rhs.is_test && lhs.need_name == rhs.need_name &&
|
||||
lhs.need_phone_number == rhs.need_phone_number && lhs.need_email_address == rhs.need_email_address &&
|
||||
lhs.need_shipping_address == rhs.need_shipping_address &&
|
||||
lhs.send_phone_number_to_provider == rhs.send_phone_number_to_provider &&
|
||||
lhs.send_email_address_to_provider == rhs.send_email_address_to_provider &&
|
||||
lhs.is_flexible == rhs.is_flexible && lhs.currency == rhs.currency && lhs.price_parts == rhs.price_parts &&
|
||||
lhs.max_tip_amount == rhs.max_tip_amount && lhs.suggested_tip_amounts == rhs.suggested_tip_amounts &&
|
||||
lhs.recurring_payment_terms_of_service_url == rhs.recurring_payment_terms_of_service_url;
|
||||
return lhs.is_test_ == rhs.is_test_ && lhs.need_name_ == rhs.need_name_ &&
|
||||
lhs.need_phone_number_ == rhs.need_phone_number_ && lhs.need_email_address_ == rhs.need_email_address_ &&
|
||||
lhs.need_shipping_address_ == rhs.need_shipping_address_ &&
|
||||
lhs.send_phone_number_to_provider_ == rhs.send_phone_number_to_provider_ &&
|
||||
lhs.send_email_address_to_provider_ == rhs.send_email_address_to_provider_ &&
|
||||
lhs.is_flexible_ == rhs.is_flexible_ && lhs.currency_ == rhs.currency_ &&
|
||||
lhs.price_parts_ == rhs.price_parts_ && lhs.max_tip_amount_ == rhs.max_tip_amount_ &&
|
||||
lhs.suggested_tip_amounts_ == rhs.suggested_tip_amounts_ &&
|
||||
lhs.recurring_payment_terms_of_service_url_ == rhs.recurring_payment_terms_of_service_url_;
|
||||
}
|
||||
|
||||
bool operator!=(const Invoice &lhs, const Invoice &rhs) {
|
||||
@ -36,28 +37,28 @@ bool operator!=(const Invoice &lhs, const Invoice &rhs) {
|
||||
}
|
||||
|
||||
StringBuilder &operator<<(StringBuilder &string_builder, const Invoice &invoice) {
|
||||
return string_builder << "[" << (invoice.is_flexible ? "Flexible" : "") << (invoice.is_test ? "Test" : "")
|
||||
<< "Invoice" << (invoice.need_name ? ", needs name" : "")
|
||||
<< (invoice.need_phone_number ? ", needs phone number" : "")
|
||||
<< (invoice.need_email_address ? ", needs email address" : "")
|
||||
<< (invoice.need_shipping_address ? ", needs shipping address" : "")
|
||||
<< (invoice.send_phone_number_to_provider ? ", sends phone number to provider" : "")
|
||||
<< (invoice.send_email_address_to_provider ? ", sends email address to provider" : "")
|
||||
<< (invoice.recurring_payment_terms_of_service_url.empty()
|
||||
return string_builder << "[" << (invoice.is_flexible_ ? "Flexible" : "") << (invoice.is_test_ ? "Test" : "")
|
||||
<< "Invoice" << (invoice.need_name_ ? ", needs name" : "")
|
||||
<< (invoice.need_phone_number_ ? ", needs phone number" : "")
|
||||
<< (invoice.need_email_address_ ? ", needs email address" : "")
|
||||
<< (invoice.need_shipping_address_ ? ", needs shipping address" : "")
|
||||
<< (invoice.send_phone_number_to_provider_ ? ", sends phone number to provider" : "")
|
||||
<< (invoice.send_email_address_to_provider_ ? ", sends email address to provider" : "")
|
||||
<< (invoice.recurring_payment_terms_of_service_url_.empty()
|
||||
? string()
|
||||
: ", recurring payments terms of service at " +
|
||||
invoice.recurring_payment_terms_of_service_url)
|
||||
<< " in " << invoice.currency << " with price parts " << format::as_array(invoice.price_parts)
|
||||
<< " and suggested tip amounts " << invoice.suggested_tip_amounts << " up to "
|
||||
<< invoice.max_tip_amount << "]";
|
||||
invoice.recurring_payment_terms_of_service_url_)
|
||||
<< " in " << invoice.currency_ << " with price parts " << format::as_array(invoice.price_parts_)
|
||||
<< " and suggested tip amounts " << invoice.suggested_tip_amounts_ << " up to "
|
||||
<< invoice.max_tip_amount_ << "]";
|
||||
}
|
||||
|
||||
bool operator==(const InputInvoice &lhs, const InputInvoice &rhs) {
|
||||
return lhs.title == rhs.title && lhs.description == rhs.description && lhs.photo == rhs.photo &&
|
||||
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.extended_media == rhs.extended_media;
|
||||
return lhs.title_ == rhs.title_ && lhs.description_ == rhs.description_ && lhs.photo_ == rhs.photo_ &&
|
||||
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.extended_media_ == rhs.extended_media_;
|
||||
}
|
||||
|
||||
bool operator!=(const InputInvoice &lhs, const InputInvoice &rhs) {
|
||||
@ -67,28 +68,28 @@ bool operator!=(const InputInvoice &lhs, const InputInvoice &rhs) {
|
||||
InputInvoice get_input_invoice(tl_object_ptr<telegram_api::messageMediaInvoice> &&message_invoice, Td *td,
|
||||
DialogId owner_dialog_id, FormattedText &&message) {
|
||||
InputInvoice result;
|
||||
result.title = std::move(message_invoice->title_);
|
||||
result.description = std::move(message_invoice->description_);
|
||||
result.photo = get_web_document_photo(td->file_manager_.get(), std::move(message_invoice->photo_), owner_dialog_id);
|
||||
result.start_parameter = std::move(message_invoice->start_param_);
|
||||
result.invoice.currency = std::move(message_invoice->currency_);
|
||||
result.invoice.is_test = message_invoice->test_;
|
||||
result.invoice.need_shipping_address = message_invoice->shipping_address_requested_;
|
||||
// result.payload = string();
|
||||
// result.provider_token = string();
|
||||
// result.provider_data = string();
|
||||
result.extended_media =
|
||||
result.title_ = std::move(message_invoice->title_);
|
||||
result.description_ = std::move(message_invoice->description_);
|
||||
result.photo_ = get_web_document_photo(td->file_manager_.get(), std::move(message_invoice->photo_), owner_dialog_id);
|
||||
result.start_parameter_ = std::move(message_invoice->start_param_);
|
||||
result.invoice_.currency_ = std::move(message_invoice->currency_);
|
||||
result.invoice_.is_test_ = message_invoice->test_;
|
||||
result.invoice_.need_shipping_address_ = message_invoice->shipping_address_requested_;
|
||||
// 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;
|
||||
}
|
||||
result.total_amount = message_invoice->total_amount_;
|
||||
result.total_amount_ = message_invoice->total_amount_;
|
||||
if ((message_invoice->flags_ & telegram_api::messageMediaInvoice::RECEIPT_MSG_ID_MASK) != 0) {
|
||||
result.receipt_message_id = MessageId(ServerMessageId(message_invoice->receipt_msg_id_));
|
||||
if (!result.receipt_message_id.is_valid()) {
|
||||
LOG(ERROR) << "Receive as receipt message " << result.receipt_message_id << " in " << owner_dialog_id;
|
||||
result.receipt_message_id = MessageId();
|
||||
result.receipt_message_id_ = MessageId(ServerMessageId(message_invoice->receipt_msg_id_));
|
||||
if (!result.receipt_message_id_.is_valid()) {
|
||||
LOG(ERROR) << "Receive as receipt message " << result.receipt_message_id_ << " in " << owner_dialog_id;
|
||||
result.receipt_message_id_ = MessageId();
|
||||
}
|
||||
}
|
||||
return result;
|
||||
@ -97,23 +98,23 @@ InputInvoice get_input_invoice(tl_object_ptr<telegram_api::messageMediaInvoice>
|
||||
InputInvoice get_input_invoice(tl_object_ptr<telegram_api::botInlineMessageMediaInvoice> &&message_invoice, Td *td,
|
||||
DialogId owner_dialog_id) {
|
||||
InputInvoice result;
|
||||
result.title = std::move(message_invoice->title_);
|
||||
result.description = std::move(message_invoice->description_);
|
||||
result.photo = get_web_document_photo(td->file_manager_.get(), std::move(message_invoice->photo_), owner_dialog_id);
|
||||
// result.start_parameter = string();
|
||||
result.invoice.currency = std::move(message_invoice->currency_);
|
||||
result.invoice.is_test = message_invoice->test_;
|
||||
result.invoice.need_shipping_address = message_invoice->shipping_address_requested_;
|
||||
// result.payload = string();
|
||||
// result.provider_token = string();
|
||||
// result.provider_data = string();
|
||||
// result.extended_media = MessageExtendedMedia();
|
||||
result.title_ = std::move(message_invoice->title_);
|
||||
result.description_ = std::move(message_invoice->description_);
|
||||
result.photo_ = get_web_document_photo(td->file_manager_.get(), std::move(message_invoice->photo_), owner_dialog_id);
|
||||
// result.start_parameter_ = string();
|
||||
result.invoice_.currency_ = std::move(message_invoice->currency_);
|
||||
result.invoice_.is_test_ = message_invoice->test_;
|
||||
result.invoice_.need_shipping_address_ = message_invoice->shipping_address_requested_;
|
||||
// result.payload_ = string();
|
||||
// result.provider_token_ = string();
|
||||
// result.provider_data_ = string();
|
||||
// result.extended_media_ = MessageExtendedMedia();
|
||||
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;
|
||||
}
|
||||
result.total_amount = message_invoice->total_amount_;
|
||||
// result.receipt_message_id = MessageId();
|
||||
result.total_amount_ = message_invoice->total_amount_;
|
||||
// result.receipt_message_id_ = MessageId();
|
||||
return result;
|
||||
}
|
||||
|
||||
@ -149,8 +150,8 @@ Result<InputInvoice> process_input_message_invoice(
|
||||
}
|
||||
|
||||
InputInvoice result;
|
||||
result.title = std::move(input_invoice->title_);
|
||||
result.description = std::move(input_invoice->description_);
|
||||
result.title_ = std::move(input_invoice->title_);
|
||||
result.description_ = std::move(input_invoice->description_);
|
||||
|
||||
auto r_http_url = parse_url(input_invoice->photo_url_);
|
||||
if (r_http_url.is_error()) {
|
||||
@ -171,14 +172,14 @@ Result<InputInvoice> process_input_message_invoice(
|
||||
s.size = input_invoice->photo_size_; // TODO use invoice_file_id size
|
||||
s.file_id = invoice_file_id;
|
||||
|
||||
result.photo.id = 0;
|
||||
result.photo.photos.push_back(s);
|
||||
result.photo_.id = 0;
|
||||
result.photo_.photos.push_back(s);
|
||||
}
|
||||
}
|
||||
result.start_parameter = std::move(input_invoice->start_parameter_);
|
||||
result.start_parameter_ = std::move(input_invoice->start_parameter_);
|
||||
|
||||
result.invoice.currency = std::move(input_invoice->invoice_->currency_);
|
||||
result.invoice.price_parts.reserve(input_invoice->invoice_->price_parts_.size());
|
||||
result.invoice_.currency_ = std::move(input_invoice->invoice_->currency_);
|
||||
result.invoice_.price_parts_.reserve(input_invoice->invoice_->price_parts_.size());
|
||||
int64 total_amount = 0;
|
||||
for (auto &price : input_invoice->invoice_->price_parts_) {
|
||||
if (!clean_input_string(price->label_)) {
|
||||
@ -187,7 +188,7 @@ Result<InputInvoice> process_input_message_invoice(
|
||||
if (!check_currency_amount(price->amount_)) {
|
||||
return Status::Error(400, "Too big amount of the currency specified");
|
||||
}
|
||||
result.invoice.price_parts.emplace_back(std::move(price->label_), price->amount_);
|
||||
result.invoice_.price_parts_.emplace_back(std::move(price->label_), price->amount_);
|
||||
total_amount += price->amount_;
|
||||
}
|
||||
if (total_amount <= 0) {
|
||||
@ -196,7 +197,7 @@ Result<InputInvoice> process_input_message_invoice(
|
||||
if (!check_currency_amount(total_amount)) {
|
||||
return Status::Error(400, "Total price is too big");
|
||||
}
|
||||
result.total_amount = total_amount;
|
||||
result.total_amount_ = total_amount;
|
||||
|
||||
if (input_invoice->invoice_->max_tip_amount_ < 0 ||
|
||||
!check_currency_amount(input_invoice->invoice_->max_tip_amount_)) {
|
||||
@ -214,34 +215,34 @@ Result<InputInvoice> process_input_message_invoice(
|
||||
return Status::Error(400, "There can be at most 4 suggested tip amounts");
|
||||
}
|
||||
|
||||
result.invoice.max_tip_amount = input_invoice->invoice_->max_tip_amount_;
|
||||
result.invoice.suggested_tip_amounts = std::move(input_invoice->invoice_->suggested_tip_amounts_);
|
||||
result.invoice.recurring_payment_terms_of_service_url =
|
||||
result.invoice_.max_tip_amount_ = input_invoice->invoice_->max_tip_amount_;
|
||||
result.invoice_.suggested_tip_amounts_ = std::move(input_invoice->invoice_->suggested_tip_amounts_);
|
||||
result.invoice_.recurring_payment_terms_of_service_url_ =
|
||||
std::move(input_invoice->invoice_->recurring_payment_terms_of_service_url_);
|
||||
result.invoice.is_test = input_invoice->invoice_->is_test_;
|
||||
result.invoice.need_name = input_invoice->invoice_->need_name_;
|
||||
result.invoice.need_phone_number = input_invoice->invoice_->need_phone_number_;
|
||||
result.invoice.need_email_address = input_invoice->invoice_->need_email_address_;
|
||||
result.invoice.need_shipping_address = input_invoice->invoice_->need_shipping_address_;
|
||||
result.invoice.send_phone_number_to_provider = input_invoice->invoice_->send_phone_number_to_provider_;
|
||||
result.invoice.send_email_address_to_provider = input_invoice->invoice_->send_email_address_to_provider_;
|
||||
result.invoice.is_flexible = input_invoice->invoice_->is_flexible_;
|
||||
if (result.invoice.send_phone_number_to_provider) {
|
||||
result.invoice.need_phone_number = true;
|
||||
result.invoice_.is_test_ = input_invoice->invoice_->is_test_;
|
||||
result.invoice_.need_name_ = input_invoice->invoice_->need_name_;
|
||||
result.invoice_.need_phone_number_ = input_invoice->invoice_->need_phone_number_;
|
||||
result.invoice_.need_email_address_ = input_invoice->invoice_->need_email_address_;
|
||||
result.invoice_.need_shipping_address_ = input_invoice->invoice_->need_shipping_address_;
|
||||
result.invoice_.send_phone_number_to_provider_ = input_invoice->invoice_->send_phone_number_to_provider_;
|
||||
result.invoice_.send_email_address_to_provider_ = input_invoice->invoice_->send_email_address_to_provider_;
|
||||
result.invoice_.is_flexible_ = input_invoice->invoice_->is_flexible_;
|
||||
if (result.invoice_.send_phone_number_to_provider_) {
|
||||
result.invoice_.need_phone_number_ = true;
|
||||
}
|
||||
if (result.invoice.send_email_address_to_provider) {
|
||||
result.invoice.need_email_address = true;
|
||||
if (result.invoice_.send_email_address_to_provider_) {
|
||||
result.invoice_.need_email_address_ = true;
|
||||
}
|
||||
if (result.invoice.is_flexible) {
|
||||
result.invoice.need_shipping_address = true;
|
||||
if (result.invoice_.is_flexible_) {
|
||||
result.invoice_.need_shipping_address_ = true;
|
||||
}
|
||||
|
||||
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_);
|
||||
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);
|
||||
// result.extended_media_ = std::move(extended_media);
|
||||
|
||||
return result;
|
||||
}
|
||||
@ -249,54 +250,54 @@ Result<InputInvoice> process_input_message_invoice(
|
||||
tl_object_ptr<td_api::messageInvoice> get_message_invoice_object(const InputInvoice &input_invoice, Td *td,
|
||||
bool skip_bot_commands, int32 max_media_timestamp) {
|
||||
return make_tl_object<td_api::messageInvoice>(
|
||||
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.extended_media.get_message_extended_media_object(td, skip_bot_commands, max_media_timestamp));
|
||||
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.extended_media_.get_message_extended_media_object(td, skip_bot_commands, max_media_timestamp));
|
||||
}
|
||||
|
||||
static tl_object_ptr<telegram_api::invoice> get_input_invoice(const Invoice &invoice) {
|
||||
int32 flags = 0;
|
||||
if (invoice.is_test) {
|
||||
if (invoice.is_test_) {
|
||||
flags |= telegram_api::invoice::TEST_MASK;
|
||||
}
|
||||
if (invoice.need_name) {
|
||||
if (invoice.need_name_) {
|
||||
flags |= telegram_api::invoice::NAME_REQUESTED_MASK;
|
||||
}
|
||||
if (invoice.need_phone_number) {
|
||||
if (invoice.need_phone_number_) {
|
||||
flags |= telegram_api::invoice::PHONE_REQUESTED_MASK;
|
||||
}
|
||||
if (invoice.need_email_address) {
|
||||
if (invoice.need_email_address_) {
|
||||
flags |= telegram_api::invoice::EMAIL_REQUESTED_MASK;
|
||||
}
|
||||
if (invoice.need_shipping_address) {
|
||||
if (invoice.need_shipping_address_) {
|
||||
flags |= telegram_api::invoice::SHIPPING_ADDRESS_REQUESTED_MASK;
|
||||
}
|
||||
if (invoice.send_phone_number_to_provider) {
|
||||
if (invoice.send_phone_number_to_provider_) {
|
||||
flags |= telegram_api::invoice::PHONE_TO_PROVIDER_MASK;
|
||||
}
|
||||
if (invoice.send_email_address_to_provider) {
|
||||
if (invoice.send_email_address_to_provider_) {
|
||||
flags |= telegram_api::invoice::EMAIL_TO_PROVIDER_MASK;
|
||||
}
|
||||
if (invoice.is_flexible) {
|
||||
if (invoice.is_flexible_) {
|
||||
flags |= telegram_api::invoice::FLEXIBLE_MASK;
|
||||
}
|
||||
if (invoice.max_tip_amount != 0) {
|
||||
if (invoice.max_tip_amount_ != 0) {
|
||||
flags |= telegram_api::invoice::MAX_TIP_AMOUNT_MASK;
|
||||
}
|
||||
if (!invoice.recurring_payment_terms_of_service_url.empty()) {
|
||||
if (!invoice.recurring_payment_terms_of_service_url_.empty()) {
|
||||
flags |= telegram_api::invoice::RECURRING_TERMS_URL_MASK;
|
||||
}
|
||||
|
||||
auto prices = transform(invoice.price_parts, [](const LabeledPricePart &price) {
|
||||
auto prices = transform(invoice.price_parts_, [](const LabeledPricePart &price) {
|
||||
return telegram_api::make_object<telegram_api::labeledPrice>(price.label, price.amount);
|
||||
});
|
||||
return make_tl_object<telegram_api::invoice>(
|
||||
flags, false /*ignored*/, false /*ignored*/, false /*ignored*/, false /*ignored*/, false /*ignored*/,
|
||||
false /*ignored*/, false /*ignored*/, false /*ignored*/, false /*ignored*/, invoice.currency, std::move(prices),
|
||||
invoice.max_tip_amount, vector<int64>(invoice.suggested_tip_amounts),
|
||||
invoice.recurring_payment_terms_of_service_url);
|
||||
false /*ignored*/, false /*ignored*/, false /*ignored*/, false /*ignored*/, invoice.currency_, std::move(prices),
|
||||
invoice.max_tip_amount_, vector<int64>(invoice.suggested_tip_amounts_),
|
||||
invoice.recurring_payment_terms_of_service_url_);
|
||||
}
|
||||
|
||||
static tl_object_ptr<telegram_api::inputWebDocument> get_input_web_document(const FileManager *file_manager,
|
||||
@ -326,20 +327,20 @@ static tl_object_ptr<telegram_api::inputWebDocument> get_input_web_document(cons
|
||||
|
||||
tl_object_ptr<telegram_api::inputMediaInvoice> get_input_media_invoice(const InputInvoice &input_invoice, Td *td) {
|
||||
int32 flags = 0;
|
||||
if (!input_invoice.start_parameter.empty()) {
|
||||
if (!input_invoice.start_parameter_.empty()) {
|
||||
flags |= telegram_api::inputMediaInvoice::START_PARAM_MASK;
|
||||
}
|
||||
auto input_web_document = get_input_web_document(td->file_manager_.get(), input_invoice.photo);
|
||||
auto input_web_document = get_input_web_document(td->file_manager_.get(), input_invoice.photo_);
|
||||
if (input_web_document != nullptr) {
|
||||
flags |= telegram_api::inputMediaInvoice::PHOTO_MASK;
|
||||
}
|
||||
|
||||
return make_tl_object<telegram_api::inputMediaInvoice>(
|
||||
flags, input_invoice.title, input_invoice.description, std::move(input_web_document),
|
||||
get_input_invoice(input_invoice.invoice), BufferSlice(input_invoice.payload), input_invoice.provider_token,
|
||||
flags, input_invoice.title_, input_invoice.description_, std::move(input_web_document),
|
||||
get_input_invoice(input_invoice.invoice_), BufferSlice(input_invoice.payload_), input_invoice.provider_token_,
|
||||
telegram_api::make_object<telegram_api::dataJSON>(
|
||||
input_invoice.provider_data.empty() ? "null" : input_invoice.provider_data),
|
||||
input_invoice.start_parameter, nullptr);
|
||||
input_invoice.provider_data_.empty() ? "null" : input_invoice.provider_data_),
|
||||
input_invoice.start_parameter_, nullptr);
|
||||
}
|
||||
|
||||
tl_object_ptr<telegram_api::inputBotInlineMessageMediaInvoice> get_input_bot_inline_message_media_invoice(
|
||||
@ -348,56 +349,56 @@ tl_object_ptr<telegram_api::inputBotInlineMessageMediaInvoice> get_input_bot_inl
|
||||
if (reply_markup != nullptr) {
|
||||
flags |= telegram_api::inputBotInlineMessageMediaInvoice::REPLY_MARKUP_MASK;
|
||||
}
|
||||
auto input_web_document = get_input_web_document(td->file_manager_.get(), input_invoice.photo);
|
||||
auto input_web_document = get_input_web_document(td->file_manager_.get(), input_invoice.photo_);
|
||||
if (input_web_document != nullptr) {
|
||||
flags |= telegram_api::inputBotInlineMessageMediaInvoice::PHOTO_MASK;
|
||||
}
|
||||
return make_tl_object<telegram_api::inputBotInlineMessageMediaInvoice>(
|
||||
flags, input_invoice.title, input_invoice.description, std::move(input_web_document),
|
||||
get_input_invoice(input_invoice.invoice), BufferSlice(input_invoice.payload), input_invoice.provider_token,
|
||||
flags, input_invoice.title_, input_invoice.description_, std::move(input_web_document),
|
||||
get_input_invoice(input_invoice.invoice_), BufferSlice(input_invoice.payload_), input_invoice.provider_token_,
|
||||
telegram_api::make_object<telegram_api::dataJSON>(
|
||||
input_invoice.provider_data.empty() ? "null" : input_invoice.provider_data),
|
||||
input_invoice.provider_data_.empty() ? "null" : input_invoice.provider_data_),
|
||||
std::move(reply_markup));
|
||||
}
|
||||
|
||||
vector<FileId> 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);
|
||||
auto file_ids = photo_get_file_ids(input_invoice.photo_);
|
||||
input_invoice.extended_media_.append_file_ids(td, file_ids);
|
||||
return file_ids;
|
||||
}
|
||||
|
||||
void input_invoice_delete_thumbnail(Td *td, InputInvoice &input_invoice) {
|
||||
input_invoice.extended_media.delete_thumbnail(td);
|
||||
input_invoice.extended_media_.delete_thumbnail(td);
|
||||
}
|
||||
|
||||
bool has_input_invoice_media_timestamp(const InputInvoice &input_invoice) {
|
||||
return input_invoice.extended_media.has_media_timestamp();
|
||||
return input_invoice.extended_media_.has_media_timestamp();
|
||||
}
|
||||
|
||||
const FormattedText *get_input_invoice_caption(const InputInvoice &input_invoice) {
|
||||
return input_invoice.extended_media.get_caption();
|
||||
return input_invoice.extended_media_.get_caption();
|
||||
}
|
||||
|
||||
int32 get_input_invoice_duration(const Td *td, const InputInvoice &input_invoice) {
|
||||
return input_invoice.extended_media.get_duration(td);
|
||||
return input_invoice.extended_media_.get_duration(td);
|
||||
}
|
||||
|
||||
FileId get_input_invoice_upload_file_id(const InputInvoice &input_invoice) {
|
||||
return input_invoice.extended_media.get_upload_file_id();
|
||||
return input_invoice.extended_media_.get_upload_file_id();
|
||||
}
|
||||
|
||||
FileId get_input_invoice_any_file_id(const InputInvoice &input_invoice) {
|
||||
return input_invoice.extended_media.get_any_file_id();
|
||||
return input_invoice.extended_media_.get_any_file_id();
|
||||
}
|
||||
|
||||
FileId get_input_invoice_thumbnail_file_id(const Td *td, const InputInvoice &input_invoice) {
|
||||
return input_invoice.extended_media.get_thumbnail_file_id(td);
|
||||
return input_invoice.extended_media_.get_thumbnail_file_id(td);
|
||||
}
|
||||
|
||||
bool update_input_invoice_extended_media(InputInvoice &input_invoice,
|
||||
telegram_api::object_ptr<telegram_api::MessageExtendedMedia> extended_media,
|
||||
DialogId owner_dialog_id, Td *td) {
|
||||
return input_invoice.extended_media.update_to(td, std::move(extended_media), owner_dialog_id);
|
||||
return input_invoice.extended_media_.update_to(td, std::move(extended_media), owner_dialog_id);
|
||||
}
|
||||
|
||||
tl_object_ptr<td_api::formattedText> get_product_description_object(const string &description) {
|
||||
|
@ -23,39 +23,39 @@ namespace td {
|
||||
class Td;
|
||||
|
||||
struct Invoice {
|
||||
string currency;
|
||||
vector<LabeledPricePart> price_parts;
|
||||
int64 max_tip_amount = 0;
|
||||
vector<int64> suggested_tip_amounts;
|
||||
string recurring_payment_terms_of_service_url;
|
||||
bool is_test = false;
|
||||
bool need_name = false;
|
||||
bool need_phone_number = false;
|
||||
bool need_email_address = false;
|
||||
bool need_shipping_address = false;
|
||||
bool send_phone_number_to_provider = false;
|
||||
bool send_email_address_to_provider = false;
|
||||
bool is_flexible = false;
|
||||
string currency_;
|
||||
vector<LabeledPricePart> price_parts_;
|
||||
int64 max_tip_amount_ = 0;
|
||||
vector<int64> suggested_tip_amounts_;
|
||||
string recurring_payment_terms_of_service_url_;
|
||||
bool is_test_ = false;
|
||||
bool need_name_ = false;
|
||||
bool need_phone_number_ = false;
|
||||
bool need_email_address_ = false;
|
||||
bool need_shipping_address_ = false;
|
||||
bool send_phone_number_to_provider_ = false;
|
||||
bool send_email_address_to_provider_ = false;
|
||||
bool is_flexible_ = false;
|
||||
|
||||
Invoice() = default;
|
||||
Invoice(string &¤cy, bool is_test, bool need_shipping_address)
|
||||
: currency(std::move(currency)), is_test(is_test), need_shipping_address(need_shipping_address) {
|
||||
: currency_(std::move(currency)), is_test_(is_test), need_shipping_address_(need_shipping_address) {
|
||||
}
|
||||
};
|
||||
|
||||
struct InputInvoice {
|
||||
string title;
|
||||
string description;
|
||||
Photo photo;
|
||||
string start_parameter;
|
||||
Invoice invoice;
|
||||
string payload;
|
||||
string provider_token;
|
||||
string provider_data;
|
||||
MessageExtendedMedia extended_media;
|
||||
string title_;
|
||||
string description_;
|
||||
Photo photo_;
|
||||
string start_parameter_;
|
||||
Invoice invoice_;
|
||||
string payload_;
|
||||
string provider_token_;
|
||||
string provider_data_;
|
||||
MessageExtendedMedia extended_media_;
|
||||
|
||||
int64 total_amount = 0;
|
||||
MessageId receipt_message_id;
|
||||
int64 total_amount_ = 0;
|
||||
MessageId receipt_message_id_;
|
||||
};
|
||||
|
||||
bool operator==(const Invoice &lhs, const Invoice &rhs);
|
||||
|
@ -18,28 +18,28 @@ namespace td {
|
||||
|
||||
template <class StorerT>
|
||||
void store(const Invoice &invoice, StorerT &storer) {
|
||||
bool has_tip = invoice.max_tip_amount != 0;
|
||||
bool is_recurring = !invoice.recurring_payment_terms_of_service_url.empty();
|
||||
bool has_tip = invoice.max_tip_amount_ != 0;
|
||||
bool is_recurring = !invoice.recurring_payment_terms_of_service_url_.empty();
|
||||
BEGIN_STORE_FLAGS();
|
||||
STORE_FLAG(invoice.is_test);
|
||||
STORE_FLAG(invoice.need_name);
|
||||
STORE_FLAG(invoice.need_phone_number);
|
||||
STORE_FLAG(invoice.need_email_address);
|
||||
STORE_FLAG(invoice.need_shipping_address);
|
||||
STORE_FLAG(invoice.is_flexible);
|
||||
STORE_FLAG(invoice.send_phone_number_to_provider);
|
||||
STORE_FLAG(invoice.send_email_address_to_provider);
|
||||
STORE_FLAG(invoice.is_test_);
|
||||
STORE_FLAG(invoice.need_name_);
|
||||
STORE_FLAG(invoice.need_phone_number_);
|
||||
STORE_FLAG(invoice.need_email_address_);
|
||||
STORE_FLAG(invoice.need_shipping_address_);
|
||||
STORE_FLAG(invoice.is_flexible_);
|
||||
STORE_FLAG(invoice.send_phone_number_to_provider_);
|
||||
STORE_FLAG(invoice.send_email_address_to_provider_);
|
||||
STORE_FLAG(has_tip);
|
||||
STORE_FLAG(is_recurring);
|
||||
END_STORE_FLAGS();
|
||||
store(invoice.currency, storer);
|
||||
store(invoice.price_parts, storer);
|
||||
store(invoice.currency_, storer);
|
||||
store(invoice.price_parts_, storer);
|
||||
if (has_tip) {
|
||||
store(invoice.max_tip_amount, storer);
|
||||
store(invoice.suggested_tip_amounts, storer);
|
||||
store(invoice.max_tip_amount_, storer);
|
||||
store(invoice.suggested_tip_amounts_, storer);
|
||||
}
|
||||
if (is_recurring) {
|
||||
store(invoice.recurring_payment_terms_of_service_url, storer);
|
||||
store(invoice.recurring_payment_terms_of_service_url_, storer);
|
||||
}
|
||||
}
|
||||
|
||||
@ -48,39 +48,39 @@ void parse(Invoice &invoice, ParserT &parser) {
|
||||
bool has_tip;
|
||||
bool is_recurring;
|
||||
BEGIN_PARSE_FLAGS();
|
||||
PARSE_FLAG(invoice.is_test);
|
||||
PARSE_FLAG(invoice.need_name);
|
||||
PARSE_FLAG(invoice.need_phone_number);
|
||||
PARSE_FLAG(invoice.need_email_address);
|
||||
PARSE_FLAG(invoice.need_shipping_address);
|
||||
PARSE_FLAG(invoice.is_flexible);
|
||||
PARSE_FLAG(invoice.send_phone_number_to_provider);
|
||||
PARSE_FLAG(invoice.send_email_address_to_provider);
|
||||
PARSE_FLAG(invoice.is_test_);
|
||||
PARSE_FLAG(invoice.need_name_);
|
||||
PARSE_FLAG(invoice.need_phone_number_);
|
||||
PARSE_FLAG(invoice.need_email_address_);
|
||||
PARSE_FLAG(invoice.need_shipping_address_);
|
||||
PARSE_FLAG(invoice.is_flexible_);
|
||||
PARSE_FLAG(invoice.send_phone_number_to_provider_);
|
||||
PARSE_FLAG(invoice.send_email_address_to_provider_);
|
||||
PARSE_FLAG(has_tip);
|
||||
PARSE_FLAG(is_recurring);
|
||||
END_PARSE_FLAGS();
|
||||
parse(invoice.currency, parser);
|
||||
parse(invoice.price_parts, parser);
|
||||
parse(invoice.currency_, parser);
|
||||
parse(invoice.price_parts_, parser);
|
||||
if (has_tip) {
|
||||
parse(invoice.max_tip_amount, parser);
|
||||
parse(invoice.suggested_tip_amounts, parser);
|
||||
parse(invoice.max_tip_amount_, parser);
|
||||
parse(invoice.suggested_tip_amounts_, parser);
|
||||
}
|
||||
if (is_recurring) {
|
||||
parse(invoice.recurring_payment_terms_of_service_url, parser);
|
||||
parse(invoice.recurring_payment_terms_of_service_url_, parser);
|
||||
}
|
||||
}
|
||||
|
||||
template <class StorerT>
|
||||
void store(const InputInvoice &input_invoice, StorerT &storer) {
|
||||
bool has_description = !input_invoice.description.empty();
|
||||
bool has_photo = !input_invoice.photo.is_empty();
|
||||
bool has_start_parameter = !input_invoice.start_parameter.empty();
|
||||
bool has_payload = !input_invoice.payload.empty();
|
||||
bool has_provider_token = !input_invoice.provider_token.empty();
|
||||
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();
|
||||
bool has_description = !input_invoice.description_.empty();
|
||||
bool has_photo = !input_invoice.photo_.is_empty();
|
||||
bool has_start_parameter = !input_invoice.start_parameter_.empty();
|
||||
bool has_payload = !input_invoice.payload_.empty();
|
||||
bool has_provider_token = !input_invoice.provider_token_.empty();
|
||||
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);
|
||||
@ -92,34 +92,34 @@ void store(const InputInvoice &input_invoice, StorerT &storer) {
|
||||
STORE_FLAG(has_receipt_message_id);
|
||||
STORE_FLAG(has_extended_media);
|
||||
END_STORE_FLAGS();
|
||||
store(input_invoice.title, storer);
|
||||
store(input_invoice.title_, storer);
|
||||
if (has_description) {
|
||||
store(input_invoice.description, storer);
|
||||
store(input_invoice.description_, storer);
|
||||
}
|
||||
if (has_photo) {
|
||||
store(input_invoice.photo, storer);
|
||||
store(input_invoice.photo_, storer);
|
||||
}
|
||||
if (has_start_parameter) {
|
||||
store(input_invoice.start_parameter, storer);
|
||||
store(input_invoice.start_parameter_, storer);
|
||||
}
|
||||
store(input_invoice.invoice, storer);
|
||||
store(input_invoice.invoice_, storer);
|
||||
if (has_payload) {
|
||||
store(input_invoice.payload, storer);
|
||||
store(input_invoice.payload_, storer);
|
||||
}
|
||||
if (has_provider_token) {
|
||||
store(input_invoice.provider_token, storer);
|
||||
store(input_invoice.provider_token_, storer);
|
||||
}
|
||||
if (has_provider_data) {
|
||||
store(input_invoice.provider_data, storer);
|
||||
store(input_invoice.provider_data_, storer);
|
||||
}
|
||||
if (has_total_amount) {
|
||||
store(input_invoice.total_amount, storer);
|
||||
store(input_invoice.total_amount_, storer);
|
||||
}
|
||||
if (has_receipt_message_id) {
|
||||
store(input_invoice.receipt_message_id, storer);
|
||||
store(input_invoice.receipt_message_id_, storer);
|
||||
}
|
||||
if (has_extended_media) {
|
||||
store(input_invoice.extended_media, storer);
|
||||
store(input_invoice.extended_media_, storer);
|
||||
}
|
||||
}
|
||||
|
||||
@ -157,34 +157,34 @@ void parse(InputInvoice &input_invoice, ParserT &parser) {
|
||||
has_receipt_message_id = true;
|
||||
has_extended_media = false;
|
||||
}
|
||||
parse(input_invoice.title, parser);
|
||||
parse(input_invoice.title_, parser);
|
||||
if (has_description) {
|
||||
parse(input_invoice.description, parser);
|
||||
parse(input_invoice.description_, parser);
|
||||
}
|
||||
if (has_photo) {
|
||||
parse(input_invoice.photo, parser);
|
||||
parse(input_invoice.photo_, parser);
|
||||
}
|
||||
if (has_start_parameter) {
|
||||
parse(input_invoice.start_parameter, parser);
|
||||
parse(input_invoice.start_parameter_, parser);
|
||||
}
|
||||
parse(input_invoice.invoice, parser);
|
||||
parse(input_invoice.invoice_, parser);
|
||||
if (has_payload) {
|
||||
parse(input_invoice.payload, parser);
|
||||
parse(input_invoice.payload_, parser);
|
||||
}
|
||||
if (has_provider_token) {
|
||||
parse(input_invoice.provider_token, parser);
|
||||
parse(input_invoice.provider_token_, parser);
|
||||
}
|
||||
if (has_provider_data) {
|
||||
parse(input_invoice.provider_data, parser);
|
||||
parse(input_invoice.provider_data_, parser);
|
||||
}
|
||||
if (has_total_amount) {
|
||||
parse(input_invoice.total_amount, parser);
|
||||
parse(input_invoice.total_amount_, parser);
|
||||
}
|
||||
if (has_receipt_message_id) {
|
||||
parse(input_invoice.receipt_message_id, parser);
|
||||
parse(input_invoice.receipt_message_id_, parser);
|
||||
}
|
||||
if (has_extended_media) {
|
||||
parse(input_invoice.extended_media, parser);
|
||||
parse(input_invoice.extended_media_, parser);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -3222,12 +3222,12 @@ void merge_message_contents(Td *td, const MessageContent *old_content, MessageCo
|
||||
case MessageContentType::Invoice: {
|
||||
const auto *old_ = static_cast<const MessageInvoice *>(old_content);
|
||||
auto *new_ = static_cast<MessageInvoice *>(new_content);
|
||||
new_->input_invoice.extended_media.update_from(old_->input_invoice.extended_media);
|
||||
new_->input_invoice.extended_media_.update_from(old_->input_invoice.extended_media_);
|
||||
if (old_->input_invoice != new_->input_invoice) {
|
||||
need_update = true;
|
||||
}
|
||||
if (old_->input_invoice.extended_media.get_unsupported_version() !=
|
||||
new_->input_invoice.extended_media.get_unsupported_version()) {
|
||||
if (old_->input_invoice.extended_media_.get_unsupported_version() !=
|
||||
new_->input_invoice.extended_media_.get_unsupported_version()) {
|
||||
is_content_changed = true;
|
||||
}
|
||||
break;
|
||||
@ -5738,7 +5738,7 @@ bool need_reget_message_content(const MessageContent *content) {
|
||||
}
|
||||
case MessageContentType::Invoice: {
|
||||
const auto *m = static_cast<const MessageInvoice *>(content);
|
||||
return m->input_invoice.extended_media.need_reget();
|
||||
return m->input_invoice.extended_media_.need_reget();
|
||||
}
|
||||
default:
|
||||
return false;
|
||||
|
Loading…
Reference in New Issue
Block a user