Add textEntityTypePhoneNumber.

GitOrigin-RevId: b8705ec13104848c5ae0597aee6cf4e6f41762db
This commit is contained in:
levlam 2018-03-13 00:17:29 +03:00
parent c489e3b91d
commit 85c2cc160d
5 changed files with 28 additions and 3 deletions

View File

@ -957,6 +957,9 @@ textEntityTypeTextUrl url:string = TextEntityType;
//@description A text shows instead of a raw mention of the user (e.g., when the user has no username) @user_id Identifier of the mentioned user //@description A text shows instead of a raw mention of the user (e.g., when the user has no username) @user_id Identifier of the mentioned user
textEntityTypeMentionName user_id:int32 = TextEntityType; textEntityTypeMentionName user_id:int32 = TextEntityType;
//@description A phone number
textEntityTypePhoneNumber = TextEntityType;
//@description A thumbnail to be sent along with a file; should be in JPEG or WEBP format for stickers, and less than 200 kB in size @thumbnail Thumbnail file to send. Sending thumbnails by file_id is currently not supported //@description A thumbnail to be sent along with a file; should be in JPEG or WEBP format for stickers, and less than 200 kB in size @thumbnail Thumbnail file to send. Sending thumbnails by file_id is currently not supported
//@width Thumbnail width, usually shouldn't exceed 90. Use 0 if unknown @height Thumbnail height, usually shouldn't exceed 90. Use 0 if unknown //@width Thumbnail width, usually shouldn't exceed 90. Use 0 if unknown @height Thumbnail height, usually shouldn't exceed 90. Use 0 if unknown

Binary file not shown.

View File

@ -67,6 +67,9 @@ StringBuilder &operator<<(StringBuilder &string_builder, const MessageEntity &me
case MessageEntity::Type::Cashtag: case MessageEntity::Type::Cashtag:
string_builder << "Cashtag"; string_builder << "Cashtag";
break; break;
case MessageEntity::Type::PhoneNumber:
string_builder << "PhoneNumber";
break;
default: default:
UNREACHABLE(); UNREACHABLE();
string_builder << "Impossible"; string_builder << "Impossible";
@ -112,6 +115,8 @@ tl_object_ptr<td_api::TextEntityType> MessageEntity::get_text_entity_type_object
return make_tl_object<td_api::textEntityTypeMentionName>(user_id.get()); return make_tl_object<td_api::textEntityTypeMentionName>(user_id.get());
case MessageEntity::Type::Cashtag: case MessageEntity::Type::Cashtag:
return make_tl_object<td_api::textEntityTypeCashtag>(); return make_tl_object<td_api::textEntityTypeCashtag>();
case MessageEntity::Type::PhoneNumber:
return make_tl_object<td_api::textEntityTypePhoneNumber>();
default: default:
UNREACHABLE(); UNREACHABLE();
return nullptr; return nullptr;
@ -1068,6 +1073,8 @@ vector<MessageEntity> find_entities(Slice text, bool skip_bot_commands, bool onl
entities.emplace_back(MessageEntity::Type::Cashtag, narrow_cast<int32>(cashtag.begin() - text.begin()), entities.emplace_back(MessageEntity::Type::Cashtag, narrow_cast<int32>(cashtag.begin() - text.begin()),
narrow_cast<int32>(cashtag.size())); narrow_cast<int32>(cashtag.size()));
} }
// TODO find_phone_numbers
} }
auto urls = find_urls(text); auto urls = find_urls(text);
@ -1186,6 +1193,8 @@ string get_first_url(Slice text, const vector<MessageEntity> &entities) {
break; break;
case MessageEntity::Type::Cashtag: case MessageEntity::Type::Cashtag:
break; break;
case MessageEntity::Type::PhoneNumber:
break;
default: default:
UNREACHABLE(); UNREACHABLE();
} }
@ -1605,6 +1614,7 @@ vector<tl_object_ptr<telegram_api::MessageEntity>> get_input_message_entities(co
case MessageEntity::Type::Url: case MessageEntity::Type::Url:
case MessageEntity::Type::EmailAddress: case MessageEntity::Type::EmailAddress:
case MessageEntity::Type::Cashtag: case MessageEntity::Type::Cashtag:
case MessageEntity::Type::PhoneNumber:
continue; continue;
case MessageEntity::Type::Bold: case MessageEntity::Type::Bold:
result.push_back(make_tl_object<telegram_api::messageEntityBold>(entity.offset, entity.length)); result.push_back(make_tl_object<telegram_api::messageEntityBold>(entity.offset, entity.length));
@ -1682,6 +1692,8 @@ vector<tl_object_ptr<secret_api::MessageEntity>> get_input_secret_message_entiti
break; break;
case MessageEntity::Type::MentionName: case MessageEntity::Type::MentionName:
break; break;
case MessageEntity::Type::PhoneNumber:
break;
default: default:
UNREACHABLE(); UNREACHABLE();
} }
@ -1705,6 +1717,7 @@ Result<vector<MessageEntity>> get_message_entities(const ContactsManager *contac
case td_api::textEntityTypeUrl::ID: case td_api::textEntityTypeUrl::ID:
case td_api::textEntityTypeEmailAddress::ID: case td_api::textEntityTypeEmailAddress::ID:
case td_api::textEntityTypeCashtag::ID: case td_api::textEntityTypeCashtag::ID:
case td_api::textEntityTypePhoneNumber::ID:
break; break;
case td_api::textEntityTypeBold::ID: case td_api::textEntityTypeBold::ID:
entities.emplace_back(MessageEntity::Type::Bold, entity->offset_, entity->length_); entities.emplace_back(MessageEntity::Type::Bold, entity->offset_, entity->length_);
@ -1780,9 +1793,11 @@ vector<MessageEntity> get_message_entities(const ContactsManager *contacts_manag
entities.emplace_back(MessageEntity::Type::Cashtag, entity_cashtag->offset_, entity_cashtag->length_); entities.emplace_back(MessageEntity::Type::Cashtag, entity_cashtag->offset_, entity_cashtag->length_);
break; break;
} }
case telegram_api::messageEntityPhone::ID: case telegram_api::messageEntityPhone::ID: {
// skip for now auto entity_phone = static_cast<const telegram_api::messageEntityPhone *>(entity.get());
entities.emplace_back(MessageEntity::Type::PhoneNumber, entity_phone->offset_, entity_phone->length_);
break; break;
}
case telegram_api::messageEntityBotCommand::ID: { case telegram_api::messageEntityBotCommand::ID: {
auto entity_bot_command = static_cast<const telegram_api::messageEntityBotCommand *>(entity.get()); auto entity_bot_command = static_cast<const telegram_api::messageEntityBotCommand *>(entity.get());
entities.emplace_back(MessageEntity::Type::BotCommand, entity_bot_command->offset_, entities.emplace_back(MessageEntity::Type::BotCommand, entity_bot_command->offset_,

View File

@ -43,7 +43,8 @@ class MessageEntity {
PreCode, PreCode,
TextUrl, TextUrl,
MentionName, MentionName,
Cashtag Cashtag,
PhoneNumber
}; };
Type type; Type type;
int32 offset; int32 offset;

View File

@ -22202,6 +22202,12 @@ bool MessagesManager::need_message_text_changed_warning(const Message *old_messa
// server has deleted first entity and ltrim the message // server has deleted first entity and ltrim the message
return false; return false;
} }
for (auto &entity : new_content->entities) {
if (entity.type == MessageEntity::Type::PhoneNumber) {
// TODO remove after find_phone_numbers is implemented
return false;
}
}
return true; return true;
} }