diff --git a/td/generate/scheme/td_api.tl b/td/generate/scheme/td_api.tl index 7dca4e740..45f92fa1e 100644 --- a/td/generate/scheme/td_api.tl +++ b/td/generate/scheme/td_api.tl @@ -1955,8 +1955,8 @@ messageCustomServiceAction text:string = MessageContent; //@description A new high score was achieved in a game @game_message_id Identifier of the message with the game, can be an identifier of a deleted message @game_id Identifier of the game; may be different from the games presented in the message with the game @score New score messageGameScore game_message_id:int53 game_id:int64 score:int32 = MessageContent; -//@description A payment has been completed @invoice_chat_id Identifier of the chat, containing the corresponding invoice message; 0 if unknown @invoice_message_id Identifier of the message with the corresponding invoice; can be an identifier of a deleted message @currency Currency for the price of the product @total_amount Total price for the product, in the smallest units of the currency -messagePaymentSuccessful invoice_chat_id:int53 invoice_message_id:int53 currency:string total_amount:int53 = MessageContent; +//@description A payment has been completed @invoice_chat_id Identifier of the chat, containing the corresponding invoice message; 0 if unknown @invoice_message_id Identifier of the message with the corresponding invoice; can be an identifier of a deleted message @currency Currency for the price of the product @total_amount Total price for the product, in the smallest units of the currency @invoice_name Name of the invoice; may be empty if unknown +messagePaymentSuccessful invoice_chat_id:int53 invoice_message_id:int53 currency:string total_amount:int53 invoice_name:string = MessageContent; //@description A payment has been completed; for bots only @currency Currency for price of the product //@total_amount Total price for the product, in the smallest units of the currency @invoice_payload Invoice payload @shipping_option_id Identifier of the shipping option chosen by the user; may be empty if not applicable @order_info Information about the order; may be null diff --git a/td/telegram/MessageContent.cpp b/td/telegram/MessageContent.cpp index 84eb706b9..5244a9284 100644 --- a/td/telegram/MessageContent.cpp +++ b/td/telegram/MessageContent.cpp @@ -500,9 +500,9 @@ class MessagePaymentSuccessful final : public MessageContent { MessageId invoice_message_id; string currency; int64 total_amount = 0; + string invoice_payload; // or invoice_slug for users // bots only part - string invoice_payload; string shipping_option_id; unique_ptr order_info; string telegram_payment_charge_id; @@ -510,11 +510,12 @@ class MessagePaymentSuccessful final : public MessageContent { MessagePaymentSuccessful() = default; MessagePaymentSuccessful(DialogId invoice_dialog_id, MessageId invoice_message_id, string &¤cy, - int64 total_amount) + int64 total_amount, string &&invoice_payload) : invoice_dialog_id(invoice_dialog_id) , invoice_message_id(invoice_message_id) , currency(std::move(currency)) - , total_amount(total_amount) { + , total_amount(total_amount) + , invoice_payload(std::move(invoice_payload)) { } MessageContentType get_type() const final { @@ -4772,13 +4773,16 @@ unique_ptr get_action_message_content(Td *td, tl_object_ptr(action); if (!reply_to_message_id.is_valid()) { - LOG(ERROR) << "Receive succesful payment message with " << reply_to_message_id << " in " << owner_dialog_id; + if (reply_to_message_id != MessageId() || payment_sent->invoice_slug_.empty()) { + LOG(ERROR) << "Receive succesful payment message with " << reply_to_message_id << " in " << owner_dialog_id; + } reply_to_message_id = MessageId(); } - auto payment_sent = move_tl_object_as(action); return td::make_unique(reply_in_dialog_id, reply_to_message_id, - std::move(payment_sent->currency_), payment_sent->total_amount_); + std::move(payment_sent->currency_), payment_sent->total_amount_, + std::move(payment_sent->invoice_slug_)); } case telegram_api::messageActionPaymentSentMe::ID: { if (!td->auth_manager_->is_bot()) { @@ -4787,8 +4791,8 @@ unique_ptr get_action_message_content(Td *td, tl_object_ptr(action); auto result = td::make_unique( - DialogId(), MessageId(), std::move(payment_sent->currency_), payment_sent->total_amount_); - result->invoice_payload = payment_sent->payload_.as_slice().str(); + DialogId(), MessageId(), std::move(payment_sent->currency_), payment_sent->total_amount_, + payment_sent->payload_.as_slice().str()); result->shipping_option_id = std::move(payment_sent->shipping_option_id_); result->order_info = get_order_info(std::move(payment_sent->info_)); result->telegram_payment_charge_id = std::move(payment_sent->charge_->id_); @@ -5089,7 +5093,7 @@ tl_object_ptr get_message_content_object(const MessageCo } else { auto invoice_dialog_id = m->invoice_dialog_id.is_valid() ? m->invoice_dialog_id : dialog_id; return make_tl_object(invoice_dialog_id.get(), m->invoice_message_id.get(), - m->currency, m->total_amount); + m->currency, m->total_amount, m->invoice_payload); } } case MessageContentType::ContactRegistered: diff --git a/td/telegram/cli.cpp b/td/telegram/cli.cpp index b5961a82f..350f442fd 100644 --- a/td/telegram/cli.cpp +++ b/td/telegram/cli.cpp @@ -4878,7 +4878,7 @@ class CliClient final : public Actor { if (it->part_size > left_size) { it->part_size = left_size; } - BufferSlice block(it->part_size); + BufferSlice block(narrow_cast(it->part_size)); FileFd::open(it->source, FileFd::Flags::Read).move_as_ok().pread(block.as_slice(), it->local_size).ensure(); if (rand_bool()) { auto open_flags = FileFd::Flags::Write | (it->local_size ? 0 : FileFd::Flags::Truncate | FileFd::Flags::Create);