diff --git a/td/telegram/MessagesManager.cpp b/td/telegram/MessagesManager.cpp index 88625dceb..9fef40c81 100644 --- a/td/telegram/MessagesManager.cpp +++ b/td/telegram/MessagesManager.cpp @@ -37366,7 +37366,7 @@ void MessagesManager::get_payment_form(FullMessageId full_message_id, return promise.set_error(r_message_id.move_as_error()); } - ::td::get_payment_form(full_message_id.get_dialog_id(), r_message_id.ok(), std::move(promise)); + ::td::get_payment_form(td_, full_message_id.get_dialog_id(), r_message_id.ok(), std::move(promise)); } void MessagesManager::validate_order_info(FullMessageId full_message_id, tl_object_ptr order_info, @@ -37377,7 +37377,7 @@ void MessagesManager::validate_order_info(FullMessageId full_message_id, tl_obje return promise.set_error(r_message_id.move_as_error()); } - ::td::validate_order_info(full_message_id.get_dialog_id(), r_message_id.ok(), std::move(order_info), allow_save, + ::td::validate_order_info(td_, full_message_id.get_dialog_id(), r_message_id.ok(), std::move(order_info), allow_save, std::move(promise)); } @@ -37390,7 +37390,7 @@ void MessagesManager::send_payment_form(FullMessageId full_message_id, int64 pay return promise.set_error(r_message_id.move_as_error()); } - ::td::send_payment_form(full_message_id.get_dialog_id(), r_message_id.ok(), payment_form_id, order_info_id, + ::td::send_payment_form(td_, full_message_id.get_dialog_id(), r_message_id.ok(), payment_form_id, order_info_id, shipping_option_id, credentials, tip_amount, std::move(promise)); } @@ -37410,7 +37410,8 @@ void MessagesManager::get_payment_receipt(FullMessageId full_message_id, return promise.set_error(Status::Error(5, "Wrong message identifier")); } - ::td::get_payment_receipt(full_message_id.get_dialog_id(), m->message_id.get_server_message_id(), std::move(promise)); + ::td::get_payment_receipt(td_, full_message_id.get_dialog_id(), m->message_id.get_server_message_id(), + std::move(promise)); } void MessagesManager::remove_sponsored_dialog() { diff --git a/td/telegram/Payments.cpp b/td/telegram/Payments.cpp index c8e231613..83924a84a 100644 --- a/td/telegram/Payments.cpp +++ b/td/telegram/Payments.cpp @@ -1070,7 +1070,8 @@ StringBuilder &operator<<(StringBuilder &string_builder, const ShippingOption &s << " with price parts " << format::as_array(shipping_option.price_parts) << "]"; } -void answer_shipping_query(int64 shipping_query_id, vector> &&shipping_options, +void answer_shipping_query(Td *td, int64 shipping_query_id, + vector> &&shipping_options, const string &error_message, Promise &&promise) { vector> options; for (auto &option : shipping_options) { @@ -1100,28 +1101,21 @@ void answer_shipping_query(int64 shipping_query_id, vectortd() - .get_actor_unsafe() - ->create_handler(std::move(promise)) + td->create_handler(std::move(promise)) ->send(shipping_query_id, error_message, std::move(options)); } -void answer_pre_checkout_query(int64 pre_checkout_query_id, const string &error_message, Promise &&promise) { - G()->td() - .get_actor_unsafe() - ->create_handler(std::move(promise)) - ->send(pre_checkout_query_id, error_message); +void answer_pre_checkout_query(Td *td, int64 pre_checkout_query_id, const string &error_message, + Promise &&promise) { + td->create_handler(std::move(promise))->send(pre_checkout_query_id, error_message); } -void get_payment_form(DialogId dialog_id, ServerMessageId server_message_id, +void get_payment_form(Td *td, DialogId dialog_id, ServerMessageId server_message_id, Promise> &&promise) { - G()->td() - .get_actor_unsafe() - ->create_handler(std::move(promise)) - ->send(dialog_id, server_message_id); + td->create_handler(std::move(promise))->send(dialog_id, server_message_id); } -void validate_order_info(DialogId dialog_id, ServerMessageId server_message_id, +void validate_order_info(Td *td, DialogId dialog_id, ServerMessageId server_message_id, tl_object_ptr order_info, bool allow_save, Promise> &&promise) { if (order_info != nullptr) { @@ -1156,13 +1150,11 @@ void validate_order_info(DialogId dialog_id, ServerMessageId server_message_id, } } - G()->td() - .get_actor_unsafe() - ->create_handler(std::move(promise)) + td->create_handler(std::move(promise)) ->send(dialog_id, server_message_id, convert_order_info(std::move(order_info)), allow_save); } -void send_payment_form(DialogId dialog_id, ServerMessageId server_message_id, int64 payment_form_id, +void send_payment_form(Td *td, DialogId dialog_id, ServerMessageId server_message_id, int64 payment_form_id, const string &order_info_id, const string &shipping_option_id, const tl_object_ptr &credentials, int64 tip_amount, Promise> &&promise) { @@ -1176,8 +1168,7 @@ void send_payment_form(DialogId dialog_id, ServerMessageId server_message_id, in if (!clean_input_string(credentials_id)) { return promise.set_error(Status::Error(400, "Credentials identifier must be encoded in UTF-8")); } - auto temp_password_state = - G()->td().get_actor_unsafe()->password_manager_->get_actor_unsafe()->get_temp_password_state_sync(); + auto temp_password_state = td->password_manager_->get_actor_unsafe()->get_temp_password_state_sync(); if (!temp_password_state.has_temp_password) { return promise.set_error(Status::Error(400, "Temporary password required to use saved credentials")); } @@ -1213,35 +1204,31 @@ void send_payment_form(DialogId dialog_id, ServerMessageId server_message_id, in UNREACHABLE(); } - G()->td() - .get_actor_unsafe() - ->create_handler(std::move(promise)) + td->create_handler(std::move(promise)) ->send(dialog_id, server_message_id, payment_form_id, order_info_id, shipping_option_id, std::move(input_credentials), tip_amount); } -void get_payment_receipt(DialogId dialog_id, ServerMessageId server_message_id, +void get_payment_receipt(Td *td, DialogId dialog_id, ServerMessageId server_message_id, Promise> &&promise) { - G()->td() - .get_actor_unsafe() - ->create_handler(std::move(promise)) - ->send(dialog_id, server_message_id); + td->create_handler(std::move(promise))->send(dialog_id, server_message_id); } -void get_saved_order_info(Promise> &&promise) { - G()->td().get_actor_unsafe()->create_handler(std::move(promise))->send(); +void get_saved_order_info(Td *td, Promise> &&promise) { + td->create_handler(std::move(promise))->send(); } -void delete_saved_order_info(Promise &&promise) { - G()->td().get_actor_unsafe()->create_handler(std::move(promise))->send(false, true); +void delete_saved_order_info(Td *td, Promise &&promise) { + td->create_handler(std::move(promise))->send(false, true); } -void delete_saved_credentials(Promise &&promise) { - G()->td().get_actor_unsafe()->create_handler(std::move(promise))->send(true, false); +void delete_saved_credentials(Td *td, Promise &&promise) { + td->create_handler(std::move(promise))->send(true, false); } -void get_bank_card_info(const string &bank_card_number, Promise> &&promise) { - G()->td().get_actor_unsafe()->create_handler(std::move(promise))->send(bank_card_number); +void get_bank_card_info(Td *td, const string &bank_card_number, + Promise> &&promise) { + td->create_handler(std::move(promise))->send(bank_card_number); } } // namespace td diff --git a/td/telegram/Payments.h b/td/telegram/Payments.h index 21230d383..5fcb86d84 100644 --- a/td/telegram/Payments.h +++ b/td/telegram/Payments.h @@ -172,32 +172,35 @@ bool operator!=(const ShippingOption &lhs, const ShippingOption &rhs); StringBuilder &operator<<(StringBuilder &string_builder, const ShippingOption &shipping_option); -void answer_shipping_query(int64 shipping_query_id, vector> &&shipping_options, +void answer_shipping_query(Td *td, int64 shipping_query_id, + vector> &&shipping_options, const string &error_message, Promise &&promise); -void answer_pre_checkout_query(int64 pre_checkout_query_id, const string &error_message, Promise &&promise); +void answer_pre_checkout_query(Td *td, int64 pre_checkout_query_id, const string &error_message, + Promise &&promise); -void get_payment_form(DialogId dialog_id, ServerMessageId server_message_id, +void get_payment_form(Td *td, DialogId dialog_id, ServerMessageId server_message_id, Promise> &&promise); -void validate_order_info(DialogId dialog_id, ServerMessageId server_message_id, +void validate_order_info(Td *td, DialogId dialog_id, ServerMessageId server_message_id, tl_object_ptr order_info, bool allow_save, Promise> &&promise); -void send_payment_form(DialogId dialog_id, ServerMessageId server_message_id, int64 payment_form_id, +void send_payment_form(Td *td, DialogId dialog_id, ServerMessageId server_message_id, int64 payment_form_id, const string &order_info_id, const string &shipping_option_id, const tl_object_ptr &credentials, int64 tip_amount, Promise> &&promise); -void get_payment_receipt(DialogId dialog_id, ServerMessageId server_message_id, +void get_payment_receipt(Td *td, DialogId dialog_id, ServerMessageId server_message_id, Promise> &&promise); -void get_saved_order_info(Promise> &&promise); +void get_saved_order_info(Td *td, Promise> &&promise); -void delete_saved_order_info(Promise &&promise); +void delete_saved_order_info(Td *td, Promise &&promise); -void delete_saved_credentials(Promise &&promise); +void delete_saved_credentials(Td *td, Promise &&promise); -void get_bank_card_info(const string &bank_card_number, Promise> &&promise); +void get_bank_card_info(Td *td, const string &bank_card_number, + Promise> &&promise); } // namespace td diff --git a/td/telegram/Td.cpp b/td/telegram/Td.cpp index 1c3b7df4e..904e03456 100644 --- a/td/telegram/Td.cpp +++ b/td/telegram/Td.cpp @@ -7693,7 +7693,7 @@ void Td::on_request(uint64 id, td_api::answerShippingQuery &request) { CHECK_IS_BOT(); CLEAN_INPUT_STRING(request.error_message_); CREATE_OK_REQUEST_PROMISE(); - answer_shipping_query(request.shipping_query_id_, std::move(request.shipping_options_), request.error_message_, + answer_shipping_query(this, request.shipping_query_id_, std::move(request.shipping_options_), request.error_message_, std::move(promise)); } @@ -7701,14 +7701,14 @@ void Td::on_request(uint64 id, td_api::answerPreCheckoutQuery &request) { CHECK_IS_BOT(); CLEAN_INPUT_STRING(request.error_message_); CREATE_OK_REQUEST_PROMISE(); - answer_pre_checkout_query(request.pre_checkout_query_id_, request.error_message_, std::move(promise)); + answer_pre_checkout_query(this, request.pre_checkout_query_id_, request.error_message_, std::move(promise)); } void Td::on_request(uint64 id, td_api::getBankCardInfo &request) { CHECK_IS_USER(); CLEAN_INPUT_STRING(request.bank_card_number_); CREATE_REQUEST_PROMISE(); - get_bank_card_info(request.bank_card_number_, std::move(promise)); + get_bank_card_info(this, request.bank_card_number_, std::move(promise)); } void Td::on_request(uint64 id, const td_api::getPaymentForm &request) { @@ -7747,19 +7747,19 @@ void Td::on_request(uint64 id, const td_api::getPaymentReceipt &request) { void Td::on_request(uint64 id, const td_api::getSavedOrderInfo &request) { CHECK_IS_USER(); CREATE_REQUEST_PROMISE(); - get_saved_order_info(std::move(promise)); + get_saved_order_info(this, std::move(promise)); } void Td::on_request(uint64 id, const td_api::deleteSavedOrderInfo &request) { CHECK_IS_USER(); CREATE_OK_REQUEST_PROMISE(); - delete_saved_order_info(std::move(promise)); + delete_saved_order_info(this, std::move(promise)); } void Td::on_request(uint64 id, const td_api::deleteSavedCredentials &request) { CHECK_IS_USER(); CREATE_OK_REQUEST_PROMISE(); - delete_saved_credentials(std::move(promise)); + delete_saved_credentials(this, std::move(promise)); } void Td::on_request(uint64 id, td_api::getPassportElement &request) {