Add source to get_input_message_entities.

GitOrigin-RevId: 505c9c96286e7e6026902cbf1b92f1cc3142f5ad
This commit is contained in:
levlam 2018-04-02 01:10:22 +03:00
parent 7e21d35e43
commit 92e9550ebd
5 changed files with 39 additions and 30 deletions

View File

@ -223,7 +223,8 @@ InlineQueriesManager::get_input_bot_inline_message_media_auto(
if (input_reply_markup != nullptr) { if (input_reply_markup != nullptr) {
flags |= telegram_api::inputBotInlineMessageText::REPLY_MARKUP_MASK; flags |= telegram_api::inputBotInlineMessageText::REPLY_MARKUP_MASK;
} }
auto entities = get_input_message_entities(td_->contacts_manager_.get(), caption.entities); auto entities = get_input_message_entities(td_->contacts_manager_.get(), caption.entities,
"get_input_bot_inline_message_media_auto");
if (!entities.empty()) { if (!entities.empty()) {
flags |= telegram_api::inputBotInlineMessageText::ENTITIES_MASK; flags |= telegram_api::inputBotInlineMessageText::ENTITIES_MASK;
} }
@ -258,7 +259,8 @@ Result<tl_object_ptr<telegram_api::InputBotInlineMessage>> InlineQueriesManager:
} }
return make_tl_object<telegram_api::inputBotInlineMessageText>( return make_tl_object<telegram_api::inputBotInlineMessageText>(
flags, false /*ignored*/, std::move(input_message_text.text.text), flags, false /*ignored*/, std::move(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,
"get_inline_message"),
std::move(input_reply_markup)); std::move(input_reply_markup));
} }
if (constructor_id == td_api::inputMessageContact::ID) { if (constructor_id == td_api::inputMessageContact::ID) {

View File

@ -1604,7 +1604,8 @@ Result<vector<MessageEntity>> parse_html(string &text) {
} }
vector<tl_object_ptr<telegram_api::MessageEntity>> get_input_message_entities(const ContactsManager *contacts_manager, vector<tl_object_ptr<telegram_api::MessageEntity>> get_input_message_entities(const ContactsManager *contacts_manager,
const vector<MessageEntity> &entities) { const vector<MessageEntity> &entities,
const char *source) {
vector<tl_object_ptr<telegram_api::MessageEntity>> result; vector<tl_object_ptr<telegram_api::MessageEntity>> result;
for (auto &entity : entities) { for (auto &entity : entities) {
switch (entity.type) { switch (entity.type) {
@ -1637,7 +1638,7 @@ vector<tl_object_ptr<telegram_api::MessageEntity>> get_input_message_entities(co
break; break;
case MessageEntity::Type::MentionName: { case MessageEntity::Type::MentionName: {
auto input_user = contacts_manager->get_input_user(entity.user_id); auto input_user = contacts_manager->get_input_user(entity.user_id);
CHECK(input_user != nullptr); CHECK(input_user != nullptr) << source;
result.push_back(make_tl_object<telegram_api::inputMessageEntityMentionName>(entity.offset, entity.length, result.push_back(make_tl_object<telegram_api::inputMessageEntityMentionName>(entity.offset, entity.length,
std::move(input_user))); std::move(input_user)));
break; break;

View File

@ -158,7 +158,8 @@ Result<vector<MessageEntity>> parse_markdown(string &text);
Result<vector<MessageEntity>> parse_html(string &text); Result<vector<MessageEntity>> parse_html(string &text);
vector<tl_object_ptr<telegram_api::MessageEntity>> get_input_message_entities(const ContactsManager *contacts_manager, vector<tl_object_ptr<telegram_api::MessageEntity>> get_input_message_entities(const ContactsManager *contacts_manager,
const vector<MessageEntity> &entities); const vector<MessageEntity> &entities,
const char *source);
vector<tl_object_ptr<secret_api::MessageEntity>> get_input_secret_message_entities( vector<tl_object_ptr<secret_api::MessageEntity>> get_input_secret_message_entities(
const vector<MessageEntity> &entities); const vector<MessageEntity> &entities);

View File

@ -850,9 +850,10 @@ class SaveDraftMessageQuery : public Td::ResultHandler {
send_query(G()->net_query_creator().create(create_storer(telegram_api::messages_saveDraft( send_query(G()->net_query_creator().create(create_storer(telegram_api::messages_saveDraft(
flags, false /*ignored*/, reply_to_message_id.get(), std::move(input_peer), flags, false /*ignored*/, reply_to_message_id.get(), std::move(input_peer),
draft_message == nullptr ? "" : draft_message->input_message_text.text.text, draft_message == nullptr ? "" : draft_message->input_message_text.text.text,
draft_message == nullptr ? vector<tl_object_ptr<telegram_api::MessageEntity>>() draft_message == nullptr
: get_input_message_entities(td->contacts_manager_.get(), ? vector<tl_object_ptr<telegram_api::MessageEntity>>()
draft_message->input_message_text.text.entities))))); : get_input_message_entities(td->contacts_manager_.get(), draft_message->input_message_text.text.entities,
"SaveDraftMessageQuery")))));
} }
void on_result(uint64 id, BufferSlice packet) override { void on_result(uint64 id, BufferSlice packet) override {
@ -16089,11 +16090,11 @@ void MessagesManager::do_send_message(DialogId dialog_id, Message *m, vector<int
get_input_secret_message_entities(message_text->text.entities), m->via_bot_user_id, get_input_secret_message_entities(message_text->text.entities), m->via_bot_user_id,
m->media_album_id, random_id); m->media_album_id, random_id);
} else { } else {
send_closure(td_->create_net_actor<SendMessageActor>(), &SendMessageActor::send, get_message_flags(m), dialog_id, send_closure(
m->reply_to_message_id, get_input_reply_markup(m->reply_markup), td_->create_net_actor<SendMessageActor>(), &SendMessageActor::send, get_message_flags(m), dialog_id,
get_input_message_entities(td_->contacts_manager_.get(), message_text->text.entities), m->reply_to_message_id, get_input_reply_markup(m->reply_markup),
message_text->text.text, random_id, &m->send_query_ref, get_input_message_entities(td_->contacts_manager_.get(), message_text->text.entities, "do_send_message"),
get_sequence_dispatcher_id(dialog_id, content_type)); message_text->text.text, random_id, &m->send_query_ref, get_sequence_dispatcher_id(dialog_id, content_type));
} }
return; return;
} }
@ -16155,11 +16156,12 @@ void MessagesManager::on_message_media_uploaded(DialogId dialog_id, Message *m,
LOG(INFO) << "Send media from " << m->message_id << " in " << dialog_id << " in reply to " LOG(INFO) << "Send media from " << m->message_id << " in " << dialog_id << " in reply to "
<< m->reply_to_message_id; << m->reply_to_message_id;
int64 random_id = begin_send_message(dialog_id, m); int64 random_id = begin_send_message(dialog_id, m);
send_closure(td_->create_net_actor<SendMediaActor>(), &SendMediaActor::send, file_id, thumbnail_file_id, send_closure(
get_message_flags(m), dialog_id, m->reply_to_message_id, get_input_reply_markup(m->reply_markup), td_->create_net_actor<SendMediaActor>(), &SendMediaActor::send, file_id, thumbnail_file_id,
get_input_message_entities(td_->contacts_manager_.get(), caption.entities), caption.text, get_message_flags(m), dialog_id, m->reply_to_message_id, get_input_reply_markup(m->reply_markup),
std::move(input_media), random_id, &m->send_query_ref, get_input_message_entities(td_->contacts_manager_.get(), caption.entities, "on_message_media_uploaded"),
get_sequence_dispatcher_id(dialog_id, m->content->get_id())); caption.text, std::move(input_media), random_id, &m->send_query_ref,
get_sequence_dispatcher_id(dialog_id, m->content->get_id()));
})); }));
} else { } else {
switch (input_media->get_id()) { switch (input_media->get_id()) {
@ -16392,7 +16394,7 @@ void MessagesManager::do_send_message_group(int64 media_album_id) {
random_ids.push_back(begin_send_message(dialog_id, m)); random_ids.push_back(begin_send_message(dialog_id, m));
auto caption = get_message_content_caption(m->content.get()); auto caption = get_message_content_caption(m->content.get());
auto input_media = get_input_media(m->content.get(), nullptr, nullptr, m->ttl); auto input_media = get_input_media(m->content.get(), nullptr, nullptr, m->ttl);
auto entities = get_input_message_entities(td_->contacts_manager_.get(), caption.entities); auto entities = get_input_message_entities(td_->contacts_manager_.get(), caption.entities, "do_send_message_group");
int32 input_single_media_flags = 0; int32 input_single_media_flags = 0;
if (!entities.empty()) { if (!entities.empty()) {
input_single_media_flags |= telegram_api::inputSingleMedia::ENTITIES_MASK; input_single_media_flags |= telegram_api::inputSingleMedia::ENTITIES_MASK;
@ -16979,10 +16981,11 @@ void MessagesManager::edit_message_text(FullMessageId full_message_id,
flags |= SEND_MESSAGE_FLAG_DISABLE_WEB_PAGE_PREVIEW; flags |= SEND_MESSAGE_FLAG_DISABLE_WEB_PAGE_PREVIEW;
} }
send_closure(td_->create_net_actor<EditMessageActor>(std::move(promise)), &EditMessageActor::send, flags, dialog_id, send_closure(
message_id, input_message_text.text.text, td_->create_net_actor<EditMessageActor>(std::move(promise)), &EditMessageActor::send, flags, dialog_id,
get_input_message_entities(td_->contacts_manager_.get(), input_message_text.text.entities), nullptr, message_id, input_message_text.text.text,
std::move(input_reply_markup), get_sequence_dispatcher_id(dialog_id, -1)); get_input_message_entities(td_->contacts_manager_.get(), input_message_text.text.entities, "edit_message_text"),
nullptr, std::move(input_reply_markup), get_sequence_dispatcher_id(dialog_id, -1));
} }
void MessagesManager::edit_message_live_location(FullMessageId full_message_id, void MessagesManager::edit_message_live_location(FullMessageId full_message_id,
@ -17081,7 +17084,8 @@ void MessagesManager::edit_message_caption(FullMessageId full_message_id,
auto input_reply_markup = get_input_reply_markup(r_new_reply_markup.ok()); auto input_reply_markup = get_input_reply_markup(r_new_reply_markup.ok());
send_closure(td_->create_net_actor<EditMessageActor>(std::move(promise)), &EditMessageActor::send, 1 << 11, dialog_id, send_closure(td_->create_net_actor<EditMessageActor>(std::move(promise)), &EditMessageActor::send, 1 << 11, dialog_id,
message_id, caption.text, get_input_message_entities(td_->contacts_manager_.get(), caption.entities), message_id, caption.text,
get_input_message_entities(td_->contacts_manager_.get(), caption.entities, "edit_message_caption"),
nullptr, std::move(input_reply_markup), get_sequence_dispatcher_id(dialog_id, -1)); nullptr, std::move(input_reply_markup), get_sequence_dispatcher_id(dialog_id, -1));
} }
@ -17163,8 +17167,9 @@ void MessagesManager::edit_inline_message_text(const string &inline_message_id,
} }
td_->create_handler<EditInlineMessageQuery>(std::move(promise)) td_->create_handler<EditInlineMessageQuery>(std::move(promise))
->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), nullptr, get_input_message_entities(td_->contacts_manager_.get(), input_message_text.text.entities,
get_input_reply_markup(r_new_reply_markup.ok())); "edit_inline_message_text"),
nullptr, get_input_reply_markup(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,
@ -17226,8 +17231,8 @@ 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), nullptr, get_input_message_entities(td_->contacts_manager_.get(), caption.entities, "edit_inline_message_caption"),
get_input_reply_markup(r_new_reply_markup.ok())); nullptr, get_input_reply_markup(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,

View File

@ -1714,8 +1714,8 @@ int64 WebPagesManager::get_web_page_preview(td_api::object_ptr<td_api::formatted
promise.set_value(Unit()); promise.set_value(Unit());
} else { } else {
td_->create_handler<GetWebPagePreviewQuery>(std::move(promise)) td_->create_handler<GetWebPagePreviewQuery>(std::move(promise))
->send(text->text_, get_input_message_entities(td_->contacts_manager_.get(), entities), request_id, ->send(text->text_, get_input_message_entities(td_->contacts_manager_.get(), entities, "get_web_page_preview"),
std::move(url)); request_id, std::move(url));
} }
return request_id; return request_id;
} }