Update layer to 101. New entities type support.

GitOrigin-RevId: c4a4e73d20c27c2ad1440bae2acb9559d1f10a5d
This commit is contained in:
levlam 2019-09-19 22:07:11 +03:00
parent 4007386372
commit 87d875ca81
11 changed files with 122 additions and 9 deletions

View File

@ -110,6 +110,12 @@ documentAttributeVideo66#ef02ce6 flags:# round_message:flags.0?true duration:int
decryptedMessage#91cc4674 flags:# random_id:long ttl:int message:string media:flags.9?DecryptedMessageMedia entities:flags.7?Vector<MessageEntity> via_bot_name:flags.11?string reply_to_random_id:flags.3?long grouped_id:flags.17?long = DecryptedMessage;
// layer 101
messageEntityUnderline#9c4e7e8b offset:int length:int = MessageEntity;
messageEntityStrike#bf0693d4 offset:int length:int = MessageEntity;
messageEntityBlockquote#20df5d0 offset:int length:int = MessageEntity;
---functions---
test.dummyFunction = Bool;

Binary file not shown.

View File

@ -488,7 +488,7 @@ secretChatStateClosed = SecretChatState;
//@ttl Current message Time To Live setting (self-destruct timer) for the chat, in seconds
//@key_hash Hash of the currently used key for comparison with the hash of the chat partner's key. This is a string of 36 bytes, which must be used to make a 12x12 square image with a color depth of 4. The first 16 bytes should be used to make a central 8x8 square, while the remaining 20 bytes should be used to construct a 2-pixel-wide border around that square.
//-Alternatively, the first 32 bytes of the hash can be converted to the hexadecimal format and printed as 32 2-digit hex numbers
//@layer Secret chat layer; determines features supported by the other client. Video notes are supported if the layer >= 66
//@layer Secret chat layer; determines features supported by the other client. Video notes are supported if the layer >= 66; nested text entities and underline and strikethrough entities are supported if the layer >= 101
secretChat id:int32 user_id:int32 state:SecretChatState is_outbound:Bool ttl:int32 key_hash:bytes layer:int32 = SecretChat;
@ -1398,6 +1398,15 @@ textEntityTypeBold = TextEntityType;
//@description An italic text
textEntityTypeItalic = TextEntityType;
//@description An underlined text
textEntityTypeUnderline = TextEntityType;
//@description A strike-through text
textEntityTypeStrikethrough = TextEntityType;
//@description A block quote; this entity can't be sent for now
textEntityTypeBlockQuote = TextEntityType;
//@description Text that must be formatted as if inside a code HTML tag
textEntityTypeCode = TextEntityType;

Binary file not shown.

View File

@ -549,6 +549,9 @@ messageEntityMentionName#352dca58 offset:int length:int user_id:int = MessageEnt
inputMessageEntityMentionName#208e68c9 offset:int length:int user_id:InputUser = MessageEntity;
messageEntityPhone#9b69e34b offset:int length:int = MessageEntity;
messageEntityCashtag#4c4e743f offset:int length:int = MessageEntity;
messageEntityUnderline#9c4e7e8b offset:int length:int = MessageEntity;
messageEntityStrike#bf0693d4 offset:int length:int = MessageEntity;
messageEntityBlockquote#20df5d0 offset:int length:int = MessageEntity;
inputChannelEmpty#ee8c1e86 = InputChannel;
inputChannel#afeb712e channel_id:int access_hash:long = InputChannel;

Binary file not shown.

View File

@ -8,6 +8,7 @@
#include "td/telegram/ContactsManager.h"
#include "td/telegram/misc.h"
#include "td/telegram/SecretChatActor.h"
#include "td/utils/format.h"
#include "td/utils/logging.h"
@ -47,6 +48,15 @@ StringBuilder &operator<<(StringBuilder &string_builder, const MessageEntity &me
case MessageEntity::Type::Italic:
string_builder << "Italic";
break;
case MessageEntity::Type::Underline:
string_builder << "Underline";
break;
case MessageEntity::Type::Strikethrough:
string_builder << "Strikethrough";
break;
case MessageEntity::Type::BlockQuote:
string_builder << "BlockQuote";
break;
case MessageEntity::Type::Code:
string_builder << "Code";
break;
@ -103,6 +113,12 @@ tl_object_ptr<td_api::TextEntityType> MessageEntity::get_text_entity_type_object
return make_tl_object<td_api::textEntityTypeBold>();
case MessageEntity::Type::Italic:
return make_tl_object<td_api::textEntityTypeItalic>();
case MessageEntity::Type::Underline:
return make_tl_object<td_api::textEntityTypeUnderline>();
case MessageEntity::Type::Strikethrough:
return make_tl_object<td_api::textEntityTypeStrikethrough>();
case MessageEntity::Type::BlockQuote:
return make_tl_object<td_api::textEntityTypeBlockQuote>();
case MessageEntity::Type::Code:
return make_tl_object<td_api::textEntityTypeCode>();
case MessageEntity::Type::Pre:
@ -1192,6 +1208,12 @@ string get_first_url(Slice text, const vector<MessageEntity> &entities) {
break;
case MessageEntity::Type::Italic:
break;
case MessageEntity::Type::Underline:
break;
case MessageEntity::Type::Strikethrough:
break;
case MessageEntity::Type::BlockQuote:
break;
case MessageEntity::Type::Code:
break;
case MessageEntity::Type::Pre:
@ -1646,6 +1668,15 @@ vector<tl_object_ptr<telegram_api::MessageEntity>> get_input_message_entities(co
case MessageEntity::Type::Italic:
result.push_back(make_tl_object<telegram_api::messageEntityItalic>(entity.offset, entity.length));
break;
case MessageEntity::Type::Underline:
result.push_back(make_tl_object<telegram_api::messageEntityUnderline>(entity.offset, entity.length));
break;
case MessageEntity::Type::Strikethrough:
result.push_back(make_tl_object<telegram_api::messageEntityStrike>(entity.offset, entity.length));
break;
case MessageEntity::Type::BlockQuote:
result.push_back(make_tl_object<telegram_api::messageEntityBlockquote>(entity.offset, entity.length));
break;
case MessageEntity::Type::Code:
result.push_back(make_tl_object<telegram_api::messageEntityCode>(entity.offset, entity.length));
break;
@ -1684,7 +1715,7 @@ vector<tl_object_ptr<telegram_api::MessageEntity>> get_input_message_entities(co
}
vector<tl_object_ptr<secret_api::MessageEntity>> get_input_secret_message_entities(
const vector<MessageEntity> &entities) {
const vector<MessageEntity> &entities, int32 layer) {
vector<tl_object_ptr<secret_api::MessageEntity>> result;
for (auto &entity : entities) {
switch (entity.type) {
@ -1710,6 +1741,21 @@ vector<tl_object_ptr<secret_api::MessageEntity>> get_input_secret_message_entiti
case MessageEntity::Type::Italic:
result.push_back(make_tl_object<secret_api::messageEntityItalic>(entity.offset, entity.length));
break;
case MessageEntity::Type::Underline:
if (layer >= SecretChatActor::NEW_ENTITIES_LAYER) {
result.push_back(make_tl_object<secret_api::messageEntityUnderline>(entity.offset, entity.length));
}
break;
case MessageEntity::Type::Strikethrough:
if (layer >= SecretChatActor::NEW_ENTITIES_LAYER) {
result.push_back(make_tl_object<secret_api::messageEntityStrike>(entity.offset, entity.length));
}
break;
case MessageEntity::Type::BlockQuote:
if (layer >= SecretChatActor::NEW_ENTITIES_LAYER) {
result.push_back(make_tl_object<secret_api::messageEntityBlockquote>(entity.offset, entity.length));
}
break;
case MessageEntity::Type::Code:
result.push_back(make_tl_object<secret_api::messageEntityCode>(entity.offset, entity.length));
break;
@ -1758,6 +1804,15 @@ Result<vector<MessageEntity>> get_message_entities(const ContactsManager *contac
case td_api::textEntityTypeItalic::ID:
entities.emplace_back(MessageEntity::Type::Italic, entity->offset_, entity->length_);
break;
case td_api::textEntityTypeUnderline::ID:
entities.emplace_back(MessageEntity::Type::Underline, entity->offset_, entity->length_);
break;
case td_api::textEntityTypeStrikethrough::ID:
entities.emplace_back(MessageEntity::Type::Strikethrough, entity->offset_, entity->length_);
break;
case td_api::textEntityTypeBlockQuote::ID:
// entities.emplace_back(MessageEntity::Type::BlockQuote, entity->offset_, entity->length_);
break;
case td_api::textEntityTypeCode::ID:
entities.emplace_back(MessageEntity::Type::Code, entity->offset_, entity->length_);
break;
@ -1856,6 +1911,21 @@ vector<MessageEntity> get_message_entities(const ContactsManager *contacts_manag
entities.emplace_back(MessageEntity::Type::Italic, entity_italic->offset_, entity_italic->length_);
break;
}
case telegram_api::messageEntityUnderline::ID: {
auto entity_bold = static_cast<const telegram_api::messageEntityUnderline *>(entity.get());
entities.emplace_back(MessageEntity::Type::Underline, entity_bold->offset_, entity_bold->length_);
break;
}
case telegram_api::messageEntityStrike::ID: {
auto entity_bold = static_cast<const telegram_api::messageEntityStrike *>(entity.get());
entities.emplace_back(MessageEntity::Type::Strikethrough, entity_bold->offset_, entity_bold->length_);
break;
}
case telegram_api::messageEntityBlockquote::ID: {
auto entity_bold = static_cast<const telegram_api::messageEntityBlockquote *>(entity.get());
entities.emplace_back(MessageEntity::Type::BlockQuote, entity_bold->offset_, entity_bold->length_);
break;
}
case telegram_api::messageEntityCode::ID: {
auto entity_code = static_cast<const telegram_api::messageEntityCode *>(entity.get());
entities.emplace_back(MessageEntity::Type::Code, entity_code->offset_, entity_code->length_);
@ -1952,6 +2022,21 @@ vector<MessageEntity> get_message_entities(vector<tl_object_ptr<secret_api::Mess
entities.emplace_back(MessageEntity::Type::Italic, entity_italic->offset_, entity_italic->length_);
break;
}
case secret_api::messageEntityUnderline::ID: {
auto entity_bold = static_cast<const secret_api::messageEntityUnderline *>(entity.get());
entities.emplace_back(MessageEntity::Type::Underline, entity_bold->offset_, entity_bold->length_);
break;
}
case secret_api::messageEntityStrike::ID: {
auto entity_bold = static_cast<const secret_api::messageEntityStrike *>(entity.get());
entities.emplace_back(MessageEntity::Type::Strikethrough, entity_bold->offset_, entity_bold->length_);
break;
}
case secret_api::messageEntityBlockquote::ID: {
auto entity_bold = static_cast<const secret_api::messageEntityBlockquote *>(entity.get());
entities.emplace_back(MessageEntity::Type::BlockQuote, entity_bold->offset_, entity_bold->length_);
break;
}
case secret_api::messageEntityCode::ID: {
auto entity_code = static_cast<const secret_api::messageEntityCode *>(entity.get());
entities.emplace_back(MessageEntity::Type::Code, entity_code->offset_, entity_code->length_);

View File

@ -45,7 +45,10 @@ class MessageEntity {
TextUrl,
MentionName,
Cashtag,
PhoneNumber
PhoneNumber,
Underline,
Strikethrough,
BlockQuote
};
Type type;
int32 offset;
@ -138,7 +141,7 @@ vector<tl_object_ptr<telegram_api::MessageEntity>> get_input_message_entities(co
const char *source);
vector<tl_object_ptr<secret_api::MessageEntity>> get_input_secret_message_entities(
const vector<MessageEntity> &entities);
const vector<MessageEntity> &entities, int32 layer);
vector<MessageEntity> get_message_entities(const ContactsManager *contacts_manager,
vector<tl_object_ptr<telegram_api::MessageEntity>> &&server_entities,

View File

@ -11082,7 +11082,8 @@ void MessagesManager::on_get_dialogs(FolderId folder_id, vector<tl_object_ptr<te
case telegram_api::dialogFolder::ID: {
auto folder = telegram_api::move_object_as<telegram_api::dialogFolder>(dialog_folder);
if (from_pinned_dialog_list) {
// TODO updata unread_muted_peers_count:int unread_unmuted_peers_count:int unread_muted_messages_count:int unread_unmuted_messages_count:int
// TODO update unread_muted_peers_count:int unread_unmuted_peers_count:int
// unread_muted_messages_count:int unread_unmuted_messages_count:int
FolderId folder_folder_id(folder->folder_->id_);
if (folder_folder_id == FolderId::archive()) {
// archive is expected in pinned dialogs list
@ -17005,8 +17006,8 @@ void MessagesManager::do_send_message(DialogId dialog_id, const Message *m, vect
send_closure(td_->create_net_actor<SendSecretMessageActor>(), &SendSecretMessageActor::send, dialog_id,
m->reply_to_random_id, m->ttl, message_text->text,
get_secret_input_media(content, td_, nullptr, BufferSlice(), layer),
get_input_secret_message_entities(message_text->entities), m->via_bot_user_id, m->media_album_id,
random_id);
get_input_secret_message_entities(message_text->entities, layer), m->via_bot_user_id,
m->media_album_id, random_id);
} else {
send_closure(td_->create_net_actor<SendMessageActor>(), &SendMessageActor::send, get_message_flags(m), dialog_id,
m->reply_to_message_id, get_input_reply_markup(m->reply_markup),

View File

@ -48,7 +48,13 @@ class NetQueryCreator;
class SecretChatActor : public NetQueryCallback {
public:
// do not change DEFAULT_LAYER, unless all it's usages are fixed
enum : int32 { DEFAULT_LAYER = 46, VIDEO_NOTES_LAYER = 66, MTPROTO_2_LAYER = 73, MY_LAYER = MTPROTO_2_LAYER };
enum : int32 {
DEFAULT_LAYER = 46,
VIDEO_NOTES_LAYER = 66,
MTPROTO_2_LAYER = 73,
NEW_ENTITIES_LAYER = 101,
MY_LAYER = NEW_ENTITIES_LAYER
};
class Context {
public:

View File

@ -8,7 +8,7 @@
namespace td {
constexpr int32 MTPROTO_LAYER = 100;
constexpr int32 MTPROTO_LAYER = 101;
enum class Version : int32 {
Initial,