diff --git a/TelegramCore/Api0.swift b/TelegramCore/Api0.swift index ed2e878852..883ae9ee02 100644 --- a/TelegramCore/Api0.swift +++ b/TelegramCore/Api0.swift @@ -30,18 +30,24 @@ fileprivate let parsers: [Int32 : (BufferReader) -> Any?] = { dict[1216809369] = { return Api.PageBlock.parse_pageBlockFooter($0) } dict[-618614392] = { return Api.PageBlock.parse_pageBlockDivider($0) } dict[-837994576] = { return Api.PageBlock.parse_pageBlockAnchor($0) } - dict[978896884] = { return Api.PageBlock.parse_pageBlockList($0) } dict[641563686] = { return Api.PageBlock.parse_pageBlockBlockquote($0) } dict[1329878739] = { return Api.PageBlock.parse_pageBlockPullquote($0) } - dict[-372860542] = { return Api.PageBlock.parse_pageBlockPhoto($0) } - dict[-640214938] = { return Api.PageBlock.parse_pageBlockVideo($0) } dict[972174080] = { return Api.PageBlock.parse_pageBlockCover($0) } - dict[-840826671] = { return Api.PageBlock.parse_pageBlockEmbed($0) } - dict[690781161] = { return Api.PageBlock.parse_pageBlockEmbedPost($0) } - dict[145955919] = { return Api.PageBlock.parse_pageBlockCollage($0) } - dict[319588707] = { return Api.PageBlock.parse_pageBlockSlideshow($0) } dict[-283684427] = { return Api.PageBlock.parse_pageBlockChannel($0) } - dict[834148991] = { return Api.PageBlock.parse_pageBlockAudio($0) } + dict[504660880] = { return Api.PageBlock.parse_pageBlockKicker($0) } + dict[-1085412734] = { return Api.PageBlock.parse_pageBlockTable($0) } + dict[391759200] = { return Api.PageBlock.parse_pageBlockPhoto($0) } + dict[2089805750] = { return Api.PageBlock.parse_pageBlockVideo($0) } + dict[-2143067670] = { return Api.PageBlock.parse_pageBlockAudio($0) } + dict[-1468953147] = { return Api.PageBlock.parse_pageBlockEmbed($0) } + dict[-229005301] = { return Api.PageBlock.parse_pageBlockEmbedPost($0) } + dict[1705048653] = { return Api.PageBlock.parse_pageBlockCollage($0) } + dict[52401552] = { return Api.PageBlock.parse_pageBlockSlideshow($0) } + dict[-454524911] = { return Api.PageBlock.parse_pageBlockList($0) } + dict[-1702174239] = { return Api.PageBlock.parse_pageBlockOrderedList($0) } + dict[1987480557] = { return Api.PageBlock.parse_pageBlockDetails($0) } + dict[370236054] = { return Api.PageBlock.parse_pageBlockRelatedArticles($0) } + dict[-1538310410] = { return Api.PageBlock.parse_pageBlockMap($0) } dict[-614138572] = { return Api.account.TmpPassword.parse_tmpPassword($0) } dict[-2103600678] = { return Api.SecureRequiredType.parse_secureRequiredType($0) } dict[41187252] = { return Api.SecureRequiredType.parse_secureRequiredTypeOneOf($0) } @@ -73,12 +79,17 @@ fileprivate let parsers: [Int32 : (BufferReader) -> Any?] = { dict[1009288385] = { return Api.RichText.parse_textUrl($0) } dict[-564523562] = { return Api.RichText.parse_textEmail($0) } dict[2120376535] = { return Api.RichText.parse_textConcat($0) } + dict[-311786236] = { return Api.RichText.parse_textSubscript($0) } + dict[-939827711] = { return Api.RichText.parse_textSuperscript($0) } + dict[55281185] = { return Api.RichText.parse_textMarked($0) } + dict[483104362] = { return Api.RichText.parse_textPhone($0) } + dict[136105807] = { return Api.RichText.parse_textImage($0) } dict[253890367] = { return Api.UserFull.parse_userFull($0) } dict[-292807034] = { return Api.InputChannel.parse_inputChannelEmpty($0) } dict[-1343524562] = { return Api.InputChannel.parse_inputChannel($0) } dict[414687501] = { return Api.DcOption.parse_dcOption($0) } dict[-1705233435] = { return Api.account.PasswordSettings.parse_passwordSettings($0) } - dict[292985073] = { return Api.LangPackLanguage.parse_langPackLanguage($0) } + dict[711286046] = { return Api.LangPackLanguage.parse_langPackLanguage($0) } dict[-1987579119] = { return Api.help.AppUpdate.parse_appUpdate($0) } dict[-1000708810] = { return Api.help.AppUpdate.parse_noAppUpdate($0) } dict[-209337866] = { return Api.LangPackDifference.parse_langPackDifference($0) } @@ -133,6 +144,7 @@ fileprivate let parsers: [Int32 : (BufferReader) -> Any?] = { dict[-1137792208] = { return Api.PrivacyKey.parse_privacyKeyStatusTimestamp($0) } dict[1343122938] = { return Api.PrivacyKey.parse_privacyKeyChatInvite($0) } dict[1030105979] = { return Api.PrivacyKey.parse_privacyKeyPhoneCall($0) } + dict[961092808] = { return Api.PrivacyKey.parse_privacyKeyPhoneP2P($0) } dict[522914557] = { return Api.Update.parse_updateNewMessage($0) } dict[1318109142] = { return Api.Update.parse_updateMessageID($0) } dict[-1576161051] = { return Api.Update.parse_updateDeleteMessages($0) } @@ -337,6 +349,7 @@ fileprivate let parsers: [Int32 : (BufferReader) -> Any?] = { dict[569137759] = { return Api.SecurePlainData.parse_securePlainEmail($0) } dict[-1269012015] = { return Api.messages.AffectedHistory.parse_affectedHistory($0) } dict[-1036572727] = { return Api.account.PasswordInputSettings.parse_passwordInputSettings($0) } + dict[878078826] = { return Api.PageTableCell.parse_pageTableCell($0) } dict[649453030] = { return Api.messages.MessageEditData.parse_messageEditData($0) } dict[-886477832] = { return Api.LabeledPrice.parse_labeledPrice($0) } dict[-438840932] = { return Api.messages.ChatFull.parse_chatFull($0) } @@ -351,6 +364,7 @@ fileprivate let parsers: [Int32 : (BufferReader) -> Any?] = { dict[-512463606] = { return Api.ReportReason.parse_inputReportReasonOther($0) } dict[-1685456582] = { return Api.ReportReason.parse_inputReportReasonCopyright($0) } dict[-247351839] = { return Api.InputEncryptedChat.parse_inputEncryptedChat($0) } + dict[-524237339] = { return Api.PageTableRow.parse_pageTableRow($0) } dict[-40996577] = { return Api.DraftMessage.parse_draftMessage($0) } dict[453805082] = { return Api.DraftMessage.parse_draftMessageEmpty($0) } dict[1568467877] = { return Api.ChannelAdminRights.parse_channelAdminRights($0) } @@ -373,6 +387,7 @@ fileprivate let parsers: [Int32 : (BufferReader) -> Any?] = { dict[1335282456] = { return Api.InputPrivacyKey.parse_inputPrivacyKeyStatusTimestamp($0) } dict[-1107622874] = { return Api.InputPrivacyKey.parse_inputPrivacyKeyChatInvite($0) } dict[-88417185] = { return Api.InputPrivacyKey.parse_inputPrivacyKeyPhoneCall($0) } + dict[-610373422] = { return Api.InputPrivacyKey.parse_inputPrivacyKeyPhoneP2P($0) } dict[235081943] = { return Api.help.RecentMeUrls.parse_recentMeUrls($0) } dict[-1606526075] = { return Api.ReplyMarkup.parse_replyKeyboardHide($0) } dict[-200242528] = { return Api.ReplyMarkup.parse_replyKeyboardForceReply($0) } @@ -385,11 +400,12 @@ fileprivate let parsers: [Int32 : (BufferReader) -> Any?] = { dict[-316748368] = { return Api.SecureValueHash.parse_secureValueHash($0) } dict[1444661369] = { return Api.ContactBlocked.parse_contactBlocked($0) } dict[-2128698738] = { return Api.auth.CheckedPhone.parse_checkedPhone($0) } + dict[-1188055347] = { return Api.PageListItem.parse_pageListItemText($0) } + dict[635466748] = { return Api.PageListItem.parse_pageListItemBlocks($0) } dict[-1182234929] = { return Api.InputUser.parse_inputUserEmpty($0) } dict[-138301121] = { return Api.InputUser.parse_inputUserSelf($0) } dict[-668391402] = { return Api.InputUser.parse_inputUser($0) } - dict[-1908433218] = { return Api.Page.parse_pagePart($0) } - dict[1433323434] = { return Api.Page.parse_pageFull($0) } + dict[-241590104] = { return Api.Page.parse_page($0) } dict[871426631] = { return Api.SecureCredentialsEncrypted.parse_secureCredentialsEncrypted($0) } dict[157948117] = { return Api.upload.File.parse_file($0) } dict[-242427324] = { return Api.upload.File.parse_fileCdnRedirect($0) } @@ -459,6 +475,7 @@ fileprivate let parsers: [Int32 : (BufferReader) -> Any?] = { dict[307276766] = { return Api.account.Authorizations.parse_authorizations($0) } dict[935395612] = { return Api.ChatPhoto.parse_chatPhotoEmpty($0) } dict[1632839530] = { return Api.ChatPhoto.parse_chatPhoto($0) } + dict[1869903447] = { return Api.PageCaption.parse_pageCaption($0) } dict[1062645411] = { return Api.payments.PaymentForm.parse_paymentForm($0) } dict[1342771681] = { return Api.payments.PaymentReceipt.parse_paymentReceipt($0) } dict[863093588] = { return Api.messages.PeerDialogs.parse_peerDialogs($0) } @@ -555,7 +572,7 @@ fileprivate let parsers: [Int32 : (BufferReader) -> Any?] = { dict[1776236393] = { return Api.ExportedChatInvite.parse_chatInviteEmpty($0) } dict[-64092740] = { return Api.ExportedChatInvite.parse_chatInviteExported($0) } dict[-1389486888] = { return Api.account.AuthorizationForm.parse_authorizationForm($0) } - dict[2079516406] = { return Api.Authorization.parse_authorization($0) } + dict[-1392388579] = { return Api.Authorization.parse_authorization($0) } dict[-1361650766] = { return Api.MaskCoords.parse_maskCoords($0) } dict[-395967805] = { return Api.messages.AllStickers.parse_allStickersNotModified($0) } dict[-302170017] = { return Api.messages.AllStickers.parse_allStickers($0) } @@ -614,8 +631,8 @@ fileprivate let parsers: [Int32 : (BufferReader) -> Any?] = { dict[462375633] = { return Api.PhoneCall.parse_phoneCallWaiting($0) } dict[-2089411356] = { return Api.PhoneCall.parse_phoneCallRequested($0) } dict[1828732223] = { return Api.PhoneCall.parse_phoneCallAccepted($0) } - dict[-1660057] = { return Api.PhoneCall.parse_phoneCall($0) } dict[1355435489] = { return Api.PhoneCall.parse_phoneCallDiscarded($0) } + dict[-419832333] = { return Api.PhoneCall.parse_phoneCall($0) } dict[-483352705] = { return Api.help.TermsOfServiceUpdate.parse_termsOfServiceUpdateEmpty($0) } dict[686618977] = { return Api.help.TermsOfServiceUpdate.parse_termsOfServiceUpdate($0) } dict[-445792507] = { return Api.DialogPeer.parse_dialogPeer($0) } @@ -630,6 +647,7 @@ fileprivate let parsers: [Int32 : (BufferReader) -> Any?] = { dict[1889961234] = { return Api.PeerNotifySettings.parse_peerNotifySettingsEmpty($0) } dict[-1353671392] = { return Api.PeerNotifySettings.parse_peerNotifySettings($0) } dict[-1995686519] = { return Api.InputBotInlineMessageID.parse_inputBotInlineMessageID($0) } + dict[-242812612] = { return Api.PageRelatedArticle.parse_pageRelatedArticle($0) } dict[313694676] = { return Api.StickerPack.parse_stickerPack($0) } dict[1326562017] = { return Api.UserProfilePhoto.parse_userProfilePhotoEmpty($0) } dict[-715532088] = { return Api.UserProfilePhoto.parse_userProfilePhoto($0) } @@ -663,6 +681,8 @@ fileprivate let parsers: [Int32 : (BufferReader) -> Any?] = { dict[-1073693790] = { return Api.auth.SentCodeType.parse_sentCodeTypeSms($0) } dict[1398007207] = { return Api.auth.SentCodeType.parse_sentCodeTypeCall($0) } dict[-1425815847] = { return Api.auth.SentCodeType.parse_sentCodeTypeFlashCall($0) } + dict[1577484359] = { return Api.PageListOrderedItem.parse_pageListOrderedItemText($0) } + dict[-1730311882] = { return Api.PageListOrderedItem.parse_pageListOrderedItemBlocks($0) } dict[-1417756512] = { return Api.EncryptedChat.parse_encryptedChatEmpty($0) } dict[1006044124] = { return Api.EncryptedChat.parse_encryptedChatWaiting($0) } dict[-931638658] = { return Api.EncryptedChat.parse_encryptedChatRequested($0) } @@ -914,6 +934,8 @@ struct Api { _1.serialize(buffer, boxed) case let _1 as Api.account.PasswordInputSettings: _1.serialize(buffer, boxed) + case let _1 as Api.PageTableCell: + _1.serialize(buffer, boxed) case let _1 as Api.messages.MessageEditData: _1.serialize(buffer, boxed) case let _1 as Api.LabeledPrice: @@ -932,6 +954,8 @@ struct Api { _1.serialize(buffer, boxed) case let _1 as Api.InputEncryptedChat: _1.serialize(buffer, boxed) + case let _1 as Api.PageTableRow: + _1.serialize(buffer, boxed) case let _1 as Api.DraftMessage: _1.serialize(buffer, boxed) case let _1 as Api.ChannelAdminRights: @@ -966,6 +990,8 @@ struct Api { _1.serialize(buffer, boxed) case let _1 as Api.auth.CheckedPhone: _1.serialize(buffer, boxed) + case let _1 as Api.PageListItem: + _1.serialize(buffer, boxed) case let _1 as Api.InputUser: _1.serialize(buffer, boxed) case let _1 as Api.Page: @@ -1030,6 +1056,8 @@ struct Api { _1.serialize(buffer, boxed) case let _1 as Api.ChatPhoto: _1.serialize(buffer, boxed) + case let _1 as Api.PageCaption: + _1.serialize(buffer, boxed) case let _1 as Api.payments.PaymentForm: _1.serialize(buffer, boxed) case let _1 as Api.payments.PaymentReceipt: @@ -1158,6 +1186,8 @@ struct Api { _1.serialize(buffer, boxed) case let _1 as Api.InputBotInlineMessageID: _1.serialize(buffer, boxed) + case let _1 as Api.PageRelatedArticle: + _1.serialize(buffer, boxed) case let _1 as Api.StickerPack: _1.serialize(buffer, boxed) case let _1 as Api.UserProfilePhoto: @@ -1178,6 +1208,8 @@ struct Api { _1.serialize(buffer, boxed) case let _1 as Api.auth.SentCodeType: _1.serialize(buffer, boxed) + case let _1 as Api.PageListOrderedItem: + _1.serialize(buffer, boxed) case let _1 as Api.EncryptedChat: _1.serialize(buffer, boxed) case let _1 as Api.Document: diff --git a/TelegramCore/Api1.swift b/TelegramCore/Api1.swift index 52838f26c0..88c3891a95 100644 --- a/TelegramCore/Api1.swift +++ b/TelegramCore/Api1.swift @@ -365,18 +365,24 @@ extension Api { case pageBlockFooter(text: Api.RichText) case pageBlockDivider case pageBlockAnchor(name: String) - case pageBlockList(ordered: Api.Bool, items: [Api.RichText]) case pageBlockBlockquote(text: Api.RichText, caption: Api.RichText) case pageBlockPullquote(text: Api.RichText, caption: Api.RichText) - case pageBlockPhoto(photoId: Int64, caption: Api.RichText) - case pageBlockVideo(flags: Int32, videoId: Int64, caption: Api.RichText) case pageBlockCover(cover: Api.PageBlock) - case pageBlockEmbed(flags: Int32, url: String?, html: String?, posterPhotoId: Int64?, w: Int32, h: Int32, caption: Api.RichText) - case pageBlockEmbedPost(url: String, webpageId: Int64, authorPhotoId: Int64, author: String, date: Int32, blocks: [Api.PageBlock], caption: Api.RichText) - case pageBlockCollage(items: [Api.PageBlock], caption: Api.RichText) - case pageBlockSlideshow(items: [Api.PageBlock], caption: Api.RichText) case pageBlockChannel(channel: Api.Chat) - case pageBlockAudio(audioId: Int64, caption: Api.RichText) + case pageBlockKicker(text: Api.RichText) + case pageBlockTable(flags: Int32, title: Api.RichText, rows: [Api.PageTableRow]) + case pageBlockPhoto(flags: Int32, photoId: Int64, caption: Api.PageCaption, url: String?, webpageId: Int64?) + case pageBlockVideo(flags: Int32, videoId: Int64, caption: Api.PageCaption) + case pageBlockAudio(audioId: Int64, caption: Api.PageCaption) + case pageBlockEmbed(flags: Int32, url: String?, html: String?, posterPhotoId: Int64?, w: Int32?, h: Int32?, caption: Api.PageCaption) + case pageBlockEmbedPost(url: String, webpageId: Int64, authorPhotoId: Int64, author: String, date: Int32, blocks: [Api.PageBlock], caption: Api.PageCaption) + case pageBlockCollage(items: [Api.PageBlock], caption: Api.PageCaption) + case pageBlockSlideshow(items: [Api.PageBlock], caption: Api.PageCaption) + case pageBlockList(items: [Api.PageListItem]) + case pageBlockOrderedList(items: [Api.PageListOrderedItem]) + case pageBlockDetails(flags: Int32, blocks: [Api.PageBlock], title: Api.RichText) + case pageBlockRelatedArticles(title: Api.RichText, articles: [Api.PageRelatedArticle]) + case pageBlockMap(geo: Api.GeoPoint, zoom: Int32, w: Int32, h: Int32, caption: Api.PageCaption) func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) { switch self { @@ -448,17 +454,6 @@ extension Api { } serializeString(name, buffer: buffer, boxed: false) break - case .pageBlockList(let ordered, let items): - if boxed { - buffer.appendInt32(978896884) - } - ordered.serialize(buffer, true) - buffer.appendInt32(481674261) - buffer.appendInt32(Int32(items.count)) - for item in items { - item.serialize(buffer, true) - } - break case .pageBlockBlockquote(let text, let caption): if boxed { buffer.appendInt32(641563686) @@ -473,42 +468,76 @@ extension Api { text.serialize(buffer, true) caption.serialize(buffer, true) break - case .pageBlockPhoto(let photoId, let caption): - if boxed { - buffer.appendInt32(-372860542) - } - serializeInt64(photoId, buffer: buffer, boxed: false) - caption.serialize(buffer, true) - break - case .pageBlockVideo(let flags, let videoId, let caption): - if boxed { - buffer.appendInt32(-640214938) - } - serializeInt32(flags, buffer: buffer, boxed: false) - serializeInt64(videoId, buffer: buffer, boxed: false) - caption.serialize(buffer, true) - break case .pageBlockCover(let cover): if boxed { buffer.appendInt32(972174080) } cover.serialize(buffer, true) break + case .pageBlockChannel(let channel): + if boxed { + buffer.appendInt32(-283684427) + } + channel.serialize(buffer, true) + break + case .pageBlockKicker(let text): + if boxed { + buffer.appendInt32(504660880) + } + text.serialize(buffer, true) + break + case .pageBlockTable(let flags, let title, let rows): + if boxed { + buffer.appendInt32(-1085412734) + } + serializeInt32(flags, buffer: buffer, boxed: false) + title.serialize(buffer, true) + buffer.appendInt32(481674261) + buffer.appendInt32(Int32(rows.count)) + for item in rows { + item.serialize(buffer, true) + } + break + case .pageBlockPhoto(let flags, let photoId, let caption, let url, let webpageId): + if boxed { + buffer.appendInt32(391759200) + } + serializeInt32(flags, buffer: buffer, boxed: false) + serializeInt64(photoId, buffer: buffer, boxed: false) + caption.serialize(buffer, true) + if Int(flags) & Int(1 << 0) != 0 {serializeString(url!, buffer: buffer, boxed: false)} + if Int(flags) & Int(1 << 0) != 0 {serializeInt64(webpageId!, buffer: buffer, boxed: false)} + break + case .pageBlockVideo(let flags, let videoId, let caption): + if boxed { + buffer.appendInt32(2089805750) + } + serializeInt32(flags, buffer: buffer, boxed: false) + serializeInt64(videoId, buffer: buffer, boxed: false) + caption.serialize(buffer, true) + break + case .pageBlockAudio(let audioId, let caption): + if boxed { + buffer.appendInt32(-2143067670) + } + serializeInt64(audioId, buffer: buffer, boxed: false) + caption.serialize(buffer, true) + break case .pageBlockEmbed(let flags, let url, let html, let posterPhotoId, let w, let h, let caption): if boxed { - buffer.appendInt32(-840826671) + buffer.appendInt32(-1468953147) } serializeInt32(flags, buffer: buffer, boxed: false) if Int(flags) & Int(1 << 1) != 0 {serializeString(url!, buffer: buffer, boxed: false)} if Int(flags) & Int(1 << 2) != 0 {serializeString(html!, buffer: buffer, boxed: false)} if Int(flags) & Int(1 << 4) != 0 {serializeInt64(posterPhotoId!, buffer: buffer, boxed: false)} - serializeInt32(w, buffer: buffer, boxed: false) - serializeInt32(h, buffer: buffer, boxed: false) + if Int(flags) & Int(1 << 5) != 0 {serializeInt32(w!, buffer: buffer, boxed: false)} + if Int(flags) & Int(1 << 5) != 0 {serializeInt32(h!, buffer: buffer, boxed: false)} caption.serialize(buffer, true) break case .pageBlockEmbedPost(let url, let webpageId, let authorPhotoId, let author, let date, let blocks, let caption): if boxed { - buffer.appendInt32(690781161) + buffer.appendInt32(-229005301) } serializeString(url, buffer: buffer, boxed: false) serializeInt64(webpageId, buffer: buffer, boxed: false) @@ -524,7 +553,7 @@ extension Api { break case .pageBlockCollage(let items, let caption): if boxed { - buffer.appendInt32(145955919) + buffer.appendInt32(1705048653) } buffer.appendInt32(481674261) buffer.appendInt32(Int32(items.count)) @@ -535,7 +564,7 @@ extension Api { break case .pageBlockSlideshow(let items, let caption): if boxed { - buffer.appendInt32(319588707) + buffer.appendInt32(52401552) } buffer.appendInt32(481674261) buffer.appendInt32(Int32(items.count)) @@ -544,17 +573,57 @@ extension Api { } caption.serialize(buffer, true) break - case .pageBlockChannel(let channel): + case .pageBlockList(let items): if boxed { - buffer.appendInt32(-283684427) + buffer.appendInt32(-454524911) + } + buffer.appendInt32(481674261) + buffer.appendInt32(Int32(items.count)) + for item in items { + item.serialize(buffer, true) } - channel.serialize(buffer, true) break - case .pageBlockAudio(let audioId, let caption): + case .pageBlockOrderedList(let items): if boxed { - buffer.appendInt32(834148991) + buffer.appendInt32(-1702174239) } - serializeInt64(audioId, buffer: buffer, boxed: false) + buffer.appendInt32(481674261) + buffer.appendInt32(Int32(items.count)) + for item in items { + item.serialize(buffer, true) + } + break + case .pageBlockDetails(let flags, let blocks, let title): + if boxed { + buffer.appendInt32(1987480557) + } + serializeInt32(flags, buffer: buffer, boxed: false) + buffer.appendInt32(481674261) + buffer.appendInt32(Int32(blocks.count)) + for item in blocks { + item.serialize(buffer, true) + } + title.serialize(buffer, true) + break + case .pageBlockRelatedArticles(let title, let articles): + if boxed { + buffer.appendInt32(370236054) + } + title.serialize(buffer, true) + buffer.appendInt32(481674261) + buffer.appendInt32(Int32(articles.count)) + for item in articles { + item.serialize(buffer, true) + } + break + case .pageBlockMap(let geo, let zoom, let w, let h, let caption): + if boxed { + buffer.appendInt32(-1538310410) + } + geo.serialize(buffer, true) + serializeInt32(zoom, buffer: buffer, boxed: false) + serializeInt32(w, buffer: buffer, boxed: false) + serializeInt32(h, buffer: buffer, boxed: false) caption.serialize(buffer, true) break } @@ -584,18 +653,24 @@ extension Api { return ("pageBlockDivider", []) case .pageBlockAnchor(let name): return ("pageBlockAnchor", [("name", name)]) - case .pageBlockList(let ordered, let items): - return ("pageBlockList", [("ordered", ordered), ("items", items)]) case .pageBlockBlockquote(let text, let caption): return ("pageBlockBlockquote", [("text", text), ("caption", caption)]) case .pageBlockPullquote(let text, let caption): return ("pageBlockPullquote", [("text", text), ("caption", caption)]) - case .pageBlockPhoto(let photoId, let caption): - return ("pageBlockPhoto", [("photoId", photoId), ("caption", caption)]) - case .pageBlockVideo(let flags, let videoId, let caption): - return ("pageBlockVideo", [("flags", flags), ("videoId", videoId), ("caption", caption)]) case .pageBlockCover(let cover): return ("pageBlockCover", [("cover", cover)]) + case .pageBlockChannel(let channel): + return ("pageBlockChannel", [("channel", channel)]) + case .pageBlockKicker(let text): + return ("pageBlockKicker", [("text", text)]) + case .pageBlockTable(let flags, let title, let rows): + return ("pageBlockTable", [("flags", flags), ("title", title), ("rows", rows)]) + case .pageBlockPhoto(let flags, let photoId, let caption, let url, let webpageId): + return ("pageBlockPhoto", [("flags", flags), ("photoId", photoId), ("caption", caption), ("url", url), ("webpageId", webpageId)]) + case .pageBlockVideo(let flags, let videoId, let caption): + return ("pageBlockVideo", [("flags", flags), ("videoId", videoId), ("caption", caption)]) + case .pageBlockAudio(let audioId, let caption): + return ("pageBlockAudio", [("audioId", audioId), ("caption", caption)]) case .pageBlockEmbed(let flags, let url, let html, let posterPhotoId, let w, let h, let caption): return ("pageBlockEmbed", [("flags", flags), ("url", url), ("html", html), ("posterPhotoId", posterPhotoId), ("w", w), ("h", h), ("caption", caption)]) case .pageBlockEmbedPost(let url, let webpageId, let authorPhotoId, let author, let date, let blocks, let caption): @@ -604,10 +679,16 @@ extension Api { return ("pageBlockCollage", [("items", items), ("caption", caption)]) case .pageBlockSlideshow(let items, let caption): return ("pageBlockSlideshow", [("items", items), ("caption", caption)]) - case .pageBlockChannel(let channel): - return ("pageBlockChannel", [("channel", channel)]) - case .pageBlockAudio(let audioId, let caption): - return ("pageBlockAudio", [("audioId", audioId), ("caption", caption)]) + case .pageBlockList(let items): + return ("pageBlockList", [("items", items)]) + case .pageBlockOrderedList(let items): + return ("pageBlockOrderedList", [("items", items)]) + case .pageBlockDetails(let flags, let blocks, let title): + return ("pageBlockDetails", [("flags", flags), ("blocks", blocks), ("title", title)]) + case .pageBlockRelatedArticles(let title, let articles): + return ("pageBlockRelatedArticles", [("title", title), ("articles", articles)]) + case .pageBlockMap(let geo, let zoom, let w, let h, let caption): + return ("pageBlockMap", [("geo", geo), ("zoom", zoom), ("w", w), ("h", h), ("caption", caption)]) } } @@ -738,24 +819,6 @@ extension Api { return nil } } - static func parse_pageBlockList(_ reader: BufferReader) -> PageBlock? { - var _1: Api.Bool? - if let signature = reader.readInt32() { - _1 = Api.parse(reader, signature: signature) as? Api.Bool - } - var _2: [Api.RichText]? - if let _ = reader.readInt32() { - _2 = Api.parseVector(reader, elementSignature: 0, elementType: Api.RichText.self) - } - let _c1 = _1 != nil - let _c2 = _2 != nil - if _c1 && _c2 { - return Api.PageBlock.pageBlockList(ordered: _1!, items: _2!) - } - else { - return nil - } - } static func parse_pageBlockBlockquote(_ reader: BufferReader) -> PageBlock? { var _1: Api.RichText? if let signature = reader.readInt32() { @@ -792,17 +855,86 @@ extension Api { return nil } } - static func parse_pageBlockPhoto(_ reader: BufferReader) -> PageBlock? { - var _1: Int64? - _1 = reader.readInt64() + static func parse_pageBlockCover(_ reader: BufferReader) -> PageBlock? { + var _1: Api.PageBlock? + if let signature = reader.readInt32() { + _1 = Api.parse(reader, signature: signature) as? Api.PageBlock + } + let _c1 = _1 != nil + if _c1 { + return Api.PageBlock.pageBlockCover(cover: _1!) + } + else { + return nil + } + } + static func parse_pageBlockChannel(_ reader: BufferReader) -> PageBlock? { + var _1: Api.Chat? + if let signature = reader.readInt32() { + _1 = Api.parse(reader, signature: signature) as? Api.Chat + } + let _c1 = _1 != nil + if _c1 { + return Api.PageBlock.pageBlockChannel(channel: _1!) + } + else { + return nil + } + } + static func parse_pageBlockKicker(_ reader: BufferReader) -> PageBlock? { + var _1: Api.RichText? + if let signature = reader.readInt32() { + _1 = Api.parse(reader, signature: signature) as? Api.RichText + } + let _c1 = _1 != nil + if _c1 { + return Api.PageBlock.pageBlockKicker(text: _1!) + } + else { + return nil + } + } + static func parse_pageBlockTable(_ reader: BufferReader) -> PageBlock? { + var _1: Int32? + _1 = reader.readInt32() var _2: Api.RichText? if let signature = reader.readInt32() { _2 = Api.parse(reader, signature: signature) as? Api.RichText } + var _3: [Api.PageTableRow]? + if let _ = reader.readInt32() { + _3 = Api.parseVector(reader, elementSignature: 0, elementType: Api.PageTableRow.self) + } let _c1 = _1 != nil let _c2 = _2 != nil - if _c1 && _c2 { - return Api.PageBlock.pageBlockPhoto(photoId: _1!, caption: _2!) + let _c3 = _3 != nil + if _c1 && _c2 && _c3 { + return Api.PageBlock.pageBlockTable(flags: _1!, title: _2!, rows: _3!) + } + else { + return nil + } + } + static func parse_pageBlockPhoto(_ reader: BufferReader) -> PageBlock? { + var _1: Int32? + _1 = reader.readInt32() + var _2: Int64? + _2 = reader.readInt64() + var _3: Api.PageCaption? + if let signature = reader.readInt32() { + _3 = Api.parse(reader, signature: signature) as? Api.PageCaption + } + var _4: String? + if Int(_1!) & Int(1 << 0) != 0 {_4 = parseString(reader) } + var _5: Int64? + if Int(_1!) & Int(1 << 0) != 0 {_5 = reader.readInt64() } + let _c1 = _1 != nil + let _c2 = _2 != nil + let _c3 = _3 != nil + let _c4 = (Int(_1!) & Int(1 << 0) == 0) || _4 != nil + let _c5 = (Int(_1!) & Int(1 << 0) == 0) || _5 != nil + if _c1 && _c2 && _c3 && _c4 && _c5 { + return Api.PageBlock.pageBlockPhoto(flags: _1!, photoId: _2!, caption: _3!, url: _4, webpageId: _5) } else { return nil @@ -813,9 +945,9 @@ extension Api { _1 = reader.readInt32() var _2: Int64? _2 = reader.readInt64() - var _3: Api.RichText? + var _3: Api.PageCaption? if let signature = reader.readInt32() { - _3 = Api.parse(reader, signature: signature) as? Api.RichText + _3 = Api.parse(reader, signature: signature) as? Api.PageCaption } let _c1 = _1 != nil let _c2 = _2 != nil @@ -827,14 +959,17 @@ extension Api { return nil } } - static func parse_pageBlockCover(_ reader: BufferReader) -> PageBlock? { - var _1: Api.PageBlock? + static func parse_pageBlockAudio(_ reader: BufferReader) -> PageBlock? { + var _1: Int64? + _1 = reader.readInt64() + var _2: Api.PageCaption? if let signature = reader.readInt32() { - _1 = Api.parse(reader, signature: signature) as? Api.PageBlock + _2 = Api.parse(reader, signature: signature) as? Api.PageCaption } let _c1 = _1 != nil - if _c1 { - return Api.PageBlock.pageBlockCover(cover: _1!) + let _c2 = _2 != nil + if _c1 && _c2 { + return Api.PageBlock.pageBlockAudio(audioId: _1!, caption: _2!) } else { return nil @@ -850,22 +985,22 @@ extension Api { var _4: Int64? if Int(_1!) & Int(1 << 4) != 0 {_4 = reader.readInt64() } var _5: Int32? - _5 = reader.readInt32() + if Int(_1!) & Int(1 << 5) != 0 {_5 = reader.readInt32() } var _6: Int32? - _6 = reader.readInt32() - var _7: Api.RichText? + if Int(_1!) & Int(1 << 5) != 0 {_6 = reader.readInt32() } + var _7: Api.PageCaption? if let signature = reader.readInt32() { - _7 = Api.parse(reader, signature: signature) as? Api.RichText + _7 = Api.parse(reader, signature: signature) as? Api.PageCaption } let _c1 = _1 != nil let _c2 = (Int(_1!) & Int(1 << 1) == 0) || _2 != nil let _c3 = (Int(_1!) & Int(1 << 2) == 0) || _3 != nil let _c4 = (Int(_1!) & Int(1 << 4) == 0) || _4 != nil - let _c5 = _5 != nil - let _c6 = _6 != nil + let _c5 = (Int(_1!) & Int(1 << 5) == 0) || _5 != nil + let _c6 = (Int(_1!) & Int(1 << 5) == 0) || _6 != nil let _c7 = _7 != nil if _c1 && _c2 && _c3 && _c4 && _c5 && _c6 && _c7 { - return Api.PageBlock.pageBlockEmbed(flags: _1!, url: _2, html: _3, posterPhotoId: _4, w: _5!, h: _6!, caption: _7!) + return Api.PageBlock.pageBlockEmbed(flags: _1!, url: _2, html: _3, posterPhotoId: _4, w: _5, h: _6, caption: _7!) } else { return nil @@ -886,9 +1021,9 @@ extension Api { if let _ = reader.readInt32() { _6 = Api.parseVector(reader, elementSignature: 0, elementType: Api.PageBlock.self) } - var _7: Api.RichText? + var _7: Api.PageCaption? if let signature = reader.readInt32() { - _7 = Api.parse(reader, signature: signature) as? Api.RichText + _7 = Api.parse(reader, signature: signature) as? Api.PageCaption } let _c1 = _1 != nil let _c2 = _2 != nil @@ -909,9 +1044,9 @@ extension Api { if let _ = reader.readInt32() { _1 = Api.parseVector(reader, elementSignature: 0, elementType: Api.PageBlock.self) } - var _2: Api.RichText? + var _2: Api.PageCaption? if let signature = reader.readInt32() { - _2 = Api.parse(reader, signature: signature) as? Api.RichText + _2 = Api.parse(reader, signature: signature) as? Api.PageCaption } let _c1 = _1 != nil let _c2 = _2 != nil @@ -927,9 +1062,9 @@ extension Api { if let _ = reader.readInt32() { _1 = Api.parseVector(reader, elementSignature: 0, elementType: Api.PageBlock.self) } - var _2: Api.RichText? + var _2: Api.PageCaption? if let signature = reader.readInt32() { - _2 = Api.parse(reader, signature: signature) as? Api.RichText + _2 = Api.parse(reader, signature: signature) as? Api.PageCaption } let _c1 = _1 != nil let _c2 = _2 != nil @@ -940,30 +1075,93 @@ extension Api { return nil } } - static func parse_pageBlockChannel(_ reader: BufferReader) -> PageBlock? { - var _1: Api.Chat? - if let signature = reader.readInt32() { - _1 = Api.parse(reader, signature: signature) as? Api.Chat + static func parse_pageBlockList(_ reader: BufferReader) -> PageBlock? { + var _1: [Api.PageListItem]? + if let _ = reader.readInt32() { + _1 = Api.parseVector(reader, elementSignature: 0, elementType: Api.PageListItem.self) } let _c1 = _1 != nil if _c1 { - return Api.PageBlock.pageBlockChannel(channel: _1!) + return Api.PageBlock.pageBlockList(items: _1!) } else { return nil } } - static func parse_pageBlockAudio(_ reader: BufferReader) -> PageBlock? { - var _1: Int64? - _1 = reader.readInt64() - var _2: Api.RichText? + static func parse_pageBlockOrderedList(_ reader: BufferReader) -> PageBlock? { + var _1: [Api.PageListOrderedItem]? + if let _ = reader.readInt32() { + _1 = Api.parseVector(reader, elementSignature: 0, elementType: Api.PageListOrderedItem.self) + } + let _c1 = _1 != nil + if _c1 { + return Api.PageBlock.pageBlockOrderedList(items: _1!) + } + else { + return nil + } + } + static func parse_pageBlockDetails(_ reader: BufferReader) -> PageBlock? { + var _1: Int32? + _1 = reader.readInt32() + var _2: [Api.PageBlock]? + if let _ = reader.readInt32() { + _2 = Api.parseVector(reader, elementSignature: 0, elementType: Api.PageBlock.self) + } + var _3: Api.RichText? if let signature = reader.readInt32() { - _2 = Api.parse(reader, signature: signature) as? Api.RichText + _3 = Api.parse(reader, signature: signature) as? Api.RichText + } + let _c1 = _1 != nil + let _c2 = _2 != nil + let _c3 = _3 != nil + if _c1 && _c2 && _c3 { + return Api.PageBlock.pageBlockDetails(flags: _1!, blocks: _2!, title: _3!) + } + else { + return nil + } + } + static func parse_pageBlockRelatedArticles(_ reader: BufferReader) -> PageBlock? { + var _1: Api.RichText? + if let signature = reader.readInt32() { + _1 = Api.parse(reader, signature: signature) as? Api.RichText + } + var _2: [Api.PageRelatedArticle]? + if let _ = reader.readInt32() { + _2 = Api.parseVector(reader, elementSignature: 0, elementType: Api.PageRelatedArticle.self) } let _c1 = _1 != nil let _c2 = _2 != nil if _c1 && _c2 { - return Api.PageBlock.pageBlockAudio(audioId: _1!, caption: _2!) + return Api.PageBlock.pageBlockRelatedArticles(title: _1!, articles: _2!) + } + else { + return nil + } + } + static func parse_pageBlockMap(_ reader: BufferReader) -> PageBlock? { + var _1: Api.GeoPoint? + if let signature = reader.readInt32() { + _1 = Api.parse(reader, signature: signature) as? Api.GeoPoint + } + var _2: Int32? + _2 = reader.readInt32() + var _3: Int32? + _3 = reader.readInt32() + var _4: Int32? + _4 = reader.readInt32() + var _5: Api.PageCaption? + if let signature = reader.readInt32() { + _5 = Api.parse(reader, signature: signature) as? Api.PageCaption + } + let _c1 = _1 != nil + let _c2 = _2 != nil + let _c3 = _3 != nil + let _c4 = _4 != nil + let _c5 = _5 != nil + if _c1 && _c2 && _c3 && _c4 && _c5 { + return Api.PageBlock.pageBlockMap(geo: _1!, zoom: _2!, w: _3!, h: _4!, caption: _5!) } else { return nil @@ -1632,6 +1830,11 @@ extension Api { case textUrl(text: Api.RichText, url: String, webpageId: Int64) case textEmail(text: Api.RichText, email: String) case textConcat(texts: [Api.RichText]) + case textSubscript(text: Api.RichText) + case textSuperscript(text: Api.RichText) + case textMarked(text: Api.RichText) + case textPhone(text: Api.RichText, phone: String) + case textImage(documentId: Int64, w: Int32, h: Int32) func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) { switch self { @@ -1702,6 +1905,39 @@ extension Api { item.serialize(buffer, true) } break + case .textSubscript(let text): + if boxed { + buffer.appendInt32(-311786236) + } + text.serialize(buffer, true) + break + case .textSuperscript(let text): + if boxed { + buffer.appendInt32(-939827711) + } + text.serialize(buffer, true) + break + case .textMarked(let text): + if boxed { + buffer.appendInt32(55281185) + } + text.serialize(buffer, true) + break + case .textPhone(let text, let phone): + if boxed { + buffer.appendInt32(483104362) + } + text.serialize(buffer, true) + serializeString(phone, buffer: buffer, boxed: false) + break + case .textImage(let documentId, let w, let h): + if boxed { + buffer.appendInt32(136105807) + } + serializeInt64(documentId, buffer: buffer, boxed: false) + serializeInt32(w, buffer: buffer, boxed: false) + serializeInt32(h, buffer: buffer, boxed: false) + break } } @@ -1727,6 +1963,16 @@ extension Api { return ("textEmail", [("text", text), ("email", email)]) case .textConcat(let texts): return ("textConcat", [("texts", texts)]) + case .textSubscript(let text): + return ("textSubscript", [("text", text)]) + case .textSuperscript(let text): + return ("textSuperscript", [("text", text)]) + case .textMarked(let text): + return ("textMarked", [("text", text)]) + case .textPhone(let text, let phone): + return ("textPhone", [("text", text), ("phone", phone)]) + case .textImage(let documentId, let w, let h): + return ("textImage", [("documentId", documentId), ("w", w), ("h", h)]) } } @@ -1857,6 +2103,78 @@ extension Api { return nil } } + static func parse_textSubscript(_ reader: BufferReader) -> RichText? { + var _1: Api.RichText? + if let signature = reader.readInt32() { + _1 = Api.parse(reader, signature: signature) as? Api.RichText + } + let _c1 = _1 != nil + if _c1 { + return Api.RichText.textSubscript(text: _1!) + } + else { + return nil + } + } + static func parse_textSuperscript(_ reader: BufferReader) -> RichText? { + var _1: Api.RichText? + if let signature = reader.readInt32() { + _1 = Api.parse(reader, signature: signature) as? Api.RichText + } + let _c1 = _1 != nil + if _c1 { + return Api.RichText.textSuperscript(text: _1!) + } + else { + return nil + } + } + static func parse_textMarked(_ reader: BufferReader) -> RichText? { + var _1: Api.RichText? + if let signature = reader.readInt32() { + _1 = Api.parse(reader, signature: signature) as? Api.RichText + } + let _c1 = _1 != nil + if _c1 { + return Api.RichText.textMarked(text: _1!) + } + else { + return nil + } + } + static func parse_textPhone(_ reader: BufferReader) -> RichText? { + var _1: Api.RichText? + if let signature = reader.readInt32() { + _1 = Api.parse(reader, signature: signature) as? Api.RichText + } + var _2: String? + _2 = parseString(reader) + let _c1 = _1 != nil + let _c2 = _2 != nil + if _c1 && _c2 { + return Api.RichText.textPhone(text: _1!, phone: _2!) + } + else { + return nil + } + } + static func parse_textImage(_ reader: BufferReader) -> RichText? { + var _1: Int64? + _1 = reader.readInt64() + var _2: Int32? + _2 = reader.readInt32() + var _3: Int32? + _3 = reader.readInt32() + let _c1 = _1 != nil + let _c2 = _2 != nil + let _c3 = _3 != nil + if _c1 && _c2 && _c3 { + return Api.RichText.textImage(documentId: _1!, w: _2!, h: _3!) + } + else { + return nil + } + } } enum UserFull: TypeConstructorDescription { @@ -2032,40 +2350,56 @@ extension Api { } enum LangPackLanguage: TypeConstructorDescription { - case langPackLanguage(name: String, nativeName: String, langCode: String) + case langPackLanguage(flags: Int32, name: String, nativeName: String, langCode: String, baseLangCode: String?, stringsCount: Int32, translatedCount: Int32) func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) { switch self { - case .langPackLanguage(let name, let nativeName, let langCode): + case .langPackLanguage(let flags, let name, let nativeName, let langCode, let baseLangCode, let stringsCount, let translatedCount): if boxed { - buffer.appendInt32(292985073) + buffer.appendInt32(711286046) } + serializeInt32(flags, buffer: buffer, boxed: false) serializeString(name, buffer: buffer, boxed: false) serializeString(nativeName, buffer: buffer, boxed: false) serializeString(langCode, buffer: buffer, boxed: false) + if Int(flags) & Int(1 << 1) != 0 {serializeString(baseLangCode!, buffer: buffer, boxed: false)} + serializeInt32(stringsCount, buffer: buffer, boxed: false) + serializeInt32(translatedCount, buffer: buffer, boxed: false) break } } func descriptionFields() -> (String, [(String, Any)]) { switch self { - case .langPackLanguage(let name, let nativeName, let langCode): - return ("langPackLanguage", [("name", name), ("nativeName", nativeName), ("langCode", langCode)]) + case .langPackLanguage(let flags, let name, let nativeName, let langCode, let baseLangCode, let stringsCount, let translatedCount): + return ("langPackLanguage", [("flags", flags), ("name", name), ("nativeName", nativeName), ("langCode", langCode), ("baseLangCode", baseLangCode), ("stringsCount", stringsCount), ("translatedCount", translatedCount)]) } } static func parse_langPackLanguage(_ reader: BufferReader) -> LangPackLanguage? { - var _1: String? - _1 = parseString(reader) + var _1: Int32? + _1 = reader.readInt32() var _2: String? _2 = parseString(reader) var _3: String? _3 = parseString(reader) + var _4: String? + _4 = parseString(reader) + var _5: String? + if Int(_1!) & Int(1 << 1) != 0 {_5 = parseString(reader) } + var _6: Int32? + _6 = reader.readInt32() + var _7: Int32? + _7 = reader.readInt32() let _c1 = _1 != nil let _c2 = _2 != nil let _c3 = _3 != nil - if _c1 && _c2 && _c3 { - return Api.LangPackLanguage.langPackLanguage(name: _1!, nativeName: _2!, langCode: _3!) + let _c4 = _4 != nil + let _c5 = (Int(_1!) & Int(1 << 1) == 0) || _5 != nil + let _c6 = _6 != nil + let _c7 = _7 != nil + if _c1 && _c2 && _c3 && _c4 && _c5 && _c6 && _c7 { + return Api.LangPackLanguage.langPackLanguage(flags: _1!, name: _2!, nativeName: _3!, langCode: _4!, baseLangCode: _5, stringsCount: _6!, translatedCount: _7!) } else { return nil @@ -2919,6 +3253,7 @@ extension Api { case privacyKeyStatusTimestamp case privacyKeyChatInvite case privacyKeyPhoneCall + case privacyKeyPhoneP2P func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) { switch self { @@ -2939,6 +3274,12 @@ extension Api { buffer.appendInt32(1030105979) } + break + case .privacyKeyPhoneP2P: + if boxed { + buffer.appendInt32(961092808) + } + break } } @@ -2951,6 +3292,8 @@ extension Api { return ("privacyKeyChatInvite", []) case .privacyKeyPhoneCall: return ("privacyKeyPhoneCall", []) + case .privacyKeyPhoneP2P: + return ("privacyKeyPhoneP2P", []) } } @@ -2963,6 +3306,9 @@ extension Api { static func parse_privacyKeyPhoneCall(_ reader: BufferReader) -> PrivacyKey? { return Api.PrivacyKey.privacyKeyPhoneCall } + static func parse_privacyKeyPhoneP2P(_ reader: BufferReader) -> PrivacyKey? { + return Api.PrivacyKey.privacyKeyPhoneP2P + } } enum Update: TypeConstructorDescription { @@ -8122,6 +8468,54 @@ extension Api { } } + } + enum PageTableCell: TypeConstructorDescription { + case pageTableCell(flags: Int32, text: Api.RichText?, colspan: Int32?, rowspan: Int32?) + + func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) { + switch self { + case .pageTableCell(let flags, let text, let colspan, let rowspan): + if boxed { + buffer.appendInt32(878078826) + } + serializeInt32(flags, buffer: buffer, boxed: false) + if Int(flags) & Int(1 << 7) != 0 {text!.serialize(buffer, true)} + if Int(flags) & Int(1 << 1) != 0 {serializeInt32(colspan!, buffer: buffer, boxed: false)} + if Int(flags) & Int(1 << 2) != 0 {serializeInt32(rowspan!, buffer: buffer, boxed: false)} + break + } + } + + func descriptionFields() -> (String, [(String, Any)]) { + switch self { + case .pageTableCell(let flags, let text, let colspan, let rowspan): + return ("pageTableCell", [("flags", flags), ("text", text), ("colspan", colspan), ("rowspan", rowspan)]) + } + } + + static func parse_pageTableCell(_ reader: BufferReader) -> PageTableCell? { + var _1: Int32? + _1 = reader.readInt32() + var _2: Api.RichText? + if Int(_1!) & Int(1 << 7) != 0 {if let signature = reader.readInt32() { + _2 = Api.parse(reader, signature: signature) as? Api.RichText + } } + var _3: Int32? + if Int(_1!) & Int(1 << 1) != 0 {_3 = reader.readInt32() } + var _4: Int32? + if Int(_1!) & Int(1 << 2) != 0 {_4 = reader.readInt32() } + let _c1 = _1 != nil + let _c2 = (Int(_1!) & Int(1 << 7) == 0) || _2 != nil + let _c3 = (Int(_1!) & Int(1 << 1) == 0) || _3 != nil + let _c4 = (Int(_1!) & Int(1 << 2) == 0) || _4 != nil + if _c1 && _c2 && _c3 && _c4 { + return Api.PageTableCell.pageTableCell(flags: _1!, text: _2, colspan: _3, rowspan: _4) + } + else { + return nil + } + } + } enum LabeledPrice: TypeConstructorDescription { case labeledPrice(label: String, amount: Int64) @@ -8370,6 +8764,46 @@ extension Api { } } + } + enum PageTableRow: TypeConstructorDescription { + case pageTableRow(cells: [Api.PageTableCell]) + + func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) { + switch self { + case .pageTableRow(let cells): + if boxed { + buffer.appendInt32(-524237339) + } + buffer.appendInt32(481674261) + buffer.appendInt32(Int32(cells.count)) + for item in cells { + item.serialize(buffer, true) + } + break + } + } + + func descriptionFields() -> (String, [(String, Any)]) { + switch self { + case .pageTableRow(let cells): + return ("pageTableRow", [("cells", cells)]) + } + } + + static func parse_pageTableRow(_ reader: BufferReader) -> PageTableRow? { + var _1: [Api.PageTableCell]? + if let _ = reader.readInt32() { + _1 = Api.parseVector(reader, elementSignature: 0, elementType: Api.PageTableCell.self) + } + let _c1 = _1 != nil + if _c1 { + return Api.PageTableRow.pageTableRow(cells: _1!) + } + else { + return nil + } + } + } enum DraftMessage: TypeConstructorDescription { case draftMessage(flags: Int32, replyToMsgId: Int32?, message: String, entities: [Api.MessageEntity]?, date: Int32) @@ -8949,6 +9383,7 @@ extension Api { case inputPrivacyKeyStatusTimestamp case inputPrivacyKeyChatInvite case inputPrivacyKeyPhoneCall + case inputPrivacyKeyPhoneP2P func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) { switch self { @@ -8969,6 +9404,12 @@ extension Api { buffer.appendInt32(-88417185) } + break + case .inputPrivacyKeyPhoneP2P: + if boxed { + buffer.appendInt32(-610373422) + } + break } } @@ -8981,6 +9422,8 @@ extension Api { return ("inputPrivacyKeyChatInvite", []) case .inputPrivacyKeyPhoneCall: return ("inputPrivacyKeyPhoneCall", []) + case .inputPrivacyKeyPhoneP2P: + return ("inputPrivacyKeyPhoneP2P", []) } } @@ -8993,6 +9436,9 @@ extension Api { static func parse_inputPrivacyKeyPhoneCall(_ reader: BufferReader) -> InputPrivacyKey? { return Api.InputPrivacyKey.inputPrivacyKeyPhoneCall } + static func parse_inputPrivacyKeyPhoneP2P(_ reader: BufferReader) -> InputPrivacyKey? { + return Api.InputPrivacyKey.inputPrivacyKeyPhoneP2P + } } enum ReplyMarkup: TypeConstructorDescription { @@ -9358,6 +9804,68 @@ extension Api { } } + } + enum PageListItem: TypeConstructorDescription { + case pageListItemText(text: Api.RichText) + case pageListItemBlocks(blocks: [Api.PageBlock]) + + func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) { + switch self { + case .pageListItemText(let text): + if boxed { + buffer.appendInt32(-1188055347) + } + text.serialize(buffer, true) + break + case .pageListItemBlocks(let blocks): + if boxed { + buffer.appendInt32(635466748) + } + buffer.appendInt32(481674261) + buffer.appendInt32(Int32(blocks.count)) + for item in blocks { + item.serialize(buffer, true) + } + break + } + } + + func descriptionFields() -> (String, [(String, Any)]) { + switch self { + case .pageListItemText(let text): + return ("pageListItemText", [("text", text)]) + case .pageListItemBlocks(let blocks): + return ("pageListItemBlocks", [("blocks", blocks)]) + } + } + + static func parse_pageListItemText(_ reader: BufferReader) -> PageListItem? { + var _1: Api.RichText? + if let signature = reader.readInt32() { + _1 = Api.parse(reader, signature: signature) as? Api.RichText + } + let _c1 = _1 != nil + if _c1 { + return Api.PageListItem.pageListItemText(text: _1!) + } + else { + return nil + } + } + static func parse_pageListItemBlocks(_ reader: BufferReader) -> PageListItem? { + var _1: [Api.PageBlock]? + if let _ = reader.readInt32() { + _1 = Api.parseVector(reader, elementSignature: 0, elementType: Api.PageBlock.self) + } + let _c1 = _1 != nil + if _c1 { + return Api.PageListItem.pageListItemBlocks(blocks: _1!) + } + else { + return nil + } + } + } enum InputUser: TypeConstructorDescription { case inputUserEmpty @@ -9422,35 +9930,15 @@ extension Api { } enum Page: TypeConstructorDescription { - case pagePart(blocks: [Api.PageBlock], photos: [Api.Photo], documents: [Api.Document]) - case pageFull(blocks: [Api.PageBlock], photos: [Api.Photo], documents: [Api.Document]) + case page(flags: Int32, blocks: [Api.PageBlock], photos: [Api.Photo], documents: [Api.Document]) func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) { switch self { - case .pagePart(let blocks, let photos, let documents): + case .page(let flags, let blocks, let photos, let documents): if boxed { - buffer.appendInt32(-1908433218) - } - buffer.appendInt32(481674261) - buffer.appendInt32(Int32(blocks.count)) - for item in blocks { - item.serialize(buffer, true) - } - buffer.appendInt32(481674261) - buffer.appendInt32(Int32(photos.count)) - for item in photos { - item.serialize(buffer, true) - } - buffer.appendInt32(481674261) - buffer.appendInt32(Int32(documents.count)) - for item in documents { - item.serialize(buffer, true) - } - break - case .pageFull(let blocks, let photos, let documents): - if boxed { - buffer.appendInt32(1433323434) + buffer.appendInt32(-241590104) } + serializeInt32(flags, buffer: buffer, boxed: false) buffer.appendInt32(481674261) buffer.appendInt32(Int32(blocks.count)) for item in blocks { @@ -9472,54 +9960,32 @@ extension Api { func descriptionFields() -> (String, [(String, Any)]) { switch self { - case .pagePart(let blocks, let photos, let documents): - return ("pagePart", [("blocks", blocks), ("photos", photos), ("documents", documents)]) - case .pageFull(let blocks, let photos, let documents): - return ("pageFull", [("blocks", blocks), ("photos", photos), ("documents", documents)]) + case .page(let flags, let blocks, let photos, let documents): + return ("page", [("flags", flags), ("blocks", blocks), ("photos", photos), ("documents", documents)]) } } - static func parse_pagePart(_ reader: BufferReader) -> Page? { - var _1: [Api.PageBlock]? + static func parse_page(_ reader: BufferReader) -> Page? { + var _1: Int32? + _1 = reader.readInt32() + var _2: [Api.PageBlock]? if let _ = reader.readInt32() { - _1 = Api.parseVector(reader, elementSignature: 0, elementType: Api.PageBlock.self) + _2 = Api.parseVector(reader, elementSignature: 0, elementType: Api.PageBlock.self) } - var _2: [Api.Photo]? + var _3: [Api.Photo]? if let _ = reader.readInt32() { - _2 = Api.parseVector(reader, elementSignature: 0, elementType: Api.Photo.self) + _3 = Api.parseVector(reader, elementSignature: 0, elementType: Api.Photo.self) } - var _3: [Api.Document]? + var _4: [Api.Document]? if let _ = reader.readInt32() { - _3 = Api.parseVector(reader, elementSignature: 0, elementType: Api.Document.self) + _4 = Api.parseVector(reader, elementSignature: 0, elementType: Api.Document.self) } let _c1 = _1 != nil let _c2 = _2 != nil let _c3 = _3 != nil - if _c1 && _c2 && _c3 { - return Api.Page.pagePart(blocks: _1!, photos: _2!, documents: _3!) - } - else { - return nil - } - } - static func parse_pageFull(_ reader: BufferReader) -> Page? { - var _1: [Api.PageBlock]? - if let _ = reader.readInt32() { - _1 = Api.parseVector(reader, elementSignature: 0, elementType: Api.PageBlock.self) - } - var _2: [Api.Photo]? - if let _ = reader.readInt32() { - _2 = Api.parseVector(reader, elementSignature: 0, elementType: Api.Photo.self) - } - var _3: [Api.Document]? - if let _ = reader.readInt32() { - _3 = Api.parseVector(reader, elementSignature: 0, elementType: Api.Document.self) - } - let _c1 = _1 != nil - let _c2 = _2 != nil - let _c3 = _3 != nil - if _c1 && _c2 && _c3 { - return Api.Page.pageFull(blocks: _1!, photos: _2!, documents: _3!) + let _c4 = _4 != nil + if _c1 && _c2 && _c3 && _c4 { + return Api.Page.page(flags: _1!, blocks: _2!, photos: _3!, documents: _4!) } else { return nil @@ -11498,6 +11964,48 @@ extension Api { } } + } + enum PageCaption: TypeConstructorDescription { + case pageCaption(text: Api.RichText, credit: Api.RichText) + + func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) { + switch self { + case .pageCaption(let text, let credit): + if boxed { + buffer.appendInt32(1869903447) + } + text.serialize(buffer, true) + credit.serialize(buffer, true) + break + } + } + + func descriptionFields() -> (String, [(String, Any)]) { + switch self { + case .pageCaption(let text, let credit): + return ("pageCaption", [("text", text), ("credit", credit)]) + } + } + + static func parse_pageCaption(_ reader: BufferReader) -> PageCaption? { + var _1: Api.RichText? + if let signature = reader.readInt32() { + _1 = Api.parse(reader, signature: signature) as? Api.RichText + } + var _2: Api.RichText? + if let signature = reader.readInt32() { + _2 = Api.parse(reader, signature: signature) as? Api.RichText + } + let _c1 = _1 != nil + let _c2 = _2 != nil + if _c1 && _c2 { + return Api.PageCaption.pageCaption(text: _1!, credit: _2!) + } + else { + return nil + } + } + } enum InputStickerSet: TypeConstructorDescription { case inputStickerSetEmpty @@ -13788,16 +14296,16 @@ extension Api { } enum Authorization: TypeConstructorDescription { - case authorization(hash: Int64, flags: Int32, deviceModel: String, platform: String, systemVersion: String, apiId: Int32, appName: String, appVersion: String, dateCreated: Int32, dateActive: Int32, ip: String, country: String, region: String) + case authorization(flags: Int32, hash: Int64, deviceModel: String, platform: String, systemVersion: String, apiId: Int32, appName: String, appVersion: String, dateCreated: Int32, dateActive: Int32, ip: String, country: String, region: String) func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) { switch self { - case .authorization(let hash, let flags, let deviceModel, let platform, let systemVersion, let apiId, let appName, let appVersion, let dateCreated, let dateActive, let ip, let country, let region): + case .authorization(let flags, let hash, let deviceModel, let platform, let systemVersion, let apiId, let appName, let appVersion, let dateCreated, let dateActive, let ip, let country, let region): if boxed { - buffer.appendInt32(2079516406) + buffer.appendInt32(-1392388579) } - serializeInt64(hash, buffer: buffer, boxed: false) serializeInt32(flags, buffer: buffer, boxed: false) + serializeInt64(hash, buffer: buffer, boxed: false) serializeString(deviceModel, buffer: buffer, boxed: false) serializeString(platform, buffer: buffer, boxed: false) serializeString(systemVersion, buffer: buffer, boxed: false) @@ -13815,16 +14323,16 @@ extension Api { func descriptionFields() -> (String, [(String, Any)]) { switch self { - case .authorization(let hash, let flags, let deviceModel, let platform, let systemVersion, let apiId, let appName, let appVersion, let dateCreated, let dateActive, let ip, let country, let region): - return ("authorization", [("hash", hash), ("flags", flags), ("deviceModel", deviceModel), ("platform", platform), ("systemVersion", systemVersion), ("apiId", apiId), ("appName", appName), ("appVersion", appVersion), ("dateCreated", dateCreated), ("dateActive", dateActive), ("ip", ip), ("country", country), ("region", region)]) + case .authorization(let flags, let hash, let deviceModel, let platform, let systemVersion, let apiId, let appName, let appVersion, let dateCreated, let dateActive, let ip, let country, let region): + return ("authorization", [("flags", flags), ("hash", hash), ("deviceModel", deviceModel), ("platform", platform), ("systemVersion", systemVersion), ("apiId", apiId), ("appName", appName), ("appVersion", appVersion), ("dateCreated", dateCreated), ("dateActive", dateActive), ("ip", ip), ("country", country), ("region", region)]) } } static func parse_authorization(_ reader: BufferReader) -> Authorization? { - var _1: Int64? - _1 = reader.readInt64() - var _2: Int32? - _2 = reader.readInt32() + var _1: Int32? + _1 = reader.readInt32() + var _2: Int64? + _2 = reader.readInt64() var _3: String? _3 = parseString(reader) var _4: String? @@ -13861,7 +14369,7 @@ extension Api { let _c12 = _12 != nil let _c13 = _13 != nil if _c1 && _c2 && _c3 && _c4 && _c5 && _c6 && _c7 && _c8 && _c9 && _c10 && _c11 && _c12 && _c13 { - return Api.Authorization.authorization(hash: _1!, flags: _2!, deviceModel: _3!, platform: _4!, systemVersion: _5!, apiId: _6!, appName: _7!, appVersion: _8!, dateCreated: _9!, dateActive: _10!, ip: _11!, country: _12!, region: _13!) + return Api.Authorization.authorization(flags: _1!, hash: _2!, deviceModel: _3!, platform: _4!, systemVersion: _5!, apiId: _6!, appName: _7!, appVersion: _8!, dateCreated: _9!, dateActive: _10!, ip: _11!, country: _12!, region: _13!) } else { return nil @@ -15036,8 +15544,8 @@ extension Api { case phoneCallWaiting(flags: Int32, id: Int64, accessHash: Int64, date: Int32, adminId: Int32, participantId: Int32, protocol: Api.PhoneCallProtocol, receiveDate: Int32?) case phoneCallRequested(id: Int64, accessHash: Int64, date: Int32, adminId: Int32, participantId: Int32, gAHash: Buffer, protocol: Api.PhoneCallProtocol) case phoneCallAccepted(id: Int64, accessHash: Int64, date: Int32, adminId: Int32, participantId: Int32, gB: Buffer, protocol: Api.PhoneCallProtocol) - case phoneCall(id: Int64, accessHash: Int64, date: Int32, adminId: Int32, participantId: Int32, gAOrB: Buffer, keyFingerprint: Int64, protocol: Api.PhoneCallProtocol, connection: Api.PhoneConnection, alternativeConnections: [Api.PhoneConnection], startDate: Int32) case phoneCallDiscarded(flags: Int32, id: Int64, reason: Api.PhoneCallDiscardReason?, duration: Int32?) + case phoneCall(flags: Int32, id: Int64, accessHash: Int64, date: Int32, adminId: Int32, participantId: Int32, gAOrB: Buffer, keyFingerprint: Int64, protocol: Api.PhoneCallProtocol, connection: Api.PhoneConnection, alternativeConnections: [Api.PhoneConnection], startDate: Int32) func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) { switch self { @@ -15084,10 +15592,20 @@ extension Api { serializeBytes(gB, buffer: buffer, boxed: false) `protocol`.serialize(buffer, true) break - case .phoneCall(let id, let accessHash, let date, let adminId, let participantId, let gAOrB, let keyFingerprint, let `protocol`, let connection, let alternativeConnections, let startDate): + case .phoneCallDiscarded(let flags, let id, let reason, let duration): if boxed { - buffer.appendInt32(-1660057) + buffer.appendInt32(1355435489) } + serializeInt32(flags, buffer: buffer, boxed: false) + serializeInt64(id, buffer: buffer, boxed: false) + if Int(flags) & Int(1 << 0) != 0 {reason!.serialize(buffer, true)} + if Int(flags) & Int(1 << 1) != 0 {serializeInt32(duration!, buffer: buffer, boxed: false)} + break + case .phoneCall(let flags, let id, let accessHash, let date, let adminId, let participantId, let gAOrB, let keyFingerprint, let `protocol`, let connection, let alternativeConnections, let startDate): + if boxed { + buffer.appendInt32(-419832333) + } + serializeInt32(flags, buffer: buffer, boxed: false) serializeInt64(id, buffer: buffer, boxed: false) serializeInt64(accessHash, buffer: buffer, boxed: false) serializeInt32(date, buffer: buffer, boxed: false) @@ -15104,15 +15622,6 @@ extension Api { } serializeInt32(startDate, buffer: buffer, boxed: false) break - case .phoneCallDiscarded(let flags, let id, let reason, let duration): - if boxed { - buffer.appendInt32(1355435489) - } - serializeInt32(flags, buffer: buffer, boxed: false) - serializeInt64(id, buffer: buffer, boxed: false) - if Int(flags) & Int(1 << 0) != 0 {reason!.serialize(buffer, true)} - if Int(flags) & Int(1 << 1) != 0 {serializeInt32(duration!, buffer: buffer, boxed: false)} - break } } @@ -15126,10 +15635,10 @@ extension Api { return ("phoneCallRequested", [("id", id), ("accessHash", accessHash), ("date", date), ("adminId", adminId), ("participantId", participantId), ("gAHash", gAHash), ("`protocol`", `protocol`)]) case .phoneCallAccepted(let id, let accessHash, let date, let adminId, let participantId, let gB, let `protocol`): return ("phoneCallAccepted", [("id", id), ("accessHash", accessHash), ("date", date), ("adminId", adminId), ("participantId", participantId), ("gB", gB), ("`protocol`", `protocol`)]) - case .phoneCall(let id, let accessHash, let date, let adminId, let participantId, let gAOrB, let keyFingerprint, let `protocol`, let connection, let alternativeConnections, let startDate): - return ("phoneCall", [("id", id), ("accessHash", accessHash), ("date", date), ("adminId", adminId), ("participantId", participantId), ("gAOrB", gAOrB), ("keyFingerprint", keyFingerprint), ("`protocol`", `protocol`), ("connection", connection), ("alternativeConnections", alternativeConnections), ("startDate", startDate)]) case .phoneCallDiscarded(let flags, let id, let reason, let duration): return ("phoneCallDiscarded", [("flags", flags), ("id", id), ("reason", reason), ("duration", duration)]) + case .phoneCall(let flags, let id, let accessHash, let date, let adminId, let participantId, let gAOrB, let keyFingerprint, let `protocol`, let connection, let alternativeConnections, let startDate): + return ("phoneCall", [("flags", flags), ("id", id), ("accessHash", accessHash), ("date", date), ("adminId", adminId), ("participantId", participantId), ("gAOrB", gAOrB), ("keyFingerprint", keyFingerprint), ("`protocol`", `protocol`), ("connection", connection), ("alternativeConnections", alternativeConnections), ("startDate", startDate)]) } } @@ -15240,53 +15749,6 @@ extension Api { return nil } } - static func parse_phoneCall(_ reader: BufferReader) -> PhoneCall? { - var _1: Int64? - _1 = reader.readInt64() - var _2: Int64? - _2 = reader.readInt64() - var _3: Int32? - _3 = reader.readInt32() - var _4: Int32? - _4 = reader.readInt32() - var _5: Int32? - _5 = reader.readInt32() - var _6: Buffer? - _6 = parseBytes(reader) - var _7: Int64? - _7 = reader.readInt64() - var _8: Api.PhoneCallProtocol? - if let signature = reader.readInt32() { - _8 = Api.parse(reader, signature: signature) as? Api.PhoneCallProtocol - } - var _9: Api.PhoneConnection? - if let signature = reader.readInt32() { - _9 = Api.parse(reader, signature: signature) as? Api.PhoneConnection - } - var _10: [Api.PhoneConnection]? - if let _ = reader.readInt32() { - _10 = Api.parseVector(reader, elementSignature: 0, elementType: Api.PhoneConnection.self) - } - var _11: Int32? - _11 = reader.readInt32() - let _c1 = _1 != nil - let _c2 = _2 != nil - let _c3 = _3 != nil - let _c4 = _4 != nil - let _c5 = _5 != nil - let _c6 = _6 != nil - let _c7 = _7 != nil - let _c8 = _8 != nil - let _c9 = _9 != nil - let _c10 = _10 != nil - let _c11 = _11 != nil - if _c1 && _c2 && _c3 && _c4 && _c5 && _c6 && _c7 && _c8 && _c9 && _c10 && _c11 { - return Api.PhoneCall.phoneCall(id: _1!, accessHash: _2!, date: _3!, adminId: _4!, participantId: _5!, gAOrB: _6!, keyFingerprint: _7!, protocol: _8!, connection: _9!, alternativeConnections: _10!, startDate: _11!) - } - else { - return nil - } - } static func parse_phoneCallDiscarded(_ reader: BufferReader) -> PhoneCall? { var _1: Int32? _1 = reader.readInt32() @@ -15309,6 +15771,56 @@ extension Api { return nil } } + static func parse_phoneCall(_ reader: BufferReader) -> PhoneCall? { + var _1: Int32? + _1 = reader.readInt32() + var _2: Int64? + _2 = reader.readInt64() + var _3: Int64? + _3 = reader.readInt64() + var _4: Int32? + _4 = reader.readInt32() + var _5: Int32? + _5 = reader.readInt32() + var _6: Int32? + _6 = reader.readInt32() + var _7: Buffer? + _7 = parseBytes(reader) + var _8: Int64? + _8 = reader.readInt64() + var _9: Api.PhoneCallProtocol? + if let signature = reader.readInt32() { + _9 = Api.parse(reader, signature: signature) as? Api.PhoneCallProtocol + } + var _10: Api.PhoneConnection? + if let signature = reader.readInt32() { + _10 = Api.parse(reader, signature: signature) as? Api.PhoneConnection + } + var _11: [Api.PhoneConnection]? + if let _ = reader.readInt32() { + _11 = Api.parseVector(reader, elementSignature: 0, elementType: Api.PhoneConnection.self) + } + var _12: Int32? + _12 = reader.readInt32() + let _c1 = _1 != nil + let _c2 = _2 != nil + let _c3 = _3 != nil + let _c4 = _4 != nil + let _c5 = _5 != nil + let _c6 = _6 != nil + let _c7 = _7 != nil + let _c8 = _8 != nil + let _c9 = _9 != nil + let _c10 = _10 != nil + let _c11 = _11 != nil + let _c12 = _12 != nil + if _c1 && _c2 && _c3 && _c4 && _c5 && _c6 && _c7 && _c8 && _c9 && _c10 && _c11 && _c12 { + return Api.PhoneCall.phoneCall(flags: _1!, id: _2!, accessHash: _3!, date: _4!, adminId: _5!, participantId: _6!, gAOrB: _7!, keyFingerprint: _8!, protocol: _9!, connection: _10!, alternativeConnections: _11!, startDate: _12!) + } + else { + return nil + } + } } enum DialogPeer: TypeConstructorDescription { @@ -15644,6 +16156,60 @@ extension Api { } } + } + enum PageRelatedArticle: TypeConstructorDescription { + case pageRelatedArticle(flags: Int32, url: String, webpageId: Int64, title: String?, description: String?, photoId: Int64?) + + func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) { + switch self { + case .pageRelatedArticle(let flags, let url, let webpageId, let title, let description, let photoId): + if boxed { + buffer.appendInt32(-242812612) + } + serializeInt32(flags, buffer: buffer, boxed: false) + serializeString(url, buffer: buffer, boxed: false) + serializeInt64(webpageId, buffer: buffer, boxed: false) + if Int(flags) & Int(1 << 0) != 0 {serializeString(title!, buffer: buffer, boxed: false)} + if Int(flags) & Int(1 << 1) != 0 {serializeString(description!, buffer: buffer, boxed: false)} + if Int(flags) & Int(1 << 2) != 0 {serializeInt64(photoId!, buffer: buffer, boxed: false)} + break + } + } + + func descriptionFields() -> (String, [(String, Any)]) { + switch self { + case .pageRelatedArticle(let flags, let url, let webpageId, let title, let description, let photoId): + return ("pageRelatedArticle", [("flags", flags), ("url", url), ("webpageId", webpageId), ("title", title), ("description", description), ("photoId", photoId)]) + } + } + + static func parse_pageRelatedArticle(_ reader: BufferReader) -> PageRelatedArticle? { + var _1: Int32? + _1 = reader.readInt32() + var _2: String? + _2 = parseString(reader) + var _3: Int64? + _3 = reader.readInt64() + var _4: String? + if Int(_1!) & Int(1 << 0) != 0 {_4 = parseString(reader) } + var _5: String? + if Int(_1!) & Int(1 << 1) != 0 {_5 = parseString(reader) } + var _6: Int64? + if Int(_1!) & Int(1 << 2) != 0 {_6 = reader.readInt64() } + let _c1 = _1 != nil + let _c2 = _2 != nil + let _c3 = _3 != nil + let _c4 = (Int(_1!) & Int(1 << 0) == 0) || _4 != nil + let _c5 = (Int(_1!) & Int(1 << 1) == 0) || _5 != nil + let _c6 = (Int(_1!) & Int(1 << 2) == 0) || _6 != nil + if _c1 && _c2 && _c3 && _c4 && _c5 && _c6 { + return Api.PageRelatedArticle.pageRelatedArticle(flags: _1!, url: _2!, webpageId: _3!, title: _4, description: _5, photoId: _6) + } + else { + return nil + } + } + } enum StickerPack: TypeConstructorDescription { case stickerPack(emoticon: String, documents: [Int64]) @@ -16238,6 +16804,76 @@ extension Api { } } + } + enum PageListOrderedItem: TypeConstructorDescription { + case pageListOrderedItemText(num: String, text: Api.RichText) + case pageListOrderedItemBlocks(num: String, blocks: [Api.PageBlock]) + + func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) { + switch self { + case .pageListOrderedItemText(let num, let text): + if boxed { + buffer.appendInt32(1577484359) + } + serializeString(num, buffer: buffer, boxed: false) + text.serialize(buffer, true) + break + case .pageListOrderedItemBlocks(let num, let blocks): + if boxed { + buffer.appendInt32(-1730311882) + } + serializeString(num, buffer: buffer, boxed: false) + buffer.appendInt32(481674261) + buffer.appendInt32(Int32(blocks.count)) + for item in blocks { + item.serialize(buffer, true) + } + break + } + } + + func descriptionFields() -> (String, [(String, Any)]) { + switch self { + case .pageListOrderedItemText(let num, let text): + return ("pageListOrderedItemText", [("num", num), ("text", text)]) + case .pageListOrderedItemBlocks(let num, let blocks): + return ("pageListOrderedItemBlocks", [("num", num), ("blocks", blocks)]) + } + } + + static func parse_pageListOrderedItemText(_ reader: BufferReader) -> PageListOrderedItem? { + var _1: String? + _1 = parseString(reader) + var _2: Api.RichText? + if let signature = reader.readInt32() { + _2 = Api.parse(reader, signature: signature) as? Api.RichText + } + let _c1 = _1 != nil + let _c2 = _2 != nil + if _c1 && _c2 { + return Api.PageListOrderedItem.pageListOrderedItemText(num: _1!, text: _2!) + } + else { + return nil + } + } + static func parse_pageListOrderedItemBlocks(_ reader: BufferReader) -> PageListOrderedItem? { + var _1: String? + _1 = parseString(reader) + var _2: [Api.PageBlock]? + if let _ = reader.readInt32() { + _2 = Api.parseVector(reader, elementSignature: 0, elementType: Api.PageBlock.self) + } + let _c1 = _1 != nil + let _c2 = _2 != nil + if _c1 && _c2 { + return Api.PageListOrderedItem.pageListOrderedItemBlocks(num: _1!, blocks: _2!) + } + else { + return nil + } + } + } enum EncryptedChat: TypeConstructorDescription { case encryptedChatEmpty(id: Int32) diff --git a/TelegramCore/Api3.swift b/TelegramCore/Api3.swift index 19fcb720cc..17289fa4c6 100644 --- a/TelegramCore/Api3.swift +++ b/TelegramCore/Api3.swift @@ -4922,6 +4922,21 @@ extension Api { return result }) } + + static func confirmPasswordEmail(email: String, code: String) -> (FunctionDescription, Buffer, DeserializeFunctionResponse) { + let buffer = Buffer() + buffer.appendInt32(-558870880) + serializeString(email, buffer: buffer, boxed: false) + serializeString(code, buffer: buffer, boxed: false) + return (FunctionDescription(name: "account.confirmPasswordEmail", parameters: [("email", email), ("code", code)]), buffer, DeserializeFunctionResponse { (buffer: Buffer) -> Api.Bool? in + let reader = BufferReader(buffer) + var result: Api.Bool? + if let signature = reader.readInt32() { + result = Api.parse(reader, signature: signature) as? Api.Bool + } + return result + }) + } } struct langpack { static func getDifference(fromVersion: Int32) -> (FunctionDescription, Buffer, DeserializeFunctionResponse) { @@ -4986,6 +5001,21 @@ extension Api { return result }) } + + static func getLanguage(langPack: String, langCode: String) -> (FunctionDescription, Buffer, DeserializeFunctionResponse) { + let buffer = Buffer() + buffer.appendInt32(1784243458) + serializeString(langPack, buffer: buffer, boxed: false) + serializeString(langCode, buffer: buffer, boxed: false) + return (FunctionDescription(name: "langpack.getLanguage", parameters: [("langPack", langPack), ("langCode", langCode)]), buffer, DeserializeFunctionResponse { (buffer: Buffer) -> Api.LangPackLanguage? in + let reader = BufferReader(buffer) + var result: Api.LangPackLanguage? + if let signature = reader.readInt32() { + result = Api.parse(reader, signature: signature) as? Api.LangPackLanguage + } + return result + }) + } } struct photos { static func updateProfilePhoto(id: Api.InputPhoto) -> (FunctionDescription, Buffer, DeserializeFunctionResponse) { diff --git a/TelegramCore/CallSessionManager.swift b/TelegramCore/CallSessionManager.swift index 84389ecf36..f453cf43da 100644 --- a/TelegramCore/CallSessionManager.swift +++ b/TelegramCore/CallSessionManager.swift @@ -557,7 +557,7 @@ private final class CallSessionManagerContext { //assertionFailure() } } - case let .phoneCall(id, _, _, _, _, gAOrB, keyFingerprint, callProtocol, connection, alternativeConnections, startDate): + case let .phoneCall(_, id, _, _, _, _, gAOrB, keyFingerprint, callProtocol, connection, alternativeConnections, startDate): if let internalId = self.contextIdByStableId[id] { if let context = self.contexts[internalId] { switch context.state { @@ -820,7 +820,7 @@ private func acceptCallSession(postbox: Postbox, network: Network, stableId: Cal return .failed case .phoneCallWaiting: return .success(.waiting(config: config)) - case let .phoneCall(id, _, _, _, _, gAOrB, keyFingerprint, callProtocol, connection, alternativeConnections, startDate): + case let .phoneCall(_, id, _, _, _, _, gAOrB, keyFingerprint, callProtocol, connection, alternativeConnections, startDate): if id == stableId { switch callProtocol{ case let .phoneCallProtocol(_, _, maxLayer): diff --git a/TelegramCore/ChannelAdminEventLogs.swift b/TelegramCore/ChannelAdminEventLogs.swift index 90d298b5ba..ba7f546ee9 100644 --- a/TelegramCore/ChannelAdminEventLogs.swift +++ b/TelegramCore/ChannelAdminEventLogs.swift @@ -58,7 +58,7 @@ public enum ChannelAdminLogEventError { case generic } -public struct AdminLogEventsFlags : OptionSet { +public struct AdminLogEventsFlags: OptionSet { public var rawValue: UInt32 public init(rawValue: UInt32) { diff --git a/TelegramCore/InstantPage.swift b/TelegramCore/InstantPage.swift index 2d759ee293..73d5a494e1 100644 --- a/TelegramCore/InstantPage.swift +++ b/TelegramCore/InstantPage.swift @@ -29,6 +29,30 @@ private enum InstantPageBlockType: Int32 { case slideshow = 20 case channelBanner = 21 case audio = 22 + case kicker = 23 + case table = 24 + case details = 25 + case relatedArticles = 26 + case map = 27 +} + +private func decodeListItems(_ decoder: PostboxDecoder) -> [InstantPageListItem] { + let legacyItems: [RichText] = decoder.decodeObjectArrayWithDecoderForKey("l") + if !legacyItems.isEmpty { + var items: [InstantPageListItem] = [] + for item in legacyItems { + items.append(.text(item, nil)) + } + return items + } + return decoder.decodeObjectArrayWithDecoderForKey("ml") +} + +private func decodeCaption(_ decoder: PostboxDecoder) -> InstantPageCaption { + if let legacyCaption = decoder.decodeObjectForKey("c", decoder: { RichText(decoder: $0) }) as? RichText { + return InstantPageCaption(text: legacyCaption, credit: .empty) + } + return decoder.decodeObjectForKey("mc", decoder: { InstantPageCaption(decoder: $0) }) as! InstantPageCaption } public indirect enum InstantPageBlock: PostboxCoding, Equatable { @@ -43,18 +67,23 @@ public indirect enum InstantPageBlock: PostboxCoding, Equatable { case footer(RichText) case divider case anchor(String) - case list(items: [RichText], ordered: Bool) + case list(items: [InstantPageListItem], ordered: Bool) case blockQuote(text: RichText, caption: RichText) case pullQuote(text: RichText, caption: RichText) - case image(id: MediaId, caption: RichText) - case video(id: MediaId, caption: RichText, autoplay: Bool, loop: Bool) - case audio(id: MediaId, caption: RichText) + case image(id: MediaId, caption: InstantPageCaption, url: String?, webpageId: MediaId?) + case video(id: MediaId, caption: InstantPageCaption, autoplay: Bool, loop: Bool) + case audio(id: MediaId, caption: InstantPageCaption) case cover(InstantPageBlock) - case webEmbed(url: String?, html: String?, dimensions: CGSize, caption: RichText, stretchToWidth: Bool, allowScrolling: Bool, coverId: MediaId?) - case postEmbed(url: String, webpageId: MediaId?, avatarId: MediaId?, author: String, date: Int32, blocks: [InstantPageBlock], caption: RichText) - case collage(items: [InstantPageBlock], caption: RichText) - case slideshow(items: [InstantPageBlock], caption: RichText) + case webEmbed(url: String?, html: String?, dimensions: CGSize?, caption: InstantPageCaption, stretchToWidth: Bool, allowScrolling: Bool, coverId: MediaId?) + case postEmbed(url: String, webpageId: MediaId?, avatarId: MediaId?, author: String, date: Int32, blocks: [InstantPageBlock], caption: InstantPageCaption) + case collage(items: [InstantPageBlock], caption: InstantPageCaption) + case slideshow(items: [InstantPageBlock], caption: InstantPageCaption) case channelBanner(TelegramChannel?) + case kicker(RichText) + case table(title: RichText, rows: [InstantPageTableRow], bordered: Bool, striped: Bool) + case details(title: RichText, blocks: [InstantPageBlock], open: Bool) + case relatedArticles(title: RichText, articles: [InstantPageRelatedArticle]) + case map(latitude: Double, longitude: Double, zoom: Int32, dimensions: CGSize, caption: InstantPageCaption) public init(decoder: PostboxDecoder) { switch decoder.decodeInt32ForKey("r", orElse: 0) { @@ -81,15 +110,19 @@ public indirect enum InstantPageBlock: PostboxCoding, Equatable { case InstantPageBlockType.anchor.rawValue: self = .anchor(decoder.decodeStringForKey("s", orElse: "")) case InstantPageBlockType.list.rawValue: - self = .list(items: decoder.decodeObjectArrayWithDecoderForKey("l"), ordered: decoder.decodeOptionalInt32ForKey("o") != 0) + self = .list(items: decodeListItems(decoder), ordered: decoder.decodeOptionalInt32ForKey("o") != 0) case InstantPageBlockType.blockQuote.rawValue: self = .blockQuote(text: decoder.decodeObjectForKey("t", decoder: { RichText(decoder: $0) }) as! RichText, caption: decoder.decodeObjectForKey("c", decoder: { RichText(decoder: $0) }) as! RichText) case InstantPageBlockType.pullQuote.rawValue: self = .pullQuote(text: decoder.decodeObjectForKey("t", decoder: { RichText(decoder: $0) }) as! RichText, caption: decoder.decodeObjectForKey("c", decoder: { RichText(decoder: $0) }) as! RichText) case InstantPageBlockType.image.rawValue: - self = .image(id: MediaId(namespace: decoder.decodeInt32ForKey("i.n", orElse: 0), id: decoder.decodeInt64ForKey("i.i", orElse: 0)), caption: decoder.decodeObjectForKey("c", decoder: { RichText(decoder: $0) }) as! RichText) + var webpageId: MediaId? + if let webpageIdNamespace = decoder.decodeOptionalInt32ForKey("wi.n"), let webpageIdId = decoder.decodeOptionalInt64ForKey("wi.i") { + webpageId = MediaId(namespace: webpageIdNamespace, id: webpageIdId) + } + self = .image(id: MediaId(namespace: decoder.decodeInt32ForKey("i.n", orElse: 0), id: decoder.decodeInt64ForKey("i.i", orElse: 0)), caption: decodeCaption(decoder), url: decoder.decodeOptionalStringForKey("u"), webpageId: webpageId) case InstantPageBlockType.video.rawValue: - self = .video(id: MediaId(namespace: decoder.decodeInt32ForKey("i.n", orElse: 0), id: decoder.decodeInt64ForKey("i.i", orElse: 0)), caption: decoder.decodeObjectForKey("c", decoder: { RichText(decoder: $0) }) as! RichText, autoplay: decoder.decodeInt32ForKey("ap", orElse: 0) != 0, loop: decoder.decodeInt32ForKey("lo", orElse: 0) != 0) + self = .video(id: MediaId(namespace: decoder.decodeInt32ForKey("i.n", orElse: 0), id: decoder.decodeInt64ForKey("i.i", orElse: 0)), caption: decodeCaption(decoder), autoplay: decoder.decodeInt32ForKey("ap", orElse: 0) != 0, loop: decoder.decodeInt32ForKey("lo", orElse: 0) != 0) case InstantPageBlockType.cover.rawValue: self = .cover(decoder.decodeObjectForKey("c", decoder: { InstantPageBlock(decoder: $0) }) as! InstantPageBlock) case InstantPageBlockType.webEmbed.rawValue: @@ -97,7 +130,11 @@ public indirect enum InstantPageBlock: PostboxCoding, Equatable { if let coverIdNamespace = decoder.decodeOptionalInt32ForKey("ci.n"), let coverIdId = decoder.decodeOptionalInt64ForKey("ci.i") { coverId = MediaId(namespace: coverIdNamespace, id: coverIdId) } - self = .webEmbed(url: decoder.decodeOptionalStringForKey("u"), html: decoder.decodeOptionalStringForKey("h"), dimensions: CGSize(width: CGFloat(decoder.decodeInt32ForKey("sw", orElse: 0)), height: CGFloat(decoder.decodeInt32ForKey("sh", orElse: 0))), caption: decoder.decodeObjectForKey("c", decoder: { RichText(decoder: $0) }) as! RichText, stretchToWidth: decoder.decodeInt32ForKey("st", orElse: 0) != 0, allowScrolling: decoder.decodeInt32ForKey("as", orElse: 0) != 0, coverId: coverId) + var dimensions: CGSize? + if let width = decoder.decodeOptionalInt32ForKey("sw"), let height = decoder.decodeOptionalInt32ForKey("sh") { + dimensions = CGSize(width: CGFloat(width), height: CGFloat(height)) + } + self = .webEmbed(url: decoder.decodeOptionalStringForKey("u"), html: decoder.decodeOptionalStringForKey("h"), dimensions: dimensions, caption: decodeCaption(decoder), stretchToWidth: decoder.decodeInt32ForKey("st", orElse: 0) != 0, allowScrolling: decoder.decodeInt32ForKey("as", orElse: 0) != 0, coverId: coverId) case InstantPageBlockType.postEmbed.rawValue: var avatarId: MediaId? let avatarIdNamespace: Int32? = decoder.decodeOptionalInt32ForKey("av.n") @@ -105,15 +142,25 @@ public indirect enum InstantPageBlock: PostboxCoding, Equatable { if let avatarIdNamespace = avatarIdNamespace, let avatarIdId = avatarIdId { avatarId = MediaId(namespace: avatarIdNamespace, id: avatarIdId) } - self = .postEmbed(url: decoder.decodeStringForKey("u", orElse: ""), webpageId: MediaId(namespace: decoder.decodeInt32ForKey("w.n", orElse: 0), id: decoder.decodeInt64ForKey("w.i", orElse: 0)), avatarId: avatarId, author: decoder.decodeStringForKey("a", orElse: ""), date: decoder.decodeInt32ForKey("d", orElse: 0), blocks: decoder.decodeObjectArrayWithDecoderForKey("b"), caption: decoder.decodeObjectForKey("c", decoder: { RichText(decoder: $0) }) as! RichText) + self = .postEmbed(url: decoder.decodeStringForKey("u", orElse: ""), webpageId: MediaId(namespace: decoder.decodeInt32ForKey("w.n", orElse: 0), id: decoder.decodeInt64ForKey("w.i", orElse: 0)), avatarId: avatarId, author: decoder.decodeStringForKey("a", orElse: ""), date: decoder.decodeInt32ForKey("d", orElse: 0), blocks: decoder.decodeObjectArrayWithDecoderForKey("b"), caption: decodeCaption(decoder)) case InstantPageBlockType.collage.rawValue: - self = .collage(items: decoder.decodeObjectArrayWithDecoderForKey("b"), caption: decoder.decodeObjectForKey("c", decoder: { RichText(decoder: $0) }) as! RichText) + self = .collage(items: decoder.decodeObjectArrayWithDecoderForKey("b"), caption: decodeCaption(decoder)) case InstantPageBlockType.slideshow.rawValue: - self = .slideshow(items: decoder.decodeObjectArrayWithDecoderForKey("b"), caption: decoder.decodeObjectForKey("c", decoder: { RichText(decoder: $0) }) as! RichText) + self = .slideshow(items: decoder.decodeObjectArrayWithDecoderForKey("b"), caption: decodeCaption(decoder)) case InstantPageBlockType.channelBanner.rawValue: self = .channelBanner(decoder.decodeObjectForKey("c") as? TelegramChannel) case InstantPageBlockType.audio.rawValue: - self = .audio(id: MediaId(namespace: decoder.decodeInt32ForKey("i.n", orElse: 0), id: decoder.decodeInt64ForKey("i.i", orElse: 0)), caption: decoder.decodeObjectForKey("c", decoder: { RichText(decoder: $0) }) as! RichText) + self = .audio(id: MediaId(namespace: decoder.decodeInt32ForKey("i.n", orElse: 0), id: decoder.decodeInt64ForKey("i.i", orElse: 0)), caption: decodeCaption(decoder)) + case InstantPageBlockType.kicker.rawValue: + self = .kicker(decoder.decodeObjectForKey("t", decoder: { RichText(decoder: $0) }) as! RichText) + case InstantPageBlockType.table.rawValue: + self = .table(title: decoder.decodeObjectForKey("t", decoder: { RichText(decoder: $0) }) as! RichText, rows: decoder.decodeObjectArrayWithDecoderForKey("r"), bordered: decoder.decodeInt32ForKey("b", orElse: 0) != 0, striped: decoder.decodeInt32ForKey("s", orElse: 0) != 0) + case InstantPageBlockType.details.rawValue: + self = .details(title: decoder.decodeObjectForKey("t", decoder: { RichText(decoder: $0) }) as! RichText, blocks: decoder.decodeObjectArrayWithDecoderForKey("b"), open: decoder.decodeInt32ForKey("o", orElse: 0) != 0) + case InstantPageBlockType.relatedArticles.rawValue: + self = .relatedArticles(title: decoder.decodeObjectForKey("t", decoder: { RichText(decoder: $0) }) as! RichText, articles: decoder.decodeObjectArrayWithDecoderForKey("a")) + case InstantPageBlockType.map.rawValue: + self = .map(latitude: decoder.decodeDoubleForKey("lat", orElse: 0.0), longitude: decoder.decodeDoubleForKey("lon", orElse: 0.0), zoom: decoder.decodeInt32ForKey("z", orElse: 0), dimensions: CGSize(width: CGFloat(decoder.decodeInt32ForKey("sw", orElse: 0)), height: CGFloat(decoder.decodeInt32ForKey("sh", orElse: 0))), caption: decodeCaption(decoder)) default: self = .unsupported } @@ -155,7 +202,7 @@ public indirect enum InstantPageBlock: PostboxCoding, Equatable { encoder.encodeString(anchor, forKey: "s") case let .list(items, ordered): encoder.encodeInt32(InstantPageBlockType.list.rawValue, forKey: "r") - encoder.encodeObjectArray(items, forKey: "l") + encoder.encodeObjectArray(items, forKey: "ml") encoder.encodeInt32(ordered ? 1 : 0, forKey: "o") case let .blockQuote(text, caption): encoder.encodeInt32(InstantPageBlockType.blockQuote.rawValue, forKey: "r") @@ -165,16 +212,28 @@ public indirect enum InstantPageBlock: PostboxCoding, Equatable { encoder.encodeInt32(InstantPageBlockType.pullQuote.rawValue, forKey: "r") encoder.encodeObject(text, forKey: "t") encoder.encodeObject(caption, forKey: "c") - case let .image(id, caption): + case let .image(id, caption, url, webpageId): encoder.encodeInt32(InstantPageBlockType.image.rawValue, forKey: "r") encoder.encodeInt32(id.namespace, forKey: "i.n") encoder.encodeInt64(id.id, forKey: "i.i") - encoder.encodeObject(caption, forKey: "c") + encoder.encodeObject(caption, forKey: "mc") + if let url = url { + encoder.encodeString(url, forKey: "u") + } else { + encoder.encodeNil(forKey: "u") + } + if let webpageId = webpageId { + encoder.encodeInt32(webpageId.namespace, forKey: "wi.n") + encoder.encodeInt64(webpageId.id, forKey: "wi.i") + } else { + encoder.encodeNil(forKey: "wi.n") + encoder.encodeNil(forKey: "wi.i") + } case let .video(id, caption, autoplay, loop): encoder.encodeInt32(InstantPageBlockType.video.rawValue, forKey: "r") encoder.encodeInt32(id.namespace, forKey: "i.n") encoder.encodeInt64(id.id, forKey: "i.i") - encoder.encodeObject(caption, forKey: "c") + encoder.encodeObject(caption, forKey: "mc") encoder.encodeInt32(autoplay ? 1 : 0, forKey: "ap") encoder.encodeInt32(loop ? 1 : 0, forKey: "lo") case let .cover(block): @@ -199,9 +258,14 @@ public indirect enum InstantPageBlock: PostboxCoding, Equatable { } else { encoder.encodeNil(forKey: "h") } - encoder.encodeInt32(Int32(dimensions.width), forKey: "sw") - encoder.encodeInt32(Int32(dimensions.height), forKey: "sh") - encoder.encodeObject(caption, forKey: "c") + if let dimensions = dimensions { + encoder.encodeInt32(Int32(dimensions.width), forKey: "sw") + encoder.encodeInt32(Int32(dimensions.height), forKey: "sh") + } else { + encoder.encodeNil(forKey: "sw") + encoder.encodeNil(forKey: "sh") + } + encoder.encodeObject(caption, forKey: "mc") encoder.encodeInt32(stretchToWidth ? 1 : 0, forKey: "st") encoder.encodeInt32(allowScrolling ? 1 : 0, forKey: "as") case let .postEmbed(url, webpageId, avatarId, author, date, blocks, caption): @@ -224,15 +288,15 @@ public indirect enum InstantPageBlock: PostboxCoding, Equatable { encoder.encodeString(author, forKey: "a") encoder.encodeInt32(date, forKey: "d") encoder.encodeObjectArray(blocks, forKey: "b") - encoder.encodeObject(caption, forKey: "c") + encoder.encodeObject(caption, forKey: "mc") case let .collage(items, caption): encoder.encodeInt32(InstantPageBlockType.collage.rawValue, forKey: "r") encoder.encodeObjectArray(items, forKey: "b") - encoder.encodeObject(caption, forKey: "c") + encoder.encodeObject(caption, forKey: "mc") case let .slideshow(items, caption): encoder.encodeInt32(InstantPageBlockType.slideshow.rawValue, forKey: "r") encoder.encodeObjectArray(items, forKey: "b") - encoder.encodeObject(caption, forKey: "c") + encoder.encodeObject(caption, forKey: "mc") case let .channelBanner(channel): encoder.encodeInt32(InstantPageBlockType.channelBanner.rawValue, forKey: "r") if let channel = channel { @@ -244,7 +308,33 @@ public indirect enum InstantPageBlock: PostboxCoding, Equatable { encoder.encodeInt32(InstantPageBlockType.audio.rawValue, forKey: "r") encoder.encodeInt32(id.namespace, forKey: "i.n") encoder.encodeInt64(id.id, forKey: "i.i") - encoder.encodeObject(caption, forKey: "c") + encoder.encodeObject(caption, forKey: "mc") + case let .kicker(text): + encoder.encodeInt32(InstantPageBlockType.kicker.rawValue, forKey: "r") + encoder.encodeObject(text, forKey: "t") + case let .table(title, rows, bordered, striped): + encoder.encodeInt32(InstantPageBlockType.table.rawValue, forKey: "r") + encoder.encodeObject(title, forKey: "t") + encoder.encodeObjectArray(rows, forKey: "r") + encoder.encodeInt32(bordered ? 1 : 0, forKey: "b") + encoder.encodeInt32(striped ? 1 : 0, forKey: "s") + case let .details(title, blocks, open): + encoder.encodeInt32(InstantPageBlockType.details.rawValue, forKey: "r") + encoder.encodeObject(title, forKey: "t") + encoder.encodeObjectArray(blocks, forKey: "b") + encoder.encodeInt32(open ? 1 : 0, forKey: "o") + case let .relatedArticles(title, articles): + encoder.encodeInt32(InstantPageBlockType.relatedArticles.rawValue, forKey: "r") + encoder.encodeObject(title, forKey: "t") + encoder.encodeObjectArray(articles, forKey: "a") + case let .map(latitude, longitude, zoom, dimensions, caption): + encoder.encodeInt32(InstantPageBlockType.map.rawValue, forKey: "r") + encoder.encodeDouble(latitude, forKey: "lat") + encoder.encodeDouble(longitude, forKey: "lon") + encoder.encodeInt32(zoom, forKey: "z") + encoder.encodeInt32(Int32(dimensions.width), forKey: "sw") + encoder.encodeInt32(Int32(dimensions.height), forKey: "sh") + encoder.encodeObject(caption, forKey: "mc") } } @@ -334,8 +424,8 @@ public indirect enum InstantPageBlock: PostboxCoding, Equatable { } else { return false } - case let .image(id, caption): - if case .image(id, caption) = rhs { + case let .image(lhsId, lhsCaption, lhsUrl, lhsWebpageId): + if case let .image(rhsId, rhsCaption, rhsUrl, rhsWebpageId) = rhs, lhsId == rhsId, lhsCaption == rhsCaption, lhsUrl == rhsUrl, lhsWebpageId == rhsWebpageId { return true } else { return false @@ -395,10 +485,307 @@ public indirect enum InstantPageBlock: PostboxCoding, Equatable { } else { return false } + case let .kicker(text): + if case .kicker(text) = rhs { + return true + } else { + return false + } + case let .table(lhsTitle, lhsRows, lhsBordered, lhsStriped): + if case let .table(rhsTitle, rhsRows, rhsBordered, rhsStriped) = rhs, lhsTitle == rhsTitle, lhsRows == rhsRows, lhsBordered == rhsBordered, lhsStriped == rhsStriped { + return true + } else { + return false + } + case let .details(lhsTitle, lhsBlocks, lhsOpen): + if case let .details(rhsTitle, rhsBlocks, rhsOpen) = rhs, lhsTitle == rhsTitle, lhsBlocks == rhsBlocks, lhsOpen == rhsOpen { + return true + } else { + return false + } + case let .relatedArticles(lhsTitle, lhsArticles): + if case let .relatedArticles(rhsTitle, rhsArticles) = rhs, lhsTitle == rhsTitle, lhsArticles == rhsArticles { + return true + } else { + return false + } + case let .map(latitude, longitude, zoom, dimensions, caption): + if case .map(latitude, longitude, zoom, dimensions, caption) = rhs { + return true + } else { + return false + } } } } +public final class InstantPageCaption: PostboxCoding, Equatable { + public let text: RichText + public let credit: RichText + + init(text: RichText, credit: RichText) { + self.text = text + self.credit = credit + } + + public init(decoder: PostboxDecoder) { + self.text = decoder.decodeObjectForKey("t", decoder: { RichText(decoder: $0) }) as! RichText + self.credit = decoder.decodeObjectForKey("c", decoder: { RichText(decoder: $0) }) as! RichText + } + + public func encode(_ encoder: PostboxEncoder) { + encoder.encodeObject(self.text, forKey: "t") + encoder.encodeObject(self.credit, forKey: "c") + } + + public static func ==(lhs: InstantPageCaption, rhs: InstantPageCaption) -> Bool { + if lhs.text != rhs.text { + return false + } + if lhs.credit != rhs.credit { + return false + } + return true + } +} + +private enum InstantPageListItemType: Int32 { + case unknown = 0 + case text = 1 + case blocks = 2 +} + +public indirect enum InstantPageListItem: PostboxCoding, Equatable { + case unknown + case text(RichText, String?) + case blocks([InstantPageBlock], String?) + + public init(decoder: PostboxDecoder) { + switch decoder.decodeInt32ForKey("r", orElse: 0) { + case InstantPageListItemType.text.rawValue: + self = .text(decoder.decodeObjectForKey("t", decoder: { RichText(decoder: $0) }) as! RichText, decoder.decodeOptionalStringForKey("n")) + case InstantPageListItemType.blocks.rawValue: + self = .blocks(decoder.decodeObjectArrayWithDecoderForKey("b"), decoder.decodeOptionalStringForKey("n")) + default: + self = .unknown + } + } + + public func encode(_ encoder: PostboxEncoder) { + switch self { + case let .text(text, num): + encoder.encodeInt32(InstantPageListItemType.text.rawValue, forKey: "r") + encoder.encodeObject(text, forKey: "t") + if let num = num { + encoder.encodeString(num, forKey: "n") + } else { + encoder.encodeNil(forKey: "n") + } + case let .blocks(blocks, num): + encoder.encodeInt32(InstantPageListItemType.blocks.rawValue, forKey: "r") + encoder.encodeObjectArray(blocks, forKey: "b") + if let num = num { + encoder.encodeString(num, forKey: "n") + } else { + encoder.encodeNil(forKey: "n") + } + default: + break + } + } + + public static func ==(lhs: InstantPageListItem, rhs: InstantPageListItem) -> Bool { + switch lhs { + case .unknown: + if case .unknown = rhs { + return true + } else { + return false + } + case let .text(lhsText, lhsNum): + if case let .text(rhsText, rhsNum) = rhs, lhsText == rhsText, lhsNum == rhsNum { + return true + } else { + return false + } + case let .blocks(lhsBlocks, lhsNum): + if case let .blocks(rhsBlocks, rhsNum) = rhs, lhsBlocks == rhsBlocks, lhsNum == rhsNum { + return true + } else { + return false + } + } + } +} + +public enum TableHorizontalAlignment: Int32 { + case left = 0 + case center = 1 + case right = 2 +} + +public enum TableVerticalAlignment: Int32 { + case top = 0 + case middle = 1 + case bottom = 2 +} + +public final class InstantPageTableCell: PostboxCoding, Equatable { + public let text: RichText? + public let header: Bool + public let alignment: TableHorizontalAlignment + public let verticalAlignment: TableVerticalAlignment + public let colspan: Int32 + public let rowspan: Int32 + + public init(text: RichText?, header: Bool, alignment: TableHorizontalAlignment, verticalAlignment: TableVerticalAlignment, colspan: Int32, rowspan: Int32) { + self.text = text + self.header = header + self.alignment = alignment + self.verticalAlignment = verticalAlignment + self.colspan = colspan + self.rowspan = rowspan + } + + public init(decoder: PostboxDecoder) { + self.text = decoder.decodeObjectForKey("t", decoder: { RichText(decoder: $0) }) as? RichText + self.header = decoder.decodeInt32ForKey("h", orElse: 0) != 0 + self.alignment = TableHorizontalAlignment(rawValue: decoder.decodeInt32ForKey("ha", orElse: 0))! + self.verticalAlignment = TableVerticalAlignment(rawValue: decoder.decodeInt32ForKey("va", orElse: 0))! + self.colspan = decoder.decodeInt32ForKey("sc", orElse: 0) + self.rowspan = decoder.decodeInt32ForKey("sr", orElse: 0) + } + + public func encode(_ encoder: PostboxEncoder) { + if let text = self.text { + encoder.encodeObject(text, forKey: "t") + } else { + encoder.encodeNil(forKey: "t") + } + encoder.encodeInt32(self.header ? 1 : 0, forKey: "h") + encoder.encodeInt32(self.alignment.rawValue, forKey: "ha") + encoder.encodeInt32(self.verticalAlignment.rawValue, forKey: "va") + encoder.encodeInt32(self.colspan, forKey: "sc") + encoder.encodeInt32(self.rowspan, forKey: "sr") + } + + public static func ==(lhs: InstantPageTableCell, rhs: InstantPageTableCell) -> Bool { + if lhs.text != rhs.text { + return false + } + if lhs.header != rhs.header { + return false + } + if lhs.alignment != rhs.alignment { + return false + } + if lhs.verticalAlignment != rhs.verticalAlignment { + return false + } + if lhs.colspan != rhs.colspan { + return false + } + if lhs.rowspan != rhs.rowspan { + return false + } + return true + } +} + +public final class InstantPageTableRow: PostboxCoding, Equatable { + public let cells: [InstantPageTableCell] + + public init(cells: [InstantPageTableCell]) { + self.cells = cells + } + + public init(decoder: PostboxDecoder) { + self.cells = decoder.decodeObjectArrayWithDecoderForKey("c") + } + + public func encode(_ encoder: PostboxEncoder) { + encoder.encodeObjectArray(self.cells, forKey: "c") + } + + public static func ==(lhs: InstantPageTableRow, rhs: InstantPageTableRow) -> Bool { + return lhs.cells == rhs.cells + } +} + +public final class InstantPageRelatedArticle: PostboxCoding, Equatable { + public let url: String + public let webpageId: MediaId + public let title: String? + public let description: String? + public let photoId: MediaId? + + init(url: String, webpageId: MediaId, title: String?, description: String?, photoId: MediaId?) { + self.url = url + self.webpageId = webpageId + self.title = title + self.description = description + self.photoId = photoId + } + + public init(decoder: PostboxDecoder) { + self.url = decoder.decodeStringForKey("u", orElse: "") + let webpageIdNamespace = decoder.decodeInt32ForKey("w.n", orElse: 0) + let webpageIdId = decoder.decodeInt64ForKey("w.i", orElse: 0) + self.webpageId = MediaId(namespace: webpageIdNamespace, id: webpageIdId) + + self.title = decoder.decodeOptionalStringForKey("t") + self.description = decoder.decodeOptionalStringForKey("d") + + var photoId: MediaId? + if let photoIdNamespace = decoder.decodeOptionalInt32ForKey("p.n"), let photoIdId = decoder.decodeOptionalInt64ForKey("p.i") { + photoId = MediaId(namespace: photoIdNamespace, id: photoIdId) + } + self.photoId = photoId + } + + public func encode(_ encoder: PostboxEncoder) { + encoder.encodeString(self.url, forKey: "u") + encoder.encodeInt32(self.webpageId.namespace, forKey: "w.n") + encoder.encodeInt64(self.webpageId.id, forKey: "w.i") + if let title = self.title { + encoder.encodeString(title, forKey: "t") + } else { + encoder.encodeNil(forKey: "t") + } + if let description = self.description { + encoder.encodeString(description, forKey: "d") + } else { + encoder.encodeNil(forKey: "d") + } + if let photoId = photoId { + encoder.encodeInt32(photoId.namespace, forKey: "p.n") + encoder.encodeInt64(photoId.id, forKey: "p.i") + } else { + encoder.encodeNil(forKey: "p.n") + encoder.encodeNil(forKey: "p.i") + } + } + + public static func ==(lhs: InstantPageRelatedArticle, rhs: InstantPageRelatedArticle) -> Bool { + if lhs.url != rhs.url { + return false + } + if lhs.webpageId != rhs.webpageId { + return false + } + if lhs.title != rhs.title { + return false + } + if lhs.description != rhs.description { + return false + } + if lhs.photoId != rhs.photoId { + return false + } + return true + } +} + private final class MediaDictionary: PostboxCoding { let dict: [MediaId: Media] @@ -438,30 +825,33 @@ public final class InstantPage: PostboxCoding, Equatable { public let blocks: [InstantPageBlock] public let media: [MediaId: Media] public let isComplete: Bool + public let rtl: Bool - init(blocks: [InstantPageBlock], media: [MediaId: Media], isComplete: Bool) { + init(blocks: [InstantPageBlock], media: [MediaId: Media], isComplete: Bool, rtl: Bool) { self.blocks = blocks self.media = media self.isComplete = isComplete + self.rtl = rtl } public init(decoder: PostboxDecoder) { self.blocks = decoder.decodeObjectArrayWithDecoderForKey("b") self.media = MediaDictionary(decoder: decoder).dict self.isComplete = decoder.decodeInt32ForKey("c", orElse: 0) != 0 + self.rtl = decoder.decodeInt32ForKey("r", orElse: 0) != 0 } public func encode(_ encoder: PostboxEncoder) { encoder.encodeObjectArray(self.blocks, forKey: "b") MediaDictionary(dict: self.media).encode(encoder) encoder.encodeInt32(self.isComplete ? 1 : 0, forKey: "c") + encoder.encodeInt32(self.rtl ? 1 : 0, forKey: "r") } public static func ==(lhs: InstantPage, rhs: InstantPage) -> Bool { if lhs.blocks != rhs.blocks { return false } - if lhs.media.count != rhs.media.count { return false } else { @@ -475,14 +865,101 @@ public final class InstantPage: PostboxCoding, Equatable { } } } - if lhs.isComplete != rhs.isComplete { return false } + if lhs.rtl != rhs.rtl { + return false + } return true } } +extension InstantPageCaption { + convenience init(apiCaption: Api.PageCaption) { + switch apiCaption { + case let .pageCaption(text, credit): + self.init(text: RichText(apiText: text), credit: RichText(apiText: credit)) + } + } +} + +public extension InstantPageListItem { + public var num: String? { + switch self { + case let .text(_, num): + return num + case let .blocks(_, num): + return num + default: + return nil + } + } +} + +extension InstantPageListItem { + init(apiListItem: Api.PageListItem) { + switch apiListItem { + case let .pageListItemText(text): + self = .text(RichText(apiText: text), nil) + case let .pageListItemBlocks(blocks): + self = .blocks(blocks.map({ InstantPageBlock(apiBlock: $0) }), nil) + } + } + + init(apiListOrderedItem: Api.PageListOrderedItem) { + switch apiListOrderedItem { + case let .pageListOrderedItemText(num, text): + self = .text(RichText(apiText: text), num) + case let .pageListOrderedItemBlocks(num, blocks): + self = .blocks(blocks.map({ InstantPageBlock(apiBlock: $0) }), num) + } + } +} + +extension InstantPageTableCell { + convenience init(apiTableCell: Api.PageTableCell) { + switch apiTableCell { + case let .pageTableCell(flags, text, colspan, rowspan): + var alignment = TableHorizontalAlignment.left + if (flags & (1 << 3)) != 0 { + alignment = .center + } else if (flags & (1 << 4)) != 0 { + alignment = .right + } + var verticalAlignment = TableVerticalAlignment.top + if (flags & (1 << 5)) != 0 { + verticalAlignment = .middle + } else if (flags & (1 << 6)) != 0 { + verticalAlignment = .bottom + } + self.init(text: text != nil ? RichText(apiText: text!) : nil, header: (flags & (1 << 0)) != 0, alignment: alignment, verticalAlignment: verticalAlignment, colspan: colspan ?? 0, rowspan: rowspan ?? 0) + } + } +} + +extension InstantPageTableRow { + convenience init(apiTableRow: Api.PageTableRow) { + switch apiTableRow { + case let .pageTableRow(cells): + self.init(cells: cells.map({ InstantPageTableCell(apiTableCell: $0) })) + } + } +} + +extension InstantPageRelatedArticle { + convenience init(apiRelatedArticle: Api.PageRelatedArticle) { + switch apiRelatedArticle { + case let .pageRelatedArticle(flags, url, webpageId, title, description, photoId): + var posterPhotoId: MediaId? + if let photoId = photoId { + posterPhotoId = MediaId(namespace: Namespaces.Media.CloudImage, id: photoId) + } + self.init(url: url, webpageId: MediaId(namespace: Namespaces.Media.CloudWebpage, id: webpageId), title: title, description: description, photoId: posterPhotoId) + } + } +} + extension InstantPageBlock { init(apiBlock: Api.PageBlock) { switch apiBlock { @@ -508,30 +985,51 @@ extension InstantPageBlock { self = .divider case let .pageBlockAnchor(name): self = .anchor(name) - case let .pageBlockList(ordered, items): - self = .list(items: items.map({ RichText(apiText: $0) }), ordered: ordered == .boolTrue) case let .pageBlockBlockquote(text, caption): self = .blockQuote(text: RichText(apiText: text), caption: RichText(apiText: caption)) case let .pageBlockPullquote(text, caption): self = .pullQuote(text: RichText(apiText: text), caption: RichText(apiText: caption)) - case let .pageBlockPhoto(photoId, caption): - self = .image(id: MediaId(namespace: Namespaces.Media.CloudImage, id: photoId), caption: RichText(apiText: caption)) + case let .pageBlockPhoto(_, photoId, caption, url, webpageId): + self = .image(id: MediaId(namespace: Namespaces.Media.CloudImage, id: photoId), caption: InstantPageCaption(apiCaption: caption), url: url, webpageId: webpageId != nil ? MediaId(namespace: Namespaces.Media.CloudWebpage, id: webpageId!) : nil) case let .pageBlockVideo(flags, videoId, caption): - self = .video(id: MediaId(namespace: Namespaces.Media.CloudFile, id: videoId), caption: RichText(apiText: caption), autoplay: (flags & (1 << 0)) != 0, loop: (flags & (1 << 1)) != 0) + self = .video(id: MediaId(namespace: Namespaces.Media.CloudFile, id: videoId), caption: InstantPageCaption(apiCaption: caption), autoplay: (flags & (1 << 0)) != 0, loop: (flags & (1 << 1)) != 0) case let .pageBlockCover(cover): self = .cover(InstantPageBlock(apiBlock: cover)) case let .pageBlockEmbed(flags, url, html, posterPhotoId, w, h, caption): - self = .webEmbed(url: url, html: html, dimensions: CGSize(width: CGFloat(w), height: CGFloat(h)), caption: RichText(apiText: caption), stretchToWidth: (flags & (1 << 0)) != 0, allowScrolling: (flags & (1 << 3)) != 0, coverId: posterPhotoId.flatMap { MediaId(namespace: Namespaces.Media.CloudImage, id: $0) }) + var dimensions: CGSize? + if let w = w, let h = h { + dimensions = CGSize(width: CGFloat(w), height: CGFloat(h)) + } + self = .webEmbed(url: url, html: html, dimensions: dimensions, caption: InstantPageCaption(apiCaption: caption), stretchToWidth: (flags & (1 << 0)) != 0, allowScrolling: (flags & (1 << 3)) != 0, coverId: posterPhotoId.flatMap { MediaId(namespace: Namespaces.Media.CloudImage, id: $0) }) case let .pageBlockEmbedPost(url, webpageId, authorPhotoId, author, date, blocks, caption): - self = .postEmbed(url: url, webpageId: webpageId == 0 ? nil : MediaId(namespace: Namespaces.Media.CloudWebpage, id: webpageId), avatarId: authorPhotoId == 0 ? nil : MediaId(namespace: Namespaces.Media.CloudImage, id: authorPhotoId), author: author, date: date, blocks: blocks.map({ InstantPageBlock(apiBlock: $0) }), caption: RichText(apiText: caption)) + self = .postEmbed(url: url, webpageId: webpageId == 0 ? nil : MediaId(namespace: Namespaces.Media.CloudWebpage, id: webpageId), avatarId: authorPhotoId == 0 ? nil : MediaId(namespace: Namespaces.Media.CloudImage, id: authorPhotoId), author: author, date: date, blocks: blocks.map({ InstantPageBlock(apiBlock: $0) }), caption: InstantPageCaption(apiCaption: caption)) case let .pageBlockCollage(items, caption): - self = .collage(items: items.map({ InstantPageBlock(apiBlock: $0) }), caption: RichText(apiText: caption)) + self = .collage(items: items.map({ InstantPageBlock(apiBlock: $0) }), caption: InstantPageCaption(apiCaption: caption)) case let .pageBlockSlideshow(items, caption): - self = .slideshow(items: items.map({ InstantPageBlock(apiBlock: $0) }), caption: RichText(apiText: caption)) + self = .slideshow(items: items.map({ InstantPageBlock(apiBlock: $0) }), caption: InstantPageCaption(apiCaption: caption)) case let .pageBlockChannel(channel: apiChat): self = .channelBanner(parseTelegramGroupOrChannel(chat: apiChat) as? TelegramChannel) case let .pageBlockAudio(audioId, caption): - self = .audio(id: MediaId(namespace: Namespaces.Media.CloudFile, id: audioId), caption: RichText(apiText: caption)) + self = .audio(id: MediaId(namespace: Namespaces.Media.CloudFile, id: audioId), caption: InstantPageCaption(apiCaption: caption)) + case let .pageBlockKicker(text): + self = .kicker(RichText(apiText: text)) + case let .pageBlockTable(flags, title, rows): + self = .table(title: RichText(apiText: title), rows: rows.map({ InstantPageTableRow(apiTableRow: $0) }), bordered: (flags & (1 << 0)) != 0, striped: (flags & (1 << 1)) != 0) + case let .pageBlockList(items): + self = .list(items: items.map({ InstantPageListItem(apiListItem: $0) }), ordered: false) + case let .pageBlockOrderedList(items): + self = .list(items: items.map({ InstantPageListItem(apiListOrderedItem: $0) }), ordered: true) + case let .pageBlockDetails(flags, blocks, title): + self = .details(title: RichText(apiText: title), blocks: blocks.map({ InstantPageBlock(apiBlock: $0) }), open: (flags & (1 << 0)) != 0) + case let .pageBlockRelatedArticles(title, articles): + self = .relatedArticles(title: RichText(apiText: title), articles: articles.map({ InstantPageRelatedArticle(apiRelatedArticle: $0) })) + case let .pageBlockMap(geo, zoom, w, h, caption): + switch geo { + case let .geoPoint(long, lat, _): + self = .map(latitude: lat, longitude: long, zoom: zoom, dimensions: CGSize(width: CGFloat(w), height: CGFloat(h)), caption: InstantPageCaption(apiCaption: caption)) + default: + self = .unsupported + } } } } @@ -542,17 +1040,14 @@ extension InstantPage { let photos: [Api.Photo] let files: [Api.Document] let isComplete: Bool + let rtl: Bool switch apiPage { - case let .pageFull(apiBlocks, apiPhotos, apiVideos): + case let .page(flags, apiBlocks, apiPhotos, apiVideos): blocks = apiBlocks photos = apiPhotos files = apiVideos - isComplete = true - case let .pagePart(apiBlocks, apiPhotos, apiVideos): - blocks = apiBlocks - photos = apiPhotos - files = apiVideos - isComplete = false + isComplete = (flags & (1 << 0)) == 0 + rtl = (flags & (1 << 1)) != 0 } var media: [MediaId: Media] = [:] for photo in photos { @@ -565,6 +1060,6 @@ extension InstantPage { media[id] = file } } - self.init(blocks: blocks.map({ InstantPageBlock(apiBlock: $0) }), media: media, isComplete: isComplete) + self.init(blocks: blocks.map({ InstantPageBlock(apiBlock: $0) }), media: media, isComplete: isComplete, rtl: rtl) } } diff --git a/TelegramCore/RecentAccountSession.swift b/TelegramCore/RecentAccountSession.swift index 7b0b6ce47e..5e2e299be0 100644 --- a/TelegramCore/RecentAccountSession.swift +++ b/TelegramCore/RecentAccountSession.swift @@ -1,5 +1,20 @@ import Foundation +public struct AccountSessionFlags: OptionSet { + public var rawValue: Int32 + + public init() { + self.rawValue = 0 + } + + public init(rawValue: Int32) { + self.rawValue = rawValue + } + + public static let isOfficial = AccountSessionFlags(rawValue: (1 << 1)) + public static let passwordPending = AccountSessionFlags(rawValue: (1 << 2)) +} + public struct RecentAccountSession: Equatable { public let hash: Int64 public let deviceModel: String @@ -13,6 +28,7 @@ public struct RecentAccountSession: Equatable { public let ip: String public let country: String public let region: String + public let flags: AccountSessionFlags public var isCurrent: Bool { return self.hash == 0 @@ -55,6 +71,9 @@ public struct RecentAccountSession: Equatable { if lhs.region != rhs.region { return false } + if lhs.flags != rhs.flags { + return false + } return true } } @@ -62,8 +81,15 @@ public struct RecentAccountSession: Equatable { extension RecentAccountSession { init(apiAuthorization: Api.Authorization) { switch apiAuthorization { - case let .authorization(hash, flags, deviceModel, platform, systemVersion, apiId, appName, appVersion, dateCreated, dateActive, ip, country, region): - self.init(hash: hash, deviceModel: deviceModel, platform: platform, systemVersion: systemVersion, apiId: apiId, appName: appName, appVersion: appVersion, creationDate: dateCreated, activityDate: dateActive, ip: ip, country: country, region: region) + case let .authorization(flags, hash, deviceModel, platform, systemVersion, apiId, appName, appVersion, dateCreated, dateActive, ip, country, region): + var accountSessionFlags: AccountSessionFlags = [] + if (flags & (1 << 1)) != 0 { + accountSessionFlags.insert(.isOfficial) + } + if (flags & (1 << 2)) != 0 { + accountSessionFlags.insert(.passwordPending) + } + self.init(hash: hash, deviceModel: deviceModel, platform: platform, systemVersion: systemVersion, apiId: apiId, appName: appName, appVersion: appVersion, creationDate: dateCreated, activityDate: dateActive, ip: ip, country: country, region: region, flags: accountSessionFlags) } } } diff --git a/TelegramCore/RichText.swift b/TelegramCore/RichText.swift index 65d35af655..f737ff6c7c 100644 --- a/TelegramCore/RichText.swift +++ b/TelegramCore/RichText.swift @@ -16,6 +16,11 @@ private enum RichTextTypes: Int32 { case url = 7 case email = 8 case concat = 9 + case `subscript` = 10 + case superscript = 11 + case marked = 12 + case phone = 13 + case image = 14 } public indirect enum RichText: PostboxCoding, Equatable { @@ -29,6 +34,11 @@ public indirect enum RichText: PostboxCoding, Equatable { case url(text: RichText, url: String, webpageId: MediaId?) case email(text: RichText, email: String) case concat([RichText]) + case `subscript`(RichText) + case superscript(RichText) + case marked(RichText) + case phone(text: RichText, phone: String) + case image(id: MediaId, dimensions: CGSize) public init(decoder: PostboxDecoder) { switch decoder.decodeInt32ForKey("r", orElse: 0) { @@ -58,6 +68,16 @@ public indirect enum RichText: PostboxCoding, Equatable { self = .email(text: decoder.decodeObjectForKey("t", decoder: { RichText(decoder: $0) }) as! RichText, email: decoder.decodeStringForKey("e", orElse: "")) case RichTextTypes.concat.rawValue: self = .concat(decoder.decodeObjectArrayWithDecoderForKey("a")) + case RichTextTypes.subscript.rawValue: + self = .subscript(decoder.decodeObjectForKey("t", decoder: { RichText(decoder: $0) }) as! RichText) + case RichTextTypes.superscript.rawValue: + self = .superscript(decoder.decodeObjectForKey("t", decoder: { RichText(decoder: $0) }) as! RichText) + case RichTextTypes.marked.rawValue: + self = .marked(decoder.decodeObjectForKey("t", decoder: { RichText(decoder: $0) }) as! RichText) + case RichTextTypes.phone.rawValue: + self = .phone(text: decoder.decodeObjectForKey("t", decoder: { RichText(decoder: $0) }) as! RichText, phone: decoder.decodeStringForKey("p", orElse: "")) + case RichTextTypes.image.rawValue: + self = .image(id: MediaId(namespace: decoder.decodeInt32ForKey("i.n", orElse: 0), id: decoder.decodeInt64ForKey("i.i", orElse: 0)), dimensions: CGSize(width: CGFloat(decoder.decodeInt32ForKey("sw", orElse: 0)), height: CGFloat(decoder.decodeInt32ForKey("sh", orElse: 0)))) default: self = .empty } @@ -103,6 +123,25 @@ public indirect enum RichText: PostboxCoding, Equatable { case let .concat(texts): encoder.encodeInt32(RichTextTypes.concat.rawValue, forKey: "r") encoder.encodeObjectArray(texts, forKey: "a") + case let .subscript(text): + encoder.encodeInt32(RichTextTypes.subscript.rawValue, forKey: "r") + encoder.encodeObject(text, forKey: "t") + case let .superscript(text): + encoder.encodeInt32(RichTextTypes.superscript.rawValue, forKey: "r") + encoder.encodeObject(text, forKey: "t") + case let .marked(text): + encoder.encodeInt32(RichTextTypes.marked.rawValue, forKey: "r") + encoder.encodeObject(text, forKey: "t") + case let .phone(text, phone): + encoder.encodeInt32(RichTextTypes.phone.rawValue, forKey: "r") + encoder.encodeObject(text, forKey: "t") + encoder.encodeString(phone, forKey: "p") + case let .image(id, dimensions): + encoder.encodeInt32(RichTextTypes.image.rawValue, forKey: "r") + encoder.encodeInt32(id.namespace, forKey: "i.n") + encoder.encodeInt64(id.id, forKey: "i.i") + encoder.encodeInt32(Int32(dimensions.width), forKey: "sw") + encoder.encodeInt32(Int32(dimensions.height), forKey: "sh") } } @@ -168,6 +207,36 @@ public indirect enum RichText: PostboxCoding, Equatable { } else { return false } + case let .subscript(text): + if case .subscript(text) = rhs { + return true + } else { + return false + } + case let .superscript(text): + if case .superscript(text) = rhs { + return true + } else { + return false + } + case let .marked(text): + if case .marked(text) = rhs { + return true + } else { + return false + } + case let .phone(text, phone): + if case .phone(text, phone) = rhs { + return true + } else { + return false + } + case let .image(id, dimensions): + if case .image(id, dimensions) = rhs { + return true + } else { + return false + } } } } @@ -199,6 +268,16 @@ public extension RichText { string += text.plainText } return string + case let .subscript(text): + return text.plainText + case let .superscript(text): + return text.plainText + case let .marked(text): + return text.plainText + case let .phone(text, _): + return text.plainText + case .image: + return "" } } } @@ -226,6 +305,16 @@ extension RichText { self = .email(text: RichText(apiText: text), email: email) case let .textConcat(texts): self = .concat(texts.map({ RichText(apiText: $0) })) + case let .textSubscript(text): + self = .subscript(RichText(apiText: text)) + case let .textSuperscript(text): + self = .superscript(RichText(apiText: text)) + case let .textMarked(text): + self = .marked(RichText(apiText: text)) + case let .textPhone(text, phone): + self = .phone(text: RichText(apiText: text), phone: phone) + case let .textImage(documentId, w, h): + self = .image(id: MediaId(namespace: Namespaces.Media.CloudFile, id: documentId), dimensions: CGSize(width: CGFloat(w), height: CGFloat(h))) } } } diff --git a/TelegramCore/Serialization.swift b/TelegramCore/Serialization.swift index 32c39556ca..f11dded846 100644 --- a/TelegramCore/Serialization.swift +++ b/TelegramCore/Serialization.swift @@ -202,7 +202,7 @@ public class BoxedMessage: NSObject { public class Serialization: NSObject, MTSerialization { public func currentLayer() -> UInt { - return 86 + return 88 } public func parseMessage(_ data: Data!) -> Any! { diff --git a/TelegramCore/StickerPack.swift b/TelegramCore/StickerPack.swift index c3afc014eb..f9fa1a35c3 100644 --- a/TelegramCore/StickerPack.swift +++ b/TelegramCore/StickerPack.swift @@ -5,7 +5,7 @@ import Foundation import Postbox #endif -public struct StickerPackCollectionInfoFlags : OptionSet { +public struct StickerPackCollectionInfoFlags: OptionSet { public var rawValue: Int32 public init(rawValue: Int32) {