Refactor Api types 70-89 to use struct-wrapped constructors

Types refactored:
- 70-79: contactStatus, dataJSON, dcOption, defaultHistoryTTL, dialog,
  dialogFolder, dialogFilter, dialogFilterChatlist, dialogFilterSuggested,
  dialogPeer, dialogPeerFolder, disallowedGiftsSettings, document, documentEmpty
- 80-89: documentAttribute* (Audio, CustomEmoji, Filename, ImageSize, Sticker, Video),
  draftMessage, draftMessageEmpty, emailVerification* (Apple, Code, Google),
  emailVerifyPurposeLoginSetup, emoji* (Group, GroupGreeting, GroupPremium,
  Keyword, KeywordDeleted, KeywordsDifference, Language, List, Status,
  StatusCollectible), inputEmojiStatusCollectible

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
Isaac 2026-01-16 02:12:20 +08:00
parent 02167b9b86
commit a78b2c0db2
42 changed files with 684 additions and 191 deletions

View file

@ -687,7 +687,15 @@ public extension Api {
}
public extension Api {
enum ContactStatus: TypeConstructorDescription {
case contactStatus(userId: Int64, status: Api.UserStatus)
public class Cons_contactStatus {
public var userId: Int64
public var status: Api.UserStatus
public init(userId: Int64, status: Api.UserStatus) {
self.userId = userId
self.status = status
}
}
case contactStatus(Cons_contactStatus)
public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) {
#if DEBUG
@ -716,7 +724,13 @@ public extension Api {
}
public extension Api {
enum DataJSON: TypeConstructorDescription {
case dataJSON(data: String)
public class Cons_dataJSON {
public var data: String
public init(data: String) {
self.data = data
}
}
case dataJSON(Cons_dataJSON)
public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) {
#if DEBUG
@ -745,7 +759,21 @@ public extension Api {
}
public extension Api {
enum DcOption: TypeConstructorDescription {
case dcOption(flags: Int32, id: Int32, ipAddress: String, port: Int32, secret: Buffer?)
public class Cons_dcOption {
public var flags: Int32
public var id: Int32
public var ipAddress: String
public var port: Int32
public var secret: Buffer?
public init(flags: Int32, id: Int32, ipAddress: String, port: Int32, secret: Buffer?) {
self.flags = flags
self.id = id
self.ipAddress = ipAddress
self.port = port
self.secret = secret
}
}
case dcOption(Cons_dcOption)
public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) {
#if DEBUG
@ -774,7 +802,13 @@ public extension Api {
}
public extension Api {
enum DefaultHistoryTTL: TypeConstructorDescription {
case defaultHistoryTTL(period: Int32)
public class Cons_defaultHistoryTTL {
public var period: Int32
public init(period: Int32) {
self.period = period
}
}
case defaultHistoryTTL(Cons_defaultHistoryTTL)
public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) {
#if DEBUG
@ -803,8 +837,58 @@ public extension Api {
}
public extension Api {
indirect enum Dialog: TypeConstructorDescription {
case dialog(flags: Int32, peer: Api.Peer, topMessage: Int32, readInboxMaxId: Int32, readOutboxMaxId: Int32, unreadCount: Int32, unreadMentionsCount: Int32, unreadReactionsCount: Int32, notifySettings: Api.PeerNotifySettings, pts: Int32?, draft: Api.DraftMessage?, folderId: Int32?, ttlPeriod: Int32?)
case dialogFolder(flags: Int32, folder: Api.Folder, peer: Api.Peer, topMessage: Int32, unreadMutedPeersCount: Int32, unreadUnmutedPeersCount: Int32, unreadMutedMessagesCount: Int32, unreadUnmutedMessagesCount: Int32)
public class Cons_dialog {
public var flags: Int32
public var peer: Api.Peer
public var topMessage: Int32
public var readInboxMaxId: Int32
public var readOutboxMaxId: Int32
public var unreadCount: Int32
public var unreadMentionsCount: Int32
public var unreadReactionsCount: Int32
public var notifySettings: Api.PeerNotifySettings
public var pts: Int32?
public var draft: Api.DraftMessage?
public var folderId: Int32?
public var ttlPeriod: Int32?
public init(flags: Int32, peer: Api.Peer, topMessage: Int32, readInboxMaxId: Int32, readOutboxMaxId: Int32, unreadCount: Int32, unreadMentionsCount: Int32, unreadReactionsCount: Int32, notifySettings: Api.PeerNotifySettings, pts: Int32?, draft: Api.DraftMessage?, folderId: Int32?, ttlPeriod: Int32?) {
self.flags = flags
self.peer = peer
self.topMessage = topMessage
self.readInboxMaxId = readInboxMaxId
self.readOutboxMaxId = readOutboxMaxId
self.unreadCount = unreadCount
self.unreadMentionsCount = unreadMentionsCount
self.unreadReactionsCount = unreadReactionsCount
self.notifySettings = notifySettings
self.pts = pts
self.draft = draft
self.folderId = folderId
self.ttlPeriod = ttlPeriod
}
}
public class Cons_dialogFolder {
public var flags: Int32
public var folder: Api.Folder
public var peer: Api.Peer
public var topMessage: Int32
public var unreadMutedPeersCount: Int32
public var unreadUnmutedPeersCount: Int32
public var unreadMutedMessagesCount: Int32
public var unreadUnmutedMessagesCount: Int32
public init(flags: Int32, folder: Api.Folder, peer: Api.Peer, topMessage: Int32, unreadMutedPeersCount: Int32, unreadUnmutedPeersCount: Int32, unreadMutedMessagesCount: Int32, unreadUnmutedMessagesCount: Int32) {
self.flags = flags
self.folder = folder
self.peer = peer
self.topMessage = topMessage
self.unreadMutedPeersCount = unreadMutedPeersCount
self.unreadUnmutedPeersCount = unreadUnmutedPeersCount
self.unreadMutedMessagesCount = unreadMutedMessagesCount
self.unreadUnmutedMessagesCount = unreadUnmutedMessagesCount
}
}
case dialog(Cons_dialog)
case dialogFolder(Cons_dialogFolder)
public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) {
#if DEBUG
@ -840,8 +924,46 @@ public extension Api {
}
public extension Api {
enum DialogFilter: TypeConstructorDescription {
case dialogFilter(flags: Int32, id: Int32, title: Api.TextWithEntities, emoticon: String?, color: Int32?, pinnedPeers: [Api.InputPeer], includePeers: [Api.InputPeer], excludePeers: [Api.InputPeer])
case dialogFilterChatlist(flags: Int32, id: Int32, title: Api.TextWithEntities, emoticon: String?, color: Int32?, pinnedPeers: [Api.InputPeer], includePeers: [Api.InputPeer])
public class Cons_dialogFilter {
public var flags: Int32
public var id: Int32
public var title: Api.TextWithEntities
public var emoticon: String?
public var color: Int32?
public var pinnedPeers: [Api.InputPeer]
public var includePeers: [Api.InputPeer]
public var excludePeers: [Api.InputPeer]
public init(flags: Int32, id: Int32, title: Api.TextWithEntities, emoticon: String?, color: Int32?, pinnedPeers: [Api.InputPeer], includePeers: [Api.InputPeer], excludePeers: [Api.InputPeer]) {
self.flags = flags
self.id = id
self.title = title
self.emoticon = emoticon
self.color = color
self.pinnedPeers = pinnedPeers
self.includePeers = includePeers
self.excludePeers = excludePeers
}
}
public class Cons_dialogFilterChatlist {
public var flags: Int32
public var id: Int32
public var title: Api.TextWithEntities
public var emoticon: String?
public var color: Int32?
public var pinnedPeers: [Api.InputPeer]
public var includePeers: [Api.InputPeer]
public init(flags: Int32, id: Int32, title: Api.TextWithEntities, emoticon: String?, color: Int32?, pinnedPeers: [Api.InputPeer], includePeers: [Api.InputPeer]) {
self.flags = flags
self.id = id
self.title = title
self.emoticon = emoticon
self.color = color
self.pinnedPeers = pinnedPeers
self.includePeers = includePeers
}
}
case dialogFilter(Cons_dialogFilter)
case dialogFilterChatlist(Cons_dialogFilterChatlist)
case dialogFilterDefault
public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) {
@ -885,7 +1007,15 @@ public extension Api {
}
public extension Api {
enum DialogFilterSuggested: TypeConstructorDescription {
case dialogFilterSuggested(filter: Api.DialogFilter, description: String)
public class Cons_dialogFilterSuggested {
public var filter: Api.DialogFilter
public var description: String
public init(filter: Api.DialogFilter, description: String) {
self.filter = filter
self.description = description
}
}
case dialogFilterSuggested(Cons_dialogFilterSuggested)
public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) {
#if DEBUG
@ -914,8 +1044,20 @@ public extension Api {
}
public extension Api {
enum DialogPeer: TypeConstructorDescription {
case dialogPeer(peer: Api.Peer)
case dialogPeerFolder(folderId: Int32)
public class Cons_dialogPeer {
public var peer: Api.Peer
public init(peer: Api.Peer) {
self.peer = peer
}
}
public class Cons_dialogPeerFolder {
public var folderId: Int32
public init(folderId: Int32) {
self.folderId = folderId
}
}
case dialogPeer(Cons_dialogPeer)
case dialogPeerFolder(Cons_dialogPeerFolder)
public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) {
#if DEBUG

View file

@ -1,6 +1,12 @@
public extension Api {
enum DisallowedGiftsSettings: TypeConstructorDescription {
case disallowedGiftsSettings(flags: Int32)
public class Cons_disallowedGiftsSettings {
public var flags: Int32
public init(flags: Int32) {
self.flags = flags
}
}
case disallowedGiftsSettings(Cons_disallowedGiftsSettings)
public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) {
#if DEBUG
@ -29,8 +35,40 @@ public extension Api {
}
public extension Api {
enum Document: TypeConstructorDescription {
case document(flags: Int32, id: Int64, accessHash: Int64, fileReference: Buffer, date: Int32, mimeType: String, size: Int64, thumbs: [Api.PhotoSize]?, videoThumbs: [Api.VideoSize]?, dcId: Int32, attributes: [Api.DocumentAttribute])
case documentEmpty(id: Int64)
public class Cons_document {
public var flags: Int32
public var id: Int64
public var accessHash: Int64
public var fileReference: Buffer
public var date: Int32
public var mimeType: String
public var size: Int64
public var thumbs: [Api.PhotoSize]?
public var videoThumbs: [Api.VideoSize]?
public var dcId: Int32
public var attributes: [Api.DocumentAttribute]
public init(flags: Int32, id: Int64, accessHash: Int64, fileReference: Buffer, date: Int32, mimeType: String, size: Int64, thumbs: [Api.PhotoSize]?, videoThumbs: [Api.VideoSize]?, dcId: Int32, attributes: [Api.DocumentAttribute]) {
self.flags = flags
self.id = id
self.accessHash = accessHash
self.fileReference = fileReference
self.date = date
self.mimeType = mimeType
self.size = size
self.thumbs = thumbs
self.videoThumbs = videoThumbs
self.dcId = dcId
self.attributes = attributes
}
}
public class Cons_documentEmpty {
public var id: Int64
public init(id: Int64) {
self.id = id
}
}
case document(Cons_document)
case documentEmpty(Cons_documentEmpty)
public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) {
#if DEBUG
@ -66,14 +104,82 @@ public extension Api {
}
public extension Api {
enum DocumentAttribute: TypeConstructorDescription {
public class Cons_documentAttributeAudio {
public var flags: Int32
public var duration: Int32
public var title: String?
public var performer: String?
public var waveform: Buffer?
public init(flags: Int32, duration: Int32, title: String?, performer: String?, waveform: Buffer?) {
self.flags = flags
self.duration = duration
self.title = title
self.performer = performer
self.waveform = waveform
}
}
public class Cons_documentAttributeCustomEmoji {
public var flags: Int32
public var alt: String
public var stickerset: Api.InputStickerSet
public init(flags: Int32, alt: String, stickerset: Api.InputStickerSet) {
self.flags = flags
self.alt = alt
self.stickerset = stickerset
}
}
public class Cons_documentAttributeFilename {
public var fileName: String
public init(fileName: String) {
self.fileName = fileName
}
}
public class Cons_documentAttributeImageSize {
public var w: Int32
public var h: Int32
public init(w: Int32, h: Int32) {
self.w = w
self.h = h
}
}
public class Cons_documentAttributeSticker {
public var flags: Int32
public var alt: String
public var stickerset: Api.InputStickerSet
public var maskCoords: Api.MaskCoords?
public init(flags: Int32, alt: String, stickerset: Api.InputStickerSet, maskCoords: Api.MaskCoords?) {
self.flags = flags
self.alt = alt
self.stickerset = stickerset
self.maskCoords = maskCoords
}
}
public class Cons_documentAttributeVideo {
public var flags: Int32
public var duration: Double
public var w: Int32
public var h: Int32
public var preloadPrefixSize: Int32?
public var videoStartTs: Double?
public var videoCodec: String?
public init(flags: Int32, duration: Double, w: Int32, h: Int32, preloadPrefixSize: Int32?, videoStartTs: Double?, videoCodec: String?) {
self.flags = flags
self.duration = duration
self.w = w
self.h = h
self.preloadPrefixSize = preloadPrefixSize
self.videoStartTs = videoStartTs
self.videoCodec = videoCodec
}
}
case documentAttributeAnimated
case documentAttributeAudio(flags: Int32, duration: Int32, title: String?, performer: String?, waveform: Buffer?)
case documentAttributeCustomEmoji(flags: Int32, alt: String, stickerset: Api.InputStickerSet)
case documentAttributeFilename(fileName: String)
case documentAttributeAudio(Cons_documentAttributeAudio)
case documentAttributeCustomEmoji(Cons_documentAttributeCustomEmoji)
case documentAttributeFilename(Cons_documentAttributeFilename)
case documentAttributeHasStickers
case documentAttributeImageSize(w: Int32, h: Int32)
case documentAttributeSticker(flags: Int32, alt: String, stickerset: Api.InputStickerSet, maskCoords: Api.MaskCoords?)
case documentAttributeVideo(flags: Int32, duration: Double, w: Int32, h: Int32, preloadPrefixSize: Int32?, videoStartTs: Double?, videoCodec: String?)
case documentAttributeImageSize(Cons_documentAttributeImageSize)
case documentAttributeSticker(Cons_documentAttributeSticker)
case documentAttributeVideo(Cons_documentAttributeVideo)
public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) {
#if DEBUG
@ -151,8 +257,36 @@ public extension Api {
}
public extension Api {
indirect enum DraftMessage: TypeConstructorDescription {
case draftMessage(flags: Int32, replyTo: Api.InputReplyTo?, message: String, entities: [Api.MessageEntity]?, media: Api.InputMedia?, date: Int32, effect: Int64?, suggestedPost: Api.SuggestedPost?)
case draftMessageEmpty(flags: Int32, date: Int32?)
public class Cons_draftMessage {
public var flags: Int32
public var replyTo: Api.InputReplyTo?
public var message: String
public var entities: [Api.MessageEntity]?
public var media: Api.InputMedia?
public var date: Int32
public var effect: Int64?
public var suggestedPost: Api.SuggestedPost?
public init(flags: Int32, replyTo: Api.InputReplyTo?, message: String, entities: [Api.MessageEntity]?, media: Api.InputMedia?, date: Int32, effect: Int64?, suggestedPost: Api.SuggestedPost?) {
self.flags = flags
self.replyTo = replyTo
self.message = message
self.entities = entities
self.media = media
self.date = date
self.effect = effect
self.suggestedPost = suggestedPost
}
}
public class Cons_draftMessageEmpty {
public var flags: Int32
public var date: Int32?
public init(flags: Int32, date: Int32?) {
self.flags = flags
self.date = date
}
}
case draftMessage(Cons_draftMessage)
case draftMessageEmpty(Cons_draftMessageEmpty)
public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) {
#if DEBUG
@ -188,9 +322,27 @@ public extension Api {
}
public extension Api {
enum EmailVerification: TypeConstructorDescription {
case emailVerificationApple(token: String)
case emailVerificationCode(code: String)
case emailVerificationGoogle(token: String)
public class Cons_emailVerificationApple {
public var token: String
public init(token: String) {
self.token = token
}
}
public class Cons_emailVerificationCode {
public var code: String
public init(code: String) {
self.code = code
}
}
public class Cons_emailVerificationGoogle {
public var token: String
public init(token: String) {
self.token = token
}
}
case emailVerificationApple(Cons_emailVerificationApple)
case emailVerificationCode(Cons_emailVerificationCode)
case emailVerificationGoogle(Cons_emailVerificationGoogle)
public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) {
#if DEBUG
@ -233,8 +385,16 @@ public extension Api {
}
public extension Api {
enum EmailVerifyPurpose: TypeConstructorDescription {
public class Cons_emailVerifyPurposeLoginSetup {
public var phoneNumber: String
public var phoneCodeHash: String
public init(phoneNumber: String, phoneCodeHash: String) {
self.phoneNumber = phoneNumber
self.phoneCodeHash = phoneCodeHash
}
}
case emailVerifyPurposeLoginChange
case emailVerifyPurposeLoginSetup(phoneNumber: String, phoneCodeHash: String)
case emailVerifyPurposeLoginSetup(Cons_emailVerifyPurposeLoginSetup)
case emailVerifyPurposePassport
public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) {
@ -278,9 +438,37 @@ public extension Api {
}
public extension Api {
enum EmojiGroup: TypeConstructorDescription {
case emojiGroup(title: String, iconEmojiId: Int64, emoticons: [String])
case emojiGroupGreeting(title: String, iconEmojiId: Int64, emoticons: [String])
case emojiGroupPremium(title: String, iconEmojiId: Int64)
public class Cons_emojiGroup {
public var title: String
public var iconEmojiId: Int64
public var emoticons: [String]
public init(title: String, iconEmojiId: Int64, emoticons: [String]) {
self.title = title
self.iconEmojiId = iconEmojiId
self.emoticons = emoticons
}
}
public class Cons_emojiGroupGreeting {
public var title: String
public var iconEmojiId: Int64
public var emoticons: [String]
public init(title: String, iconEmojiId: Int64, emoticons: [String]) {
self.title = title
self.iconEmojiId = iconEmojiId
self.emoticons = emoticons
}
}
public class Cons_emojiGroupPremium {
public var title: String
public var iconEmojiId: Int64
public init(title: String, iconEmojiId: Int64) {
self.title = title
self.iconEmojiId = iconEmojiId
}
}
case emojiGroup(Cons_emojiGroup)
case emojiGroupGreeting(Cons_emojiGroupGreeting)
case emojiGroupPremium(Cons_emojiGroupPremium)
public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) {
#if DEBUG
@ -323,8 +511,24 @@ public extension Api {
}
public extension Api {
enum EmojiKeyword: TypeConstructorDescription {
case emojiKeyword(keyword: String, emoticons: [String])
case emojiKeywordDeleted(keyword: String, emoticons: [String])
public class Cons_emojiKeyword {
public var keyword: String
public var emoticons: [String]
public init(keyword: String, emoticons: [String]) {
self.keyword = keyword
self.emoticons = emoticons
}
}
public class Cons_emojiKeywordDeleted {
public var keyword: String
public var emoticons: [String]
public init(keyword: String, emoticons: [String]) {
self.keyword = keyword
self.emoticons = emoticons
}
}
case emojiKeyword(Cons_emojiKeyword)
case emojiKeywordDeleted(Cons_emojiKeywordDeleted)
public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) {
#if DEBUG
@ -360,7 +564,19 @@ public extension Api {
}
public extension Api {
enum EmojiKeywordsDifference: TypeConstructorDescription {
case emojiKeywordsDifference(langCode: String, fromVersion: Int32, version: Int32, keywords: [Api.EmojiKeyword])
public class Cons_emojiKeywordsDifference {
public var langCode: String
public var fromVersion: Int32
public var version: Int32
public var keywords: [Api.EmojiKeyword]
public init(langCode: String, fromVersion: Int32, version: Int32, keywords: [Api.EmojiKeyword]) {
self.langCode = langCode
self.fromVersion = fromVersion
self.version = version
self.keywords = keywords
}
}
case emojiKeywordsDifference(Cons_emojiKeywordsDifference)
public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) {
#if DEBUG
@ -389,7 +605,13 @@ public extension Api {
}
public extension Api {
enum EmojiLanguage: TypeConstructorDescription {
case emojiLanguage(langCode: String)
public class Cons_emojiLanguage {
public var langCode: String
public init(langCode: String) {
self.langCode = langCode
}
}
case emojiLanguage(Cons_emojiLanguage)
public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) {
#if DEBUG
@ -418,7 +640,15 @@ public extension Api {
}
public extension Api {
enum EmojiList: TypeConstructorDescription {
case emojiList(hash: Int64, documentId: [Int64])
public class Cons_emojiList {
public var hash: Int64
public var documentId: [Int64]
public init(hash: Int64, documentId: [Int64]) {
self.hash = hash
self.documentId = documentId
}
}
case emojiList(Cons_emojiList)
case emojiListNotModified
public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) {
@ -455,10 +685,56 @@ public extension Api {
}
public extension Api {
enum EmojiStatus: TypeConstructorDescription {
case emojiStatus(flags: Int32, documentId: Int64, until: Int32?)
case emojiStatusCollectible(flags: Int32, collectibleId: Int64, documentId: Int64, title: String, slug: String, patternDocumentId: Int64, centerColor: Int32, edgeColor: Int32, patternColor: Int32, textColor: Int32, until: Int32?)
public class Cons_emojiStatus {
public var flags: Int32
public var documentId: Int64
public var until: Int32?
public init(flags: Int32, documentId: Int64, until: Int32?) {
self.flags = flags
self.documentId = documentId
self.until = until
}
}
public class Cons_emojiStatusCollectible {
public var flags: Int32
public var collectibleId: Int64
public var documentId: Int64
public var title: String
public var slug: String
public var patternDocumentId: Int64
public var centerColor: Int32
public var edgeColor: Int32
public var patternColor: Int32
public var textColor: Int32
public var until: Int32?
public init(flags: Int32, collectibleId: Int64, documentId: Int64, title: String, slug: String, patternDocumentId: Int64, centerColor: Int32, edgeColor: Int32, patternColor: Int32, textColor: Int32, until: Int32?) {
self.flags = flags
self.collectibleId = collectibleId
self.documentId = documentId
self.title = title
self.slug = slug
self.patternDocumentId = patternDocumentId
self.centerColor = centerColor
self.edgeColor = edgeColor
self.patternColor = patternColor
self.textColor = textColor
self.until = until
}
}
public class Cons_inputEmojiStatusCollectible {
public var flags: Int32
public var collectibleId: Int64
public var until: Int32?
public init(flags: Int32, collectibleId: Int64, until: Int32?) {
self.flags = flags
self.collectibleId = collectibleId
self.until = until
}
}
case emojiStatus(Cons_emojiStatus)
case emojiStatusCollectible(Cons_emojiStatusCollectible)
case emojiStatusEmpty
case inputEmojiStatusCollectible(flags: Int32, collectibleId: Int64, until: Int32?)
case inputEmojiStatusCollectible(Cons_inputEmojiStatusCollectible)
public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) {
#if DEBUG

View file

@ -535,7 +535,8 @@ func _internal_requestPasskeyRegistration(network: Network) -> Signal<String?, N
switch options {
case let .passkeyRegistrationOptions(options):
switch options {
case let .dataJSON(data):
case let .dataJSON(dataJSONData):
let data = dataJSONData.data
return data
}
}
@ -543,7 +544,7 @@ func _internal_requestPasskeyRegistration(network: Network) -> Signal<String?, N
}
func _internal_requestCreatePasskey(network: Network, id: String, clientData: String, attestationObject: Data) -> Signal<TelegramPasskey?, NoError> {
return network.request(Api.functions.account.registerPasskey(credential: .inputPasskeyCredentialPublicKey(id: id, rawId: id, response: .inputPasskeyResponseRegister(clientData: .dataJSON(data: clientData), attestationData: Buffer(data: attestationObject)))))
return network.request(Api.functions.account.registerPasskey(credential: .inputPasskeyCredentialPublicKey(id: id, rawId: id, response: .inputPasskeyResponseRegister(clientData: .dataJSON(.init(data: clientData)), attestationData: Buffer(data: attestationObject)))))
|> map(Optional.init)
|> `catch` { _ -> Signal<Api.Passkey?, NoError> in
return .single(nil)
@ -577,7 +578,8 @@ func _internal_requestPasskeyLoginData(network: Network, apiId: Int32, apiHash:
switch result {
case let .passkeyLoginOptions(options):
switch options {
case let .dataJSON(data):
case let .dataJSON(dataJSONData):
let data = dataJSONData.data
return data
}
}

View file

@ -108,17 +108,21 @@ func telegramMediaFileAttributesFromApiAttributes(_ attributes: [Api.DocumentAtt
var result: [TelegramMediaFileAttribute] = []
for attribute in attributes {
switch attribute {
case let .documentAttributeFilename(fileName):
case let .documentAttributeFilename(documentAttributeFilenameData):
let fileName = documentAttributeFilenameData.fileName
result.append(.FileName(fileName: fileName))
case let .documentAttributeSticker(_, alt, stickerSet, maskCoords):
case let .documentAttributeSticker(documentAttributeStickerData):
let (alt, stickerSet, maskCoords) = (documentAttributeStickerData.alt, documentAttributeStickerData.stickerset, documentAttributeStickerData.maskCoords)
result.append(.Sticker(displayText: alt, packReference: StickerPackReference(apiInputSet: stickerSet), maskData: maskCoords.flatMap(StickerMaskCoords.init)))
case .documentAttributeHasStickers:
result.append(.HasLinkedStickers)
case let .documentAttributeImageSize(w, h):
case let .documentAttributeImageSize(documentAttributeImageSizeData):
let (w, h) = (documentAttributeImageSizeData.w, documentAttributeImageSizeData.h)
result.append(.ImageSize(size: PixelDimensions(width: w, height: h)))
case .documentAttributeAnimated:
result.append(.Animated)
case let .documentAttributeVideo(flags, duration, w, h, preloadSize, videoStart, videoCodec):
case let .documentAttributeVideo(documentAttributeVideoData):
let (flags, duration, w, h, preloadSize, videoStart, videoCodec) = (documentAttributeVideoData.flags, documentAttributeVideoData.duration, documentAttributeVideoData.w, documentAttributeVideoData.h, documentAttributeVideoData.preloadPrefixSize, documentAttributeVideoData.videoStartTs, documentAttributeVideoData.videoCodec)
var videoFlags = TelegramMediaVideoFlags()
if (flags & (1 << 0)) != 0 {
videoFlags.insert(.instantRoundVideo)
@ -130,11 +134,13 @@ func telegramMediaFileAttributesFromApiAttributes(_ attributes: [Api.DocumentAtt
videoFlags.insert(.isSilent)
}
result.append(.Video(duration: Double(duration), size: PixelDimensions(width: w, height: h), flags: videoFlags, preloadSize: preloadSize, coverTime: videoStart, videoCodec: videoCodec))
case let .documentAttributeAudio(flags, duration, title, performer, waveform):
case let .documentAttributeAudio(documentAttributeAudioData):
let (flags, duration, title, performer, waveform) = (documentAttributeAudioData.flags, documentAttributeAudioData.duration, documentAttributeAudioData.title, documentAttributeAudioData.performer, documentAttributeAudioData.waveform)
let isVoice = (flags & (1 << 10)) != 0
let waveformBuffer: Data? = waveform?.makeData()
result.append(.Audio(isVoice: isVoice, duration: Int(duration), title: title, performer: performer, waveform: waveformBuffer))
case let .documentAttributeCustomEmoji(flags, alt, stickerSet):
case let .documentAttributeCustomEmoji(documentAttributeCustomEmojiData):
let (flags, alt, stickerSet) = (documentAttributeCustomEmojiData.flags, documentAttributeCustomEmojiData.alt, documentAttributeCustomEmojiData.stickerset)
let isFree = (flags & (1 << 0)) != 0
let isSingleColor = (flags & (1 << 1)) != 0
result.append(.CustomEmoji(isPremium: !isFree, isSingleColor: isSingleColor, alt: alt, packReference: StickerPackReference(apiInputSet: stickerSet)))
@ -179,7 +185,8 @@ func telegramMediaFileThumbnailRepresentationsFromApiSizes(datacenterId: Int32,
func telegramMediaFileFromApiDocument(_ document: Api.Document, altDocuments: [Api.Document]?, videoCover: Api.Photo? = nil) -> TelegramMediaFile? {
switch document {
case let .document(_, id, accessHash, fileReference, _, mimeType, size, thumbs, videoThumbs, dcId, attributes):
case let .document(documentData):
let (id, accessHash, fileReference, mimeType, size, thumbs, videoThumbs, dcId, attributes) = (documentData.id, documentData.accessHash, documentData.fileReference, documentData.mimeType, documentData.size, documentData.thumbs, documentData.videoThumbs, documentData.dcId, documentData.attributes)
var parsedAttributes = telegramMediaFileAttributesFromApiAttributes(attributes)
var isSticker = false
var isAnimated = false

View file

@ -787,7 +787,7 @@ public func sendLoginEmailCode(account: UnauthorizedAccount, email: String) -> S
if let state = transaction.getState() as? UnauthorizedAccountState {
switch state.contents {
case let .confirmationCodeEntry(phoneNumber, _, phoneCodeHash, _, _, syncContacts, _, _):
return account.network.request(Api.functions.account.sendVerifyEmailCode(purpose: .emailVerifyPurposeLoginSetup(phoneNumber: phoneNumber, phoneCodeHash: phoneCodeHash), email: email), automaticFloodWait: false)
return account.network.request(Api.functions.account.sendVerifyEmailCode(purpose: .emailVerifyPurposeLoginSetup(.init(phoneNumber: phoneNumber, phoneCodeHash: phoneCodeHash)), email: email), automaticFloodWait: false)
|> `catch` { error -> Signal<Api.account.SentEmailCode, AuthorizationSendEmailCodeError> in
let errorDescription = error.errorDescription ?? ""
if errorDescription.hasPrefix("FLOOD_WAIT") {
@ -832,11 +832,11 @@ public func verifyLoginEmailChange(account: Account, code: AuthorizationCode.Ema
let verification: Api.EmailVerification
switch code {
case let .emailCode(code):
verification = .emailVerificationCode(code: code)
verification = .emailVerificationCode(.init(code: code))
case let .appleToken(token):
verification = .emailVerificationApple(token: token)
verification = .emailVerificationApple(.init(token: token))
case let .googleToken(token):
verification = .emailVerificationGoogle(token: token)
verification = .emailVerificationGoogle(.init(token: token))
}
return account.network.request(Api.functions.account.verifyEmail(purpose: .emailVerifyPurposeLoginChange, verification: verification), automaticFloodWait: false)
@ -869,14 +869,14 @@ public func verifyLoginEmailSetup(account: UnauthorizedAccount, code: Authorizat
let verification: Api.EmailVerification
switch code {
case let .emailCode(code):
verification = .emailVerificationCode(code: code)
verification = .emailVerificationCode(.init(code: code))
case let .appleToken(token):
verification = .emailVerificationApple(token: token)
verification = .emailVerificationApple(.init(token: token))
case let .googleToken(token):
verification = .emailVerificationGoogle(token: token)
verification = .emailVerificationGoogle(.init(token: token))
}
return account.network.request(Api.functions.account.verifyEmail(purpose: .emailVerifyPurposeLoginSetup(phoneNumber: phoneNumber, phoneCodeHash: phoneCodeHash), verification: verification), automaticFloodWait: false)
return account.network.request(Api.functions.account.verifyEmail(purpose: .emailVerifyPurposeLoginSetup(.init(phoneNumber: phoneNumber, phoneCodeHash: phoneCodeHash)), verification: verification), automaticFloodWait: false)
|> `catch` { error -> Signal<Api.account.EmailVerified, AuthorizationEmailVerificationError> in
let errorDescription = error.errorDescription ?? ""
if errorDescription.hasPrefix("FLOOD_WAIT") {
@ -1012,11 +1012,11 @@ public func authorizeWithCode(accountManager: AccountManager<TelegramAccountMana
flags = 1 << 1
switch verification {
case let .emailCode(code):
emailVerification = .emailVerificationCode(code: code)
emailVerification = .emailVerificationCode(.init(code: code))
case let .appleToken(token):
emailVerification = .emailVerificationApple(token: token)
emailVerification = .emailVerificationApple(.init(token: token))
case let .googleToken(token):
emailVerification = .emailVerificationGoogle(token: token)
emailVerification = .emailVerificationGoogle(.init(token: token))
}
}
@ -1215,7 +1215,7 @@ public func authorizeWithPasskey(accountManager: AccountManager<TelegramAccountM
if foreignDatacenter != nil {
flags |= 1 << 0
}
return account.network.request(Api.functions.auth.finishPasskeyLogin(flags: flags, credential: .inputPasskeyCredentialPublicKey(id: passkey.id, rawId: passkey.id, response: .inputPasskeyResponseLogin(clientData: .dataJSON(data: passkey.clientData), authenticatorData: Buffer(data: passkey.authenticatorData), signature: Buffer(data: passkey.signature), userHandle: passkey.userHandle)), fromDcId: (foreignDatacenter?.id).flatMap(Int32.init), fromAuthKeyId: foreignDatacenter?.authKeyId), automaticFloodWait: false)
return account.network.request(Api.functions.auth.finishPasskeyLogin(flags: flags, credential: .inputPasskeyCredentialPublicKey(id: passkey.id, rawId: passkey.id, response: .inputPasskeyResponseLogin(clientData: .dataJSON(.init(data: passkey.clientData)), authenticatorData: Buffer(data: passkey.authenticatorData), signature: Buffer(data: passkey.signature), userHandle: passkey.userHandle)), fromDcId: (foreignDatacenter?.id).flatMap(Int32.init), fromAuthKeyId: foreignDatacenter?.authKeyId), automaticFloodWait: false)
|> map { authorization in
return .authorization(authorization)
}

View file

@ -727,9 +727,9 @@ func inputDocumentAttributesFromFileAttributes(_ fileAttributes: [TelegramMediaF
case .Animated:
attributes.append(.documentAttributeAnimated)
case let .FileName(fileName):
attributes.append(.documentAttributeFilename(fileName: fileName))
attributes.append(.documentAttributeFilename(.init(fileName: fileName)))
case let .ImageSize(size):
attributes.append(.documentAttributeImageSize(w: Int32(size.width), h: Int32(size.height)))
attributes.append(.documentAttributeImageSize(.init(w: Int32(size.width), h: Int32(size.height))))
case let .Sticker(displayText, packReference, maskCoords):
var stickerSet: Api.InputStickerSet = .inputStickerSetEmpty
var flags: Int32 = 0
@ -748,7 +748,7 @@ func inputDocumentAttributesFromFileAttributes(_ fileAttributes: [TelegramMediaF
flags |= 1 << 0
inputMaskCoords = .maskCoords(n: maskCoords.n, x: maskCoords.x, y: maskCoords.y, zoom: maskCoords.zoom)
}
attributes.append(.documentAttributeSticker(flags: flags, alt: displayText, stickerset: stickerSet, maskCoords: inputMaskCoords))
attributes.append(.documentAttributeSticker(.init(flags: flags, alt: displayText, stickerset: stickerSet, maskCoords: inputMaskCoords)))
case .HasLinkedStickers:
attributes.append(.documentAttributeHasStickers)
case let .Video(duration, size, videoFlags, preloadSize, coverTime, videoCodec):
@ -771,7 +771,7 @@ func inputDocumentAttributesFromFileAttributes(_ fileAttributes: [TelegramMediaF
if videoCodec != nil {
flags |= (1 << 5)
}
attributes.append(.documentAttributeVideo(flags: flags, duration: duration, w: Int32(size.width), h: Int32(size.height), preloadPrefixSize: preloadSize, videoStartTs: coverTime, videoCodec: videoCodec))
attributes.append(.documentAttributeVideo(.init(flags: flags, duration: duration, w: Int32(size.width), h: Int32(size.height), preloadPrefixSize: preloadSize, videoStartTs: coverTime, videoCodec: videoCodec)))
case let .Audio(isVoice, duration, title, performer, waveform):
var flags: Int32 = 0
if isVoice {
@ -788,7 +788,7 @@ func inputDocumentAttributesFromFileAttributes(_ fileAttributes: [TelegramMediaF
flags |= Int32(1 << 2)
waveformBuffer = Buffer(data: waveform)
}
attributes.append(.documentAttributeAudio(flags: flags, duration: Int32(duration), title: title, performer: performer, waveform: waveformBuffer))
attributes.append(.documentAttributeAudio(.init(flags: flags, duration: Int32(duration), title: title, performer: performer, waveform: waveformBuffer)))
case .hintFileIsLarge:
break
case .hintIsValidated:

View file

@ -337,7 +337,8 @@ extension TelegramDisallowedGifts {
init(apiDisallowedGifts: Api.DisallowedGiftsSettings?) {
var disallowedGifts: TelegramDisallowedGifts = []
switch apiDisallowedGifts {
case let .disallowedGiftsSettings(giftFlags):
case let .disallowedGiftsSettings(disallowedGiftsSettingsData):
let giftFlags = disallowedGiftsSettingsData.flags
if (giftFlags & (1 << 0)) != 0 {
disallowedGifts.insert(.unlimited)
}

View file

@ -9,7 +9,8 @@ extension UnauthorizedAccountTermsOfService {
case let .termsOfService(_, id, text, entities, minAgeConfirm):
let idData: String
switch id {
case let .dataJSON(data):
case let .dataJSON(dataJSONData):
let data = dataJSONData.data
idData = data
}
self.init(id: idData, text: text, entities: messageTextEntitiesFromApiEntities(entities), ageConfirmation: minAgeConfirm)

View file

@ -1224,7 +1224,8 @@ private func finalStateWithUpdatesAndServerTime(accountPeerId: PeerId, postbox:
updatedState.readThread(peerId: PeerId(namespace: Namespaces.Peer.CloudChannel, id: PeerId.Id._internalFromInt64Value(channelId)), threadId: savedPeerId.peerId.toInt64(), readMaxId: readMaxId, isIncoming: false, mainChannelMessage: nil)
case let .updateDialogUnreadMark(flags, peer, savedPeerId):
switch peer {
case let .dialogPeer(peer):
case let .dialogPeer(dialogPeerData):
let peer = dialogPeerData.peer
let peerId = peer.peerId
if let savedPeerId {
updatedState.updatePeerChatUnreadMark(peerId, threadId: savedPeerId.peerId.toInt64(), namespace: Namespaces.Message.Cloud, value: (flags & (1 << 0)) != 0)
@ -1507,7 +1508,8 @@ private func finalStateWithUpdatesAndServerTime(accountPeerId: PeerId, postbox:
let groupId: PeerGroupId = folderId.flatMap(PeerGroupId.init(rawValue:)) ?? .root
let item: PinnedItemId
switch peer {
case let .dialogPeer(peer):
case let .dialogPeer(dialogPeerData):
let peer = dialogPeerData.peer
item = .peer(peer.peerId)
case .dialogPeerFolder:
preconditionFailure()
@ -1523,7 +1525,8 @@ private func finalStateWithUpdatesAndServerTime(accountPeerId: PeerId, postbox:
updatedState.addUpdatePinnedItemIds(groupId: groupId, operation: .reorder(order.map {
let item: PinnedItemId
switch $0 {
case let .dialogPeer(peer):
case let .dialogPeer(dialogPeerData):
let peer = dialogPeerData.peer
item = .peer(peer.peerId)
case .dialogPeerFolder:
preconditionFailure()
@ -1534,7 +1537,8 @@ private func finalStateWithUpdatesAndServerTime(accountPeerId: PeerId, postbox:
updatedState.addUpdatePinnedItemIds(groupId: groupId, operation: .sync)
}
case let .updateSavedDialogPinned(flags, peer):
if case let .dialogPeer(peer) = peer {
if case let .dialogPeer(dialogPeerData) = peer {
let peer = dialogPeerData.peer
if (flags & (1 << 0)) != 0 {
updatedState.addUpdatePinnedSavedItemIds(operation: .pin(.peer(peer.peerId)))
} else {
@ -1545,7 +1549,8 @@ private func finalStateWithUpdatesAndServerTime(accountPeerId: PeerId, postbox:
if let order = order {
updatedState.addUpdatePinnedSavedItemIds(operation: .reorder(order.compactMap {
switch $0 {
case let .dialogPeer(peer):
case let .dialogPeer(dialogPeerData):
let peer = dialogPeerData.peer
return .peer(peer.peerId)
case .dialogPeerFolder:
return nil
@ -1602,7 +1607,8 @@ private func finalStateWithUpdatesAndServerTime(accountPeerId: PeerId, postbox:
switch draft {
case .draftMessageEmpty:
inputState = nil
case let .draftMessage(_, replyToMsgHeader, message, entities, media, date, messageEffectId, suggestedPost):
case let .draftMessage(draftMessageData):
let (replyToMsgHeader, message, entities, media, date, messageEffectId, suggestedPost) = (draftMessageData.replyTo, draftMessageData.message, draftMessageData.entities, draftMessageData.media, draftMessageData.date, draftMessageData.effect, draftMessageData.suggestedPost)
let _ = media
var replySubject: EngineMessageReplySubject?
var parsedSuggestedPost: SynchronizeableChatInputState.SuggestedPost?
@ -2859,7 +2865,8 @@ private func resolveMissingPeerChatInfos(accountPeerId: PeerId, network: Network
for dialog in dialogs {
switch dialog {
case let .dialog(_, peer, topMessage, readInboxMaxId, readOutboxMaxId, unreadCount, unreadMentionsCount, unreadReactionsCount, notifySettings, pts, _, folderId, ttlPeriod):
case let .dialog(dialogData):
let (peer, topMessage, readInboxMaxId, readOutboxMaxId, unreadCount, unreadMentionsCount, unreadReactionsCount, notifySettings, pts, folderId, ttlPeriod) = (dialogData.peer, dialogData.topMessage, dialogData.readInboxMaxId, dialogData.readOutboxMaxId, dialogData.unreadCount, dialogData.unreadMentionsCount, dialogData.unreadReactionsCount, dialogData.notifySettings, dialogData.pts, dialogData.folderId, dialogData.ttlPeriod)
let peerId = peer.peerId
updatedState.setNeedsHoleFromPreviousState(peerId: peerId, namespace: Namespaces.Message.Cloud, validateChannelPts: pts)
@ -3114,7 +3121,8 @@ func resetChannels(accountPeerId: PeerId, postbox: Postbox, network: Network, pe
let groupId: PeerGroupId
let apiTtlPeriod: Int32?
switch dialog {
case let .dialog(flags, peer, topMessage, readInboxMaxId, readOutboxMaxId, unreadCount, unreadMentionsCount, unreadReactionsCount, peerNotificationSettings, pts, _, folderId, ttlPeriod):
case let .dialog(dialogData):
let (flags, peer, topMessage, readInboxMaxId, readOutboxMaxId, unreadCount, unreadMentionsCount, unreadReactionsCount, peerNotificationSettings, pts, folderId, ttlPeriod) = (dialogData.flags, dialogData.peer, dialogData.topMessage, dialogData.readInboxMaxId, dialogData.readOutboxMaxId, dialogData.unreadCount, dialogData.unreadMentionsCount, dialogData.unreadReactionsCount, dialogData.notifySettings, dialogData.pts, dialogData.folderId, dialogData.ttlPeriod)
apiPeer = peer
apiTopMessage = topMessage
apiReadInboxMaxId = readInboxMaxId
@ -3450,7 +3458,8 @@ private func pollChannel(accountPeerId: PeerId, postbox: Postbox, network: Netwo
var parameters: (peer: Api.Peer, pts: Int32, topMessage: Int32, readInboxMaxId: Int32, readOutboxMaxId: Int32, unreadCount: Int32, unreadMentionsCount: Int32, unreadReactionsCount: Int32, ttlPeriod: Int32?)?
switch dialog {
case let .dialog(_, peer, topMessage, readInboxMaxId, readOutboxMaxId, unreadCount, unreadMentionsCount, unreadReactionsCount, _, pts, _, _, ttlPeriod):
case let .dialog(dialogData):
let (peer, topMessage, readInboxMaxId, readOutboxMaxId, unreadCount, unreadMentionsCount, unreadReactionsCount, pts, ttlPeriod) = (dialogData.peer, dialogData.topMessage, dialogData.readInboxMaxId, dialogData.readOutboxMaxId, dialogData.unreadCount, dialogData.unreadMentionsCount, dialogData.unreadReactionsCount, dialogData.pts, dialogData.ttlPeriod)
if let pts = pts {
parameters = (peer, pts, topMessage, readInboxMaxId, readOutboxMaxId, unreadCount, unreadMentionsCount, unreadReactionsCount, ttlPeriod)
}

View file

@ -1206,13 +1206,14 @@ private final class CallSessionManagerContext {
switch customParameters {
case .none:
break
case let .dataJSON(data):
case let .dataJSON(dataJSONData):
let data = dataJSONData.data
customParametersValue = data
}
let isVideoPossible = self.videoVersions().contains(where: { versions.contains($0) })
context.isVideoPossible = isVideoPossible
context.state = .active(id: id, accessHash: accessHash, beginTimestamp: startDate, key: key, keyId: calculatedKeyId, keyVisualHash: keyVisualHash, connections: parseConnectionSet(primary: connections.first!, alternative: Array(connections[1...])), maxLayer: maxLayer, version: versions[0], customParameters: customParametersValue, allowsP2P: allowsP2P, supportsConferenceCalls: supportsConferenceCalls)
self.contextUpdated(internalId: internalId)
} else {
@ -1233,13 +1234,14 @@ private final class CallSessionManagerContext {
switch customParameters {
case .none:
break
case let .dataJSON(data):
case let .dataJSON(dataJSONData):
let data = dataJSONData.data
customParametersValue = data
}
let isVideoPossible = self.videoVersions().contains(where: { versions.contains($0) })
context.isVideoPossible = isVideoPossible
context.state = .active(id: id, accessHash: accessHash, beginTimestamp: startDate, key: key, keyId: keyId, keyVisualHash: keyVisualHash, connections: parseConnectionSet(primary: connections.first!, alternative: Array(connections[1...])), maxLayer: maxLayer, version: versions[0], customParameters: customParametersValue, allowsP2P: allowsP2P, supportsConferenceCalls: supportsConferenceCalls)
self.contextUpdated(internalId: internalId)
} else {
@ -1624,10 +1626,11 @@ private func acceptCallSession(accountPeerId: PeerId, postbox: Postbox, network:
switch customParameters {
case .none:
break
case let .dataJSON(data):
case let .dataJSON(dataJSONData):
let data = dataJSONData.data
customParametersValue = data
}
return .success(.call(config: config, gA: gAOrB.makeData(), timestamp: startDate, connections: parseConnectionSet(primary: connections.first!, alternative: Array(connections[1...])), maxLayer: maxLayer, version: versions[0], customParameters: customParametersValue, allowsP2P: (flags & (1 << 5)) != 0, supportsConferenceCalls: (flags & (1 << 8)) != 0))
} else {
return .failed

View file

@ -405,7 +405,8 @@ private func updateContactPresences(postbox: Postbox, network: Network, accountP
var peerPresences: [PeerId: PeerPresence] = [:]
for status in statuses {
switch status {
case let .contactStatus(userId, status):
case let .contactStatus(contactStatusData):
let (userId, status) = (contactStatusData.userId, contactStatusData.status)
peerPresences[PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt64Value(userId))] = TelegramUserPresence(apiStatus: status)
}
}

View file

@ -164,21 +164,24 @@ func managedSynchronizeEmojiSearchCategories(postbox: Postbox, network: Network,
hash: hash,
groups: groups.compactMap { item -> EmojiSearchCategories.Group? in
switch item {
case let .emojiGroup(title, iconEmojiId, emoticons):
case let .emojiGroup(emojiGroupData):
let (title, iconEmojiId, emoticons) = (emojiGroupData.title, emojiGroupData.iconEmojiId, emojiGroupData.emoticons)
return EmojiSearchCategories.Group(
id: iconEmojiId,
title: title,
identifiers: emoticons,
kind: .generic
)
case let .emojiGroupGreeting(title, iconEmojiId, emoticons):
case let .emojiGroupGreeting(emojiGroupGreetingData):
let (title, iconEmojiId, emoticons) = (emojiGroupGreetingData.title, emojiGroupGreetingData.iconEmojiId, emojiGroupGreetingData.emoticons)
return EmojiSearchCategories.Group(
id: iconEmojiId,
title: title,
identifiers: emoticons,
kind: .greeting
)
case let .emojiGroupPremium(title, iconEmojiId):
case let .emojiGroupPremium(emojiGroupPremiumData):
let (title, iconEmojiId) = (emojiGroupPremiumData.title, emojiGroupPremiumData.iconEmojiId)
return EmojiSearchCategories.Group(
id: iconEmojiId,
title: title,

View file

@ -77,7 +77,8 @@ private func parseDialogs(accountPeerId: PeerId, apiDialogs: [Api.Dialog], apiMe
var apiChannelPts: Int32?
let apiNotificationSettings: Api.PeerNotifySettings
switch dialog {
case let .dialog(flags, peer, topMessage, readInboxMaxId, readOutboxMaxId, unreadCount, unreadMentionsCount, unreadReactionsCount, peerNotificationSettings, pts, _, _, ttlPeriod):
case let .dialog(dialogData):
let (flags, peer, topMessage, readInboxMaxId, readOutboxMaxId, unreadCount, unreadMentionsCount, unreadReactionsCount, peerNotificationSettings, pts, ttlPeriod) = (dialogData.flags, dialogData.peer, dialogData.topMessage, dialogData.readInboxMaxId, dialogData.readOutboxMaxId, dialogData.unreadCount, dialogData.unreadMentionsCount, dialogData.unreadReactionsCount, dialogData.notifySettings, dialogData.pts, dialogData.ttlPeriod)
if let peer = peers.get(peer.peerId) {
var isExluded = false
if let group = peer as? TelegramGroup {
@ -133,7 +134,8 @@ private func parseDialogs(accountPeerId: PeerId, apiDialogs: [Api.Dialog], apiMe
}
notificationSettings[peerId] = TelegramPeerNotificationSettings(apiSettings: apiNotificationSettings)
case let .dialogFolder(_, folder, _, _, unreadMutedPeersCount, _, unreadMutedMessagesCount, _):
case let .dialogFolder(dialogFolderData):
let (folder, unreadMutedPeersCount, unreadMutedMessagesCount) = (dialogFolderData.folder, dialogFolderData.unreadMutedPeersCount, dialogFolderData.unreadMutedMessagesCount)
switch folder {
case let .folder(_, id, _, _):
referencedFolders[PeerGroupId(rawValue: id)] = PeerGroupUnreadCountersSummary(all: PeerGroupUnreadCounters(messageCount: unreadMutedMessagesCount, chatCount: unreadMutedPeersCount))

View file

@ -19,7 +19,8 @@ func managedConfigurationUpdates(accountManager: AccountManager<TelegramAccountM
var addressList: [Int: [MTDatacenterAddress]] = [:]
for option in dcOptions {
switch option {
case let .dcOption(flags, id, ipAddress, port, secret):
case let .dcOption(dcOptionData):
let (flags, id, ipAddress, port, secret) = (dcOptionData.flags, dcOptionData.id, dcOptionData.ipAddress, dcOptionData.port, dcOptionData.secret)
let preferForMedia = (flags & (1 << 1)) != 0
if addressList[Int(id)] == nil {
addressList[Int(id)] = []
@ -78,7 +79,8 @@ func managedConfigurationUpdates(accountManager: AccountManager<TelegramAccountM
let messageAutoremoveSeconds: Int32?
switch defaultHistoryTtl {
case let .defaultHistoryTTL(period):
case let .defaultHistoryTTL(defaultHistoryTTLData):
let period = defaultHistoryTTLData.period
if period != 0 {
messageAutoremoveSeconds = period
} else {

View file

@ -399,7 +399,8 @@ private func synchronizeUnseenPersonalMentionsTag(postbox: Postbox, network: Net
let apiTopMessage: Int32
let apiUnreadMentionsCount: Int32
switch dialog {
case let .dialog(_, _, topMessage, _, _, _, unreadMentionsCount, _, _, _, _, _, _):
case let .dialog(dialogData):
let (topMessage, unreadMentionsCount) = (dialogData.topMessage, dialogData.unreadMentionsCount)
apiTopMessage = topMessage
apiUnreadMentionsCount = unreadMentionsCount
@ -441,7 +442,8 @@ private func synchronizeUnseenReactionsTag(postbox: Postbox, network: Network, e
let apiTopMessage: Int32
let apiUnreadReactionsCount: Int32
switch dialog {
case let .dialog(_, _, topMessage, _, _, _, _, unreadReactionsCount, _, _, _, _, _):
case let .dialog(dialogData):
let (topMessage, unreadReactionsCount) = (dialogData.topMessage, dialogData.unreadReactionsCount)
apiTopMessage = topMessage
apiUnreadReactionsCount = unreadReactionsCount

View file

@ -132,7 +132,7 @@ private func actionFromActivity(_ activity: PeerInputActivity?) -> Api.SendMessa
case .choosingSticker:
return .sendMessageChooseStickerAction
case let .interactingWithEmoji(emoticon, messageId, interaction):
return .sendMessageEmojiInteraction(emoticon: emoticon, msgId: messageId.id, interaction: interaction?.apiDataJson ?? .dataJSON(data: ""))
return .sendMessageEmojiInteraction(emoticon: emoticon, msgId: messageId.id, interaction: interaction?.apiDataJson ?? .dataJSON(.init(data: "")))
case let .seeingEmojiInteraction(emoticon):
return .sendMessageEmojiInteractionSeen(emoticon: emoticon)
}

View file

@ -395,7 +395,8 @@ func managedProfilePhotoEmoji(postbox: Postbox, network: Network) -> Signal<Void
switch result {
case .emojiListNotModified:
return .single(nil)
case let .emojiList(_, documentIds):
case let .emojiList(emojiListData):
let documentIds = emojiListData.documentId
return _internal_resolveInlineStickers(postbox: postbox, network: network, fileIds: documentIds)
|> map { files -> [OrderedItemListEntry] in
var items: [OrderedItemListEntry] = []
@ -426,7 +427,8 @@ func managedGroupPhotoEmoji(postbox: Postbox, network: Network) -> Signal<Void,
switch result {
case .emojiListNotModified:
return .single(nil)
case let .emojiList(_, documentIds):
case let .emojiList(emojiListData):
let documentIds = emojiListData.documentId
return _internal_resolveInlineStickers(postbox: postbox, network: network, fileIds: documentIds)
|> map { files -> [OrderedItemListEntry] in
var items: [OrderedItemListEntry] = []
@ -457,7 +459,8 @@ func managedBackgroundIconEmoji(postbox: Postbox, network: Network) -> Signal<Vo
switch result {
case .emojiListNotModified:
return .single(nil)
case let .emojiList(_, documentIds):
case let .emojiList(emojiListData):
let documentIds = emojiListData.documentId
return _internal_resolveInlineStickers(postbox: postbox, network: network, fileIds: documentIds)
|> map { files -> [OrderedItemListEntry] in
var items: [OrderedItemListEntry] = []
@ -488,7 +491,8 @@ func managedDisabledChannelStatusIconEmoji(postbox: Postbox, network: Network) -
switch result {
case .emojiListNotModified:
return .single(nil)
case let .emojiList(_, documentIds):
case let .emojiList(emojiListData):
let documentIds = emojiListData.documentId
return _internal_resolveInlineStickers(postbox: postbox, network: network, fileIds: documentIds)
|> map { files -> [OrderedItemListEntry] in
var items: [OrderedItemListEntry] = []

View file

@ -123,18 +123,21 @@ private func synchronizeEmojiKeywords(postbox: Postbox, transaction: Transaction
|> retryRequest
|> mapToSignal { result -> Signal<Void, NoError> in
switch result {
case let .emojiKeywordsDifference(langCode, _, version, keywords):
case let .emojiKeywordsDifference(emojiKeywordsDifferenceData):
let (langCode, version, keywords) = (emojiKeywordsDifferenceData.langCode, emojiKeywordsDifferenceData.version, emojiKeywordsDifferenceData.keywords)
if langCode == languageCode {
var itemsToAppend: [String: EmojiKeywordItem] = [:]
var itemsToSubtract: [String: EmojiKeywordItem] = [:]
for apiEmojiKeyword in keywords {
switch apiEmojiKeyword {
case let .emojiKeyword(keyword, emoticons):
let keyword = keyword.replacingOccurrences(of: " ", with: "")
case let .emojiKeyword(emojiKeywordData):
let (rawKeyword, emoticons) = (emojiKeywordData.keyword, emojiKeywordData.emoticons)
let keyword = rawKeyword.replacingOccurrences(of: " ", with: "")
let indexKeys = stringIndexTokens(keyword, transliteration: .none).map { $0.toMemoryBuffer() }
let item = EmojiKeywordItem(index: ItemCollectionItemIndex(index: 0, id: 0), collectionId: collectionId.id, keyword: keyword, emoticons: emoticons, indexKeys: indexKeys)
itemsToAppend[keyword] = item
case let .emojiKeywordDeleted(keyword, emoticons):
case let .emojiKeywordDeleted(emojiKeywordDeletedData):
let (keyword, emoticons) = (emojiKeywordDeletedData.keyword, emojiKeywordDeletedData.emoticons)
let item = EmojiKeywordItem(index: ItemCollectionItemIndex(index: 0, id: 0), collectionId: collectionId.id, keyword: keyword, emoticons: emoticons, indexKeys: [])
itemsToSubtract[keyword] = item
}
@ -195,11 +198,13 @@ private func synchronizeEmojiKeywords(postbox: Postbox, transaction: Transaction
|> retryRequest
|> mapToSignal { result -> Signal<Void, NoError> in
switch result {
case let .emojiKeywordsDifference(langCode, _, version, keywords):
case let .emojiKeywordsDifference(emojiKeywordsDifferenceData):
let (langCode, version, keywords) = (emojiKeywordsDifferenceData.langCode, emojiKeywordsDifferenceData.version, emojiKeywordsDifferenceData.keywords)
var items: [EmojiKeywordItem] = []
var index: Int32 = 0
for apiEmojiKeyword in keywords {
if case let .emojiKeyword(fullKeyword, emoticons) = apiEmojiKeyword, !emoticons.isEmpty {
if case let .emojiKeyword(emojiKeywordData) = apiEmojiKeyword, !emojiKeywordData.emoticons.isEmpty {
let (fullKeyword, emoticons) = (emojiKeywordData.keyword, emojiKeywordData.emoticons)
let keyword = fullKeyword
let indexKeys = stringIndexTokens(keyword, transliteration: .none).map { $0.toMemoryBuffer() }
let item = EmojiKeywordItem(index: ItemCollectionItemIndex(index: index, id: keywordCollectionItemId(keyword, inputLanguageCode: operation.inputLanguageCode)), collectionId: collectionId.id, keyword: keyword, emoticons: emoticons, indexKeys: indexKeys)

View file

@ -91,7 +91,8 @@ private func synchronizeGroupMessageStats(postbox: Postbox, network: Network, gr
case let .peerDialogs(dialogs, _, _, _, _):
for dialog in dialogs {
switch dialog {
case let .dialogFolder(_, _, _, _, unreadMutedPeersCount, _, unreadMutedMessagesCount, _):
case let .dialogFolder(dialogFolderData):
let (unreadMutedPeersCount, unreadMutedMessagesCount) = (dialogFolderData.unreadMutedPeersCount, dialogFolderData.unreadMutedMessagesCount)
transaction.resetPeerGroupSummary(groupId: groupId, namespace: namespace, summary: PeerGroupUnreadCountersSummary(all: PeerGroupUnreadCounters(messageCount: unreadMutedMessagesCount, chatCount: unreadMutedPeersCount)))
case .dialog:
assertionFailure()

View file

@ -160,7 +160,8 @@ private func synchronizePinnedChats(transaction: Transaction, postbox: Postbox,
let apiTtlPeriod: Int32?
let apiNotificationSettings: Api.PeerNotifySettings
switch dialog {
case let .dialog(flags, peer, topMessage, readInboxMaxId, readOutboxMaxId, unreadCount, _, _, peerNotificationSettings, pts, _, _, ttlPeriod):
case let .dialog(dialogData):
let (flags, peer, topMessage, readInboxMaxId, readOutboxMaxId, unreadCount, peerNotificationSettings, pts, ttlPeriod) = (dialogData.flags, dialogData.peer, dialogData.topMessage, dialogData.readInboxMaxId, dialogData.readOutboxMaxId, dialogData.unreadCount, dialogData.notifySettings, dialogData.pts, dialogData.ttlPeriod)
apiPeer = peer
apiTopMessage = topMessage
apiReadInboxMaxId = readInboxMaxId

View file

@ -11,7 +11,8 @@ func managedVoipConfigurationUpdates(postbox: Postbox, network: Network) -> Sign
|> mapToSignal { result -> Signal<Void, NoError> in
return postbox.transaction { transaction -> Void in
switch result {
case let .dataJSON(data):
case let .dataJSON(dataJSONData):
let data = dataJSONData.data
updateVoipConfiguration(transaction: transaction, { configuration in
var configuration = configuration
configuration.serializedData = data

View file

@ -20,28 +20,33 @@ public struct EmojiInteraction: Equatable {
}
public init?(apiDataJson: Api.DataJSON) {
if case let .dataJSON(string) = apiDataJson, let data = string.data(using: .utf8) {
do {
let decodedData = try JSONSerialization.jsonObject(with: data, options: [])
guard let item = decodedData as? [String: Any] else {
return nil
}
guard let version = item["v"] as? Int, version == 1 else {
return nil
}
guard let animationsArray = item["a"] as? [Any] else {
return nil
}
var animations: [EmojiInteraction.Animation] = []
for animationDict in animationsArray {
if let animationDict = animationDict as? [String: Any] {
if let index = animationDict["i"] as? Int, let timeOffset = animationDict["t"] as? Double {
animations.append(EmojiInteraction.Animation(index: index, timeOffset: Float(timeOffset)))
if case let .dataJSON(dataJSONData) = apiDataJson {
let string = dataJSONData.data
if let data = string.data(using: .utf8) {
do {
let decodedData = try JSONSerialization.jsonObject(with: data, options: [])
guard let item = decodedData as? [String: Any] else {
return nil
}
guard let version = item["v"] as? Int, version == 1 else {
return nil
}
guard let animationsArray = item["a"] as? [Any] else {
return nil
}
var animations: [EmojiInteraction.Animation] = []
for animationDict in animationsArray {
if let animationDict = animationDict as? [String: Any] {
if let index = animationDict["i"] as? Int, let timeOffset = animationDict["t"] as? Double {
animations.append(EmojiInteraction.Animation(index: index, timeOffset: Float(timeOffset)))
}
}
}
self.animations = animations
} catch {
return nil
}
self.animations = animations
} catch {
} else {
return nil
}
} else {
@ -54,9 +59,9 @@ public struct EmojiInteraction: Equatable {
public var apiDataJson: Api.DataJSON {
let dict = ["v": 1, "a": self.animations.map({ ["i": $0.index, "t": NSDecimalNumber(value: $0.timeOffset).rounding(accordingToBehavior: roundingBehavior)] as [String : Any] })] as [String : Any]
if let data = try? JSONSerialization.data(withJSONObject: dict, options: []), let dataString = String(data: data, encoding: .utf8) {
return .dataJSON(data: dataString)
return .dataJSON(.init(data: dataString))
} else {
return .dataJSON(data: "")
return .dataJSON(.init(data: ""))
}
}
}

View file

@ -251,7 +251,8 @@ public class Serialization: NSObject, MTSerialization {
var addressDict: [NSNumber: [Any]] = [:]
for option in dcOptions {
switch option {
case let .dcOption(flags, id, ipAddress, port, secret):
case let .dcOption(dcOptionData):
let (flags, id, ipAddress, port, secret) = (dcOptionData.flags, dcOptionData.id, dcOptionData.ipAddress, dcOptionData.port, dcOptionData.secret)
if addressDict[id as NSNumber] == nil {
addressDict[id as NSNumber] = []
}

View file

@ -87,7 +87,8 @@ private func dialogReadState(network: Network, postbox: Postbox, peerId: PeerId)
let apiMarkedUnread: Bool
var apiChannelPts: Int32 = 0
switch dialog {
case let .dialog(flags, _, topMessage, readInboxMaxId, readOutboxMaxId, unreadCount, _, _, _, pts, _, _, _):
case let .dialog(dialogData):
let (flags, topMessage, readInboxMaxId, readOutboxMaxId, unreadCount, pts) = (dialogData.flags, dialogData.topMessage, dialogData.readInboxMaxId, dialogData.readOutboxMaxId, dialogData.unreadCount, dialogData.pts)
apiTopMessage = topMessage
apiReadInboxMaxId = readInboxMaxId
apiReadOutboxMaxId = readOutboxMaxId

View file

@ -24,7 +24,8 @@ private func collectPreCachedResources(for photo: Api.Photo) -> [(MediaResource,
private func collectPreCachedResources(for document: Api.Document) -> [(MediaResource, Data)]? {
switch document {
case let .document(_, id, accessHash, fileReference, _, _, _, thumbs, _, dcId, _):
case let .document(documentData):
let (id, accessHash, fileReference, thumbs, dcId) = (documentData.id, documentData.accessHash, documentData.fileReference, documentData.thumbs, documentData.dcId)
if let thumbs = thumbs {
for thumb in thumbs {
switch thumb {
@ -226,8 +227,8 @@ extension Api.Peer {
extension Api.Dialog {
var peerId: PeerId? {
switch self {
case let .dialog(_, peer, _, _, _, _, _, _, _, _, _, _, _):
return peer.peerId
case let .dialog(dialogData):
return dialogData.peer.peerId
case .dialogFolder:
return nil
}

View file

@ -1115,23 +1115,28 @@ extension StatsGraph {
init(apiStatsGraph: Api.StatsGraph) {
switch apiStatsGraph {
case let .statsGraph(_, json, zoomToken):
if case let .dataJSON(string) = json, let data = string.data(using: .utf8) {
do {
let decodedData = try JSONSerialization.jsonObject(with: data, options: [])
guard let item = decodedData as? [String: Any] else {
self = .Failed(error: "")
return
}
if let columns = item["columns"] as? [[Any]] {
if columns.isEmpty {
self = .Empty
} else {
self = .Loaded(token: zoomToken, data: string)
if case let .dataJSON(dataJSONData) = json {
let string = dataJSONData.data
if let data = string.data(using: .utf8) {
do {
let decodedData = try JSONSerialization.jsonObject(with: data, options: [])
guard let item = decodedData as? [String: Any] else {
self = .Failed(error: "")
return
}
} else {
self = .Empty
if let columns = item["columns"] as? [[Any]] {
if columns.isEmpty {
self = .Empty
} else {
self = .Loaded(token: zoomToken, data: string)
}
} else {
self = .Empty
}
} catch {
self = .Failed(error: "")
}
} catch {
} else {
self = .Failed(error: "")
}
} else {

View file

@ -559,9 +559,11 @@ public struct PeerEmojiStatus: Equatable, Codable {
extension PeerEmojiStatus {
init?(apiStatus: Api.EmojiStatus) {
switch apiStatus {
case let .emojiStatus(_, documentId, until):
case let .emojiStatus(emojiStatusData):
let (documentId, until) = (emojiStatusData.documentId, emojiStatusData.until)
self.init(content: .emoji(fileId: documentId), expirationDate: until)
case let .emojiStatusCollectible(_, collectibleId, documentId, title, slug, patternDocumentId, centerColor, edgeColor, patternColor, textColor, until):
case let .emojiStatusCollectible(emojiStatusCollectibleData):
let (collectibleId, documentId, title, slug, patternDocumentId, centerColor, edgeColor, patternColor, textColor, until) = (emojiStatusCollectibleData.collectibleId, emojiStatusCollectibleData.documentId, emojiStatusCollectibleData.title, emojiStatusCollectibleData.slug, emojiStatusCollectibleData.patternDocumentId, emojiStatusCollectibleData.centerColor, emojiStatusCollectibleData.edgeColor, emojiStatusCollectibleData.patternColor, emojiStatusCollectibleData.textColor, emojiStatusCollectibleData.until)
self.init(content: .starGift(id: collectibleId, fileId: documentId, title: title, slug: slug, patternFileId: patternDocumentId, innerColor: centerColor, outerColor: edgeColor, patternColor: patternColor, textColor: textColor), expirationDate: until)
case .emojiStatusEmpty, .inputEmojiStatusCollectible:
return nil

View file

@ -106,7 +106,7 @@ public extension TelegramEngine {
let apiEmojiStatus: Api.EmojiStatus
var emojiStatus: PeerEmojiStatus?
if let file, let patternFile, let innerColor, let outerColor, let patternColor, let textColor {
apiEmojiStatus = .inputEmojiStatusCollectible(flags: flags, collectibleId: starGift.id, until: expirationDate)
apiEmojiStatus = .inputEmojiStatusCollectible(.init(flags: flags, collectibleId: starGift.id, until: expirationDate))
emojiStatus = PeerEmojiStatus(content: .starGift(id: starGift.id, fileId: file.fileId.id, title: starGift.title, slug: starGift.slug, patternFileId: patternFile.fileId.id, innerColor: innerColor, outerColor: outerColor, patternColor: patternColor, textColor: textColor), expirationDate: expirationDate)
} else {
apiEmojiStatus = .emojiStatusEmpty
@ -143,7 +143,7 @@ public extension TelegramEngine {
if let _ = expirationDate {
flags |= (1 << 0)
}
return Api.EmojiStatus.emojiStatus(flags: flags, documentId: file.fileId.id, until: expirationDate)
return Api.EmojiStatus.emojiStatus(.init(flags: flags, documentId: file.fileId.id, until: expirationDate))
}) ?? Api.EmojiStatus.emojiStatusEmpty))
|> `catch` { _ -> Signal<Api.Bool, NoError> in
return .single(.boolFalse)

View file

@ -25,7 +25,8 @@ extension TermsOfServiceUpdate {
case let .termsOfService(_, id, text, entities, minAgeConfirm):
let idData: String
switch id {
case let .dataJSON(data):
case let .dataJSON(dataJSONData):
let data = dataJSONData.data
idData = data
}
self.init(id: idData, text: text, entities: messageTextEntitiesFromApiEntities(entities), ageConfirmation: minAgeConfirm)
@ -34,7 +35,7 @@ extension TermsOfServiceUpdate {
}
func _internal_acceptTermsOfService(account: Account, id: String) -> Signal<Void, NoError> {
return account.network.request(Api.functions.help.acceptTermsOfService(id: .dataJSON(data: id)))
return account.network.request(Api.functions.help.acceptTermsOfService(id: .dataJSON(.init(data: id))))
|> `catch` { _ -> Signal<Api.Bool, NoError> in
return .complete()
}

View file

@ -692,7 +692,7 @@ func _internal_joinGroupCall(account: Account, peerId: PeerId?, joinAs: PeerId?,
flags |= (1 << 3)
}
let joinRequest = account.network.request(Api.functions.phone.joinGroupCall(flags: flags, call: reference.apiInputGroupCall, joinAs: inputJoinAs, inviteHash: inviteHash, publicKey: e2eData?.publicKey.value, block: (e2eData?.block).flatMap({ Buffer.init(data: $0) }), params: .dataJSON(data: joinPayload)))
let joinRequest = account.network.request(Api.functions.phone.joinGroupCall(flags: flags, call: reference.apiInputGroupCall, joinAs: inputJoinAs, inviteHash: inviteHash, publicKey: e2eData?.publicKey.value, block: (e2eData?.block).flatMap({ Buffer.init(data: $0) }), params: .dataJSON(.init(data: joinPayload))))
|> `catch` { error -> Signal<Api.Updates, InternalJoinError> in
if error.errorDescription == "GROUPCALL_ANONYMOUS_FORBIDDEN" {
return .fail(.error(.anonymousNotAllowed))
@ -805,7 +805,8 @@ func _internal_joinGroupCall(account: Account, peerId: PeerId?, joinAs: PeerId?,
}
case let .updateGroupCallConnection(_, params):
switch params {
case let .dataJSON(data):
case let .dataJSON(dataJSONData):
let data = dataJSONData.data
maybeParsedClientParams = data
}
default:
@ -1034,7 +1035,7 @@ public struct JoinGroupCallAsScreencastResult {
}
func _internal_joinGroupCallAsScreencast(account: Account, callId: Int64, accessHash: Int64, joinPayload: String) -> Signal<JoinGroupCallAsScreencastResult, JoinGroupCallError> {
return account.network.request(Api.functions.phone.joinGroupCallPresentation(call: .inputGroupCall(id: callId, accessHash: accessHash), params: .dataJSON(data: joinPayload)))
return account.network.request(Api.functions.phone.joinGroupCallPresentation(call: .inputGroupCall(id: callId, accessHash: accessHash), params: .dataJSON(.init(data: joinPayload))))
|> mapError { _ -> JoinGroupCallError in
return .generic
}
@ -1046,7 +1047,8 @@ func _internal_joinGroupCallAsScreencast(account: Account, callId: Int64, access
switch update {
case let .updateGroupCallConnection(_, params):
switch params {
case let .dataJSON(data):
case let .dataJSON(dataJSONData):
let data = dataJSONData.data
maybeParsedClientParams = data
}
default:

View file

@ -23,7 +23,7 @@ func _internal_saveCallDebugLog(network: Network, callId: CallId, log: String) -
if log.count > 1024 * 16 {
return .complete()
}
return network.request(Api.functions.phone.saveCallDebug(peer: Api.InputPhoneCall.inputPhoneCall(id: callId.id, accessHash: callId.accessHash), debug: .dataJSON(data: log)))
return network.request(Api.functions.phone.saveCallDebug(peer: Api.InputPhoneCall.inputPhoneCall(id: callId.id, accessHash: callId.accessHash), debug: .dataJSON(.init(data: log))))
|> `catch` { _ -> Signal<Api.Bool, NoError> in
return .single(.boolTrue)
}

View file

@ -141,7 +141,7 @@ public extension TelegramEngine {
inputMedia = .inputMediaUploadedPhoto(flags: 0, file: inputFile, stickers: nil, ttlSeconds: nil)
case .file, .video, .sticker, .voice:
var attributes: [Api.DocumentAttribute] = []
attributes.append(.documentAttributeFilename(fileName: fileName))
attributes.append(.documentAttributeFilename(.init(fileName: fileName)))
var resolvedMimeType = mimeType
switch type {
case .video:

View file

@ -19,7 +19,7 @@ public enum RequestSimpleWebViewSource : Equatable {
func _internal_requestSimpleWebView(postbox: Postbox, network: Network, botId: PeerId, url: String?, source: RequestSimpleWebViewSource, themeParams: [String: Any]?) -> Signal<RequestWebViewResult, RequestWebViewError> {
var serializedThemeParams: Api.DataJSON?
if let themeParams = themeParams, let data = try? JSONSerialization.data(withJSONObject: themeParams, options: []), let dataString = String(data: data, encoding: .utf8) {
serializedThemeParams = .dataJSON(data: dataString)
serializedThemeParams = .dataJSON(.init(data: dataString))
}
return postbox.transaction { transaction -> Signal<RequestWebViewResult, RequestWebViewError> in
guard let bot = transaction.getPeer(botId), let inputUser = apiInputUser(bot) else {
@ -70,7 +70,7 @@ func _internal_requestSimpleWebView(postbox: Postbox, network: Network, botId: P
func _internal_requestMainWebView(postbox: Postbox, network: Network, peerId: PeerId, botId: PeerId, source: RequestSimpleWebViewSource, themeParams: [String: Any]?) -> Signal<RequestWebViewResult, RequestWebViewError> {
var serializedThemeParams: Api.DataJSON?
if let themeParams = themeParams, let data = try? JSONSerialization.data(withJSONObject: themeParams, options: []), let dataString = String(data: data, encoding: .utf8) {
serializedThemeParams = .dataJSON(data: dataString)
serializedThemeParams = .dataJSON(.init(data: dataString))
}
return postbox.transaction { transaction -> Signal<RequestWebViewResult, RequestWebViewError> in
guard let bot = transaction.getPeer(botId), let inputUser = apiInputUser(bot) else {
@ -204,7 +204,7 @@ private func keepWebViewSignal(network: Network, stateManager: AccountStateManag
func _internal_requestWebView(postbox: Postbox, network: Network, stateManager: AccountStateManager, peerId: PeerId, botId: PeerId, url: String?, payload: String?, themeParams: [String: Any]?, fromMenu: Bool, replyToMessageId: MessageId?, threadId: Int64?) -> Signal<RequestWebViewResult, RequestWebViewError> {
var serializedThemeParams: Api.DataJSON?
if let themeParams = themeParams, let data = try? JSONSerialization.data(withJSONObject: themeParams, options: []), let dataString = String(data: data, encoding: .utf8) {
serializedThemeParams = .dataJSON(data: dataString)
serializedThemeParams = .dataJSON(.init(data: dataString))
}
return postbox.transaction { transaction -> Signal<RequestWebViewResult, RequestWebViewError> in
@ -309,7 +309,7 @@ func _internal_sendWebViewData(postbox: Postbox, network: Network, stateManager:
func _internal_requestAppWebView(postbox: Postbox, network: Network, stateManager: AccountStateManager, peerId: PeerId, appReference: BotAppReference, payload: String?, themeParams: [String: Any]?, compact: Bool, fullscreen: Bool, allowWrite: Bool) -> Signal<RequestWebViewResult, RequestWebViewError> {
var serializedThemeParams: Api.DataJSON?
if let themeParams = themeParams, let data = try? JSONSerialization.data(withJSONObject: themeParams, options: []), let dataString = String(data: data, encoding: .utf8) {
serializedThemeParams = .dataJSON(data: dataString)
serializedThemeParams = .dataJSON(.init(data: dataString))
}
return postbox.transaction { transaction -> Signal<RequestWebViewResult, RequestWebViewError> in
@ -415,7 +415,7 @@ public enum InvokeBotCustomMethodError {
}
func _internal_invokeBotCustomMethod(postbox: Postbox, network: Network, botId: PeerId, method: String, params: String) -> Signal<String, InvokeBotCustomMethodError> {
let params = Api.DataJSON.dataJSON(data: params)
let params = Api.DataJSON.dataJSON(.init(data: params))
return postbox.transaction { transaction -> Signal<String, InvokeBotCustomMethodError> in
guard let bot = transaction.getPeer(botId), let inputUser = apiInputUser(bot) else {
return .fail(.generic)
@ -425,7 +425,8 @@ func _internal_invokeBotCustomMethod(postbox: Postbox, network: Network, botId:
return .generic
}
|> map { result -> String in
if case let .dataJSON(data) = result {
if case let .dataJSON(dataJSONData) = result {
let data = dataJSONData.data
return data
} else {
return ""

View file

@ -20,7 +20,8 @@ func _internal_markAllChatsAsRead(postbox: Postbox, network: Network, stateManag
var signals: [Signal<Void, NoError>] = []
for peer in result {
switch peer {
case let .dialogPeer(peer):
case let .dialogPeer(dialogPeerData):
let peer = dialogPeerData.peer
let peerId = peer.peerId
if peerId.namespace == Namespaces.Peer.CloudChannel {
if let inputChannel = transaction.getPeer(peerId).flatMap(apiInputChannel) {

View file

@ -513,7 +513,7 @@ func _internal_fetchBotPaymentForm(accountPeerId: PeerId, postbox: Postbox, netw
var flags: Int32 = 0
var serializedThemeParams: Api.DataJSON?
if let themeParams = themeParams, let data = try? JSONSerialization.data(withJSONObject: themeParams, options: []), let dataString = String(data: data, encoding: .utf8) {
serializedThemeParams = Api.DataJSON.dataJSON(data: dataString)
serializedThemeParams = Api.DataJSON.dataJSON(.init(data: dataString))
}
if serializedThemeParams != nil {
flags |= 1 << 0
@ -550,7 +550,8 @@ func _internal_fetchBotPaymentForm(accountPeerId: PeerId, postbox: Postbox, netw
var parsedNativeProvider: BotPaymentNativeProvider?
if let nativeProvider = nativeProvider, let nativeParams = nativeParams {
switch nativeParams {
case let .dataJSON(data):
case let .dataJSON(dataJSONData):
let data = dataJSONData.data
parsedNativeProvider = BotPaymentNativeProvider(name: nativeProvider, params: data)
}
}
@ -721,11 +722,11 @@ func _internal_sendBotPaymentForm(account: Account, formId: Int64, source: BotPa
if saveOnServer {
credentialsFlags |= (1 << 0)
}
apiCredentials = .inputPaymentCredentials(flags: credentialsFlags, data: .dataJSON(data: data))
apiCredentials = .inputPaymentCredentials(flags: credentialsFlags, data: .dataJSON(.init(data: data)))
case let .saved(id, tempPassword):
apiCredentials = .inputPaymentCredentialsSaved(id: id, tmpPassword: Buffer(data: tempPassword))
case let .applePay(data):
apiCredentials = .inputPaymentCredentialsApplePay(paymentData: .dataJSON(data: data))
apiCredentials = .inputPaymentCredentialsApplePay(paymentData: .dataJSON(.init(data: data)))
}
var flags: Int32 = 0
if validatedInfoId != nil {

View file

@ -341,7 +341,8 @@ extension ChatListFilter {
switch apiFilter {
case .dialogFilterDefault:
self = .allChats
case let .dialogFilter(flags, id, title, emoticon, color, pinnedPeers, includePeers, excludePeers):
case let .dialogFilter(dialogFilterData):
let (flags, id, title, emoticon, color, pinnedPeers, includePeers, excludePeers) = (dialogFilterData.flags, dialogFilterData.id, dialogFilterData.title, dialogFilterData.emoticon, dialogFilterData.color, dialogFilterData.pinnedPeers, dialogFilterData.includePeers, dialogFilterData.excludePeers)
let titleText: String
let titleEntities: [MessageTextEntity]
switch title {
@ -399,7 +400,8 @@ extension ChatListFilter {
color: color.flatMap(PeerNameColor.init(rawValue:))
)
)
case let .dialogFilterChatlist(flags, id, title, emoticon, color, pinnedPeers, includePeers):
case let .dialogFilterChatlist(dialogFilterChatlistData):
let (flags, id, title, emoticon, color, pinnedPeers, includePeers) = (dialogFilterChatlistData.flags, dialogFilterChatlistData.id, dialogFilterChatlistData.title, dialogFilterChatlistData.emoticon, dialogFilterChatlistData.color, dialogFilterChatlistData.pinnedPeers, dialogFilterChatlistData.includePeers)
let titleText: String
let titleEntities: [MessageTextEntity]
switch title {
@ -466,14 +468,14 @@ extension ChatListFilter {
if !title.enableAnimations {
flags |= 1 << 28
}
return .dialogFilterChatlist(flags: flags, id: id, title: .textWithEntities(text: title.text, entities: apiEntitiesFromMessageTextEntities(title.entities, associatedPeers: SimpleDictionary())), emoticon: emoticon, color: data.color?.rawValue, pinnedPeers: data.includePeers.pinnedPeers.compactMap { peerId -> Api.InputPeer? in
return .dialogFilterChatlist(.init(flags: flags, id: id, title: .textWithEntities(text: title.text, entities: apiEntitiesFromMessageTextEntities(title.entities, associatedPeers: SimpleDictionary())), emoticon: emoticon, color: data.color?.rawValue, pinnedPeers: data.includePeers.pinnedPeers.compactMap { peerId -> Api.InputPeer? in
return transaction.getPeer(peerId).flatMap(apiInputPeer)
}, includePeers: data.includePeers.peers.compactMap { peerId -> Api.InputPeer? in
if data.includePeers.pinnedPeers.contains(peerId) {
return nil
}
return transaction.getPeer(peerId).flatMap(apiInputPeer)
})
}))
} else {
var flags: Int32 = 0
if data.excludeMuted {
@ -495,7 +497,7 @@ extension ChatListFilter {
if !title.enableAnimations {
flags |= 1 << 28
}
return .dialogFilter(flags: flags, id: id, title: .textWithEntities(text: title.text, entities: apiEntitiesFromMessageTextEntities(title.entities, associatedPeers: SimpleDictionary())), emoticon: emoticon, color: data.color?.rawValue, pinnedPeers: data.includePeers.pinnedPeers.compactMap { peerId -> Api.InputPeer? in
return .dialogFilter(.init(flags: flags, id: id, title: .textWithEntities(text: title.text, entities: apiEntitiesFromMessageTextEntities(title.entities, associatedPeers: SimpleDictionary())), emoticon: emoticon, color: data.color?.rawValue, pinnedPeers: data.includePeers.pinnedPeers.compactMap { peerId -> Api.InputPeer? in
return transaction.getPeer(peerId).flatMap(apiInputPeer)
}, includePeers: data.includePeers.peers.compactMap { peerId -> Api.InputPeer? in
if data.includePeers.pinnedPeers.contains(peerId) {
@ -504,7 +506,7 @@ extension ChatListFilter {
return transaction.getPeer(peerId).flatMap(apiInputPeer)
}, excludePeers: data.excludePeers.compactMap { peerId -> Api.InputPeer? in
return transaction.getPeer(peerId).flatMap(apiInputPeer)
})
}))
}
}
}
@ -574,7 +576,8 @@ private func requestChatListFilters(accountPeerId: PeerId, postbox: Postbox, net
switch apiFilter {
case .dialogFilterDefault:
break
case let .dialogFilter(_, _, _, _, _, pinnedPeers, includePeers, excludePeers):
case let .dialogFilter(dialogFilterData):
let (pinnedPeers, includePeers, excludePeers) = (dialogFilterData.pinnedPeers, dialogFilterData.includePeers, dialogFilterData.excludePeers)
for peer in pinnedPeers + includePeers + excludePeers {
var peerId: PeerId?
switch peer {
@ -614,7 +617,8 @@ private func requestChatListFilters(accountPeerId: PeerId, postbox: Postbox, net
}
}
}
case let .dialogFilterChatlist(_, _, _, _, _, pinnedPeers, includePeers):
case let .dialogFilterChatlist(dialogFilterChatlistData):
let (pinnedPeers, includePeers) = (dialogFilterChatlistData.pinnedPeers, dialogFilterChatlistData.includePeers)
for peer in pinnedPeers + includePeers {
var peerId: PeerId?
switch peer {
@ -806,7 +810,8 @@ private func loadAndStorePeerChatInfos(accountPeerId: PeerId, postbox: Postbox,
for dialog in dialogs {
switch dialog {
case let .dialog(_, peer, topMessage, readInboxMaxId, readOutboxMaxId, unreadCount, unreadMentionsCount, unreadReactionsCount, notifySettings, pts, _, folderId, ttlPeriod):
case let .dialog(dialogData):
let (peer, topMessage, readInboxMaxId, readOutboxMaxId, unreadCount, unreadMentionsCount, unreadReactionsCount, notifySettings, pts, folderId, ttlPeriod) = (dialogData.peer, dialogData.topMessage, dialogData.readInboxMaxId, dialogData.readOutboxMaxId, dialogData.unreadCount, dialogData.unreadMentionsCount, dialogData.unreadReactionsCount, dialogData.notifySettings, dialogData.pts, dialogData.folderId, dialogData.ttlPeriod)
let peerId = peer.peerId
if topMessage != 0 {
@ -1269,7 +1274,8 @@ func _internal_updateChatListFeaturedFilters(postbox: Postbox, network: Network)
var state = entry?.get(ChatListFiltersFeaturedState.self) ?? ChatListFiltersFeaturedState(filters: [], isSeen: false)
state.filters = result.compactMap { item -> ChatListFeaturedFilter? in
switch item {
case let .dialogFilterSuggested(filter, description):
case let .dialogFilterSuggested(dialogFilterSuggestedData):
let (filter, description) = (dialogFilterSuggestedData.filter, dialogFilterSuggestedData.description)
let parsedFilter = ChatListFilter(apiFilter: filter)
if case let .filter(_, title, _, data) = parsedFilter {
return ChatListFeaturedFilter(title: title, description: description, data: data)

View file

@ -293,7 +293,7 @@ func _internal_updatePeerEmojiStatus(account: Account, peerId: PeerId, fileId: I
if let _ = expirationDate {
flags |= (1 << 0)
}
mappedStatus = .emojiStatus(flags: flags, documentId: fileId, until: expirationDate)
mappedStatus = .emojiStatus(.init(flags: flags, documentId: fileId, until: expirationDate))
} else {
mappedStatus = .emojiStatusEmpty
}
@ -338,7 +338,7 @@ func _internal_updatePeerStarGiftStatus(account: Account, peerId: PeerId, starGi
let apiEmojiStatus: Api.EmojiStatus
var emojiStatus: PeerEmojiStatus?
if let file, let patternFile, let innerColor, let outerColor, let patternColor, let textColor {
apiEmojiStatus = .inputEmojiStatusCollectible(flags: flags, collectibleId: starGift.id, until: expirationDate)
apiEmojiStatus = .inputEmojiStatusCollectible(.init(flags: flags, collectibleId: starGift.id, until: expirationDate))
emojiStatus = PeerEmojiStatus(content: .starGift(id: starGift.id, fileId: file.fileId.id, title: starGift.title, slug: starGift.slug, patternFileId: patternFile.fileId.id, innerColor: innerColor, outerColor: outerColor, patternColor: patternColor, textColor: textColor), expirationDate: expirationDate)
} else {
apiEmojiStatus = .emojiStatusEmpty

View file

@ -86,7 +86,8 @@ func _internal_requestAccountPrivacySettings(account: Account) -> Signal<Account
let messageAutoremoveSeconds: Int32?
switch messageAutoremoveTimeout {
case let .defaultHistoryTTL(period):
case let .defaultHistoryTTL(defaultHistoryTTLData):
let period = defaultHistoryTTLData.period
if period != 0 {
messageAutoremoveSeconds = period
} else {
@ -404,7 +405,7 @@ func _internal_updateGlobalPrivacySettings(account: Account, settings: GlobalPri
}
flags |= 1 << 6
let disallowedStargifts: Api.DisallowedGiftsSettings = .disallowedGiftsSettings(flags: giftFlags)
let disallowedStargifts: Api.DisallowedGiftsSettings = .disallowedGiftsSettings(.init(flags: giftFlags))
return account.network.request(Api.functions.account.setGlobalPrivacySettings(
settings: .globalPrivacySettings(flags: flags, noncontactPeersPaidStars: noncontactPeersPaidStars, disallowedGifts: disallowedStargifts)
))

View file

@ -29,7 +29,8 @@ public func secureIdConfiguration(postbox: Postbox, network: Network) -> Signal<
}
case let .passportConfig(hash, countriesLangs):
switch countriesLangs {
case let .dataJSON(data):
case let .dataJSON(dataJSONData):
let data = dataJSONData.data
let value = SecureIdConfiguration(jsonString: data)
parsed = CachedSecureIdConfiguration(value: value, hash: hash)
}

View file

@ -97,7 +97,7 @@ public enum SecureIdCommitEmailVerificationError {
}
public func secureIdCommitEmailVerification(postbox: Postbox, network: Network, context: SecureIdAccessContext, payload: SecureIdPrepareEmailVerificationPayload, code: String) -> Signal<SecureIdValueWithContext, SecureIdCommitEmailVerificationError> {
return network.request(Api.functions.account.verifyEmail(purpose: .emailVerifyPurposePassport, verification: .emailVerificationCode(code: code)), automaticFloodWait: false)
return network.request(Api.functions.account.verifyEmail(purpose: .emailVerifyPurposePassport, verification: .emailVerificationCode(.init(code: code))), automaticFloodWait: false)
|> mapError { error -> SecureIdCommitEmailVerificationError in
if error.errorDescription.hasPrefix("FLOOD_WAIT") {
return .flood

View file

@ -78,11 +78,11 @@ func _internal_uploadSticker(account: Account, peer: Peer, resource: MediaResour
flags |= (1 << 2)
}
var attributes: [Api.DocumentAttribute] = []
attributes.append(.documentAttributeSticker(flags: 0, alt: alt, stickerset: .inputStickerSetEmpty, maskCoords: nil))
attributes.append(.documentAttributeSticker(.init(flags: 0, alt: alt, stickerset: .inputStickerSetEmpty, maskCoords: nil)))
if let duration {
attributes.append(.documentAttributeVideo(flags: 0, duration: duration, w: dimensions.width, h: dimensions.height, preloadPrefixSize: nil, videoStartTs: nil, videoCodec: nil))
attributes.append(.documentAttributeVideo(.init(flags: 0, duration: duration, w: dimensions.width, h: dimensions.height, preloadPrefixSize: nil, videoStartTs: nil, videoCodec: nil)))
}
attributes.append(.documentAttributeImageSize(w: dimensions.width, h: dimensions.height))
attributes.append(.documentAttributeImageSize(.init(w: dimensions.width, h: dimensions.height)))
return account.network.request(Api.functions.messages.uploadMedia(flags: 0, businessConnectionId: nil, peer: inputPeer, media: Api.InputMedia.inputMediaUploadedDocument(flags: flags, file: file, thumb: thumbnailFile, mimeType: mimeType, attributes: attributes, stickers: nil, videoCover: nil, videoTimestamp: nil, ttlSeconds: nil)))
|> mapError { _ -> UploadStickerError in return .generic }
|> mapToSignal { media -> Signal<UploadStickerStatus, UploadStickerError> in

View file

@ -995,7 +995,8 @@ func _internal_searchEmoji(account: Account, query: String?, emoticon: [String],
switch result {
case .emojiListNotModified:
return .single(nil)
case let .emojiList(hash, documentIds):
case let .emojiList(emojiListData):
let (hash, documentIds) = (emojiListData.hash, emojiListData.documentId)
return TelegramEngine(account: account).stickers.resolveInlineStickers(fileIds: documentIds)
|> map { fileMap -> (files: [TelegramMediaFile], hash: Int64)? in
var files: [TelegramMediaFile] = []