Add source to get_message_entities.

GitOrigin-RevId: af699950241416adb082a08a8f6c4e106f0fb24d
This commit is contained in:
levlam 2018-02-11 19:43:58 +03:00
parent cc24f0edcc
commit 2cd12d5049
4 changed files with 13 additions and 9 deletions

View File

@ -330,7 +330,8 @@ bool InlineQueriesManager::register_inline_message_content(
switch (inline_message->get_id()) {
case telegram_api::botInlineMessageText::ID: {
auto inline_message_text = move_tl_object_as<telegram_api::botInlineMessageText>(inline_message);
auto entities = get_message_entities(td_->contacts_manager_.get(), std::move(inline_message_text->entities_));
auto entities = get_message_entities(td_->contacts_manager_.get(), std::move(inline_message_text->entities_),
"botInlineMessageText");
auto status =
MessagesManager::fix_text_message(inline_message_text->message_, entities, false, true, true, false);
if (status.is_error()) {

View File

@ -1641,7 +1641,8 @@ Result<vector<MessageEntity>> get_message_entities(const ContactsManager *contac
}
vector<MessageEntity> get_message_entities(const ContactsManager *contacts_manager,
vector<tl_object_ptr<telegram_api::MessageEntity>> &&server_entities) {
vector<tl_object_ptr<telegram_api::MessageEntity>> &&server_entities,
const char *source) {
vector<MessageEntity> entities;
entities.reserve(server_entities.size());
for (auto &entity : server_entities) {
@ -1704,7 +1705,8 @@ vector<MessageEntity> get_message_entities(const ContactsManager *contacts_manag
auto entity_text_url = static_cast<telegram_api::messageEntityTextUrl *>(entity.get());
auto r_http_url = parse_url(entity_text_url->url_);
if (r_http_url.is_error()) {
LOG(ERROR) << "Wrong URL entity: \"" << entity_text_url->url_ << "\": " << r_http_url.error().message();
LOG(ERROR) << "Wrong URL entity: \"" << entity_text_url->url_ << "\": " << r_http_url.error().message()
<< " from " << source;
continue;
}
entities.emplace_back(MessageEntity::Type::TextUrl, entity_text_url->offset_, entity_text_url->length_,
@ -1715,15 +1717,15 @@ vector<MessageEntity> get_message_entities(const ContactsManager *contacts_manag
auto entity_mention_name = static_cast<const telegram_api::messageEntityMentionName *>(entity.get());
UserId user_id(entity_mention_name->user_id_);
if (!user_id.is_valid()) {
LOG(ERROR) << "Receive invalid " << user_id << " in MentionName";
LOG(ERROR) << "Receive invalid " << user_id << " in MentionName from " << source;
continue;
}
if (!contacts_manager->have_user(user_id)) {
LOG(ERROR) << "Receive unknown " << user_id << " in MentionName";
LOG(ERROR) << "Receive unknown " << user_id << " in MentionName from " << source;
continue;
}
if (!contacts_manager->have_input_user(user_id)) {
LOG(ERROR) << "Receive unaccessible " << user_id << " in MentionName";
LOG(ERROR) << "Receive unaccessible " << user_id << " in MentionName from " << source;
continue;
}
entities.emplace_back(entity_mention_name->offset_, entity_mention_name->length_, user_id);

View File

@ -166,7 +166,8 @@ vector<tl_object_ptr<secret_api::MessageEntity>> get_input_secret_message_entiti
const vector<MessageEntity> &entities);
vector<MessageEntity> get_message_entities(const ContactsManager *contacts_manager,
vector<tl_object_ptr<telegram_api::MessageEntity>> &&server_entities);
vector<tl_object_ptr<telegram_api::MessageEntity>> &&server_entities,
const char *source);
vector<MessageEntity> get_message_entities(vector<tl_object_ptr<secret_api::MessageEntity>> &&secret_entities);

View File

@ -12333,7 +12333,7 @@ unique_ptr<DraftMessage> MessagesManager::get_draft_message(
}
}
auto entities = get_message_entities(contacts_manager, std::move(draft->entities_));
auto entities = get_message_entities(contacts_manager, std::move(draft->entities_), "draftMessage");
auto status = fix_text_message(draft->message_, entities, true, true, true, true);
if (status.is_error()) {
LOG(ERROR) << "Receive error " << status << " while parsing draft " << draft->message_;
@ -19944,7 +19944,7 @@ FormattedText MessagesManager::get_secret_media_caption(string &&message_text, s
FormattedText MessagesManager::get_message_text(string message_text,
vector<tl_object_ptr<telegram_api::MessageEntity>> &&server_entities,
int32 send_date) const {
auto entities = get_message_entities(td_->contacts_manager_.get(), std::move(server_entities));
auto entities = get_message_entities(td_->contacts_manager_.get(), std::move(server_entities), "get_message_text");
auto status = fix_text_message(message_text, entities, true, true, true, false);
if (status.is_error()) {
if (send_date == 0 || send_date > 1497000000) { // approximate fix date