diff --git a/td/telegram/InlineQueriesManager.cpp b/td/telegram/InlineQueriesManager.cpp index c84aa8ce..682da9e5 100644 --- a/td/telegram/InlineQueriesManager.cpp +++ b/td/telegram/InlineQueriesManager.cpp @@ -223,7 +223,8 @@ InlineQueriesManager::get_input_bot_inline_message_media_auto( if (input_reply_markup != nullptr) { 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()) { flags |= telegram_api::inputBotInlineMessageText::ENTITIES_MASK; } @@ -258,7 +259,8 @@ Result> InlineQueriesManager: } return make_tl_object( 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)); } if (constructor_id == td_api::inputMessageContact::ID) { diff --git a/td/telegram/MessageEntity.cpp b/td/telegram/MessageEntity.cpp index 8830101a..f9602d29 100644 --- a/td/telegram/MessageEntity.cpp +++ b/td/telegram/MessageEntity.cpp @@ -1604,7 +1604,8 @@ Result> parse_html(string &text) { } vector> get_input_message_entities(const ContactsManager *contacts_manager, - const vector &entities) { + const vector &entities, + const char *source) { vector> result; for (auto &entity : entities) { switch (entity.type) { @@ -1637,7 +1638,7 @@ vector> get_input_message_entities(co break; case MessageEntity::Type::MentionName: { 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(entity.offset, entity.length, std::move(input_user))); break; diff --git a/td/telegram/MessageEntity.h b/td/telegram/MessageEntity.h index 871af94f..78376510 100644 --- a/td/telegram/MessageEntity.h +++ b/td/telegram/MessageEntity.h @@ -158,7 +158,8 @@ Result> parse_markdown(string &text); Result> parse_html(string &text); vector> get_input_message_entities(const ContactsManager *contacts_manager, - const vector &entities); + const vector &entities, + const char *source); vector> get_input_secret_message_entities( const vector &entities); diff --git a/td/telegram/MessagesManager.cpp b/td/telegram/MessagesManager.cpp index 531167a9..ccf278e7 100644 --- a/td/telegram/MessagesManager.cpp +++ b/td/telegram/MessagesManager.cpp @@ -850,9 +850,10 @@ class SaveDraftMessageQuery : public Td::ResultHandler { 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), draft_message == nullptr ? "" : draft_message->input_message_text.text.text, - draft_message == nullptr ? vector>() - : get_input_message_entities(td->contacts_manager_.get(), - draft_message->input_message_text.text.entities))))); + draft_message == nullptr + ? vector>() + : get_input_message_entities(td->contacts_manager_.get(), draft_message->input_message_text.text.entities, + "SaveDraftMessageQuery"))))); } void on_result(uint64 id, BufferSlice packet) override { @@ -16089,11 +16090,11 @@ void MessagesManager::do_send_message(DialogId dialog_id, Message *m, vectortext.entities), m->via_bot_user_id, m->media_album_id, random_id); } else { - send_closure(td_->create_net_actor(), &SendMessageActor::send, get_message_flags(m), dialog_id, - m->reply_to_message_id, get_input_reply_markup(m->reply_markup), - get_input_message_entities(td_->contacts_manager_.get(), message_text->text.entities), - message_text->text.text, random_id, &m->send_query_ref, - get_sequence_dispatcher_id(dialog_id, content_type)); + send_closure( + td_->create_net_actor(), &SendMessageActor::send, get_message_flags(m), dialog_id, + m->reply_to_message_id, get_input_reply_markup(m->reply_markup), + get_input_message_entities(td_->contacts_manager_.get(), message_text->text.entities, "do_send_message"), + message_text->text.text, random_id, &m->send_query_ref, get_sequence_dispatcher_id(dialog_id, content_type)); } 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 " << m->reply_to_message_id; int64 random_id = begin_send_message(dialog_id, m); - send_closure(td_->create_net_actor(), &SendMediaActor::send, file_id, thumbnail_file_id, - get_message_flags(m), dialog_id, m->reply_to_message_id, get_input_reply_markup(m->reply_markup), - get_input_message_entities(td_->contacts_manager_.get(), caption.entities), caption.text, - std::move(input_media), random_id, &m->send_query_ref, - get_sequence_dispatcher_id(dialog_id, m->content->get_id())); + send_closure( + td_->create_net_actor(), &SendMediaActor::send, file_id, thumbnail_file_id, + get_message_flags(m), dialog_id, m->reply_to_message_id, get_input_reply_markup(m->reply_markup), + get_input_message_entities(td_->contacts_manager_.get(), caption.entities, "on_message_media_uploaded"), + caption.text, std::move(input_media), random_id, &m->send_query_ref, + get_sequence_dispatcher_id(dialog_id, m->content->get_id())); })); } else { 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)); auto caption = get_message_content_caption(m->content.get()); 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; if (!entities.empty()) { 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; } - send_closure(td_->create_net_actor(std::move(promise)), &EditMessageActor::send, flags, dialog_id, - message_id, input_message_text.text.text, - get_input_message_entities(td_->contacts_manager_.get(), input_message_text.text.entities), nullptr, - std::move(input_reply_markup), get_sequence_dispatcher_id(dialog_id, -1)); + send_closure( + td_->create_net_actor(std::move(promise)), &EditMessageActor::send, flags, dialog_id, + message_id, input_message_text.text.text, + 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, @@ -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()); send_closure(td_->create_net_actor(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)); } @@ -17163,8 +17167,9 @@ void MessagesManager::edit_inline_message_text(const string &inline_message_id, } td_->create_handler(std::move(promise)) ->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_reply_markup(r_new_reply_markup.ok())); + get_input_message_entities(td_->contacts_manager_.get(), input_message_text.text.entities, + "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, @@ -17226,8 +17231,8 @@ void MessagesManager::edit_inline_message_caption(const string &inline_message_i td_->create_handler(std::move(promise)) ->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_reply_markup(r_new_reply_markup.ok())); + get_input_message_entities(td_->contacts_manager_.get(), caption.entities, "edit_inline_message_caption"), + nullptr, get_input_reply_markup(r_new_reply_markup.ok())); } void MessagesManager::edit_inline_message_reply_markup(const string &inline_message_id, diff --git a/td/telegram/WebPagesManager.cpp b/td/telegram/WebPagesManager.cpp index 4e0157e3..36fabae5 100644 --- a/td/telegram/WebPagesManager.cpp +++ b/td/telegram/WebPagesManager.cpp @@ -1714,8 +1714,8 @@ int64 WebPagesManager::get_web_page_preview(td_api::object_ptrcreate_handler(std::move(promise)) - ->send(text->text_, get_input_message_entities(td_->contacts_manager_.get(), entities), request_id, - std::move(url)); + ->send(text->text_, get_input_message_entities(td_->contacts_manager_.get(), entities, "get_web_page_preview"), + request_id, std::move(url)); } return request_id; }