diff --git a/td/generate/scheme/secret_api.tl b/td/generate/scheme/secret_api.tl index 4dd5e8345..35d6b6575 100644 --- a/td/generate/scheme/secret_api.tl +++ b/td/generate/scheme/secret_api.tl @@ -121,6 +121,11 @@ messageEntityBlockquote#20df5d0 offset:int length:int = MessageEntity; decryptedMessageMediaDocument#6abd9782 thumb:bytes thumb_w:int thumb_h:int mime_type:string size:long key:bytes iv:bytes attributes:Vector caption:string = DecryptedMessageMedia; +// layer 144 + +messageEntitySpoiler#32ca960f offset:int length:int = MessageEntity; +messageEntityCustomEmoji#c8cf05f8 offset:int length:int document_id:long = MessageEntity; + ---functions--- test.dummyFunction = Bool; diff --git a/td/generate/scheme/td_api.tl b/td/generate/scheme/td_api.tl index 85b618866..babf6a9db 100644 --- a/td/generate/scheme/td_api.tl +++ b/td/generate/scheme/td_api.tl @@ -766,7 +766,7 @@ secretChatStateClosed = SecretChatState; //@is_outbound True, if the chat was created by the current user; otherwise false //@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 little-endian bytes, which must be split into groups of 2 bits, each denoting a pixel of one of 4 colors FFFFFF, D5E6F3, 2D5775, and 2F99C9. //-The pixels must be used to make a 12x12 square image filled from left to right, top to bottom. 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 chat partner's application. Nested text entities and underline and strikethrough entities are supported if the layer >= 101, files bigger than 2000MB are supported if the layer >= 143 +//@layer Secret chat layer; determines features supported by the chat partner's application. Nested text entities and underline and strikethrough entities are supported if the layer >= 101, files bigger than 2000MB are supported if the layer >= 143, spoiler and custom emoji text entities are supported if the layer >= 144 secretChat id:int32 user_id:int53 state:SecretChatState is_outbound:Bool key_hash:bytes layer:int32 = SecretChat; @@ -2075,7 +2075,7 @@ textEntityTypeUnderline = TextEntityType; //@description A strikethrough text textEntityTypeStrikethrough = TextEntityType; -//@description A spoiler text. Not supported in secret chats +//@description A spoiler text textEntityTypeSpoiler = TextEntityType; //@description Text that must be formatted as if inside a code HTML tag @@ -2093,7 +2093,7 @@ 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 textEntityTypeMentionName user_id:int53 = TextEntityType; -//@description A custom emoji. Not supported in secret chats. The text behind a custom emoji must be an emoji. Only premium users can use premium custom emoji @custom_emoji_id Unique identifier of the custom emoji +//@description A custom emoji. The text behind a custom emoji must be an emoji. Only premium users can use premium custom emoji @custom_emoji_id Unique identifier of the custom emoji textEntityTypeCustomEmoji custom_emoji_id:int64 = TextEntityType; //@description A media timestamp @media_timestamp Timestamp from which a video/audio/video note/voice note playing must start, in seconds. The media can be in the content or the web page preview of the current message, or in the same places in the replied message diff --git a/td/telegram/MessageEntity.cpp b/td/telegram/MessageEntity.cpp index fee706470..4342e17b0 100644 --- a/td/telegram/MessageEntity.cpp +++ b/td/telegram/MessageEntity.cpp @@ -3273,8 +3273,15 @@ vector> get_input_secret_message_entiti case MessageEntity::Type::MediaTimestamp: break; case MessageEntity::Type::Spoiler: + if (layer >= static_cast(SecretChatLayer::SpoilerAndCustomEmojiEntities)) { + result.push_back(make_tl_object(entity.offset, entity.length)); + } break; case MessageEntity::Type::CustomEmoji: + if (layer >= static_cast(SecretChatLayer::SpoilerAndCustomEmojiEntities)) { + result.push_back( + make_tl_object(entity.offset, entity.length, entity.document_id)); + } break; default: UNREACHABLE(); @@ -3636,6 +3643,16 @@ vector get_message_entities(vector(secret_entity.get()); + entities.emplace_back(MessageEntity::Type::Spoiler, entity->offset_, entity->length_); + break; + } + case secret_api::messageEntityCustomEmoji::ID: { + auto entity = static_cast(secret_entity.get()); + entities.emplace_back(MessageEntity::Type::CustomEmoji, entity->offset_, entity->length_, entity->document_id_); + break; + } default: UNREACHABLE(); } @@ -4392,7 +4409,8 @@ void remove_unallowed_entities(const Td *td, FormattedText &text, DialogId dialo entity.type == MessageEntity::Type::BlockQuote)) { return true; } - if (entity.type == MessageEntity::Type::Spoiler || entity.type == MessageEntity::Type::CustomEmoji) { + if (layer < static_cast(SecretChatLayer::SpoilerAndCustomEmojiEntities) && + (entity.type == MessageEntity::Type::Spoiler || entity.type == MessageEntity::Type::CustomEmoji)) { return true; } return false; diff --git a/td/telegram/SecretChatLayer.h b/td/telegram/SecretChatLayer.h index 8ce137c93..7ed8bc225 100644 --- a/td/telegram/SecretChatLayer.h +++ b/td/telegram/SecretChatLayer.h @@ -14,7 +14,8 @@ enum class SecretChatLayer : int32 { NewEntities = 101, DeleteMessagesOnClose = 123, SupportBigFiles = 143, - Current = SupportBigFiles + SpoilerAndCustomEmojiEntities = 144, + Current = SpoilerAndCustomEmojiEntities }; } // namespace td