Explicitly pass ContactsManager to

get_input_reply_markup/get_reply_markup_object.
This commit is contained in:
levlam 2022-06-28 18:34:53 +03:00
parent 8f472521d4
commit e8dccae751
5 changed files with 45 additions and 40 deletions

View File

@ -349,7 +349,7 @@ Result<tl_object_ptr<telegram_api::InputBotInlineMessage>> InlineQueriesManager:
return Status::Error(400, "Inline message can't be empty"); return Status::Error(400, "Inline message can't be empty");
} }
TRY_RESULT(reply_markup, get_reply_markup(std::move(reply_markup_ptr), true, true, false, true)); TRY_RESULT(reply_markup, get_reply_markup(std::move(reply_markup_ptr), true, true, false, true));
auto input_reply_markup = get_input_reply_markup(reply_markup); auto input_reply_markup = get_input_reply_markup(td_->contacts_manager_.get(), reply_markup);
auto constructor_id = input_message_content->get_id(); auto constructor_id = input_message_content->get_id();
if (constructor_id == td_api::inputMessageText::ID) { if (constructor_id == td_api::inputMessageText::ID) {
@ -694,7 +694,7 @@ Result<tl_object_ptr<telegram_api::InputBotInlineResult>> InlineQueriesManager::
return r_reply_markup.move_as_error(); return r_reply_markup.move_as_error();
} }
auto input_reply_markup = get_input_reply_markup(r_reply_markup.ok()); auto input_reply_markup = get_input_reply_markup(td_->contacts_manager_.get(), r_reply_markup.ok());
int32 flags = 0; int32 flags = 0;
if (input_reply_markup != nullptr) { if (input_reply_markup != nullptr) {
flags |= telegram_api::inputBotInlineMessageGame::REPLY_MARKUP_MASK; flags |= telegram_api::inputBotInlineMessageGame::REPLY_MARKUP_MASK;

View File

@ -24602,7 +24602,7 @@ tl_object_ptr<td_api::message> MessagesManager::get_message_object(DialogId dial
auto edit_date = m->hide_edit_date ? 0 : m->edit_date; auto edit_date = m->hide_edit_date ? 0 : m->edit_date;
auto is_pinned = is_scheduled ? false : m->is_pinned; auto is_pinned = is_scheduled ? false : m->is_pinned;
auto has_timestamped_media = for_event_log || reply_to_message_id == 0 || m->max_own_media_timestamp >= 0; auto has_timestamped_media = for_event_log || reply_to_message_id == 0 || m->max_own_media_timestamp >= 0;
auto reply_markup = get_reply_markup_object(m->reply_markup); auto reply_markup = get_reply_markup_object(td_->contacts_manager_.get(), m->reply_markup);
auto live_location_date = m->is_failed_to_send ? 0 : m->date; auto live_location_date = m->is_failed_to_send ? 0 : m->date;
auto skip_bot_commands = for_event_log ? true : need_skip_bot_commands(dialog_id, m); auto skip_bot_commands = for_event_log ? true : need_skip_bot_commands(dialog_id, m);
@ -25725,7 +25725,7 @@ void MessagesManager::on_message_media_uploaded(DialogId dialog_id, const Messag
auto message_id = m->message_id; auto message_id = m->message_id;
if (message_id.is_any_server()) { if (message_id.is_any_server()) {
const FormattedText *caption = get_message_content_caption(m->edited_content.get()); const FormattedText *caption = get_message_content_caption(m->edited_content.get());
auto input_reply_markup = get_input_reply_markup(m->edited_reply_markup); auto input_reply_markup = get_input_reply_markup(td_->contacts_manager_.get(), m->edited_reply_markup);
bool was_uploaded = FileManager::extract_was_uploaded(input_media); bool was_uploaded = FileManager::extract_was_uploaded(input_media);
bool was_thumbnail_uploaded = FileManager::extract_was_thumbnail_uploaded(input_media); bool was_thumbnail_uploaded = FileManager::extract_was_thumbnail_uploaded(input_media);
@ -25765,7 +25765,8 @@ void MessagesManager::on_message_media_uploaded(DialogId dialog_id, const Messag
int64 random_id = begin_send_message(dialog_id, m); int64 random_id = begin_send_message(dialog_id, m);
td_->create_handler<SendMediaQuery>()->send( td_->create_handler<SendMediaQuery>()->send(
file_id, thumbnail_file_id, get_message_flags(m), dialog_id, get_send_message_as_input_peer(m), file_id, thumbnail_file_id, get_message_flags(m), dialog_id, get_send_message_as_input_peer(m),
m->reply_to_message_id, get_message_schedule_date(m), get_input_reply_markup(m->reply_markup), m->reply_to_message_id, get_message_schedule_date(m),
get_input_reply_markup(td_->contacts_manager_.get(), m->reply_markup),
get_input_message_entities(td_->contacts_manager_.get(), caption, "on_message_media_uploaded"), get_input_message_entities(td_->contacts_manager_.get(), caption, "on_message_media_uploaded"),
caption == nullptr ? "" : caption->text, std::move(input_media), m->content->get_type(), m->is_copy, caption == nullptr ? "" : caption->text, std::move(input_media), m->content->get_type(), m->is_copy,
random_id, &m->send_query_ref); random_id, &m->send_query_ref);
@ -26171,7 +26172,7 @@ void MessagesManager::on_text_message_ready_to_send(DialogId dialog_id, MessageI
int64 random_id = begin_send_message(dialog_id, m); int64 random_id = begin_send_message(dialog_id, m);
td_->create_handler<SendMessageQuery>()->send( td_->create_handler<SendMessageQuery>()->send(
get_message_flags(m), dialog_id, get_send_message_as_input_peer(m), m->reply_to_message_id, get_message_flags(m), dialog_id, get_send_message_as_input_peer(m), m->reply_to_message_id,
get_message_schedule_date(m), get_input_reply_markup(m->reply_markup), get_message_schedule_date(m), get_input_reply_markup(td_->contacts_manager_.get(), m->reply_markup),
get_input_message_entities(td_->contacts_manager_.get(), message_text->entities, "do_send_message"), get_input_message_entities(td_->contacts_manager_.get(), message_text->entities, "do_send_message"),
message_text->text, m->is_copy, random_id, &m->send_query_ref); message_text->text, m->is_copy, random_id, &m->send_query_ref);
} }
@ -26880,7 +26881,7 @@ void MessagesManager::edit_message_text(FullMessageId full_message_id,
if (r_new_reply_markup.is_error()) { if (r_new_reply_markup.is_error()) {
return promise.set_error(r_new_reply_markup.move_as_error()); return promise.set_error(r_new_reply_markup.move_as_error());
} }
auto input_reply_markup = get_input_reply_markup(r_new_reply_markup.ok()); auto input_reply_markup = get_input_reply_markup(td_->contacts_manager_.get(), r_new_reply_markup.ok());
int32 flags = 0; int32 flags = 0;
if (input_message_text.disable_web_page_preview) { if (input_message_text.disable_web_page_preview) {
flags |= SEND_MESSAGE_FLAG_DISABLE_WEB_PAGE_PREVIEW; flags |= SEND_MESSAGE_FLAG_DISABLE_WEB_PAGE_PREVIEW;
@ -26936,7 +26937,7 @@ void MessagesManager::edit_message_live_location(FullMessageId full_message_id,
if (r_new_reply_markup.is_error()) { if (r_new_reply_markup.is_error()) {
return promise.set_error(r_new_reply_markup.move_as_error()); return promise.set_error(r_new_reply_markup.move_as_error());
} }
auto input_reply_markup = get_input_reply_markup(r_new_reply_markup.ok()); auto input_reply_markup = get_input_reply_markup(td_->contacts_manager_.get(), r_new_reply_markup.ok());
int32 flags = 0; int32 flags = 0;
if (location.empty()) { if (location.empty()) {
@ -27172,7 +27173,7 @@ void MessagesManager::edit_message_caption(FullMessageId full_message_id,
if (r_new_reply_markup.is_error()) { if (r_new_reply_markup.is_error()) {
return promise.set_error(r_new_reply_markup.move_as_error()); return promise.set_error(r_new_reply_markup.move_as_error());
} }
auto input_reply_markup = get_input_reply_markup(r_new_reply_markup.ok()); auto input_reply_markup = get_input_reply_markup(td_->contacts_manager_.get(), r_new_reply_markup.ok());
td_->create_handler<EditMessageQuery>(std::move(promise)) td_->create_handler<EditMessageQuery>(std::move(promise))
->send(1 << 11, dialog_id, m->message_id, caption.text, ->send(1 << 11, dialog_id, m->message_id, caption.text,
@ -27212,7 +27213,7 @@ void MessagesManager::edit_message_reply_markup(FullMessageId full_message_id,
if (r_new_reply_markup.is_error()) { if (r_new_reply_markup.is_error()) {
return promise.set_error(r_new_reply_markup.move_as_error()); return promise.set_error(r_new_reply_markup.move_as_error());
} }
auto input_reply_markup = get_input_reply_markup(r_new_reply_markup.ok()); auto input_reply_markup = get_input_reply_markup(td_->contacts_manager_.get(), r_new_reply_markup.ok());
td_->create_handler<EditMessageQuery>(std::move(promise)) td_->create_handler<EditMessageQuery>(std::move(promise))
->send(0, dialog_id, m->message_id, string(), vector<tl_object_ptr<telegram_api::MessageEntity>>(), nullptr, ->send(0, dialog_id, m->message_id, string(), vector<tl_object_ptr<telegram_api::MessageEntity>>(), nullptr,
std::move(input_reply_markup), get_message_schedule_date(m)); std::move(input_reply_markup), get_message_schedule_date(m));
@ -27259,7 +27260,7 @@ void MessagesManager::edit_inline_message_text(const string &inline_message_id,
->send(flags, std::move(input_bot_inline_message_id), input_message_text.text.text, ->send(flags, std::move(input_bot_inline_message_id), input_message_text.text.text,
get_input_message_entities(td_->contacts_manager_.get(), input_message_text.text.entities, get_input_message_entities(td_->contacts_manager_.get(), input_message_text.text.entities,
"edit_inline_message_text"), "edit_inline_message_text"),
nullptr, get_input_reply_markup(r_new_reply_markup.ok())); nullptr, get_input_reply_markup(td_->contacts_manager_.get(), r_new_reply_markup.ok()));
} }
void MessagesManager::edit_inline_message_live_location(const string &inline_message_id, void MessagesManager::edit_inline_message_live_location(const string &inline_message_id,
@ -27297,7 +27298,7 @@ void MessagesManager::edit_inline_message_live_location(const string &inline_mes
flags, false /*ignored*/, location.get_input_geo_point(), heading, 0, proximity_alert_radius); flags, false /*ignored*/, location.get_input_geo_point(), heading, 0, proximity_alert_radius);
td_->create_handler<EditInlineMessageQuery>(std::move(promise)) td_->create_handler<EditInlineMessageQuery>(std::move(promise))
->send(0, std::move(input_bot_inline_message_id), "", vector<tl_object_ptr<telegram_api::MessageEntity>>(), ->send(0, std::move(input_bot_inline_message_id), "", vector<tl_object_ptr<telegram_api::MessageEntity>>(),
std::move(input_media), get_input_reply_markup(r_new_reply_markup.ok())); std::move(input_media), get_input_reply_markup(td_->contacts_manager_.get(), r_new_reply_markup.ok()));
} }
void MessagesManager::edit_inline_message_media(const string &inline_message_id, void MessagesManager::edit_inline_message_media(const string &inline_message_id,
@ -27349,7 +27350,7 @@ void MessagesManager::edit_inline_message_media(const string &inline_message_id,
td_->create_handler<EditInlineMessageQuery>(std::move(promise)) td_->create_handler<EditInlineMessageQuery>(std::move(promise))
->send(1 << 11, std::move(input_bot_inline_message_id), caption == nullptr ? "" : caption->text, ->send(1 << 11, std::move(input_bot_inline_message_id), caption == nullptr ? "" : caption->text,
get_input_message_entities(td_->contacts_manager_.get(), caption, "edit_inline_message_media"), get_input_message_entities(td_->contacts_manager_.get(), caption, "edit_inline_message_media"),
std::move(input_media), get_input_reply_markup(r_new_reply_markup.ok())); std::move(input_media), get_input_reply_markup(td_->contacts_manager_.get(), r_new_reply_markup.ok()));
} }
void MessagesManager::edit_inline_message_caption(const string &inline_message_id, void MessagesManager::edit_inline_message_caption(const string &inline_message_id,
@ -27380,7 +27381,7 @@ void MessagesManager::edit_inline_message_caption(const string &inline_message_i
td_->create_handler<EditInlineMessageQuery>(std::move(promise)) td_->create_handler<EditInlineMessageQuery>(std::move(promise))
->send(1 << 11, std::move(input_bot_inline_message_id), caption.text, ->send(1 << 11, std::move(input_bot_inline_message_id), caption.text,
get_input_message_entities(td_->contacts_manager_.get(), caption.entities, "edit_inline_message_caption"), get_input_message_entities(td_->contacts_manager_.get(), caption.entities, "edit_inline_message_caption"),
nullptr, get_input_reply_markup(r_new_reply_markup.ok())); nullptr, get_input_reply_markup(td_->contacts_manager_.get(), r_new_reply_markup.ok()));
} }
void MessagesManager::edit_inline_message_reply_markup(const string &inline_message_id, void MessagesManager::edit_inline_message_reply_markup(const string &inline_message_id,
@ -27402,7 +27403,7 @@ void MessagesManager::edit_inline_message_reply_markup(const string &inline_mess
td_->create_handler<EditInlineMessageQuery>(std::move(promise)) td_->create_handler<EditInlineMessageQuery>(std::move(promise))
->send(0, std::move(input_bot_inline_message_id), string(), vector<tl_object_ptr<telegram_api::MessageEntity>>(), ->send(0, std::move(input_bot_inline_message_id), string(), vector<tl_object_ptr<telegram_api::MessageEntity>>(),
nullptr, get_input_reply_markup(r_new_reply_markup.ok())); nullptr, get_input_reply_markup(td_->contacts_manager_.get(), r_new_reply_markup.ok()));
} }
void MessagesManager::edit_message_scheduling_state( void MessagesManager::edit_message_scheduling_state(
@ -30391,8 +30392,9 @@ void MessagesManager::send_update_message_edited(DialogId dialog_id, const Messa
cancel_dialog_action(dialog_id, m); cancel_dialog_action(dialog_id, m);
auto edit_date = m->hide_edit_date ? 0 : m->edit_date; auto edit_date = m->hide_edit_date ? 0 : m->edit_date;
send_closure(G()->td(), &Td::send_update, send_closure(G()->td(), &Td::send_update,
make_tl_object<td_api::updateMessageEdited>(dialog_id.get(), m->message_id.get(), edit_date, make_tl_object<td_api::updateMessageEdited>(
get_reply_markup_object(m->reply_markup))); dialog_id.get(), m->message_id.get(), edit_date,
get_reply_markup_object(td_->contacts_manager_.get(), m->reply_markup)));
} }
void MessagesManager::send_update_message_interaction_info(DialogId dialog_id, const Message *m) const { void MessagesManager::send_update_message_interaction_info(DialogId dialog_id, const Message *m) const {

View File

@ -195,7 +195,7 @@ class StopPollQuery final : public Td::ResultHandler {
} }
int32 flags = telegram_api::messages_editMessage::MEDIA_MASK; int32 flags = telegram_api::messages_editMessage::MEDIA_MASK;
auto input_reply_markup = get_input_reply_markup(reply_markup); auto input_reply_markup = get_input_reply_markup(td_->contacts_manager_.get(), reply_markup);
if (input_reply_markup != nullptr) { if (input_reply_markup != nullptr) {
flags |= telegram_api::messages_editMessage::REPLY_MARKUP_MASK; flags |= telegram_api::messages_editMessage::REPLY_MARKUP_MASK;
} }

View File

@ -11,7 +11,6 @@
#include "td/telegram/Global.h" #include "td/telegram/Global.h"
#include "td/telegram/LinkManager.h" #include "td/telegram/LinkManager.h"
#include "td/telegram/misc.h" #include "td/telegram/misc.h"
#include "td/telegram/Td.h"
#include "td/telegram/td_api.h" #include "td/telegram/td_api.h"
#include "td/telegram/telegram_api.h" #include "td/telegram/telegram_api.h"
@ -703,7 +702,7 @@ Result<unique_ptr<ReplyMarkup>> get_reply_markup(tl_object_ptr<td_api::ReplyMark
return std::move(reply_markup); return std::move(reply_markup);
} }
static tl_object_ptr<telegram_api::KeyboardButton> get_keyboard_button(const KeyboardButton &keyboard_button) { static tl_object_ptr<telegram_api::KeyboardButton> get_input_keyboard_button(const KeyboardButton &keyboard_button) {
switch (keyboard_button.type) { switch (keyboard_button.type) {
case KeyboardButton::Type::Text: case KeyboardButton::Type::Text:
return make_tl_object<telegram_api::keyboardButton>(keyboard_button.text); return make_tl_object<telegram_api::keyboardButton>(keyboard_button.text);
@ -725,8 +724,8 @@ static tl_object_ptr<telegram_api::KeyboardButton> get_keyboard_button(const Key
} }
} }
static tl_object_ptr<telegram_api::KeyboardButton> get_inline_keyboard_button( static tl_object_ptr<telegram_api::KeyboardButton> get_input_keyboard_button(
const InlineKeyboardButton &keyboard_button) { ContactsManager *contacts_manager, const InlineKeyboardButton &keyboard_button) {
switch (keyboard_button.type) { switch (keyboard_button.type) {
case InlineKeyboardButton::Type::Url: case InlineKeyboardButton::Type::Url:
return make_tl_object<telegram_api::keyboardButtonUrl>(keyboard_button.text, keyboard_button.data); return make_tl_object<telegram_api::keyboardButtonUrl>(keyboard_button.text, keyboard_button.data);
@ -757,7 +756,7 @@ static tl_object_ptr<telegram_api::KeyboardButton> get_inline_keyboard_button(
if (!keyboard_button.forward_text.empty()) { if (!keyboard_button.forward_text.empty()) {
flags |= telegram_api::inputKeyboardButtonUrlAuth::FWD_TEXT_MASK; flags |= telegram_api::inputKeyboardButtonUrlAuth::FWD_TEXT_MASK;
} }
auto r_input_user = G()->td().get_actor_unsafe()->contacts_manager_->get_input_user(UserId(bot_user_id)); auto r_input_user = contacts_manager->get_input_user(UserId(bot_user_id));
if (r_input_user.is_error()) { if (r_input_user.is_error()) {
LOG(ERROR) << "Failed to get InputUser for " << bot_user_id << ": " << r_input_user.error(); LOG(ERROR) << "Failed to get InputUser for " << bot_user_id << ": " << r_input_user.error();
return make_tl_object<telegram_api::keyboardButtonUrl>(keyboard_button.text, keyboard_button.data); return make_tl_object<telegram_api::keyboardButtonUrl>(keyboard_button.text, keyboard_button.data);
@ -770,7 +769,7 @@ static tl_object_ptr<telegram_api::KeyboardButton> get_inline_keyboard_button(
UNREACHABLE(); UNREACHABLE();
break; break;
case InlineKeyboardButton::Type::User: { case InlineKeyboardButton::Type::User: {
auto r_input_user = G()->td().get_actor_unsafe()->contacts_manager_->get_input_user(keyboard_button.user_id); auto r_input_user = contacts_manager->get_input_user(keyboard_button.user_id);
if (r_input_user.is_error()) { if (r_input_user.is_error()) {
LOG(ERROR) << "Failed to get InputUser for " << keyboard_button.user_id << ": " << r_input_user.error(); LOG(ERROR) << "Failed to get InputUser for " << keyboard_button.user_id << ": " << r_input_user.error();
r_input_user = make_tl_object<telegram_api::inputUserEmpty>(); r_input_user = make_tl_object<telegram_api::inputUserEmpty>();
@ -786,7 +785,7 @@ static tl_object_ptr<telegram_api::KeyboardButton> get_inline_keyboard_button(
} }
} }
tl_object_ptr<telegram_api::ReplyMarkup> ReplyMarkup::get_input_reply_markup() const { tl_object_ptr<telegram_api::ReplyMarkup> ReplyMarkup::get_input_reply_markup(ContactsManager *contacts_manager) const {
LOG(DEBUG) << "Send " << *this; LOG(DEBUG) << "Send " << *this;
switch (type) { switch (type) {
case ReplyMarkup::Type::InlineKeyboard: { case ReplyMarkup::Type::InlineKeyboard: {
@ -796,7 +795,7 @@ tl_object_ptr<telegram_api::ReplyMarkup> ReplyMarkup::get_input_reply_markup() c
vector<tl_object_ptr<telegram_api::KeyboardButton>> buttons; vector<tl_object_ptr<telegram_api::KeyboardButton>> buttons;
buttons.reserve(row.size()); buttons.reserve(row.size());
for (auto &button : row) { for (auto &button : row) {
buttons.push_back(get_inline_keyboard_button(button)); buttons.push_back(get_input_keyboard_button(contacts_manager, button));
} }
rows.push_back(make_tl_object<telegram_api::keyboardButtonRow>(std::move(buttons))); rows.push_back(make_tl_object<telegram_api::keyboardButtonRow>(std::move(buttons)));
} }
@ -810,7 +809,7 @@ tl_object_ptr<telegram_api::ReplyMarkup> ReplyMarkup::get_input_reply_markup() c
vector<tl_object_ptr<telegram_api::KeyboardButton>> buttons; vector<tl_object_ptr<telegram_api::KeyboardButton>> buttons;
buttons.reserve(row.size()); buttons.reserve(row.size());
for (auto &button : row) { for (auto &button : row) {
buttons.push_back(get_keyboard_button(button)); buttons.push_back(get_input_keyboard_button(button));
} }
rows.push_back(make_tl_object<telegram_api::keyboardButtonRow>(std::move(buttons))); rows.push_back(make_tl_object<telegram_api::keyboardButtonRow>(std::move(buttons)));
} }
@ -868,7 +867,7 @@ static tl_object_ptr<td_api::keyboardButton> get_keyboard_button_object(const Ke
} }
static tl_object_ptr<td_api::inlineKeyboardButton> get_inline_keyboard_button_object( static tl_object_ptr<td_api::inlineKeyboardButton> get_inline_keyboard_button_object(
const InlineKeyboardButton &keyboard_button) { ContactsManager *contacts_manager, const InlineKeyboardButton &keyboard_button) {
tl_object_ptr<td_api::InlineKeyboardButtonType> type; tl_object_ptr<td_api::InlineKeyboardButtonType> type;
switch (keyboard_button.type) { switch (keyboard_button.type) {
case InlineKeyboardButton::Type::Url: case InlineKeyboardButton::Type::Url:
@ -898,8 +897,7 @@ static tl_object_ptr<td_api::inlineKeyboardButton> get_inline_keyboard_button_ob
break; break;
case InlineKeyboardButton::Type::User: case InlineKeyboardButton::Type::User:
type = make_tl_object<td_api::inlineKeyboardButtonTypeUser>( type = make_tl_object<td_api::inlineKeyboardButtonTypeUser>(
G()->td().get_actor_unsafe()->contacts_manager_->get_user_id_object(keyboard_button.user_id, contacts_manager->get_user_id_object(keyboard_button.user_id, "get_inline_keyboard_button_object"));
"get_inline_keyboard_button_object"));
break; break;
case InlineKeyboardButton::Type::WebView: case InlineKeyboardButton::Type::WebView:
type = make_tl_object<td_api::inlineKeyboardButtonTypeWebApp>(keyboard_button.data); type = make_tl_object<td_api::inlineKeyboardButtonTypeWebApp>(keyboard_button.data);
@ -911,7 +909,7 @@ static tl_object_ptr<td_api::inlineKeyboardButton> get_inline_keyboard_button_ob
return make_tl_object<td_api::inlineKeyboardButton>(keyboard_button.text, std::move(type)); return make_tl_object<td_api::inlineKeyboardButton>(keyboard_button.text, std::move(type));
} }
tl_object_ptr<td_api::ReplyMarkup> ReplyMarkup::get_reply_markup_object() const { tl_object_ptr<td_api::ReplyMarkup> ReplyMarkup::get_reply_markup_object(ContactsManager *contacts_manager) const {
switch (type) { switch (type) {
case ReplyMarkup::Type::InlineKeyboard: { case ReplyMarkup::Type::InlineKeyboard: {
vector<vector<tl_object_ptr<td_api::inlineKeyboardButton>>> rows; vector<vector<tl_object_ptr<td_api::inlineKeyboardButton>>> rows;
@ -920,7 +918,7 @@ tl_object_ptr<td_api::ReplyMarkup> ReplyMarkup::get_reply_markup_object() const
vector<tl_object_ptr<td_api::inlineKeyboardButton>> buttons; vector<tl_object_ptr<td_api::inlineKeyboardButton>> buttons;
buttons.reserve(row.size()); buttons.reserve(row.size());
for (auto &button : row) { for (auto &button : row) {
buttons.push_back(get_inline_keyboard_button_object(button)); buttons.push_back(get_inline_keyboard_button_object(contacts_manager, button));
} }
rows.push_back(std::move(buttons)); rows.push_back(std::move(buttons));
} }
@ -952,20 +950,22 @@ tl_object_ptr<td_api::ReplyMarkup> ReplyMarkup::get_reply_markup_object() const
} }
} }
tl_object_ptr<telegram_api::ReplyMarkup> get_input_reply_markup(const unique_ptr<ReplyMarkup> &reply_markup) { tl_object_ptr<telegram_api::ReplyMarkup> get_input_reply_markup(ContactsManager *contacts_manager,
const unique_ptr<ReplyMarkup> &reply_markup) {
if (reply_markup == nullptr) { if (reply_markup == nullptr) {
return nullptr; return nullptr;
} }
return reply_markup->get_input_reply_markup(); return reply_markup->get_input_reply_markup(contacts_manager);
} }
tl_object_ptr<td_api::ReplyMarkup> get_reply_markup_object(const unique_ptr<ReplyMarkup> &reply_markup) { tl_object_ptr<td_api::ReplyMarkup> get_reply_markup_object(ContactsManager *contacts_manager,
const unique_ptr<ReplyMarkup> &reply_markup) {
if (reply_markup == nullptr) { if (reply_markup == nullptr) {
return nullptr; return nullptr;
} }
return reply_markup->get_reply_markup_object(); return reply_markup->get_reply_markup_object(contacts_manager);
} }
void add_reply_markup_dependencies(Dependencies &dependencies, const ReplyMarkup *reply_markup) { void add_reply_markup_dependencies(Dependencies &dependencies, const ReplyMarkup *reply_markup) {

View File

@ -16,6 +16,7 @@
namespace td { namespace td {
class ContactsManager;
class Dependencies; class Dependencies;
struct KeyboardButton { struct KeyboardButton {
@ -72,9 +73,9 @@ struct ReplyMarkup {
StringBuilder &print(StringBuilder &string_builder) const; StringBuilder &print(StringBuilder &string_builder) const;
tl_object_ptr<telegram_api::ReplyMarkup> get_input_reply_markup() const; tl_object_ptr<telegram_api::ReplyMarkup> get_input_reply_markup(ContactsManager *contacts_manager) const;
tl_object_ptr<td_api::ReplyMarkup> get_reply_markup_object() const; tl_object_ptr<td_api::ReplyMarkup> get_reply_markup_object(ContactsManager *contacts_manager) const;
}; };
bool operator==(const ReplyMarkup &lhs, const ReplyMarkup &rhs); bool operator==(const ReplyMarkup &lhs, const ReplyMarkup &rhs);
@ -89,9 +90,11 @@ Result<unique_ptr<ReplyMarkup>> get_reply_markup(tl_object_ptr<td_api::ReplyMark
bool only_inline_keyboard, bool request_buttons_allowed, bool only_inline_keyboard, bool request_buttons_allowed,
bool switch_inline_buttons_allowed) TD_WARN_UNUSED_RESULT; bool switch_inline_buttons_allowed) TD_WARN_UNUSED_RESULT;
tl_object_ptr<telegram_api::ReplyMarkup> get_input_reply_markup(const unique_ptr<ReplyMarkup> &reply_markup); tl_object_ptr<telegram_api::ReplyMarkup> get_input_reply_markup(ContactsManager *contacts_manager,
const unique_ptr<ReplyMarkup> &reply_markup);
tl_object_ptr<td_api::ReplyMarkup> get_reply_markup_object(const unique_ptr<ReplyMarkup> &reply_markup); tl_object_ptr<td_api::ReplyMarkup> get_reply_markup_object(ContactsManager *contacts_manager,
const unique_ptr<ReplyMarkup> &reply_markup);
void add_reply_markup_dependencies(Dependencies &dependencies, const ReplyMarkup *reply_markup); void add_reply_markup_dependencies(Dependencies &dependencies, const ReplyMarkup *reply_markup);