From 87d875ca81078313888dbe2854bfb486e0d0301e Mon Sep 17 00:00:00 2001 From: levlam Date: Thu, 19 Sep 2019 22:07:11 +0300 Subject: [PATCH] Update layer to 101. New entities type support. GitOrigin-RevId: c4a4e73d20c27c2ad1440bae2acb9559d1f10a5d --- td/generate/scheme/secret_api.tl | 6 ++ td/generate/scheme/secret_api.tlo | Bin 14120 -> 14500 bytes td/generate/scheme/td_api.tl | 11 +++- td/generate/scheme/td_api.tlo | Bin 160508 -> 160708 bytes td/generate/scheme/telegram_api.tl | 3 + td/generate/scheme/telegram_api.tlo | Bin 187308 -> 187688 bytes td/telegram/MessageEntity.cpp | 87 +++++++++++++++++++++++++++- td/telegram/MessageEntity.h | 7 ++- td/telegram/MessagesManager.cpp | 7 ++- td/telegram/SecretChatActor.h | 8 ++- td/telegram/Version.h | 2 +- 11 files changed, 122 insertions(+), 9 deletions(-) diff --git a/td/generate/scheme/secret_api.tl b/td/generate/scheme/secret_api.tl index 32db7251..74d55329 100644 --- a/td/generate/scheme/secret_api.tl +++ b/td/generate/scheme/secret_api.tl @@ -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 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; diff --git a/td/generate/scheme/secret_api.tlo b/td/generate/scheme/secret_api.tlo index d6be21615f0f4d5e908bcf1bc27e1160d2dd197b..5a6e4ad2d0d0ae85011e5ec4a0cc02bf547af75b 100644 GIT binary patch delta 478 zcmZ3Hx1?}`1(Rrt$T4QnPsl zdj}(!HF*Vl&gKQ22jn5V1nmF_V~3^&nuvuKy2uU;5esbnLb}}%8bkH?jnas9d7)4WXNl|8YDog{0Ef>D>GKr&TaLUO~ T&Mqv?FM(?UyMA+n!3s72=3=@f delta 323 zcmZ2dxFTT4QnPsl zdj}(!HF*Vl&gKQ22jn5V1nmF_V~3^&nuvuKy2uU;5esb= 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; diff --git a/td/generate/scheme/td_api.tlo b/td/generate/scheme/td_api.tlo index a806ebd971ab788d81617a820b2abdfe69e0dfc8..4bdb117d664da199d6601118725fd1ad08b58595 100644 GIT binary patch delta 652 zcmezKl=H}Q&J8nEMYUJ(rt*cPR+PBrm1LGwhEx`$G6+sy$R@t|h^h(;DbG;MN;Z&8UJ~ zwg<1?3wZVN)G%t)jSM~@nh#=Ab qp@z`}!qTXPicJ>i(SZoH)G|U@6ABm&AYw0oVmRY%yG|YBg)acmZ^|10 delta 456 zcmX@|ob%69&J8nEMY|^lZ|4h1ttfHLE6FUW45=(gW#F5mHMhUi zWb_VT0jZpBQN?H@0b<=eCgj5a1VzqlIvlob2f?yERg4p<~ diff --git a/td/generate/scheme/telegram_api.tl b/td/generate/scheme/telegram_api.tl index 7845be8e..0cca35ee 100644 --- a/td/generate/scheme/telegram_api.tl +++ b/td/generate/scheme/telegram_api.tl @@ -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; diff --git a/td/generate/scheme/telegram_api.tlo b/td/generate/scheme/telegram_api.tlo index 61d97ea333246265b778995a700b6f82a1a829ef..de4f025ed073f9b6b33d7d8910924df43841e153 100644 GIT binary patch delta 823 zcmZ3poqNSD?hQMHMSWw+ck=qC78fU`r@H2qWR_GiFbGXv$SA(}iLfjq`{t(x{mmqY3J+=J_FC$9>#D5=J7!|hj^fAs*f~1h?j9VGy zx1ZR+*u#V@P_dcu2Q#w3l`89%ToXet;yz z?E#+{=afK1Kcq3`NI;kg^-LX%$Y%32GPOuU1sVl_&e<}DNrf9Kuuzjpe*2&0OeQb^ Xu!BQ3Gkt)W@$n3k!uHIqOwMWm7`+^^ delta 676 zcmZ3ni+jy>?hQMHMGv_c&EWM-EiO(>Pj$^J$tT+5aL(qMMG+PdJvVNp$U;~S zKko2?S<@BR7y}@z5;jH+bg?g3#7fw)sAFeTLDyTrfhqO|i&zFHrn)Cs#1gn*>U6jn zeWssLhB{*!H_Sai@f?UN=5RCWKv-wE84DmR2OdTPxLC~e3p|XF5S#vj2WBuLFj9D7 zhQh_RC-5_}G(f_9x?u~W{PvE1#u-WwBR}k5RM_saiLr+XiT`B_;}2#qe>+e=hTH MessageEntity::get_text_entity_type_object return make_tl_object(); case MessageEntity::Type::Italic: return make_tl_object(); + case MessageEntity::Type::Underline: + return make_tl_object(); + case MessageEntity::Type::Strikethrough: + return make_tl_object(); + case MessageEntity::Type::BlockQuote: + return make_tl_object(); case MessageEntity::Type::Code: return make_tl_object(); case MessageEntity::Type::Pre: @@ -1192,6 +1208,12 @@ string get_first_url(Slice text, const vector &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> get_input_message_entities(co case MessageEntity::Type::Italic: result.push_back(make_tl_object(entity.offset, entity.length)); break; + case MessageEntity::Type::Underline: + result.push_back(make_tl_object(entity.offset, entity.length)); + break; + case MessageEntity::Type::Strikethrough: + result.push_back(make_tl_object(entity.offset, entity.length)); + break; + case MessageEntity::Type::BlockQuote: + result.push_back(make_tl_object(entity.offset, entity.length)); + break; case MessageEntity::Type::Code: result.push_back(make_tl_object(entity.offset, entity.length)); break; @@ -1684,7 +1715,7 @@ vector> get_input_message_entities(co } vector> get_input_secret_message_entities( - const vector &entities) { + const vector &entities, int32 layer) { vector> result; for (auto &entity : entities) { switch (entity.type) { @@ -1710,6 +1741,21 @@ vector> get_input_secret_message_entiti case MessageEntity::Type::Italic: result.push_back(make_tl_object(entity.offset, entity.length)); break; + case MessageEntity::Type::Underline: + if (layer >= SecretChatActor::NEW_ENTITIES_LAYER) { + result.push_back(make_tl_object(entity.offset, entity.length)); + } + break; + case MessageEntity::Type::Strikethrough: + if (layer >= SecretChatActor::NEW_ENTITIES_LAYER) { + result.push_back(make_tl_object(entity.offset, entity.length)); + } + break; + case MessageEntity::Type::BlockQuote: + if (layer >= SecretChatActor::NEW_ENTITIES_LAYER) { + result.push_back(make_tl_object(entity.offset, entity.length)); + } + break; case MessageEntity::Type::Code: result.push_back(make_tl_object(entity.offset, entity.length)); break; @@ -1758,6 +1804,15 @@ Result> 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 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(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(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(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(entity.get()); entities.emplace_back(MessageEntity::Type::Code, entity_code->offset_, entity_code->length_); @@ -1952,6 +2022,21 @@ vector get_message_entities(vectoroffset_, entity_italic->length_); break; } + case secret_api::messageEntityUnderline::ID: { + auto entity_bold = static_cast(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(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(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(entity.get()); entities.emplace_back(MessageEntity::Type::Code, entity_code->offset_, entity_code->length_); diff --git a/td/telegram/MessageEntity.h b/td/telegram/MessageEntity.h index 591ec65b..73b2f155 100644 --- a/td/telegram/MessageEntity.h +++ b/td/telegram/MessageEntity.h @@ -45,7 +45,10 @@ class MessageEntity { TextUrl, MentionName, Cashtag, - PhoneNumber + PhoneNumber, + Underline, + Strikethrough, + BlockQuote }; Type type; int32 offset; @@ -138,7 +141,7 @@ vector> get_input_message_entities(co const char *source); vector> get_input_secret_message_entities( - const vector &entities); + const vector &entities, int32 layer); vector get_message_entities(const ContactsManager *contacts_manager, vector> &&server_entities, diff --git a/td/telegram/MessagesManager.cpp b/td/telegram/MessagesManager.cpp index 3b718221..e1d977ff 100644 --- a/td/telegram/MessagesManager.cpp +++ b/td/telegram/MessagesManager.cpp @@ -11082,7 +11082,8 @@ void MessagesManager::on_get_dialogs(FolderId folder_id, vector(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::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::send, get_message_flags(m), dialog_id, m->reply_to_message_id, get_input_reply_markup(m->reply_markup), diff --git a/td/telegram/SecretChatActor.h b/td/telegram/SecretChatActor.h index 614e0a84..4146061d 100644 --- a/td/telegram/SecretChatActor.h +++ b/td/telegram/SecretChatActor.h @@ -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: diff --git a/td/telegram/Version.h b/td/telegram/Version.h index 407b5ad7..c1c19e9b 100644 --- a/td/telegram/Version.h +++ b/td/telegram/Version.h @@ -8,7 +8,7 @@ namespace td { -constexpr int32 MTPROTO_LAYER = 100; +constexpr int32 MTPROTO_LAYER = 101; enum class Version : int32 { Initial,