From e68bdc05ca8a2cc836b60fd0daed6a5e67cdf760 Mon Sep 17 00:00:00 2001 From: Isaac <> Date: Fri, 16 Jan 2026 15:18:11 +0800 Subject: [PATCH] Refactor Api types 150-179 to use struct-wrapped constructors - Update pattern matches to use struct-based extraction for inputPeer*, inputMedia*, inputReplyTo*, inputSticker*, inputPhoto, inputUser, etc. - Wrap constructor calls with .init() for struct-wrapped enum cases - 47 TelegramCore source files modified - 5 TelegramApi files regenerated with --struct-count=180 Co-Authored-By: Claude Opus 4.5 --- submodules/TelegramApi/Sources/Api10.swift | 156 +++++++- submodules/TelegramApi/Sources/Api11.swift | 352 +++++++++++++++-- submodules/TelegramApi/Sources/Api12.swift | 164 +++++++- submodules/TelegramApi/Sources/Api13.swift | 370 ++++++++++++++++-- submodules/TelegramApi/Sources/Api14.swift | 100 ++++- .../Sources/Account/Account.swift | 2 +- .../Sources/ApiUtils/ApiUtils.swift | 22 +- .../Sources/ApiUtils/TelegramMediaFile.swift | 9 +- .../Sources/ApiUtils/Wallpaper.swift | 8 +- .../Sources/MacOS/MacInternal.swift | 2 +- .../PendingMessageUploadedContent.swift | 58 +-- .../PendingMessages/RequestEditMessage.swift | 6 +- .../StandaloneSendMessage.swift | 48 +-- .../StandaloneUploadedMedia.swift | 4 +- .../State/AccountStateManagementUtils.swift | 41 +- .../Sources/State/AccountViewTracker.swift | 16 +- .../Sources/State/CallSessionManager.swift | 10 +- .../State/HistoryViewStateValidation.swift | 4 +- .../TelegramCore/Sources/State/Holes.swift | 10 +- .../ManagedGlobalNotificationSettings.swift | 2 +- ...nagedPendingPeerNotificationSettings.swift | 8 +- ...dSynchronizeChatInputStateOperations.swift | 6 +- ...onizeInstalledStickerPacksOperations.swift | 12 +- .../Sources/State/PendingMessageManager.swift | 64 +-- .../Sources/State/StickerManagement.swift | 2 +- .../State/SynchronizePeerReadState.swift | 3 +- .../Sources/State/UpdatesApiUtils.swift | 10 +- .../TelegramEngine/Calls/RateCall.swift | 6 +- .../TelegramEngine/Messages/BotWebView.swift | 6 +- .../Messages/ClearCloudDrafts.swift | 4 +- .../Messages/LoadMessagesIfNecessary.swift | 4 +- .../TelegramEngine/Messages/Polls.swift | 2 +- .../Messages/SearchMessages.swift | 8 +- .../TelegramEngine/Messages/Stories.swift | 24 +- .../Messages/StoryListContext.swift | 4 +- .../TelegramEngine/Payments/AppStore.swift | 16 +- .../Payments/BotPaymentForm.swift | 42 +- .../TelegramEngine/Payments/GiftCodes.swift | 4 +- .../TelegramEngine/Payments/StarGifts.swift | 6 +- .../Payments/StarGiftsAuctions.swift | 4 +- .../TelegramEngine/Payments/Stars.swift | 2 +- .../TelegramEngine/Peers/AddressNames.swift | 2 +- .../Peers/ChatListFiltering.swift | 98 +++-- .../Peers/PeerPhotoUpdater.swift | 4 +- .../Peers/UpdateGroupSpecificStickerset.swift | 4 +- .../UpdatedAccountPrivacySettings.swift | 16 +- .../SecureId/SaveSecureIdValue.swift | 6 +- .../Stickers/ArchivedStickerPacks.swift | 2 +- .../Stickers/ImportStickers.swift | 8 +- .../Stickers/LoadedStickerPack.swift | 6 +- .../TelegramEngine/Stickers/StickerPack.swift | 8 +- .../Stickers/StickerSetInstallation.swift | 10 +- 52 files changed, 1391 insertions(+), 394 deletions(-) diff --git a/submodules/TelegramApi/Sources/Api10.swift b/submodules/TelegramApi/Sources/Api10.swift index ad3c341a91..33a1b7377e 100644 --- a/submodules/TelegramApi/Sources/Api10.swift +++ b/submodules/TelegramApi/Sources/Api10.swift @@ -407,21 +407,147 @@ public extension Api { } public extension Api { indirect enum InputInvoice: TypeConstructorDescription { - case inputInvoiceBusinessBotTransferStars(bot: Api.InputUser, stars: Int64) - case inputInvoiceChatInviteSubscription(hash: String) - case inputInvoiceMessage(peer: Api.InputPeer, msgId: Int32) - case inputInvoicePremiumAuthCode(purpose: Api.InputStorePaymentPurpose) - case inputInvoicePremiumGiftCode(purpose: Api.InputStorePaymentPurpose, option: Api.PremiumGiftCodeOption) - case inputInvoicePremiumGiftStars(flags: Int32, userId: Api.InputUser, months: Int32, message: Api.TextWithEntities?) - case inputInvoiceSlug(slug: String) - case inputInvoiceStarGift(flags: Int32, peer: Api.InputPeer, giftId: Int64, message: Api.TextWithEntities?) - case inputInvoiceStarGiftAuctionBid(flags: Int32, peer: Api.InputPeer?, giftId: Int64, bidAmount: Int64, message: Api.TextWithEntities?) - case inputInvoiceStarGiftDropOriginalDetails(stargift: Api.InputSavedStarGift) - case inputInvoiceStarGiftPrepaidUpgrade(peer: Api.InputPeer, hash: String) - case inputInvoiceStarGiftResale(flags: Int32, slug: String, toId: Api.InputPeer) - case inputInvoiceStarGiftTransfer(stargift: Api.InputSavedStarGift, toId: Api.InputPeer) - case inputInvoiceStarGiftUpgrade(flags: Int32, stargift: Api.InputSavedStarGift) - case inputInvoiceStars(purpose: Api.InputStorePaymentPurpose) + public class Cons_inputInvoiceBusinessBotTransferStars { + public var bot: Api.InputUser + public var stars: Int64 + public init(bot: Api.InputUser, stars: Int64) { + self.bot = bot + self.stars = stars + } + } + public class Cons_inputInvoiceChatInviteSubscription { + public var hash: String + public init(hash: String) { + self.hash = hash + } + } + public class Cons_inputInvoiceMessage { + public var peer: Api.InputPeer + public var msgId: Int32 + public init(peer: Api.InputPeer, msgId: Int32) { + self.peer = peer + self.msgId = msgId + } + } + public class Cons_inputInvoicePremiumAuthCode { + public var purpose: Api.InputStorePaymentPurpose + public init(purpose: Api.InputStorePaymentPurpose) { + self.purpose = purpose + } + } + public class Cons_inputInvoicePremiumGiftCode { + public var purpose: Api.InputStorePaymentPurpose + public var option: Api.PremiumGiftCodeOption + public init(purpose: Api.InputStorePaymentPurpose, option: Api.PremiumGiftCodeOption) { + self.purpose = purpose + self.option = option + } + } + public class Cons_inputInvoicePremiumGiftStars { + public var flags: Int32 + public var userId: Api.InputUser + public var months: Int32 + public var message: Api.TextWithEntities? + public init(flags: Int32, userId: Api.InputUser, months: Int32, message: Api.TextWithEntities?) { + self.flags = flags + self.userId = userId + self.months = months + self.message = message + } + } + public class Cons_inputInvoiceSlug { + public var slug: String + public init(slug: String) { + self.slug = slug + } + } + public class Cons_inputInvoiceStarGift { + public var flags: Int32 + public var peer: Api.InputPeer + public var giftId: Int64 + public var message: Api.TextWithEntities? + public init(flags: Int32, peer: Api.InputPeer, giftId: Int64, message: Api.TextWithEntities?) { + self.flags = flags + self.peer = peer + self.giftId = giftId + self.message = message + } + } + public class Cons_inputInvoiceStarGiftAuctionBid { + public var flags: Int32 + public var peer: Api.InputPeer? + public var giftId: Int64 + public var bidAmount: Int64 + public var message: Api.TextWithEntities? + public init(flags: Int32, peer: Api.InputPeer?, giftId: Int64, bidAmount: Int64, message: Api.TextWithEntities?) { + self.flags = flags + self.peer = peer + self.giftId = giftId + self.bidAmount = bidAmount + self.message = message + } + } + public class Cons_inputInvoiceStarGiftDropOriginalDetails { + public var stargift: Api.InputSavedStarGift + public init(stargift: Api.InputSavedStarGift) { + self.stargift = stargift + } + } + public class Cons_inputInvoiceStarGiftPrepaidUpgrade { + public var peer: Api.InputPeer + public var hash: String + public init(peer: Api.InputPeer, hash: String) { + self.peer = peer + self.hash = hash + } + } + public class Cons_inputInvoiceStarGiftResale { + public var flags: Int32 + public var slug: String + public var toId: Api.InputPeer + public init(flags: Int32, slug: String, toId: Api.InputPeer) { + self.flags = flags + self.slug = slug + self.toId = toId + } + } + public class Cons_inputInvoiceStarGiftTransfer { + public var stargift: Api.InputSavedStarGift + public var toId: Api.InputPeer + public init(stargift: Api.InputSavedStarGift, toId: Api.InputPeer) { + self.stargift = stargift + self.toId = toId + } + } + public class Cons_inputInvoiceStarGiftUpgrade { + public var flags: Int32 + public var stargift: Api.InputSavedStarGift + public init(flags: Int32, stargift: Api.InputSavedStarGift) { + self.flags = flags + self.stargift = stargift + } + } + public class Cons_inputInvoiceStars { + public var purpose: Api.InputStorePaymentPurpose + public init(purpose: Api.InputStorePaymentPurpose) { + self.purpose = purpose + } + } + case inputInvoiceBusinessBotTransferStars(Cons_inputInvoiceBusinessBotTransferStars) + case inputInvoiceChatInviteSubscription(Cons_inputInvoiceChatInviteSubscription) + case inputInvoiceMessage(Cons_inputInvoiceMessage) + case inputInvoicePremiumAuthCode(Cons_inputInvoicePremiumAuthCode) + case inputInvoicePremiumGiftCode(Cons_inputInvoicePremiumGiftCode) + case inputInvoicePremiumGiftStars(Cons_inputInvoicePremiumGiftStars) + case inputInvoiceSlug(Cons_inputInvoiceSlug) + case inputInvoiceStarGift(Cons_inputInvoiceStarGift) + case inputInvoiceStarGiftAuctionBid(Cons_inputInvoiceStarGiftAuctionBid) + case inputInvoiceStarGiftDropOriginalDetails(Cons_inputInvoiceStarGiftDropOriginalDetails) + case inputInvoiceStarGiftPrepaidUpgrade(Cons_inputInvoiceStarGiftPrepaidUpgrade) + case inputInvoiceStarGiftResale(Cons_inputInvoiceStarGiftResale) + case inputInvoiceStarGiftTransfer(Cons_inputInvoiceStarGiftTransfer) + case inputInvoiceStarGiftUpgrade(Cons_inputInvoiceStarGiftUpgrade) + case inputInvoiceStars(Cons_inputInvoiceStars) public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) { #if DEBUG diff --git a/submodules/TelegramApi/Sources/Api11.swift b/submodules/TelegramApi/Sources/Api11.swift index 8de4c6ab22..cd0373e501 100644 --- a/submodules/TelegramApi/Sources/Api11.swift +++ b/submodules/TelegramApi/Sources/Api11.swift @@ -1,25 +1,251 @@ public extension Api { indirect enum InputMedia: TypeConstructorDescription { - case inputMediaContact(phoneNumber: String, firstName: String, lastName: String, vcard: String) - case inputMediaDice(emoticon: String) - case inputMediaDocument(flags: Int32, id: Api.InputDocument, videoCover: Api.InputPhoto?, videoTimestamp: Int32?, ttlSeconds: Int32?, query: String?) - case inputMediaDocumentExternal(flags: Int32, url: String, ttlSeconds: Int32?, videoCover: Api.InputPhoto?, videoTimestamp: Int32?) + public class Cons_inputMediaContact { + public var phoneNumber: String + public var firstName: String + public var lastName: String + public var vcard: String + public init(phoneNumber: String, firstName: String, lastName: String, vcard: String) { + self.phoneNumber = phoneNumber + self.firstName = firstName + self.lastName = lastName + self.vcard = vcard + } + } + public class Cons_inputMediaDice { + public var emoticon: String + public init(emoticon: String) { + self.emoticon = emoticon + } + } + public class Cons_inputMediaDocument { + public var flags: Int32 + public var id: Api.InputDocument + public var videoCover: Api.InputPhoto? + public var videoTimestamp: Int32? + public var ttlSeconds: Int32? + public var query: String? + public init(flags: Int32, id: Api.InputDocument, videoCover: Api.InputPhoto?, videoTimestamp: Int32?, ttlSeconds: Int32?, query: String?) { + self.flags = flags + self.id = id + self.videoCover = videoCover + self.videoTimestamp = videoTimestamp + self.ttlSeconds = ttlSeconds + self.query = query + } + } + public class Cons_inputMediaDocumentExternal { + public var flags: Int32 + public var url: String + public var ttlSeconds: Int32? + public var videoCover: Api.InputPhoto? + public var videoTimestamp: Int32? + public init(flags: Int32, url: String, ttlSeconds: Int32?, videoCover: Api.InputPhoto?, videoTimestamp: Int32?) { + self.flags = flags + self.url = url + self.ttlSeconds = ttlSeconds + self.videoCover = videoCover + self.videoTimestamp = videoTimestamp + } + } + public class Cons_inputMediaGame { + public var id: Api.InputGame + public init(id: Api.InputGame) { + self.id = id + } + } + public class Cons_inputMediaGeoLive { + public var flags: Int32 + public var geoPoint: Api.InputGeoPoint + public var heading: Int32? + public var period: Int32? + public var proximityNotificationRadius: Int32? + public init(flags: Int32, geoPoint: Api.InputGeoPoint, heading: Int32?, period: Int32?, proximityNotificationRadius: Int32?) { + self.flags = flags + self.geoPoint = geoPoint + self.heading = heading + self.period = period + self.proximityNotificationRadius = proximityNotificationRadius + } + } + public class Cons_inputMediaGeoPoint { + public var geoPoint: Api.InputGeoPoint + public init(geoPoint: Api.InputGeoPoint) { + self.geoPoint = geoPoint + } + } + public class Cons_inputMediaInvoice { + public var flags: Int32 + public var title: String + public var description: String + public var photo: Api.InputWebDocument? + public var invoice: Api.Invoice + public var payload: Buffer + public var provider: String? + public var providerData: Api.DataJSON + public var startParam: String? + public var extendedMedia: Api.InputMedia? + public init(flags: Int32, title: String, description: String, photo: Api.InputWebDocument?, invoice: Api.Invoice, payload: Buffer, provider: String?, providerData: Api.DataJSON, startParam: String?, extendedMedia: Api.InputMedia?) { + self.flags = flags + self.title = title + self.description = description + self.photo = photo + self.invoice = invoice + self.payload = payload + self.provider = provider + self.providerData = providerData + self.startParam = startParam + self.extendedMedia = extendedMedia + } + } + public class Cons_inputMediaPaidMedia { + public var flags: Int32 + public var starsAmount: Int64 + public var extendedMedia: [Api.InputMedia] + public var payload: String? + public init(flags: Int32, starsAmount: Int64, extendedMedia: [Api.InputMedia], payload: String?) { + self.flags = flags + self.starsAmount = starsAmount + self.extendedMedia = extendedMedia + self.payload = payload + } + } + public class Cons_inputMediaPhoto { + public var flags: Int32 + public var id: Api.InputPhoto + public var ttlSeconds: Int32? + public init(flags: Int32, id: Api.InputPhoto, ttlSeconds: Int32?) { + self.flags = flags + self.id = id + self.ttlSeconds = ttlSeconds + } + } + public class Cons_inputMediaPhotoExternal { + public var flags: Int32 + public var url: String + public var ttlSeconds: Int32? + public init(flags: Int32, url: String, ttlSeconds: Int32?) { + self.flags = flags + self.url = url + self.ttlSeconds = ttlSeconds + } + } + public class Cons_inputMediaPoll { + public var flags: Int32 + public var poll: Api.Poll + public var correctAnswers: [Buffer]? + public var solution: String? + public var solutionEntities: [Api.MessageEntity]? + public init(flags: Int32, poll: Api.Poll, correctAnswers: [Buffer]?, solution: String?, solutionEntities: [Api.MessageEntity]?) { + self.flags = flags + self.poll = poll + self.correctAnswers = correctAnswers + self.solution = solution + self.solutionEntities = solutionEntities + } + } + public class Cons_inputMediaStakeDice { + public var gameHash: String + public var tonAmount: Int64 + public var clientSeed: Buffer + public init(gameHash: String, tonAmount: Int64, clientSeed: Buffer) { + self.gameHash = gameHash + self.tonAmount = tonAmount + self.clientSeed = clientSeed + } + } + public class Cons_inputMediaStory { + public var peer: Api.InputPeer + public var id: Int32 + public init(peer: Api.InputPeer, id: Int32) { + self.peer = peer + self.id = id + } + } + public class Cons_inputMediaTodo { + public var todo: Api.TodoList + public init(todo: Api.TodoList) { + self.todo = todo + } + } + public class Cons_inputMediaUploadedDocument { + public var flags: Int32 + public var file: Api.InputFile + public var thumb: Api.InputFile? + public var mimeType: String + public var attributes: [Api.DocumentAttribute] + public var stickers: [Api.InputDocument]? + public var videoCover: Api.InputPhoto? + public var videoTimestamp: Int32? + public var ttlSeconds: Int32? + public init(flags: Int32, file: Api.InputFile, thumb: Api.InputFile?, mimeType: String, attributes: [Api.DocumentAttribute], stickers: [Api.InputDocument]?, videoCover: Api.InputPhoto?, videoTimestamp: Int32?, ttlSeconds: Int32?) { + self.flags = flags + self.file = file + self.thumb = thumb + self.mimeType = mimeType + self.attributes = attributes + self.stickers = stickers + self.videoCover = videoCover + self.videoTimestamp = videoTimestamp + self.ttlSeconds = ttlSeconds + } + } + public class Cons_inputMediaUploadedPhoto { + public var flags: Int32 + public var file: Api.InputFile + public var stickers: [Api.InputDocument]? + public var ttlSeconds: Int32? + public init(flags: Int32, file: Api.InputFile, stickers: [Api.InputDocument]?, ttlSeconds: Int32?) { + self.flags = flags + self.file = file + self.stickers = stickers + self.ttlSeconds = ttlSeconds + } + } + public class Cons_inputMediaVenue { + public var geoPoint: Api.InputGeoPoint + public var title: String + public var address: String + public var provider: String + public var venueId: String + public var venueType: String + public init(geoPoint: Api.InputGeoPoint, title: String, address: String, provider: String, venueId: String, venueType: String) { + self.geoPoint = geoPoint + self.title = title + self.address = address + self.provider = provider + self.venueId = venueId + self.venueType = venueType + } + } + public class Cons_inputMediaWebPage { + public var flags: Int32 + public var url: String + public init(flags: Int32, url: String) { + self.flags = flags + self.url = url + } + } + case inputMediaContact(Cons_inputMediaContact) + case inputMediaDice(Cons_inputMediaDice) + case inputMediaDocument(Cons_inputMediaDocument) + case inputMediaDocumentExternal(Cons_inputMediaDocumentExternal) case inputMediaEmpty - case inputMediaGame(id: Api.InputGame) - case inputMediaGeoLive(flags: Int32, geoPoint: Api.InputGeoPoint, heading: Int32?, period: Int32?, proximityNotificationRadius: Int32?) - case inputMediaGeoPoint(geoPoint: Api.InputGeoPoint) - case inputMediaInvoice(flags: Int32, title: String, description: String, photo: Api.InputWebDocument?, invoice: Api.Invoice, payload: Buffer, provider: String?, providerData: Api.DataJSON, startParam: String?, extendedMedia: Api.InputMedia?) - case inputMediaPaidMedia(flags: Int32, starsAmount: Int64, extendedMedia: [Api.InputMedia], payload: String?) - case inputMediaPhoto(flags: Int32, id: Api.InputPhoto, ttlSeconds: Int32?) - case inputMediaPhotoExternal(flags: Int32, url: String, ttlSeconds: Int32?) - case inputMediaPoll(flags: Int32, poll: Api.Poll, correctAnswers: [Buffer]?, solution: String?, solutionEntities: [Api.MessageEntity]?) - case inputMediaStakeDice(gameHash: String, tonAmount: Int64, clientSeed: Buffer) - case inputMediaStory(peer: Api.InputPeer, id: Int32) - case inputMediaTodo(todo: Api.TodoList) - case inputMediaUploadedDocument(flags: Int32, file: Api.InputFile, thumb: Api.InputFile?, mimeType: String, attributes: [Api.DocumentAttribute], stickers: [Api.InputDocument]?, videoCover: Api.InputPhoto?, videoTimestamp: Int32?, ttlSeconds: Int32?) - case inputMediaUploadedPhoto(flags: Int32, file: Api.InputFile, stickers: [Api.InputDocument]?, ttlSeconds: Int32?) - case inputMediaVenue(geoPoint: Api.InputGeoPoint, title: String, address: String, provider: String, venueId: String, venueType: String) - case inputMediaWebPage(flags: Int32, url: String) + case inputMediaGame(Cons_inputMediaGame) + case inputMediaGeoLive(Cons_inputMediaGeoLive) + case inputMediaGeoPoint(Cons_inputMediaGeoPoint) + case inputMediaInvoice(Cons_inputMediaInvoice) + case inputMediaPaidMedia(Cons_inputMediaPaidMedia) + case inputMediaPhoto(Cons_inputMediaPhoto) + case inputMediaPhotoExternal(Cons_inputMediaPhotoExternal) + case inputMediaPoll(Cons_inputMediaPoll) + case inputMediaStakeDice(Cons_inputMediaStakeDice) + case inputMediaStory(Cons_inputMediaStory) + case inputMediaTodo(Cons_inputMediaTodo) + case inputMediaUploadedDocument(Cons_inputMediaUploadedDocument) + case inputMediaUploadedPhoto(Cons_inputMediaUploadedPhoto) + case inputMediaVenue(Cons_inputMediaVenue) + case inputMediaWebPage(Cons_inputMediaWebPage) public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) { #if DEBUG @@ -181,10 +407,30 @@ public extension Api { } public extension Api { enum InputMessage: TypeConstructorDescription { - case inputMessageCallbackQuery(id: Int32, queryId: Int64) - case inputMessageID(id: Int32) + public class Cons_inputMessageCallbackQuery { + public var id: Int32 + public var queryId: Int64 + public init(id: Int32, queryId: Int64) { + self.id = id + self.queryId = queryId + } + } + public class Cons_inputMessageID { + public var id: Int32 + public init(id: Int32) { + self.id = id + } + } + public class Cons_inputMessageReplyTo { + public var id: Int32 + public init(id: Int32) { + self.id = id + } + } + case inputMessageCallbackQuery(Cons_inputMessageCallbackQuery) + case inputMessageID(Cons_inputMessageID) case inputMessagePinned - case inputMessageReplyTo(id: Int32) + case inputMessageReplyTo(Cons_inputMessageReplyTo) public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) { #if DEBUG @@ -234,10 +480,24 @@ public extension Api { } public extension Api { indirect enum InputNotifyPeer: TypeConstructorDescription { + public class Cons_inputNotifyForumTopic { + public var peer: Api.InputPeer + public var topMsgId: Int32 + public init(peer: Api.InputPeer, topMsgId: Int32) { + self.peer = peer + self.topMsgId = topMsgId + } + } + public class Cons_inputNotifyPeer { + public var peer: Api.InputPeer + public init(peer: Api.InputPeer) { + self.peer = peer + } + } case inputNotifyBroadcasts case inputNotifyChats - case inputNotifyForumTopic(peer: Api.InputPeer, topMsgId: Int32) - case inputNotifyPeer(peer: Api.InputPeer) + case inputNotifyForumTopic(Cons_inputNotifyForumTopic) + case inputNotifyPeer(Cons_inputNotifyPeer) case inputNotifyUsers public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) { @@ -295,8 +555,24 @@ public extension Api { } public extension Api { enum InputPasskeyCredential: TypeConstructorDescription { - case inputPasskeyCredentialFirebasePNV(pnvToken: String) - case inputPasskeyCredentialPublicKey(id: String, rawId: String, response: Api.InputPasskeyResponse) + public class Cons_inputPasskeyCredentialFirebasePNV { + public var pnvToken: String + public init(pnvToken: String) { + self.pnvToken = pnvToken + } + } + public class Cons_inputPasskeyCredentialPublicKey { + public var id: String + public var rawId: String + public var response: Api.InputPasskeyResponse + public init(id: String, rawId: String, response: Api.InputPasskeyResponse) { + self.id = id + self.rawId = rawId + self.response = response + } + } + case inputPasskeyCredentialFirebasePNV(Cons_inputPasskeyCredentialFirebasePNV) + case inputPasskeyCredentialPublicKey(Cons_inputPasskeyCredentialPublicKey) public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) { #if DEBUG @@ -332,8 +608,28 @@ public extension Api { } public extension Api { enum InputPasskeyResponse: TypeConstructorDescription { - case inputPasskeyResponseLogin(clientData: Api.DataJSON, authenticatorData: Buffer, signature: Buffer, userHandle: String) - case inputPasskeyResponseRegister(clientData: Api.DataJSON, attestationData: Buffer) + public class Cons_inputPasskeyResponseLogin { + public var clientData: Api.DataJSON + public var authenticatorData: Buffer + public var signature: Buffer + public var userHandle: String + public init(clientData: Api.DataJSON, authenticatorData: Buffer, signature: Buffer, userHandle: String) { + self.clientData = clientData + self.authenticatorData = authenticatorData + self.signature = signature + self.userHandle = userHandle + } + } + public class Cons_inputPasskeyResponseRegister { + public var clientData: Api.DataJSON + public var attestationData: Buffer + public init(clientData: Api.DataJSON, attestationData: Buffer) { + self.clientData = clientData + self.attestationData = attestationData + } + } + case inputPasskeyResponseLogin(Cons_inputPasskeyResponseLogin) + case inputPasskeyResponseRegister(Cons_inputPasskeyResponseRegister) public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) { #if DEBUG diff --git a/submodules/TelegramApi/Sources/Api12.swift b/submodules/TelegramApi/Sources/Api12.swift index 0e7961c7e2..7362460e5e 100644 --- a/submodules/TelegramApi/Sources/Api12.swift +++ b/submodules/TelegramApi/Sources/Api12.swift @@ -1,9 +1,37 @@ public extension Api { enum InputPaymentCredentials: TypeConstructorDescription { - case inputPaymentCredentials(flags: Int32, data: Api.DataJSON) - case inputPaymentCredentialsApplePay(paymentData: Api.DataJSON) - case inputPaymentCredentialsGooglePay(paymentToken: Api.DataJSON) - case inputPaymentCredentialsSaved(id: String, tmpPassword: Buffer) + public class Cons_inputPaymentCredentials { + public var flags: Int32 + public var data: Api.DataJSON + public init(flags: Int32, data: Api.DataJSON) { + self.flags = flags + self.data = data + } + } + public class Cons_inputPaymentCredentialsApplePay { + public var paymentData: Api.DataJSON + public init(paymentData: Api.DataJSON) { + self.paymentData = paymentData + } + } + public class Cons_inputPaymentCredentialsGooglePay { + public var paymentToken: Api.DataJSON + public init(paymentToken: Api.DataJSON) { + self.paymentToken = paymentToken + } + } + public class Cons_inputPaymentCredentialsSaved { + public var id: String + public var tmpPassword: Buffer + public init(id: String, tmpPassword: Buffer) { + self.id = id + self.tmpPassword = tmpPassword + } + } + case inputPaymentCredentials(Cons_inputPaymentCredentials) + case inputPaymentCredentialsApplePay(Cons_inputPaymentCredentialsApplePay) + case inputPaymentCredentialsGooglePay(Cons_inputPaymentCredentialsGooglePay) + case inputPaymentCredentialsSaved(Cons_inputPaymentCredentialsSaved) public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) { #if DEBUG @@ -53,13 +81,55 @@ public extension Api { } public extension Api { indirect enum InputPeer: TypeConstructorDescription { - case inputPeerChannel(channelId: Int64, accessHash: Int64) - case inputPeerChannelFromMessage(peer: Api.InputPeer, msgId: Int32, channelId: Int64) - case inputPeerChat(chatId: Int64) + public class Cons_inputPeerChannel { + public var channelId: Int64 + public var accessHash: Int64 + public init(channelId: Int64, accessHash: Int64) { + self.channelId = channelId + self.accessHash = accessHash + } + } + public class Cons_inputPeerChannelFromMessage { + public var peer: Api.InputPeer + public var msgId: Int32 + public var channelId: Int64 + public init(peer: Api.InputPeer, msgId: Int32, channelId: Int64) { + self.peer = peer + self.msgId = msgId + self.channelId = channelId + } + } + public class Cons_inputPeerChat { + public var chatId: Int64 + public init(chatId: Int64) { + self.chatId = chatId + } + } + public class Cons_inputPeerUser { + public var userId: Int64 + public var accessHash: Int64 + public init(userId: Int64, accessHash: Int64) { + self.userId = userId + self.accessHash = accessHash + } + } + public class Cons_inputPeerUserFromMessage { + public var peer: Api.InputPeer + public var msgId: Int32 + public var userId: Int64 + public init(peer: Api.InputPeer, msgId: Int32, userId: Int64) { + self.peer = peer + self.msgId = msgId + self.userId = userId + } + } + case inputPeerChannel(Cons_inputPeerChannel) + case inputPeerChannelFromMessage(Cons_inputPeerChannelFromMessage) + case inputPeerChat(Cons_inputPeerChat) case inputPeerEmpty case inputPeerSelf - case inputPeerUser(userId: Int64, accessHash: Int64) - case inputPeerUserFromMessage(peer: Api.InputPeer, msgId: Int32, userId: Int64) + case inputPeerUser(Cons_inputPeerUser) + case inputPeerUserFromMessage(Cons_inputPeerUserFromMessage) public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) { #if DEBUG @@ -130,7 +200,27 @@ public extension Api { } public extension Api { enum InputPeerNotifySettings: TypeConstructorDescription { - case inputPeerNotifySettings(flags: Int32, showPreviews: Api.Bool?, silent: Api.Bool?, muteUntil: Int32?, sound: Api.NotificationSound?, storiesMuted: Api.Bool?, storiesHideSender: Api.Bool?, storiesSound: Api.NotificationSound?) + public class Cons_inputPeerNotifySettings { + public var flags: Int32 + public var showPreviews: Api.Bool? + public var silent: Api.Bool? + public var muteUntil: Int32? + public var sound: Api.NotificationSound? + public var storiesMuted: Api.Bool? + public var storiesHideSender: Api.Bool? + public var storiesSound: Api.NotificationSound? + public init(flags: Int32, showPreviews: Api.Bool?, silent: Api.Bool?, muteUntil: Int32?, sound: Api.NotificationSound?, storiesMuted: Api.Bool?, storiesHideSender: Api.Bool?, storiesSound: Api.NotificationSound?) { + self.flags = flags + self.showPreviews = showPreviews + self.silent = silent + self.muteUntil = muteUntil + self.sound = sound + self.storiesMuted = storiesMuted + self.storiesHideSender = storiesHideSender + self.storiesSound = storiesSound + } + } + case inputPeerNotifySettings(Cons_inputPeerNotifySettings) public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) { #if DEBUG @@ -159,7 +249,15 @@ public extension Api { } public extension Api { enum InputPhoneCall: TypeConstructorDescription { - case inputPhoneCall(id: Int64, accessHash: Int64) + public class Cons_inputPhoneCall { + public var id: Int64 + public var accessHash: Int64 + public init(id: Int64, accessHash: Int64) { + self.id = id + self.accessHash = accessHash + } + } + case inputPhoneCall(Cons_inputPhoneCall) public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) { #if DEBUG @@ -188,7 +286,17 @@ public extension Api { } public extension Api { enum InputPhoto: TypeConstructorDescription { - case inputPhoto(id: Int64, accessHash: Int64, fileReference: Buffer) + public class Cons_inputPhoto { + public var id: Int64 + public var accessHash: Int64 + public var fileReference: Buffer + public init(id: Int64, accessHash: Int64, fileReference: Buffer) { + self.id = id + self.accessHash = accessHash + self.fileReference = fileReference + } + } + case inputPhoto(Cons_inputPhoto) case inputPhotoEmpty public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) { @@ -358,18 +466,42 @@ public extension Api { } public extension Api { enum InputPrivacyRule: TypeConstructorDescription { + public class Cons_inputPrivacyValueAllowChatParticipants { + public var chats: [Int64] + public init(chats: [Int64]) { + self.chats = chats + } + } + public class Cons_inputPrivacyValueAllowUsers { + public var users: [Api.InputUser] + public init(users: [Api.InputUser]) { + self.users = users + } + } + public class Cons_inputPrivacyValueDisallowChatParticipants { + public var chats: [Int64] + public init(chats: [Int64]) { + self.chats = chats + } + } + public class Cons_inputPrivacyValueDisallowUsers { + public var users: [Api.InputUser] + public init(users: [Api.InputUser]) { + self.users = users + } + } case inputPrivacyValueAllowAll case inputPrivacyValueAllowBots - case inputPrivacyValueAllowChatParticipants(chats: [Int64]) + case inputPrivacyValueAllowChatParticipants(Cons_inputPrivacyValueAllowChatParticipants) case inputPrivacyValueAllowCloseFriends case inputPrivacyValueAllowContacts case inputPrivacyValueAllowPremium - case inputPrivacyValueAllowUsers(users: [Api.InputUser]) + case inputPrivacyValueAllowUsers(Cons_inputPrivacyValueAllowUsers) case inputPrivacyValueDisallowAll case inputPrivacyValueDisallowBots - case inputPrivacyValueDisallowChatParticipants(chats: [Int64]) + case inputPrivacyValueDisallowChatParticipants(Cons_inputPrivacyValueDisallowChatParticipants) case inputPrivacyValueDisallowContacts - case inputPrivacyValueDisallowUsers(users: [Api.InputUser]) + case inputPrivacyValueDisallowUsers(Cons_inputPrivacyValueDisallowUsers) public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) { #if DEBUG diff --git a/submodules/TelegramApi/Sources/Api13.swift b/submodules/TelegramApi/Sources/Api13.swift index ed3c336a8a..041d0d501b 100644 --- a/submodules/TelegramApi/Sources/Api13.swift +++ b/submodules/TelegramApi/Sources/Api13.swift @@ -1,7 +1,19 @@ public extension Api { enum InputQuickReplyShortcut: TypeConstructorDescription { - case inputQuickReplyShortcut(shortcut: String) - case inputQuickReplyShortcutId(shortcutId: Int32) + public class Cons_inputQuickReplyShortcut { + public var shortcut: String + public init(shortcut: String) { + self.shortcut = shortcut + } + } + public class Cons_inputQuickReplyShortcutId { + public var shortcutId: Int32 + public init(shortcutId: Int32) { + self.shortcutId = shortcutId + } + } + case inputQuickReplyShortcut(Cons_inputQuickReplyShortcut) + case inputQuickReplyShortcutId(Cons_inputQuickReplyShortcutId) public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) { #if DEBUG @@ -37,9 +49,45 @@ public extension Api { } public extension Api { indirect enum InputReplyTo: TypeConstructorDescription { - case inputReplyToMessage(flags: Int32, replyToMsgId: Int32, topMsgId: Int32?, replyToPeerId: Api.InputPeer?, quoteText: String?, quoteEntities: [Api.MessageEntity]?, quoteOffset: Int32?, monoforumPeerId: Api.InputPeer?, todoItemId: Int32?) - case inputReplyToMonoForum(monoforumPeerId: Api.InputPeer) - case inputReplyToStory(peer: Api.InputPeer, storyId: Int32) + public class Cons_inputReplyToMessage { + public var flags: Int32 + public var replyToMsgId: Int32 + public var topMsgId: Int32? + public var replyToPeerId: Api.InputPeer? + public var quoteText: String? + public var quoteEntities: [Api.MessageEntity]? + public var quoteOffset: Int32? + public var monoforumPeerId: Api.InputPeer? + public var todoItemId: Int32? + public init(flags: Int32, replyToMsgId: Int32, topMsgId: Int32?, replyToPeerId: Api.InputPeer?, quoteText: String?, quoteEntities: [Api.MessageEntity]?, quoteOffset: Int32?, monoforumPeerId: Api.InputPeer?, todoItemId: Int32?) { + self.flags = flags + self.replyToMsgId = replyToMsgId + self.topMsgId = topMsgId + self.replyToPeerId = replyToPeerId + self.quoteText = quoteText + self.quoteEntities = quoteEntities + self.quoteOffset = quoteOffset + self.monoforumPeerId = monoforumPeerId + self.todoItemId = todoItemId + } + } + public class Cons_inputReplyToMonoForum { + public var monoforumPeerId: Api.InputPeer + public init(monoforumPeerId: Api.InputPeer) { + self.monoforumPeerId = monoforumPeerId + } + } + public class Cons_inputReplyToStory { + public var peer: Api.InputPeer + public var storyId: Int32 + public init(peer: Api.InputPeer, storyId: Int32) { + self.peer = peer + self.storyId = storyId + } + } + case inputReplyToMessage(Cons_inputReplyToMessage) + case inputReplyToMonoForum(Cons_inputReplyToMonoForum) + case inputReplyToStory(Cons_inputReplyToStory) public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) { #if DEBUG @@ -82,9 +130,29 @@ public extension Api { } public extension Api { indirect enum InputSavedStarGift: TypeConstructorDescription { - case inputSavedStarGiftChat(peer: Api.InputPeer, savedId: Int64) - case inputSavedStarGiftSlug(slug: String) - case inputSavedStarGiftUser(msgId: Int32) + public class Cons_inputSavedStarGiftChat { + public var peer: Api.InputPeer + public var savedId: Int64 + public init(peer: Api.InputPeer, savedId: Int64) { + self.peer = peer + self.savedId = savedId + } + } + public class Cons_inputSavedStarGiftSlug { + public var slug: String + public init(slug: String) { + self.slug = slug + } + } + public class Cons_inputSavedStarGiftUser { + public var msgId: Int32 + public init(msgId: Int32) { + self.msgId = msgId + } + } + case inputSavedStarGiftChat(Cons_inputSavedStarGiftChat) + case inputSavedStarGiftSlug(Cons_inputSavedStarGiftSlug) + case inputSavedStarGiftUser(Cons_inputSavedStarGiftUser) public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) { #if DEBUG @@ -127,8 +195,30 @@ public extension Api { } public extension Api { enum InputSecureFile: TypeConstructorDescription { - case inputSecureFile(id: Int64, accessHash: Int64) - case inputSecureFileUploaded(id: Int64, parts: Int32, md5Checksum: String, fileHash: Buffer, secret: Buffer) + public class Cons_inputSecureFile { + public var id: Int64 + public var accessHash: Int64 + public init(id: Int64, accessHash: Int64) { + self.id = id + self.accessHash = accessHash + } + } + public class Cons_inputSecureFileUploaded { + public var id: Int64 + public var parts: Int32 + public var md5Checksum: String + public var fileHash: Buffer + public var secret: Buffer + public init(id: Int64, parts: Int32, md5Checksum: String, fileHash: Buffer, secret: Buffer) { + self.id = id + self.parts = parts + self.md5Checksum = md5Checksum + self.fileHash = fileHash + self.secret = secret + } + } + case inputSecureFile(Cons_inputSecureFile) + case inputSecureFileUploaded(Cons_inputSecureFileUploaded) public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) { #if DEBUG @@ -164,7 +254,29 @@ public extension Api { } public extension Api { enum InputSecureValue: TypeConstructorDescription { - case inputSecureValue(flags: Int32, type: Api.SecureValueType, data: Api.SecureData?, frontSide: Api.InputSecureFile?, reverseSide: Api.InputSecureFile?, selfie: Api.InputSecureFile?, translation: [Api.InputSecureFile]?, files: [Api.InputSecureFile]?, plainData: Api.SecurePlainData?) + public class Cons_inputSecureValue { + public var flags: Int32 + public var type: Api.SecureValueType + public var data: Api.SecureData? + public var frontSide: Api.InputSecureFile? + public var reverseSide: Api.InputSecureFile? + public var selfie: Api.InputSecureFile? + public var translation: [Api.InputSecureFile]? + public var files: [Api.InputSecureFile]? + public var plainData: Api.SecurePlainData? + public init(flags: Int32, type: Api.SecureValueType, data: Api.SecureData?, frontSide: Api.InputSecureFile?, reverseSide: Api.InputSecureFile?, selfie: Api.InputSecureFile?, translation: [Api.InputSecureFile]?, files: [Api.InputSecureFile]?, plainData: Api.SecurePlainData?) { + self.flags = flags + self.type = type + self.data = data + self.frontSide = frontSide + self.reverseSide = reverseSide + self.selfie = selfie + self.translation = translation + self.files = files + self.plainData = plainData + } + } + case inputSecureValue(Cons_inputSecureValue) public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) { #if DEBUG @@ -193,7 +305,21 @@ public extension Api { } public extension Api { indirect enum InputSingleMedia: TypeConstructorDescription { - case inputSingleMedia(flags: Int32, media: Api.InputMedia, randomId: Int64, message: String, entities: [Api.MessageEntity]?) + public class Cons_inputSingleMedia { + public var flags: Int32 + public var media: Api.InputMedia + public var randomId: Int64 + public var message: String + public var entities: [Api.MessageEntity]? + public init(flags: Int32, media: Api.InputMedia, randomId: Int64, message: String, entities: [Api.MessageEntity]?) { + self.flags = flags + self.media = media + self.randomId = randomId + self.message = message + self.entities = entities + } + } + case inputSingleMedia(Cons_inputSingleMedia) public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) { #if DEBUG @@ -222,8 +348,20 @@ public extension Api { } public extension Api { enum InputStarGiftAuction: TypeConstructorDescription { - case inputStarGiftAuction(giftId: Int64) - case inputStarGiftAuctionSlug(slug: String) + public class Cons_inputStarGiftAuction { + public var giftId: Int64 + public init(giftId: Int64) { + self.giftId = giftId + } + } + public class Cons_inputStarGiftAuctionSlug { + public var slug: String + public init(slug: String) { + self.slug = slug + } + } + case inputStarGiftAuction(Cons_inputStarGiftAuction) + case inputStarGiftAuctionSlug(Cons_inputStarGiftAuctionSlug) public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) { #if DEBUG @@ -259,7 +397,15 @@ public extension Api { } public extension Api { enum InputStarsTransaction: TypeConstructorDescription { - case inputStarsTransaction(flags: Int32, id: String) + public class Cons_inputStarsTransaction { + public var flags: Int32 + public var id: String + public init(flags: Int32, id: String) { + self.flags = flags + self.id = id + } + } + case inputStarsTransaction(Cons_inputStarsTransaction) public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) { #if DEBUG @@ -288,17 +434,37 @@ public extension Api { } public extension Api { enum InputStickerSet: TypeConstructorDescription { + public class Cons_inputStickerSetDice { + public var emoticon: String + public init(emoticon: String) { + self.emoticon = emoticon + } + } + public class Cons_inputStickerSetID { + public var id: Int64 + public var accessHash: Int64 + public init(id: Int64, accessHash: Int64) { + self.id = id + self.accessHash = accessHash + } + } + public class Cons_inputStickerSetShortName { + public var shortName: String + public init(shortName: String) { + self.shortName = shortName + } + } case inputStickerSetAnimatedEmoji case inputStickerSetAnimatedEmojiAnimations - case inputStickerSetDice(emoticon: String) + case inputStickerSetDice(Cons_inputStickerSetDice) case inputStickerSetEmojiChannelDefaultStatuses case inputStickerSetEmojiDefaultStatuses case inputStickerSetEmojiDefaultTopicIcons case inputStickerSetEmojiGenericAnimations case inputStickerSetEmpty - case inputStickerSetID(id: Int64, accessHash: Int64) + case inputStickerSetID(Cons_inputStickerSetID) case inputStickerSetPremiumGifts - case inputStickerSetShortName(shortName: String) + case inputStickerSetShortName(Cons_inputStickerSetShortName) case inputStickerSetTonGifts public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) { @@ -405,7 +571,21 @@ public extension Api { } public extension Api { enum InputStickerSetItem: TypeConstructorDescription { - case inputStickerSetItem(flags: Int32, document: Api.InputDocument, emoji: String, maskCoords: Api.MaskCoords?, keywords: String?) + public class Cons_inputStickerSetItem { + public var flags: Int32 + public var document: Api.InputDocument + public var emoji: String + public var maskCoords: Api.MaskCoords? + public var keywords: String? + public init(flags: Int32, document: Api.InputDocument, emoji: String, maskCoords: Api.MaskCoords?, keywords: String?) { + self.flags = flags + self.document = document + self.emoji = emoji + self.maskCoords = maskCoords + self.keywords = keywords + } + } + case inputStickerSetItem(Cons_inputStickerSetItem) public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) { #if DEBUG @@ -434,8 +614,20 @@ public extension Api { } public extension Api { enum InputStickeredMedia: TypeConstructorDescription { - case inputStickeredMediaDocument(id: Api.InputDocument) - case inputStickeredMediaPhoto(id: Api.InputPhoto) + public class Cons_inputStickeredMediaDocument { + public var id: Api.InputDocument + public init(id: Api.InputDocument) { + self.id = id + } + } + public class Cons_inputStickeredMediaPhoto { + public var id: Api.InputPhoto + public init(id: Api.InputPhoto) { + self.id = id + } + } + case inputStickeredMediaDocument(Cons_inputStickeredMediaDocument) + case inputStickeredMediaPhoto(Cons_inputStickeredMediaPhoto) public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) { #if DEBUG @@ -471,14 +663,134 @@ public extension Api { } public extension Api { indirect enum InputStorePaymentPurpose: TypeConstructorDescription { - case inputStorePaymentAuthCode(flags: Int32, phoneNumber: String, phoneCodeHash: String, currency: String, amount: Int64) - case inputStorePaymentGiftPremium(userId: Api.InputUser, currency: String, amount: Int64) - case inputStorePaymentPremiumGiftCode(flags: Int32, users: [Api.InputUser], boostPeer: Api.InputPeer?, currency: String, amount: Int64, message: Api.TextWithEntities?) - case inputStorePaymentPremiumGiveaway(flags: Int32, boostPeer: Api.InputPeer, additionalPeers: [Api.InputPeer]?, countriesIso2: [String]?, prizeDescription: String?, randomId: Int64, untilDate: Int32, currency: String, amount: Int64) - case inputStorePaymentPremiumSubscription(flags: Int32) - case inputStorePaymentStarsGift(userId: Api.InputUser, stars: Int64, currency: String, amount: Int64) - case inputStorePaymentStarsGiveaway(flags: Int32, stars: Int64, boostPeer: Api.InputPeer, additionalPeers: [Api.InputPeer]?, countriesIso2: [String]?, prizeDescription: String?, randomId: Int64, untilDate: Int32, currency: String, amount: Int64, users: Int32) - case inputStorePaymentStarsTopup(flags: Int32, stars: Int64, currency: String, amount: Int64, spendPurposePeer: Api.InputPeer?) + public class Cons_inputStorePaymentAuthCode { + public var flags: Int32 + public var phoneNumber: String + public var phoneCodeHash: String + public var currency: String + public var amount: Int64 + public init(flags: Int32, phoneNumber: String, phoneCodeHash: String, currency: String, amount: Int64) { + self.flags = flags + self.phoneNumber = phoneNumber + self.phoneCodeHash = phoneCodeHash + self.currency = currency + self.amount = amount + } + } + public class Cons_inputStorePaymentGiftPremium { + public var userId: Api.InputUser + public var currency: String + public var amount: Int64 + public init(userId: Api.InputUser, currency: String, amount: Int64) { + self.userId = userId + self.currency = currency + self.amount = amount + } + } + public class Cons_inputStorePaymentPremiumGiftCode { + public var flags: Int32 + public var users: [Api.InputUser] + public var boostPeer: Api.InputPeer? + public var currency: String + public var amount: Int64 + public var message: Api.TextWithEntities? + public init(flags: Int32, users: [Api.InputUser], boostPeer: Api.InputPeer?, currency: String, amount: Int64, message: Api.TextWithEntities?) { + self.flags = flags + self.users = users + self.boostPeer = boostPeer + self.currency = currency + self.amount = amount + self.message = message + } + } + public class Cons_inputStorePaymentPremiumGiveaway { + public var flags: Int32 + public var boostPeer: Api.InputPeer + public var additionalPeers: [Api.InputPeer]? + public var countriesIso2: [String]? + public var prizeDescription: String? + public var randomId: Int64 + public var untilDate: Int32 + public var currency: String + public var amount: Int64 + public init(flags: Int32, boostPeer: Api.InputPeer, additionalPeers: [Api.InputPeer]?, countriesIso2: [String]?, prizeDescription: String?, randomId: Int64, untilDate: Int32, currency: String, amount: Int64) { + self.flags = flags + self.boostPeer = boostPeer + self.additionalPeers = additionalPeers + self.countriesIso2 = countriesIso2 + self.prizeDescription = prizeDescription + self.randomId = randomId + self.untilDate = untilDate + self.currency = currency + self.amount = amount + } + } + public class Cons_inputStorePaymentPremiumSubscription { + public var flags: Int32 + public init(flags: Int32) { + self.flags = flags + } + } + public class Cons_inputStorePaymentStarsGift { + public var userId: Api.InputUser + public var stars: Int64 + public var currency: String + public var amount: Int64 + public init(userId: Api.InputUser, stars: Int64, currency: String, amount: Int64) { + self.userId = userId + self.stars = stars + self.currency = currency + self.amount = amount + } + } + public class Cons_inputStorePaymentStarsGiveaway { + public var flags: Int32 + public var stars: Int64 + public var boostPeer: Api.InputPeer + public var additionalPeers: [Api.InputPeer]? + public var countriesIso2: [String]? + public var prizeDescription: String? + public var randomId: Int64 + public var untilDate: Int32 + public var currency: String + public var amount: Int64 + public var users: Int32 + public init(flags: Int32, stars: Int64, boostPeer: Api.InputPeer, additionalPeers: [Api.InputPeer]?, countriesIso2: [String]?, prizeDescription: String?, randomId: Int64, untilDate: Int32, currency: String, amount: Int64, users: Int32) { + self.flags = flags + self.stars = stars + self.boostPeer = boostPeer + self.additionalPeers = additionalPeers + self.countriesIso2 = countriesIso2 + self.prizeDescription = prizeDescription + self.randomId = randomId + self.untilDate = untilDate + self.currency = currency + self.amount = amount + self.users = users + } + } + public class Cons_inputStorePaymentStarsTopup { + public var flags: Int32 + public var stars: Int64 + public var currency: String + public var amount: Int64 + public var spendPurposePeer: Api.InputPeer? + public init(flags: Int32, stars: Int64, currency: String, amount: Int64, spendPurposePeer: Api.InputPeer?) { + self.flags = flags + self.stars = stars + self.currency = currency + self.amount = amount + self.spendPurposePeer = spendPurposePeer + } + } + case inputStorePaymentAuthCode(Cons_inputStorePaymentAuthCode) + case inputStorePaymentGiftPremium(Cons_inputStorePaymentGiftPremium) + case inputStorePaymentPremiumGiftCode(Cons_inputStorePaymentPremiumGiftCode) + case inputStorePaymentPremiumGiveaway(Cons_inputStorePaymentPremiumGiveaway) + case inputStorePaymentPremiumSubscription(Cons_inputStorePaymentPremiumSubscription) + case inputStorePaymentStarsGift(Cons_inputStorePaymentStarsGift) + case inputStorePaymentStarsGiveaway(Cons_inputStorePaymentStarsGiveaway) + case inputStorePaymentStarsTopup(Cons_inputStorePaymentStarsTopup) public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) { #if DEBUG diff --git a/submodules/TelegramApi/Sources/Api14.swift b/submodules/TelegramApi/Sources/Api14.swift index d4ee450a6b..44b5a5e707 100644 --- a/submodules/TelegramApi/Sources/Api14.swift +++ b/submodules/TelegramApi/Sources/Api14.swift @@ -1,7 +1,21 @@ public extension Api { enum InputTheme: TypeConstructorDescription { - case inputTheme(id: Int64, accessHash: Int64) - case inputThemeSlug(slug: String) + public class Cons_inputTheme { + public var id: Int64 + public var accessHash: Int64 + public init(id: Int64, accessHash: Int64) { + self.id = id + self.accessHash = accessHash + } + } + public class Cons_inputThemeSlug { + public var slug: String + public init(slug: String) { + self.slug = slug + } + } + case inputTheme(Cons_inputTheme) + case inputThemeSlug(Cons_inputThemeSlug) public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) { #if DEBUG @@ -37,7 +51,25 @@ public extension Api { } public extension Api { enum InputThemeSettings: TypeConstructorDescription { - case inputThemeSettings(flags: Int32, baseTheme: Api.BaseTheme, accentColor: Int32, outboxAccentColor: Int32?, messageColors: [Int32]?, wallpaper: Api.InputWallPaper?, wallpaperSettings: Api.WallPaperSettings?) + public class Cons_inputThemeSettings { + public var flags: Int32 + public var baseTheme: Api.BaseTheme + public var accentColor: Int32 + public var outboxAccentColor: Int32? + public var messageColors: [Int32]? + public var wallpaper: Api.InputWallPaper? + public var wallpaperSettings: Api.WallPaperSettings? + public init(flags: Int32, baseTheme: Api.BaseTheme, accentColor: Int32, outboxAccentColor: Int32?, messageColors: [Int32]?, wallpaper: Api.InputWallPaper?, wallpaperSettings: Api.WallPaperSettings?) { + self.flags = flags + self.baseTheme = baseTheme + self.accentColor = accentColor + self.outboxAccentColor = outboxAccentColor + self.messageColors = messageColors + self.wallpaper = wallpaper + self.wallpaperSettings = wallpaperSettings + } + } + case inputThemeSettings(Cons_inputThemeSettings) public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) { #if DEBUG @@ -66,9 +98,27 @@ public extension Api { } public extension Api { indirect enum InputUser: TypeConstructorDescription { - case inputUser(userId: Int64, accessHash: Int64) + public class Cons_inputUser { + public var userId: Int64 + public var accessHash: Int64 + public init(userId: Int64, accessHash: Int64) { + self.userId = userId + self.accessHash = accessHash + } + } + public class Cons_inputUserFromMessage { + public var peer: Api.InputPeer + public var msgId: Int32 + public var userId: Int64 + public init(peer: Api.InputPeer, msgId: Int32, userId: Int64) { + self.peer = peer + self.msgId = msgId + self.userId = userId + } + } + case inputUser(Cons_inputUser) case inputUserEmpty - case inputUserFromMessage(peer: Api.InputPeer, msgId: Int32, userId: Int64) + case inputUserFromMessage(Cons_inputUserFromMessage) case inputUserSelf public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) { @@ -119,9 +169,29 @@ public extension Api { } public extension Api { enum InputWallPaper: TypeConstructorDescription { - case inputWallPaper(id: Int64, accessHash: Int64) - case inputWallPaperNoFile(id: Int64) - case inputWallPaperSlug(slug: String) + public class Cons_inputWallPaper { + public var id: Int64 + public var accessHash: Int64 + public init(id: Int64, accessHash: Int64) { + self.id = id + self.accessHash = accessHash + } + } + public class Cons_inputWallPaperNoFile { + public var id: Int64 + public init(id: Int64) { + self.id = id + } + } + public class Cons_inputWallPaperSlug { + public var slug: String + public init(slug: String) { + self.slug = slug + } + } + case inputWallPaper(Cons_inputWallPaper) + case inputWallPaperNoFile(Cons_inputWallPaperNoFile) + case inputWallPaperSlug(Cons_inputWallPaperSlug) public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) { #if DEBUG @@ -164,7 +234,19 @@ public extension Api { } public extension Api { enum InputWebDocument: TypeConstructorDescription { - case inputWebDocument(url: String, size: Int32, mimeType: String, attributes: [Api.DocumentAttribute]) + public class Cons_inputWebDocument { + public var url: String + public var size: Int32 + public var mimeType: String + public var attributes: [Api.DocumentAttribute] + public init(url: String, size: Int32, mimeType: String, attributes: [Api.DocumentAttribute]) { + self.url = url + self.size = size + self.mimeType = mimeType + self.attributes = attributes + } + } + case inputWebDocument(Cons_inputWebDocument) public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) { #if DEBUG diff --git a/submodules/TelegramCore/Sources/Account/Account.swift b/submodules/TelegramCore/Sources/Account/Account.swift index 2f38c63485..483c81b92a 100644 --- a/submodules/TelegramCore/Sources/Account/Account.swift +++ b/submodules/TelegramCore/Sources/Account/Account.swift @@ -544,7 +544,7 @@ func _internal_requestPasskeyRegistration(network: Network) -> Signal Signal { - return network.request(Api.functions.account.registerPasskey(credential: .inputPasskeyCredentialPublicKey(id: id, rawId: id, response: .inputPasskeyResponseRegister(clientData: .dataJSON(.init(data: clientData)), attestationData: Buffer(data: attestationObject))))) + return network.request(Api.functions.account.registerPasskey(credential: .inputPasskeyCredentialPublicKey(.init(id: id, rawId: id, response: .inputPasskeyResponseRegister(.init(clientData: .dataJSON(.init(data: clientData)), attestationData: Buffer(data: attestationObject))))))) |> map(Optional.init) |> `catch` { _ -> Signal in return .single(nil) diff --git a/submodules/TelegramCore/Sources/ApiUtils/ApiUtils.swift b/submodules/TelegramCore/Sources/ApiUtils/ApiUtils.swift index d65d3be740..43a8d691e6 100644 --- a/submodules/TelegramCore/Sources/ApiUtils/ApiUtils.swift +++ b/submodules/TelegramCore/Sources/ApiUtils/ApiUtils.swift @@ -20,17 +20,17 @@ extension PeerReference { var inputPeer: Api.InputPeer { switch self { case let .user(id, accessHash): - return .inputPeerUser(userId: id, accessHash: accessHash) + return .inputPeerUser(.init(userId: id, accessHash: accessHash)) case let .group(id): - return .inputPeerChat(chatId: id) + return .inputPeerChat(.init(chatId: id)) case let .channel(id, accessHash): - return .inputPeerChannel(channelId: id, accessHash: accessHash) + return .inputPeerChannel(.init(channelId: id, accessHash: accessHash)) } } var inputUser: Api.InputUser? { if case let .user(id, accessHash) = self { - return .inputUser(userId: id, accessHash: accessHash) + return .inputUser(.init(userId: id, accessHash: accessHash)) } else { return nil } @@ -48,12 +48,12 @@ extension PeerReference { func forceApiInputPeer(_ peer: Peer) -> Api.InputPeer? { switch peer { case let user as TelegramUser: - return Api.InputPeer.inputPeerUser(userId: user.id.id._internalGetInt64Value(), accessHash: user.accessHash?.value ?? 0) + return Api.InputPeer.inputPeerUser(.init(userId: user.id.id._internalGetInt64Value(), accessHash: user.accessHash?.value ?? 0)) case let group as TelegramGroup: - return Api.InputPeer.inputPeerChat(chatId: group.id.id._internalGetInt64Value()) + return Api.InputPeer.inputPeerChat(.init(chatId: group.id.id._internalGetInt64Value())) case let channel as TelegramChannel: if let accessHash = channel.accessHash { - return Api.InputPeer.inputPeerChannel(channelId: channel.id.id._internalGetInt64Value(), accessHash: accessHash.value) + return Api.InputPeer.inputPeerChannel(.init(channelId: channel.id.id._internalGetInt64Value(), accessHash: accessHash.value)) } else { return nil } @@ -65,12 +65,12 @@ func forceApiInputPeer(_ peer: Peer) -> Api.InputPeer? { func apiInputPeer(_ peer: Peer) -> Api.InputPeer? { switch peer { case let user as TelegramUser where user.accessHash != nil: - return Api.InputPeer.inputPeerUser(userId: user.id.id._internalGetInt64Value(), accessHash: user.accessHash!.value) + return Api.InputPeer.inputPeerUser(.init(userId: user.id.id._internalGetInt64Value(), accessHash: user.accessHash!.value)) case let group as TelegramGroup: - return Api.InputPeer.inputPeerChat(chatId: group.id.id._internalGetInt64Value()) + return Api.InputPeer.inputPeerChat(.init(chatId: group.id.id._internalGetInt64Value())) case let channel as TelegramChannel: if let accessHash = channel.accessHash { - return Api.InputPeer.inputPeerChannel(channelId: channel.id.id._internalGetInt64Value(), accessHash: accessHash.value) + return Api.InputPeer.inputPeerChannel(.init(channelId: channel.id.id._internalGetInt64Value(), accessHash: accessHash.value)) } else { return nil } @@ -96,7 +96,7 @@ func apiInputChannel(_ peer: Peer) -> Api.InputChannel? { func apiInputUser(_ peer: Peer) -> Api.InputUser? { if let user = peer as? TelegramUser, let accessHash = user.accessHash { - return Api.InputUser.inputUser(userId: user.id.id._internalGetInt64Value(), accessHash: accessHash.value) + return Api.InputUser.inputUser(.init(userId: user.id.id._internalGetInt64Value(), accessHash: accessHash.value)) } else { return nil } diff --git a/submodules/TelegramCore/Sources/ApiUtils/TelegramMediaFile.swift b/submodules/TelegramCore/Sources/ApiUtils/TelegramMediaFile.swift index b49f9cc350..270eba45ad 100644 --- a/submodules/TelegramCore/Sources/ApiUtils/TelegramMediaFile.swift +++ b/submodules/TelegramCore/Sources/ApiUtils/TelegramMediaFile.swift @@ -69,13 +69,16 @@ extension StickerPackReference { switch apiInputSet { case .inputStickerSetEmpty: return nil - case let .inputStickerSetID(id, accessHash): + case let .inputStickerSetID(inputStickerSetIDData): + let (id, accessHash) = (inputStickerSetIDData.id, inputStickerSetIDData.accessHash) self = .id(id: id, accessHash: accessHash) - case let .inputStickerSetShortName(shortName): + case let .inputStickerSetShortName(inputStickerSetShortNameData): + let shortName = inputStickerSetShortNameData.shortName self = .name(shortName) case .inputStickerSetAnimatedEmoji: self = .animatedEmoji - case let .inputStickerSetDice(emoticon): + case let .inputStickerSetDice(inputStickerSetDiceData): + let emoticon = inputStickerSetDiceData.emoticon self = .dice(emoticon) case .inputStickerSetAnimatedEmojiAnimations: self = .animatedEmojiAnimations diff --git a/submodules/TelegramCore/Sources/ApiUtils/Wallpaper.swift b/submodules/TelegramCore/Sources/ApiUtils/Wallpaper.swift index a7eebe3809..389c16b0b5 100644 --- a/submodules/TelegramCore/Sources/ApiUtils/Wallpaper.swift +++ b/submodules/TelegramCore/Sources/ApiUtils/Wallpaper.swift @@ -107,13 +107,13 @@ extension TelegramWallpaper { case .builtin: return nil case let .file(file): - return (.inputWallPaperSlug(slug: file.slug), apiWallpaperSettings(file.settings)) + return (.inputWallPaperSlug(.init(slug: file.slug)), apiWallpaperSettings(file.settings)) case let .color(color): - return (.inputWallPaperNoFile(id: 0), apiWallpaperSettings(WallpaperSettings(colors: [color]))) + return (.inputWallPaperNoFile(.init(id: 0)), apiWallpaperSettings(WallpaperSettings(colors: [color]))) case let .gradient(gradient): - return (.inputWallPaperNoFile(id: gradient.id ?? 0), apiWallpaperSettings(WallpaperSettings(colors: gradient.colors, rotation: gradient.settings.rotation))) + return (.inputWallPaperNoFile(.init(id: gradient.id ?? 0)), apiWallpaperSettings(WallpaperSettings(colors: gradient.colors, rotation: gradient.settings.rotation))) case let .emoticon(emoticon): - return (.inputWallPaperNoFile(id: 0), apiWallpaperSettings(WallpaperSettings(emoticon: emoticon))) + return (.inputWallPaperNoFile(.init(id: 0)), apiWallpaperSettings(WallpaperSettings(emoticon: emoticon))) default: return nil } diff --git a/submodules/TelegramCore/Sources/MacOS/MacInternal.swift b/submodules/TelegramCore/Sources/MacOS/MacInternal.swift index 9fc5a71097..10a7edf8c3 100644 --- a/submodules/TelegramCore/Sources/MacOS/MacInternal.swift +++ b/submodules/TelegramCore/Sources/MacOS/MacInternal.swift @@ -93,7 +93,7 @@ public func downloadAppUpdate(account: Account, source: String, messageId: Int32 } |> mapToSignal { peer in if let peer = peer, let inputChannel = apiInputChannel(peer) { - return account.network.request(Api.functions.channels.getMessages(channel: inputChannel, id: [Api.InputMessage.inputMessageID(id: messageId)])) + return account.network.request(Api.functions.channels.getMessages(channel: inputChannel, id: [Api.InputMessage.inputMessageID(.init(id: messageId))])) |> retryRequest |> castError(InternalUpdaterError.self) |> mapToSignal { messages in diff --git a/submodules/TelegramCore/Sources/PendingMessages/PendingMessageUploadedContent.swift b/submodules/TelegramCore/Sources/PendingMessages/PendingMessageUploadedContent.swift index 92ecb4d471..814f67da16 100644 --- a/submodules/TelegramCore/Sources/PendingMessages/PendingMessageUploadedContent.swift +++ b/submodules/TelegramCore/Sources/PendingMessages/PendingMessageUploadedContent.swift @@ -103,7 +103,7 @@ func messageContentToUpload(accountPeerId: PeerId, network: Network, postbox: Po guard let inputPeer = transaction.getPeer(media.storyId.peerId).flatMap(apiInputPeer) else { return .progress(PendingMessageUploadedContentProgress(progress: 0.0)) } - return .content(PendingMessageUploadedContentAndReuploadInfo(content: .media(.inputMediaStory(peer: inputPeer, id: media.storyId.id), ""), reuploadInfo: nil, cacheReferenceKey: nil)) + return .content(PendingMessageUploadedContentAndReuploadInfo(content: .media(.inputMediaStory(.init(peer: inputPeer, id: media.storyId.id)), ""), reuploadInfo: nil, cacheReferenceKey: nil)) } |> castError(PendingMessageUploadError.self), .text) } else if let media = media.first as? TelegramMediaWebpage, case let .Loaded(content) = media.content { @@ -119,7 +119,7 @@ func messageContentToUpload(accountPeerId: PeerId, network: Network, postbox: Po } } } - return .content(PendingMessageUploadedContentAndReuploadInfo(content: .media(.inputMediaWebPage(flags: flags, url: content.url), text), reuploadInfo: nil, cacheReferenceKey: nil)) + return .content(PendingMessageUploadedContentAndReuploadInfo(content: .media(.inputMediaWebPage(.init(flags: flags, url: content.url)), text), reuploadInfo: nil, cacheReferenceKey: nil)) } |> castError(PendingMessageUploadError.self), .text) } else if let media = media.first, let mediaResult = mediaContentToUpload(accountPeerId: accountPeerId, network: network, postbox: postbox, auxiliaryMethods: auxiliaryMethods, transformOutgoingMessageMedia: transformOutgoingMessageMedia, messageMediaPreuploadManager: messageMediaPreuploadManager, revalidationContext: revalidationContext, forceReupload: forceReupload, isGrouped: isGrouped, passFetchProgress: passFetchProgress, forceNoBigParts: forceNoBigParts, peerId: peerId, media: media, text: text, autoremoveMessageAttribute: autoremoveMessageAttribute, autoclearMessageAttribute: autoclearMessageAttribute, messageId: messageId, attributes: attributes, mediaReference: mediaReference, explicitPartialReference: explicitPartialReference) { @@ -184,7 +184,7 @@ func mediaContentToUpload(accountPeerId: PeerId, network: Network, postbox: Post return .single(.content(PendingMessageUploadedContentAndReuploadInfo(content: .secretMedia(.inputEncryptedFile(.init(id: resource.fileId, accessHash: resource.accessHash)), resource.decryptedSize, resource.key), reuploadInfo: nil, cacheReferenceKey: nil))) } if peerId.namespace != Namespaces.Peer.SecretChat, let reference = image.reference, case let .cloud(id, accessHash, maybeFileReference) = reference, let fileReference = maybeFileReference { - return .single(.content(PendingMessageUploadedContentAndReuploadInfo(content: .media(Api.InputMedia.inputMediaPhoto(flags: 0, id: Api.InputPhoto.inputPhoto(id: id, accessHash: accessHash, fileReference: Buffer(data: fileReference)), ttlSeconds: nil), text), reuploadInfo: nil, cacheReferenceKey: nil))) + return .single(.content(PendingMessageUploadedContentAndReuploadInfo(content: .media(Api.InputMedia.inputMediaPhoto(.init(flags: 0, id: Api.InputPhoto.inputPhoto(.init(id: id, accessHash: accessHash, fileReference: Buffer(data: fileReference))), ttlSeconds: nil)), text), reuploadInfo: nil, cacheReferenceKey: nil))) } else { return uploadedMediaImageContent(network: network, postbox: postbox, transformOutgoingMessageMedia: transformOutgoingMessageMedia, forceReupload: forceReupload, isGrouped: isGrouped, peerId: peerId, image: image, messageId: messageId, text: text, attributes: attributes, autoremoveMessageAttribute: autoremoveMessageAttribute, autoclearMessageAttribute: autoclearMessageAttribute, auxiliaryMethods: auxiliaryMethods) } @@ -244,7 +244,7 @@ func mediaContentToUpload(accountPeerId: PeerId, network: Network, postbox: Post flags |= 1 << 4 } - return .single(.content(PendingMessageUploadedContentAndReuploadInfo(content: .media(Api.InputMedia.inputMediaDocument(flags: flags, id: Api.InputDocument.inputDocument(.init(id: resource.fileId, accessHash: resource.accessHash, fileReference: Buffer(data: reference))), videoCover: nil, videoTimestamp: videoTimestamp, ttlSeconds: nil, query: nil), text), reuploadInfo: nil, cacheReferenceKey: nil))) + return .single(.content(PendingMessageUploadedContentAndReuploadInfo(content: .media(Api.InputMedia.inputMediaDocument(.init(flags: flags, id: Api.InputDocument.inputDocument(.init(id: resource.fileId, accessHash: resource.accessHash, fileReference: Buffer(data: reference))), videoCover: nil, videoTimestamp: videoTimestamp, ttlSeconds: nil, query: nil)), text), reuploadInfo: nil, cacheReferenceKey: nil))) } else { return .fail(.generic) } @@ -265,13 +265,13 @@ func mediaContentToUpload(accountPeerId: PeerId, network: Network, postbox: Post } } - return .single(.content(PendingMessageUploadedContentAndReuploadInfo(content: .media(Api.InputMedia.inputMediaDocument(flags: flags, id: Api.InputDocument.inputDocument(.init(id: resource.fileId, accessHash: resource.accessHash, fileReference: Buffer(data: resource.fileReference ?? Data()))), videoCover: nil, videoTimestamp: videoTimestamp, ttlSeconds: nil, query: emojiSearchQuery), text), reuploadInfo: nil, cacheReferenceKey: nil))) + return .single(.content(PendingMessageUploadedContentAndReuploadInfo(content: .media(Api.InputMedia.inputMediaDocument(.init(flags: flags, id: Api.InputDocument.inputDocument(.init(id: resource.fileId, accessHash: resource.accessHash, fileReference: Buffer(data: resource.fileReference ?? Data()))), videoCover: nil, videoTimestamp: videoTimestamp, ttlSeconds: nil, query: emojiSearchQuery)), text), reuploadInfo: nil, cacheReferenceKey: nil))) } } else { return uploadedMediaFileContent(network: network, postbox: postbox, auxiliaryMethods: auxiliaryMethods, transformOutgoingMessageMedia: transformOutgoingMessageMedia, messageMediaPreuploadManager: messageMediaPreuploadManager, forceReupload: forceReupload, isGrouped: isGrouped, isPaid: false, passFetchProgress: passFetchProgress, forceNoBigParts: forceNoBigParts, peerId: peerId, messageId: messageId, text: text, attributes: attributes, autoremoveMessageAttribute: autoremoveMessageAttribute, autoclearMessageAttribute: autoclearMessageAttribute, file: file) } } else if let contact = media as? TelegramMediaContact { - let input = Api.InputMedia.inputMediaContact(phoneNumber: contact.phoneNumber, firstName: contact.firstName, lastName: contact.lastName, vcard: contact.vCardData ?? "") + let input = Api.InputMedia.inputMediaContact(.init(phoneNumber: contact.phoneNumber, firstName: contact.firstName, lastName: contact.lastName, vcard: contact.vCardData ?? "")) return .single(.content(PendingMessageUploadedContentAndReuploadInfo(content: .media(input, text), reuploadInfo: nil, cacheReferenceKey: nil))) } else if let map = media as? TelegramMediaMap { let input: Api.InputMedia @@ -287,11 +287,11 @@ func mediaContentToUpload(accountPeerId: PeerId, network: Network, postbox: Post geoFlags |= 1 << 0 } if let liveBroadcastingTimeout = map.liveBroadcastingTimeout { - input = .inputMediaGeoLive(flags: flags, geoPoint: Api.InputGeoPoint.inputGeoPoint(.init(flags: geoFlags, lat: map.latitude, long: map.longitude, accuracyRadius: map.accuracyRadius.flatMap({ Int32($0) }))), heading: map.heading, period: liveBroadcastingTimeout, proximityNotificationRadius: map.liveProximityNotificationRadius.flatMap({ Int32($0) })) + input = .inputMediaGeoLive(.init(flags: flags, geoPoint: Api.InputGeoPoint.inputGeoPoint(.init(flags: geoFlags, lat: map.latitude, long: map.longitude, accuracyRadius: map.accuracyRadius.flatMap({ Int32($0) }))), heading: map.heading, period: liveBroadcastingTimeout, proximityNotificationRadius: map.liveProximityNotificationRadius.flatMap({ Int32($0) }))) } else if let venue = map.venue { - input = .inputMediaVenue(geoPoint: Api.InputGeoPoint.inputGeoPoint(.init(flags: geoFlags, lat: map.latitude, long: map.longitude, accuracyRadius: map.accuracyRadius.flatMap({ Int32($0) }))), title: venue.title, address: venue.address ?? "", provider: venue.provider ?? "", venueId: venue.id ?? "", venueType: venue.type ?? "") + input = .inputMediaVenue(.init(geoPoint: Api.InputGeoPoint.inputGeoPoint(.init(flags: geoFlags, lat: map.latitude, long: map.longitude, accuracyRadius: map.accuracyRadius.flatMap({ Int32($0) }))), title: venue.title, address: venue.address ?? "", provider: venue.provider ?? "", venueId: venue.id ?? "", venueType: venue.type ?? "")) } else { - input = .inputMediaGeoPoint(geoPoint: Api.InputGeoPoint.inputGeoPoint(.init(flags: geoFlags, lat: map.latitude, long: map.longitude, accuracyRadius: map.accuracyRadius.flatMap({ Int32($0) })))) + input = .inputMediaGeoPoint(.init(geoPoint: Api.InputGeoPoint.inputGeoPoint(.init(flags: geoFlags, lat: map.latitude, long: map.longitude, accuracyRadius: map.accuracyRadius.flatMap({ Int32($0) }))))) } return .single(.content(PendingMessageUploadedContentAndReuploadInfo(content: .media(input, text), reuploadInfo: nil, cacheReferenceKey: nil))) } else if let poll = media as? TelegramMediaPoll { @@ -330,7 +330,7 @@ func mediaContentToUpload(accountPeerId: PeerId, network: Network, postbox: Post mappedSolutionEntities = apiTextAttributeEntities(TextEntitiesMessageAttribute(entities: solution.entities), associatedPeers: SimpleDictionary()) pollMediaFlags |= 1 << 1 } - let inputPoll = Api.InputMedia.inputMediaPoll(flags: pollMediaFlags, poll: Api.Poll.poll(id: 0, flags: pollFlags, question: .textWithEntities(text: poll.text, entities: apiEntitiesFromMessageTextEntities(poll.textEntities, associatedPeers: SimpleDictionary())), answers: poll.options.map({ $0.apiOption }), closePeriod: poll.deadlineTimeout, closeDate: nil), correctAnswers: correctAnswers, solution: mappedSolution, solutionEntities: mappedSolutionEntities) + let inputPoll = Api.InputMedia.inputMediaPoll(.init(flags: pollMediaFlags, poll: Api.Poll.poll(.init(id: 0, flags: pollFlags, question: .textWithEntities(.init(text: poll.text, entities: apiEntitiesFromMessageTextEntities(poll.textEntities, associatedPeers: SimpleDictionary()))), answers: poll.options.map({ $0.apiOption }), closePeriod: poll.deadlineTimeout, closeDate: nil)), correctAnswers: correctAnswers, solution: mappedSolution, solutionEntities: mappedSolutionEntities)) return .single(.content(PendingMessageUploadedContentAndReuploadInfo(content: .media(inputPoll, text), reuploadInfo: nil, cacheReferenceKey: nil))) } else if let todo = media as? TelegramMediaTodo { var flags: Int32 = 0 @@ -340,7 +340,7 @@ func mediaContentToUpload(accountPeerId: PeerId, network: Network, postbox: Post if todo.flags.contains(.othersCanComplete) { flags |= 1 << 1 } - let inputTodo = Api.InputMedia.inputMediaTodo(todo: .todoList(flags: flags, title: .textWithEntities(text: todo.text, entities: apiEntitiesFromMessageTextEntities(todo.textEntities, associatedPeers: SimpleDictionary())), list: todo.items.map { $0.apiItem })) + let inputTodo = Api.InputMedia.inputMediaTodo(.init(todo: .todoList(.init(flags: flags, title: .textWithEntities(.init(text: todo.text, entities: apiEntitiesFromMessageTextEntities(todo.textEntities, associatedPeers: SimpleDictionary()))), list: todo.items.map { $0.apiItem })))) return .single(.content(PendingMessageUploadedContentAndReuploadInfo(content: .media(inputTodo, text), reuploadInfo: nil, cacheReferenceKey: nil))) } else if let dice = media as? TelegramMediaDice { if let tonAmount = dice.tonAmount { @@ -351,7 +351,7 @@ func mediaContentToUpload(accountPeerId: PeerId, network: Network, postbox: Post return postbox.transaction { transaction -> Signal in let gameInfo = currentEmojiGameInfo(transaction: transaction) if case let .available(info) = gameInfo { - let inputStakeDice = Api.InputMedia.inputMediaStakeDice(gameHash: info.gameHash, tonAmount: tonAmount, clientSeed: Buffer(buffer: clientSeed)) + let inputStakeDice = Api.InputMedia.inputMediaStakeDice(.init(gameHash: info.gameHash, tonAmount: tonAmount, clientSeed: Buffer(buffer: clientSeed))) return .single(.content(PendingMessageUploadedContentAndReuploadInfo(content: .media(inputStakeDice, text), reuploadInfo: nil, cacheReferenceKey: nil))) } else { return .fail(.generic) @@ -360,7 +360,7 @@ func mediaContentToUpload(accountPeerId: PeerId, network: Network, postbox: Post |> castError(PendingMessageUploadError.self) |> switchToLatest } else { - let inputDice = Api.InputMedia.inputMediaDice(emoticon: dice.emoji) + let inputDice = Api.InputMedia.inputMediaDice(.init(emoticon: dice.emoji)) return .single(.content(PendingMessageUploadedContentAndReuploadInfo(content: .media(inputDice, text), reuploadInfo: nil, cacheReferenceKey: nil))) } } else if let webPage = media as? TelegramMediaWebpage, case let .Loaded(content) = webPage.content { @@ -375,7 +375,7 @@ func mediaContentToUpload(accountPeerId: PeerId, network: Network, postbox: Post } } } - return .single(.content(PendingMessageUploadedContentAndReuploadInfo(content: .media(.inputMediaWebPage(flags: flags, url: content.url), text), reuploadInfo: nil, cacheReferenceKey: nil))) + return .single(.content(PendingMessageUploadedContentAndReuploadInfo(content: .media(.inputMediaWebPage(.init(flags: flags, url: content.url)), text), reuploadInfo: nil, cacheReferenceKey: nil))) } else { return nil } @@ -535,7 +535,7 @@ if "".isEmpty { } return .single(.progress(PendingMessageUploadedContentProgress(progress: 1.0))) |> then( - .single(.content(PendingMessageUploadedContentAndReuploadInfo(content: .media(.inputMediaPhoto(flags: flags, id: .inputPhoto(id: id, accessHash: accessHash, fileReference: Buffer(data: fileReference)), ttlSeconds: ttlSeconds), text), reuploadInfo: nil, cacheReferenceKey: nil))) + .single(.content(PendingMessageUploadedContentAndReuploadInfo(content: .media(.inputMediaPhoto(.init(flags: flags, id: .inputPhoto(.init(id: id, accessHash: accessHash, fileReference: Buffer(data: fileReference))), ttlSeconds: ttlSeconds)), text), reuploadInfo: nil, cacheReferenceKey: nil))) ) } referenceKey = key @@ -676,10 +676,10 @@ if "".isEmpty { |> mapToSignal { inputPeer -> Signal in if let inputPeer = inputPeer { if autoclearMessageAttribute != nil { - return .single(.content(PendingMessageUploadedContentAndReuploadInfo(content: .media(.inputMediaUploadedPhoto(flags: flags, file: file, stickers: stickers, ttlSeconds: ttlSeconds), text), reuploadInfo: nil, cacheReferenceKey: nil))) + return .single(.content(PendingMessageUploadedContentAndReuploadInfo(content: .media(.inputMediaUploadedPhoto(.init(flags: flags, file: file, stickers: stickers, ttlSeconds: ttlSeconds)), text), reuploadInfo: nil, cacheReferenceKey: nil))) } - return network.request(Api.functions.messages.uploadMedia(flags: 0, businessConnectionId: nil, peer: inputPeer, media: Api.InputMedia.inputMediaUploadedPhoto(flags: flags, file: file, stickers: stickers, ttlSeconds: ttlSeconds))) + return network.request(Api.functions.messages.uploadMedia(flags: 0, businessConnectionId: nil, peer: inputPeer, media: Api.InputMedia.inputMediaUploadedPhoto(.init(flags: flags, file: file, stickers: stickers, ttlSeconds: ttlSeconds)))) |> mapError { _ -> PendingMessageUploadError in return .generic } |> mapToSignal { result -> Signal in switch result { @@ -695,7 +695,7 @@ if "".isEmpty { flags |= 1 << 1 } - let result: PendingMessageUploadedContentResult = .content(PendingMessageUploadedContentAndReuploadInfo(content: .media(.inputMediaPhoto(flags: flags, id: .inputPhoto(id: id, accessHash: accessHash, fileReference: Buffer(data: fileReference)), ttlSeconds: ttlSeconds), text), reuploadInfo: nil, cacheReferenceKey: nil)) + let result: PendingMessageUploadedContentResult = .content(PendingMessageUploadedContentAndReuploadInfo(content: .media(.inputMediaPhoto(.init(flags: flags, id: .inputPhoto(.init(id: id, accessHash: accessHash, fileReference: Buffer(data: fileReference))), ttlSeconds: ttlSeconds)), text), reuploadInfo: nil, cacheReferenceKey: nil)) if let _ = ttlSeconds { return .single(result) } else { @@ -736,9 +736,9 @@ func inputDocumentAttributesFromFileAttributes(_ fileAttributes: [TelegramMediaF if let packReference = packReference { switch packReference { case let .id(id, accessHash): - stickerSet = .inputStickerSetID(id: id, accessHash: accessHash) + stickerSet = .inputStickerSetID(.init(id: id, accessHash: accessHash)) case let .name(name): - stickerSet = .inputStickerSetShortName(shortName: name) + stickerSet = .inputStickerSetShortName(.init(shortName: name)) default: stickerSet = .inputStickerSetEmpty } @@ -746,7 +746,7 @@ func inputDocumentAttributesFromFileAttributes(_ fileAttributes: [TelegramMediaF var inputMaskCoords: Api.MaskCoords? if let maskCoords = maskCoords { flags |= 1 << 0 - inputMaskCoords = .maskCoords(n: maskCoords.n, x: maskCoords.x, y: maskCoords.y, zoom: maskCoords.zoom) + inputMaskCoords = .maskCoords(.init(n: maskCoords.n, x: maskCoords.x, y: maskCoords.y, zoom: maskCoords.zoom)) } attributes.append(.documentAttributeSticker(.init(flags: flags, alt: displayText, stickerset: stickerSet, maskCoords: inputMaskCoords))) case .HasLinkedStickers: @@ -849,13 +849,13 @@ private func uploadedVideoCover(network: Network, postbox: Postbox, resourceRefe case .progress: return .complete() case let .inputFile(file): - return network.request(Api.functions.messages.uploadMedia(flags: 0, businessConnectionId: nil, peer: inputPeer, media: Api.InputMedia.inputMediaUploadedPhoto(flags: 0, file: file, stickers: [], ttlSeconds: nil))) + return network.request(Api.functions.messages.uploadMedia(flags: 0, businessConnectionId: nil, peer: inputPeer, media: Api.InputMedia.inputMediaUploadedPhoto(.init(flags: 0, file: file, stickers: [], ttlSeconds: nil)))) |> mapError { _ -> PendingMessageUploadError in return .generic } |> map { uploadResult in switch uploadResult { case let .messageMediaPhoto(_, photo, _): if case let .photo(_, id, accessHash, fileReference, _, _, _, _) = photo { - return .inputPhoto(id: id, accessHash: accessHash, fileReference: fileReference) + return .inputPhoto(.init(id: id, accessHash: accessHash, fileReference: fileReference)) } else { return .inputPhotoEmpty } @@ -947,7 +947,7 @@ private func uploadedMediaFileContent(network: Network, postbox: Postbox, auxili return .single(.progress(PendingMessageUploadedContentProgress(progress: 1.0))) |> then( - .single(.content(PendingMessageUploadedContentAndReuploadInfo(content: .media(Api.InputMedia.inputMediaDocument(flags: flags, id: Api.InputDocument.inputDocument(.init(id: resource.fileId, accessHash: resource.accessHash, fileReference: Buffer(data: fileReference))), videoCover: videoCoverPhoto, videoTimestamp: videoTimestamp, ttlSeconds: ttlSeconds, query: nil), text), reuploadInfo: nil, cacheReferenceKey: nil))) + .single(.content(PendingMessageUploadedContentAndReuploadInfo(content: .media(Api.InputMedia.inputMediaDocument(.init(flags: flags, id: Api.InputDocument.inputDocument(.init(id: resource.fileId, accessHash: resource.accessHash, fileReference: Buffer(data: fileReference))), videoCover: videoCoverPhoto, videoTimestamp: videoTimestamp, ttlSeconds: ttlSeconds, query: nil)), text), reuploadInfo: nil, cacheReferenceKey: nil))) ) } } @@ -1211,11 +1211,11 @@ private func uploadedMediaFileContent(network: Network, postbox: Postbox, auxili } if ttlSeconds != nil { - return .single(.content(PendingMessageUploadedContentAndReuploadInfo(content: .media(.inputMediaUploadedDocument(flags: flags, file: inputFile, thumb: thumbnailFile, mimeType: file.mimeType, attributes: inputDocumentAttributesFromFileAttributes(file.attributes), stickers: stickers, videoCover: videoCoverPhoto, videoTimestamp: videoTimestamp, ttlSeconds: ttlSeconds), text), reuploadInfo: nil, cacheReferenceKey: referenceKey))) + return .single(.content(PendingMessageUploadedContentAndReuploadInfo(content: .media(.inputMediaUploadedDocument(.init(flags: flags, file: inputFile, thumb: thumbnailFile, mimeType: file.mimeType, attributes: inputDocumentAttributesFromFileAttributes(file.attributes), stickers: stickers, videoCover: videoCoverPhoto, videoTimestamp: videoTimestamp, ttlSeconds: ttlSeconds)), text), reuploadInfo: nil, cacheReferenceKey: referenceKey))) } - + if !isGrouped { - let resultInfo = PendingMessageUploadedContentAndReuploadInfo(content: .media(.inputMediaUploadedDocument(flags: flags, file: inputFile, thumb: thumbnailFile, mimeType: file.mimeType, attributes: inputDocumentAttributesFromFileAttributes(file.attributes), stickers: stickers, videoCover: videoCoverPhoto, videoTimestamp: videoTimestamp, ttlSeconds: ttlSeconds), text), reuploadInfo: nil, cacheReferenceKey: referenceKey) + let resultInfo = PendingMessageUploadedContentAndReuploadInfo(content: .media(.inputMediaUploadedDocument(.init(flags: flags, file: inputFile, thumb: thumbnailFile, mimeType: file.mimeType, attributes: inputDocumentAttributesFromFileAttributes(file.attributes), stickers: stickers, videoCover: videoCoverPhoto, videoTimestamp: videoTimestamp, ttlSeconds: ttlSeconds)), text), reuploadInfo: nil, cacheReferenceKey: referenceKey) return .single(.content(resultInfo)) } @@ -1226,7 +1226,7 @@ private func uploadedMediaFileContent(network: Network, postbox: Postbox, auxili |> mapError { _ -> PendingMessageUploadError in } |> mapToSignal { inputPeer -> Signal in if let inputPeer = inputPeer { - return network.request(Api.functions.messages.uploadMedia(flags: 0, businessConnectionId: nil, peer: inputPeer, media: .inputMediaUploadedDocument(flags: flags, file: inputFile, thumb: thumbnailFile, mimeType: file.mimeType, attributes: inputDocumentAttributesFromFileAttributes(file.attributes), stickers: stickers, videoCover: videoCoverPhoto, videoTimestamp: videoTimestamp, ttlSeconds: ttlSeconds))) + return network.request(Api.functions.messages.uploadMedia(flags: 0, businessConnectionId: nil, peer: inputPeer, media: .inputMediaUploadedDocument(.init(flags: flags, file: inputFile, thumb: thumbnailFile, mimeType: file.mimeType, attributes: inputDocumentAttributesFromFileAttributes(file.attributes), stickers: stickers, videoCover: videoCoverPhoto, videoTimestamp: videoTimestamp, ttlSeconds: ttlSeconds)))) |> mapError { _ -> PendingMessageUploadError in return .generic } |> mapToSignal { result -> Signal in switch result { @@ -1248,7 +1248,7 @@ private func uploadedMediaFileContent(network: Network, postbox: Postbox, auxili flags |= (1 << 4) } - let result: PendingMessageUploadedContentResult = .content(PendingMessageUploadedContentAndReuploadInfo(content: .media(.inputMediaDocument(flags: flags, id: .inputDocument(.init(id: resource.fileId, accessHash: resource.accessHash, fileReference: Buffer(data: fileReference))), videoCover: videoCoverPhoto, videoTimestamp: videoTimestamp, ttlSeconds: ttlSeconds, query: nil), text), reuploadInfo: nil, cacheReferenceKey: nil)) + let result: PendingMessageUploadedContentResult = .content(PendingMessageUploadedContentAndReuploadInfo(content: .media(.inputMediaDocument(.init(flags: flags, id: .inputDocument(.init(id: resource.fileId, accessHash: resource.accessHash, fileReference: Buffer(data: fileReference))), videoCover: videoCoverPhoto, videoTimestamp: videoTimestamp, ttlSeconds: ttlSeconds, query: nil)), text), reuploadInfo: nil, cacheReferenceKey: nil)) if let _ = ttlSeconds { return .single(result) } else { diff --git a/submodules/TelegramCore/Sources/PendingMessages/RequestEditMessage.swift b/submodules/TelegramCore/Sources/PendingMessages/RequestEditMessage.swift index 3bc3cbc1ee..afdcdd24e6 100644 --- a/submodules/TelegramCore/Sources/PendingMessages/RequestEditMessage.swift +++ b/submodules/TelegramCore/Sources/PendingMessages/RequestEditMessage.swift @@ -76,7 +76,7 @@ private func requestEditMessageInternal(accountPeerId: PeerId, postbox: Postbox, if todo.flags.contains(.othersCanComplete) { flags |= 1 << 1 } - let inputTodo = Api.InputMedia.inputMediaTodo(todo: .todoList(flags: flags, title: .textWithEntities(text: todo.text, entities: apiEntitiesFromMessageTextEntities(todo.textEntities, associatedPeers: SimpleDictionary())), list: todo.items.map { $0.apiItem })) + let inputTodo = Api.InputMedia.inputMediaTodo(.init(todo: .todoList(flags: flags, title: .textWithEntities(text: todo.text, entities: apiEntitiesFromMessageTextEntities(todo.textEntities, associatedPeers: SimpleDictionary())), list: todo.items.map { $0.apiItem }))) uploadedMedia = .single(.content(PendingMessageUploadedContentAndReuploadInfo(content: .media(inputTodo, text), reuploadInfo: nil, cacheReferenceKey: nil))) } else if let uploadSignal = generateUploadSignal(forceReupload) { @@ -341,9 +341,9 @@ func _internal_requestEditLiveLocation(postbox: Postbox, network: Network, state period = liveBroadcastingTimeout } - inputMedia = .inputMediaGeoLive(flags: flags, geoPoint: inputGeoPoint, heading: heading, period: period, proximityNotificationRadius: proximityNotificationRadius) + inputMedia = .inputMediaGeoLive(.init(flags: flags, geoPoint: inputGeoPoint, heading: heading, period: period, proximityNotificationRadius: proximityNotificationRadius)) } else { - inputMedia = .inputMediaGeoLive(flags: 1 << 0, geoPoint: .inputGeoPoint(.init(flags: 0, lat: media.latitude, long: media.longitude, accuracyRadius: nil)), heading: nil, period: nil, proximityNotificationRadius: nil) + inputMedia = .inputMediaGeoLive(.init(flags: 1 << 0, geoPoint: .inputGeoPoint(.init(flags: 0, lat: media.latitude, long: media.longitude, accuracyRadius: nil)), heading: nil, period: nil, proximityNotificationRadius: nil)) } return network.request(Api.functions.messages.editMessage(flags: 1 << 14, peer: inputPeer, id: messageId.id, message: nil, media: inputMedia, replyMarkup: nil, entities: nil, scheduleDate: nil, scheduleRepeatPeriod: nil, quickReplyShortcutId: nil)) diff --git a/submodules/TelegramCore/Sources/PendingMessages/StandaloneSendMessage.swift b/submodules/TelegramCore/Sources/PendingMessages/StandaloneSendMessage.swift index 29ec018028..2a22aa5409 100644 --- a/submodules/TelegramCore/Sources/PendingMessages/StandaloneSendMessage.swift +++ b/submodules/TelegramCore/Sources/PendingMessages/StandaloneSendMessage.swift @@ -445,14 +445,14 @@ private func sendUploadedMessageContent( if let _ = replyTodoItemId { replyFlags |= 1 << 6 } - replyTo = .inputReplyToMessage(flags: replyFlags, replyToMsgId: replyMessageId, topMsgId: topMsgId, replyToPeerId: nil, quoteText: nil, quoteEntities: nil, quoteOffset: nil, monoforumPeerId: monoforumPeerId, todoItemId: replyTodoItemId) + replyTo = .inputReplyToMessage(.init(flags: replyFlags, replyToMsgId: replyMessageId, topMsgId: topMsgId, replyToPeerId: nil, quoteText: nil, quoteEntities: nil, quoteOffset: nil, monoforumPeerId: monoforumPeerId, todoItemId: replyTodoItemId)) } else if let replyToStoryId { if let inputPeer = transaction.getPeer(replyToStoryId.peerId).flatMap(apiInputPeer) { flags |= 1 << 0 - replyTo = .inputReplyToStory(peer: inputPeer, storyId: replyToStoryId.id) + replyTo = .inputReplyToStory(.init(peer: inputPeer, storyId: replyToStoryId.id)) } } else if let monoforumPeerId { - replyTo = .inputReplyToMonoForum(monoforumPeerId: monoforumPeerId) + replyTo = .inputReplyToMonoForum(.init(monoforumPeerId: monoforumPeerId)) } if suggestedPost != nil { @@ -479,11 +479,11 @@ private func sendUploadedMessageContent( if let _ = replyTodoItemId { replyFlags |= 1 << 6 } - replyTo = .inputReplyToMessage(flags: replyFlags, replyToMsgId: replyMessageId, topMsgId: topMsgId, replyToPeerId: nil, quoteText: nil, quoteEntities: nil, quoteOffset: nil, monoforumPeerId: monoforumPeerId, todoItemId: replyTodoItemId) + replyTo = .inputReplyToMessage(.init(flags: replyFlags, replyToMsgId: replyMessageId, topMsgId: topMsgId, replyToPeerId: nil, quoteText: nil, quoteEntities: nil, quoteOffset: nil, monoforumPeerId: monoforumPeerId, todoItemId: replyTodoItemId)) } else if let replyToStoryId = replyToStoryId { if let inputPeer = transaction.getPeer(replyToStoryId.peerId).flatMap(apiInputPeer) { flags |= 1 << 0 - replyTo = .inputReplyToStory(peer: inputPeer, storyId: replyToStoryId.id) + replyTo = .inputReplyToStory(.init(peer: inputPeer, storyId: replyToStoryId.id)) } } @@ -520,33 +520,33 @@ private func sendUploadedMessageContent( if monoforumPeerId != nil { replyFlags |= 1 << 5 } - replyTo = .inputReplyToMessage(flags: replyFlags, replyToMsgId: replyMessageId, topMsgId: topMsgId, replyToPeerId: nil, quoteText: nil, quoteEntities: nil, quoteOffset: nil, monoforumPeerId: monoforumPeerId, todoItemId: nil) + replyTo = .inputReplyToMessage(.init(flags: replyFlags, replyToMsgId: replyMessageId, topMsgId: topMsgId, replyToPeerId: nil, quoteText: nil, quoteEntities: nil, quoteOffset: nil, monoforumPeerId: monoforumPeerId, todoItemId: nil)) } else if let replyToStoryId = replyToStoryId { if let inputPeer = transaction.getPeer(replyToStoryId.peerId).flatMap(apiInputPeer) { flags |= 1 << 0 - replyTo = .inputReplyToStory(peer: inputPeer, storyId: replyToStoryId.id) + replyTo = .inputReplyToStory(.init(peer: inputPeer, storyId: replyToStoryId.id)) } } - + sendMessageRequest = network.request(Api.functions.messages.sendInlineBotResult(flags: flags, peer: inputPeer, replyTo: replyTo, randomId: uniqueId, queryId: chatContextResult.queryId, id: chatContextResult.id, scheduleDate: scheduleTime, sendAs: sendAsInputPeer, quickReplyShortcut: nil, allowPaidStars: allowPaidStars)) |> map(NetworkRequestResult.result) case .messageScreenshot: let replyTo: Api.InputReplyTo - + if let replyMessageId = replyMessageId { let replyFlags: Int32 = 0 - replyTo = .inputReplyToMessage(flags: replyFlags, replyToMsgId: replyMessageId, topMsgId: nil, replyToPeerId: nil, quoteText: nil, quoteEntities: nil, quoteOffset: nil, monoforumPeerId: nil, todoItemId: nil) + replyTo = .inputReplyToMessage(.init(flags: replyFlags, replyToMsgId: replyMessageId, topMsgId: nil, replyToPeerId: nil, quoteText: nil, quoteEntities: nil, quoteOffset: nil, monoforumPeerId: nil, todoItemId: nil)) } else if let replyToStoryId = replyToStoryId { if let inputPeer = transaction.getPeer(replyToStoryId.peerId).flatMap(apiInputPeer) { flags |= 1 << 0 - replyTo = .inputReplyToStory(peer: inputPeer, storyId: replyToStoryId.id) + replyTo = .inputReplyToStory(.init(peer: inputPeer, storyId: replyToStoryId.id)) } else { let replyFlags: Int32 = 0 - replyTo = .inputReplyToMessage(flags: replyFlags, replyToMsgId: 0, topMsgId: nil, replyToPeerId: nil, quoteText: nil, quoteEntities: nil, quoteOffset: nil, monoforumPeerId: nil, todoItemId: nil) + replyTo = .inputReplyToMessage(.init(flags: replyFlags, replyToMsgId: 0, topMsgId: nil, replyToPeerId: nil, quoteText: nil, quoteEntities: nil, quoteOffset: nil, monoforumPeerId: nil, todoItemId: nil)) } } else { let replyFlags: Int32 = 0 - replyTo = .inputReplyToMessage(flags: replyFlags, replyToMsgId: 0, topMsgId: nil, replyToPeerId: nil, quoteText: nil, quoteEntities: nil, quoteOffset: nil, monoforumPeerId: nil, todoItemId: nil) + replyTo = .inputReplyToMessage(.init(flags: replyFlags, replyToMsgId: 0, topMsgId: nil, replyToPeerId: nil, quoteText: nil, quoteEntities: nil, quoteOffset: nil, monoforumPeerId: nil, todoItemId: nil)) } sendMessageRequest = network.request(Api.functions.messages.sendScreenshotNotification(peer: inputPeer, replyTo: replyTo, randomId: uniqueId)) @@ -698,19 +698,19 @@ private func sendMessageContent(account: Account, peerId: PeerId, attributes: [M var replyTo: Api.InputReplyTo? if let replyMessageId = replyMessageId { flags |= 1 << 0 - + let replyFlags: Int32 = 0 - replyTo = .inputReplyToMessage(flags: replyFlags, replyToMsgId: replyMessageId, topMsgId: nil, replyToPeerId: nil, quoteText: nil, quoteEntities: nil, quoteOffset: nil, monoforumPeerId: nil, todoItemId: nil) + replyTo = .inputReplyToMessage(.init(flags: replyFlags, replyToMsgId: replyMessageId, topMsgId: nil, replyToPeerId: nil, quoteText: nil, quoteEntities: nil, quoteOffset: nil, monoforumPeerId: nil, todoItemId: nil)) } else if let replyToStoryId = replyToStoryId { if let inputPeer = transaction.getPeer(replyToStoryId.peerId).flatMap(apiInputPeer) { flags |= 1 << 0 - replyTo = .inputReplyToStory(peer: inputPeer, storyId: replyToStoryId.id) + replyTo = .inputReplyToStory(.init(peer: inputPeer, storyId: replyToStoryId.id)) } } else if let threadId { flags |= 1 << 0 - replyTo = .inputReplyToMessage(flags: flags, replyToMsgId: threadId, topMsgId: threadId, replyToPeerId: nil, quoteText: nil, quoteEntities: nil, quoteOffset: nil, monoforumPeerId: nil, todoItemId: nil) + replyTo = .inputReplyToMessage(.init(flags: flags, replyToMsgId: threadId, topMsgId: threadId, replyToPeerId: nil, quoteText: nil, quoteEntities: nil, quoteOffset: nil, monoforumPeerId: nil, todoItemId: nil)) } - + sendMessageRequest = account.network.request(Api.functions.messages.sendMessage(flags: flags, peer: inputPeer, replyTo: replyTo, message: text, randomId: uniqueId, replyMarkup: nil, entities: messageEntities, scheduleDate: scheduleTime, scheduleRepeatPeriod: scheduleRepeatPeriod, sendAs: sendAsInputPeer, quickReplyShortcut: nil, effect: nil, allowPaidStars: allowPaidStars, suggestedPost: nil)) |> `catch` { _ -> Signal in return .complete() @@ -719,17 +719,17 @@ private func sendMessageContent(account: Account, peerId: PeerId, attributes: [M var replyTo: Api.InputReplyTo? if let replyMessageId = replyMessageId { flags |= 1 << 0 - + let replyFlags: Int32 = 0 - replyTo = .inputReplyToMessage(flags: replyFlags, replyToMsgId: replyMessageId, topMsgId: nil, replyToPeerId: nil, quoteText: nil, quoteEntities: nil, quoteOffset: nil, monoforumPeerId: nil, todoItemId: nil) + replyTo = .inputReplyToMessage(.init(flags: replyFlags, replyToMsgId: replyMessageId, topMsgId: nil, replyToPeerId: nil, quoteText: nil, quoteEntities: nil, quoteOffset: nil, monoforumPeerId: nil, todoItemId: nil)) } else if let replyToStoryId = replyToStoryId { if let inputPeer = transaction.getPeer(replyToStoryId.peerId).flatMap(apiInputPeer) { flags |= 1 << 0 - replyTo = .inputReplyToStory(peer: inputPeer, storyId: replyToStoryId.id) + replyTo = .inputReplyToStory(.init(peer: inputPeer, storyId: replyToStoryId.id)) } } else if let threadId { flags |= 1 << 0 - replyTo = .inputReplyToMessage(flags: flags, replyToMsgId: threadId, topMsgId: threadId, replyToPeerId: nil, quoteText: nil, quoteEntities: nil, quoteOffset: nil, monoforumPeerId: nil, todoItemId: nil) + replyTo = .inputReplyToMessage(.init(flags: flags, replyToMsgId: threadId, topMsgId: threadId, replyToPeerId: nil, quoteText: nil, quoteEntities: nil, quoteOffset: nil, monoforumPeerId: nil, todoItemId: nil)) } if suggestedPost != nil { @@ -767,7 +767,7 @@ private func uploadedImage(account: Account, data: Data) -> Signal mapError { _ -> StandaloneUploadMediaError in } |> mapToSignal { inputPeer -> Signal in if let inputPeer = inputPeer { - return network.request(Api.functions.messages.uploadMedia(flags: 0, businessConnectionId: nil, peer: inputPeer, media: Api.InputMedia.inputMediaUploadedPhoto(flags: 0, file: inputFile, stickers: nil, ttlSeconds: nil))) + return network.request(Api.functions.messages.uploadMedia(flags: 0, businessConnectionId: nil, peer: inputPeer, media: Api.InputMedia.inputMediaUploadedPhoto(.init(flags: 0, file: inputFile, stickers: nil, ttlSeconds: nil)))) |> mapError { _ -> StandaloneUploadMediaError in return .generic } |> mapToSignal { media -> Signal in switch media { @@ -159,7 +159,7 @@ public func standaloneUploadedFile(postbox: Postbox, network: Network, peerId: P if let _ = thumbnailFile { flags |= 1 << 2 } - return network.request(Api.functions.messages.uploadMedia(flags: 0, businessConnectionId: nil, peer: inputPeer, media: Api.InputMedia.inputMediaUploadedDocument(flags: flags, file: inputFile, thumb: thumbnailFile, mimeType: mimeType, attributes: inputDocumentAttributesFromFileAttributes(attributes), stickers: nil, videoCover: nil, videoTimestamp: nil, ttlSeconds: nil))) + return network.request(Api.functions.messages.uploadMedia(flags: 0, businessConnectionId: nil, peer: inputPeer, media: Api.InputMedia.inputMediaUploadedDocument(.init(flags: flags, file: inputFile, thumb: thumbnailFile, mimeType: mimeType, attributes: inputDocumentAttributesFromFileAttributes(attributes), stickers: nil, videoCover: nil, videoTimestamp: nil, ttlSeconds: nil)))) |> mapError { _ -> StandaloneUploadMediaError in return .generic } |> mapToSignal { media -> Signal in switch media { diff --git a/submodules/TelegramCore/Sources/State/AccountStateManagementUtils.swift b/submodules/TelegramCore/Sources/State/AccountStateManagementUtils.swift index 2c0ac46dc2..7af0d1c1d0 100644 --- a/submodules/TelegramCore/Sources/State/AccountStateManagementUtils.swift +++ b/submodules/TelegramCore/Sources/State/AccountStateManagementUtils.swift @@ -1621,7 +1621,8 @@ private func finalStateWithUpdatesAndServerTime(accountPeerId: PeerId, postbox: } if let replyToMsgHeader { switch replyToMsgHeader { - case let .inputReplyToMessage(_, replyToMsgId, topMsgId, replyToPeerId, quoteText, quoteEntities, quoteOffset, monoforumPeerId, todoItemId): + case let .inputReplyToMessage(inputReplyToMessageData): + let (replyToMsgId, topMsgId, replyToPeerId, quoteText, quoteEntities, quoteOffset, monoforumPeerId, todoItemId) = (inputReplyToMessageData.replyToMsgId, inputReplyToMessageData.topMsgId, inputReplyToMessageData.replyToPeerId, inputReplyToMessageData.quoteText, inputReplyToMessageData.quoteEntities, inputReplyToMessageData.quoteOffset, inputReplyToMessageData.monoforumPeerId, inputReplyToMessageData.todoItemId) let _ = topMsgId let _ = monoforumPeerId @@ -1637,19 +1638,24 @@ private func finalStateWithUpdatesAndServerTime(accountPeerId: PeerId, postbox: var parsedReplyToPeerId: PeerId? switch replyToPeerId { - case let .inputPeerChannel(channelId, _): + case let .inputPeerChannel(inputPeerChannelData): + let channelId = inputPeerChannelData.channelId parsedReplyToPeerId = PeerId(namespace: Namespaces.Peer.CloudChannel, id: PeerId.Id._internalFromInt64Value(channelId)) - case let .inputPeerChannelFromMessage(_, _, channelId): + case let .inputPeerChannelFromMessage(inputPeerChannelFromMessageData): + let channelId = inputPeerChannelFromMessageData.channelId parsedReplyToPeerId = PeerId(namespace: Namespaces.Peer.CloudChannel, id: PeerId.Id._internalFromInt64Value(channelId)) - case let .inputPeerChat(chatId): + case let .inputPeerChat(inputPeerChatData): + let chatId = inputPeerChatData.chatId parsedReplyToPeerId = PeerId(namespace: Namespaces.Peer.CloudGroup, id: PeerId.Id._internalFromInt64Value(chatId)) case .inputPeerEmpty: break case .inputPeerSelf: parsedReplyToPeerId = accountPeerId - case let .inputPeerUser(userId, _): + case let .inputPeerUser(inputPeerUserData): + let userId = inputPeerUserData.userId parsedReplyToPeerId = PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt64Value(userId)) - case let .inputPeerUserFromMessage(_, _, userId): + case let .inputPeerUserFromMessage(inputPeerUserFromMessageData): + let userId = inputPeerUserFromMessageData.userId parsedReplyToPeerId = PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt64Value(userId)) case .none: break @@ -1896,19 +1902,24 @@ private func finalStateWithUpdatesAndServerTime(accountPeerId: PeerId, postbox: case let .paidReactionPrivacyPeer(peer): let peerId: PeerId switch peer { - case let .inputPeerChannel(channelId, _): + case let .inputPeerChannel(inputPeerChannelData): + let channelId = inputPeerChannelData.channelId peerId = PeerId(namespace: Namespaces.Peer.CloudChannel, id: PeerId.Id._internalFromInt64Value(channelId)) - case let .inputPeerChannelFromMessage(_, _, channelId): + case let .inputPeerChannelFromMessage(inputPeerChannelFromMessageData): + let channelId = inputPeerChannelFromMessageData.channelId peerId = PeerId(namespace: Namespaces.Peer.CloudChannel, id: PeerId.Id._internalFromInt64Value(channelId)) - case let .inputPeerChat(chatId): + case let .inputPeerChat(inputPeerChatData): + let chatId = inputPeerChatData.chatId peerId = PeerId(namespace: Namespaces.Peer.CloudGroup, id: PeerId.Id._internalFromInt64Value(chatId)) case .inputPeerEmpty: peerId = accountPeerId case .inputPeerSelf: peerId = accountPeerId - case let .inputPeerUser(userId, _): + case let .inputPeerUser(inputPeerUserData): + let userId = inputPeerUserData.userId peerId = PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt64Value(userId)) - case let .inputPeerUserFromMessage(_, _, userId): + case let .inputPeerUserFromMessage(inputPeerUserFromMessageData): + let userId = inputPeerUserFromMessageData.userId peerId = PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt64Value(userId)) } mappedPrivacy = .peer(peerId) @@ -2733,10 +2744,10 @@ private func resolveAssociatedMessages(accountPeerId: PeerId, postbox: Postbox, if let peer = state.peers[peerId] { var signal: Signal? if peerId.namespace == Namespaces.Peer.CloudUser || peerId.namespace == Namespaces.Peer.CloudGroup { - signal = network.request(Api.functions.messages.getMessages(id: messageIds.targetIdsBySourceId.values.map({ Api.InputMessage.inputMessageReplyTo(id: $0.id) }))) + signal = network.request(Api.functions.messages.getMessages(id: messageIds.targetIdsBySourceId.values.map({ Api.InputMessage.inputMessageReplyTo(.init(id: $0.id)) }))) } else if peerId.namespace == Namespaces.Peer.CloudChannel { if let inputChannel = apiInputChannel(peer) { - signal = network.request(Api.functions.channels.getMessages(channel: inputChannel, id: messageIds.targetIdsBySourceId.values.map({ Api.InputMessage.inputMessageReplyTo(id: $0.id) }))) + signal = network.request(Api.functions.channels.getMessages(channel: inputChannel, id: messageIds.targetIdsBySourceId.values.map({ Api.InputMessage.inputMessageReplyTo(.init(id: $0.id)) }))) } } if let signal = signal { @@ -2766,10 +2777,10 @@ private func resolveAssociatedMessages(accountPeerId: PeerId, postbox: Postbox, if let peer = state.peers[peerId] { var signal: Signal? if peerId.namespace == Namespaces.Peer.CloudUser || peerId.namespace == Namespaces.Peer.CloudGroup { - signal = network.request(Api.functions.messages.getMessages(id: messageIds.map({ Api.InputMessage.inputMessageID(id: $0.id) }))) + signal = network.request(Api.functions.messages.getMessages(id: messageIds.map({ Api.InputMessage.inputMessageID(.init(id: $0.id)) }))) } else if peerId.namespace == Namespaces.Peer.CloudChannel { if let inputChannel = apiInputChannel(peer) { - signal = network.request(Api.functions.channels.getMessages(channel: inputChannel, id: messageIds.map({ Api.InputMessage.inputMessageID(id: $0.id) }))) + signal = network.request(Api.functions.channels.getMessages(channel: inputChannel, id: messageIds.map({ Api.InputMessage.inputMessageID(.init(id: $0.id)) }))) } } if let signal = signal { diff --git a/submodules/TelegramCore/Sources/State/AccountViewTracker.swift b/submodules/TelegramCore/Sources/State/AccountViewTracker.swift index b761043830..6454664cf7 100644 --- a/submodules/TelegramCore/Sources/State/AccountViewTracker.swift +++ b/submodules/TelegramCore/Sources/State/AccountViewTracker.swift @@ -87,10 +87,11 @@ private func fetchWebpage(account: Account, messageId: MessageId, threadId: Int6 } } else { switch inputPeer { - case let .inputPeerChannel(channelId, accessHash): - messages = account.network.request(Api.functions.channels.getMessages(channel: Api.InputChannel.inputChannel(.init(channelId: channelId, accessHash: accessHash)), id: [Api.InputMessage.inputMessageID(id: messageId.id)])) + case let .inputPeerChannel(inputPeerChannelData): + let (channelId, accessHash) = (inputPeerChannelData.channelId, inputPeerChannelData.accessHash) + messages = account.network.request(Api.functions.channels.getMessages(channel: Api.InputChannel.inputChannel(.init(channelId: channelId, accessHash: accessHash)), id: [Api.InputMessage.inputMessageID(.init(id: messageId.id))])) default: - messages = account.network.request(Api.functions.messages.getMessages(id: [Api.InputMessage.inputMessageID(id: messageId.id)])) + messages = account.network.request(Api.functions.messages.getMessages(id: [Api.InputMessage.inputMessageID(.init(id: messageId.id))])) } } return messages @@ -949,7 +950,8 @@ public final class AccountViewTracker { case .inputPeerChat, .inputPeerSelf, .inputPeerUser: request = account.network.request(Api.functions.messages.readMessageContents(id: messageIds.map { $0.id })) |> map { _ in true } - case let .inputPeerChannel(channelId, accessHash): + case let .inputPeerChannel(inputPeerChannelData): + let (channelId, accessHash) = (inputPeerChannelData.channelId, inputPeerChannelData.accessHash) request = account.network.request(Api.functions.channels.readMessageContents(channel: .inputChannel(.init(channelId: channelId, accessHash: accessHash)), id: messageIds.map { $0.id })) |> map { _ in true } default: @@ -1074,10 +1076,10 @@ public final class AccountViewTracker { fetchSignal = .never() } } else if peerIdAndThreadId.peerId.namespace == Namespaces.Peer.CloudUser || peerIdAndThreadId.peerId.namespace == Namespaces.Peer.CloudGroup { - fetchSignal = account.network.request(Api.functions.messages.getMessages(id: messageIds.map { Api.InputMessage.inputMessageID(id: $0.id) })) + fetchSignal = account.network.request(Api.functions.messages.getMessages(id: messageIds.map { Api.InputMessage.inputMessageID(.init(id: $0.id)) })) } else if peerIdAndThreadId.peerId.namespace == Namespaces.Peer.CloudChannel { if let inputChannel = apiInputChannel(peer) { - fetchSignal = account.network.request(Api.functions.channels.getMessages(channel: inputChannel, id: messageIds.map { Api.InputMessage.inputMessageID(id: $0.id) })) + fetchSignal = account.network.request(Api.functions.channels.getMessages(channel: inputChannel, id: messageIds.map { Api.InputMessage.inputMessageID(.init(id: $0.id)) })) } } guard let signal = fetchSignal else { @@ -1180,7 +1182,7 @@ public final class AccountViewTracker { var requests: [Signal] = [] for reference in stickerPacks { if case let .id(id, accessHash) = reference { - requests.append(account.network.request(Api.functions.messages.getStickerSet(stickerset: .inputStickerSetID(id: id, accessHash: accessHash), hash: 0)) + requests.append(account.network.request(Api.functions.messages.getStickerSet(stickerset: .inputStickerSetID(.init(id: id, accessHash: accessHash)), hash: 0)) |> map(Optional.init) |> `catch` { _ -> Signal in return .single(nil) diff --git a/submodules/TelegramCore/Sources/State/CallSessionManager.swift b/submodules/TelegramCore/Sources/State/CallSessionManager.swift index 18475e674c..40322c5e91 100644 --- a/submodules/TelegramCore/Sources/State/CallSessionManager.swift +++ b/submodules/TelegramCore/Sources/State/CallSessionManager.swift @@ -752,7 +752,7 @@ private final class CallSessionManagerContext { self.contexts[internalId] = context let queue = self.queue - let requestSignal: Signal = self.network.request(Api.functions.phone.receivedCall(peer: .inputPhoneCall(id: stableId, accessHash: accessHash))) + let requestSignal: Signal = self.network.request(Api.functions.phone.receivedCall(peer: .inputPhoneCall(.init(id: stableId, accessHash: accessHash)))) context.acknowledgeIncomingCallDisposable.set(requestSignal.start(error: { [weak self] _ in queue.async { @@ -1019,7 +1019,7 @@ private final class CallSessionManagerContext { if let context = self.contexts[internalId] { switch context.state { case let .active(id, accessHash, _, _, _, _, _, _, _, _, _, _): - context.signalingDisposables.add(self.network.request(Api.functions.phone.sendSignalingData(peer: .inputPhoneCall(id: id, accessHash: accessHash), data: Buffer(data: data))).start()) + context.signalingDisposables.add(self.network.request(Api.functions.phone.sendSignalingData(peer: .inputPhoneCall(.init(id: id, accessHash: accessHash)), data: Buffer(data: data))).start()) default: break } @@ -1601,7 +1601,7 @@ private func acceptCallSession(accountPeerId: PeerId, postbox: Postbox, network: return .single(.failed) } - return network.request(Api.functions.phone.acceptCall(peer: .inputPhoneCall(id: stableId, accessHash: accessHash), gB: Buffer(data: gb), protocol: .phoneCallProtocol(flags: (1 << 0) | (1 << 1), minLayer: minLayer, maxLayer: maxLayer, libraryVersions: versions))) + return network.request(Api.functions.phone.acceptCall(peer: .inputPhoneCall(.init(id: stableId, accessHash: accessHash)), gB: Buffer(data: gb), protocol: .phoneCallProtocol(flags: (1 << 0) | (1 << 1), minLayer: minLayer, maxLayer: maxLayer, libraryVersions: versions))) |> map(Optional.init) |> `catch` { _ -> Signal in return .single(nil) @@ -1713,7 +1713,7 @@ private func requestCallSession(postbox: Postbox, network: Network, peerId: Peer } private func confirmCallSession(network: Network, stableId: CallSessionStableId, accessHash: Int64, gA: Data, keyFingerprint: Int64, maxLayer: Int32, versions: [String]) -> Signal { - return network.request(Api.functions.phone.confirmCall(peer: Api.InputPhoneCall.inputPhoneCall(id: stableId, accessHash: accessHash), gA: Buffer(data: gA), keyFingerprint: keyFingerprint, protocol: .phoneCallProtocol(flags: (1 << 0) | (1 << 1), minLayer: minLayer, maxLayer: maxLayer, libraryVersions: versions))) + return network.request(Api.functions.phone.confirmCall(peer: Api.InputPhoneCall.inputPhoneCall(.init(id: stableId, accessHash: accessHash)), gA: Buffer(data: gA), keyFingerprint: keyFingerprint, protocol: .phoneCallProtocol(flags: (1 << 0) | (1 << 1), minLayer: minLayer, maxLayer: maxLayer, libraryVersions: versions))) |> map(Optional.init) |> `catch` { _ -> Signal in return .single(nil) @@ -1763,7 +1763,7 @@ private func dropCallSession(network: Network, addUpdates: @escaping (Api.Update callFlags |= 1 << 0 } - return network.request(Api.functions.phone.discardCall(flags: callFlags, peer: Api.InputPhoneCall.inputPhoneCall(id: stableId, accessHash: accessHash), duration: duration, reason: mappedReason, connectionId: 0)) + return network.request(Api.functions.phone.discardCall(flags: callFlags, peer: Api.InputPhoneCall.inputPhoneCall(.init(id: stableId, accessHash: accessHash)), duration: duration, reason: mappedReason, connectionId: 0)) |> map(Optional.init) |> `catch` { _ -> Signal in return .single(nil) diff --git a/submodules/TelegramCore/Sources/State/HistoryViewStateValidation.swift b/submodules/TelegramCore/Sources/State/HistoryViewStateValidation.swift index 038f565027..11baaeb4cd 100644 --- a/submodules/TelegramCore/Sources/State/HistoryViewStateValidation.swift +++ b/submodules/TelegramCore/Sources/State/HistoryViewStateValidation.swift @@ -802,7 +802,7 @@ private func validateBatch(postbox: Postbox, network: Network, transaction: Tran case let .channel(peerId, _): actuallyRemovedMessagesSignal = postbox.transaction { transaction -> Signal, NoError> in if let inputChannel = transaction.getPeer(peerId).flatMap(apiInputChannel) { - return network.request(Api.functions.channels.getMessages(channel: inputChannel, id: maybeRemovedMessageIds.map({ Api.InputMessage.inputMessageID(id: $0.id) }))) + return network.request(Api.functions.channels.getMessages(channel: inputChannel, id: maybeRemovedMessageIds.map({ Api.InputMessage.inputMessageID(.init(id: $0.id)) }))) |> map { result -> Set in let apiMessages: [Api.Message] switch result { @@ -1051,7 +1051,7 @@ private func validateReplyThreadBatch(postbox: Postbox, network: Network, transa } else { actuallyRemovedMessagesSignal = postbox.transaction { transaction -> Signal, NoError> in if let inputChannel = transaction.getPeer(peerId).flatMap(apiInputChannel) { - return network.request(Api.functions.channels.getMessages(channel: inputChannel, id: maybeRemovedMessageIds.map({ Api.InputMessage.inputMessageID(id: $0.id) }))) + return network.request(Api.functions.channels.getMessages(channel: inputChannel, id: maybeRemovedMessageIds.map({ Api.InputMessage.inputMessageID(.init(id: $0.id)) }))) |> map { result -> Set in let apiMessages: [Api.Message] switch result { diff --git a/submodules/TelegramCore/Sources/State/Holes.swift b/submodules/TelegramCore/Sources/State/Holes.swift index 974ea0d5e8..b07a91c878 100644 --- a/submodules/TelegramCore/Sources/State/Holes.swift +++ b/submodules/TelegramCore/Sources/State/Holes.swift @@ -244,10 +244,10 @@ func withResolvedAssociatedMessages(postbox: Postbox, source: FetchMessageHis if let peer = transaction.getPeer(peerId) ?? parsedPeers.get(peerId) { var signal: Signal? if peerId.namespace == Namespaces.Peer.CloudUser || peerId.namespace == Namespaces.Peer.CloudGroup { - signal = source.request(Api.functions.messages.getMessages(id: messageIds.targetIdsBySourceId.values.map({ Api.InputMessage.inputMessageReplyTo(id: $0.id) }))) + signal = source.request(Api.functions.messages.getMessages(id: messageIds.targetIdsBySourceId.values.map({ Api.InputMessage.inputMessageReplyTo(.init(id: $0.id)) }))) } else if peerId.namespace == Namespaces.Peer.CloudChannel { if let inputChannel = apiInputChannel(peer) { - signal = source.request(Api.functions.channels.getMessages(channel: inputChannel, id: messageIds.targetIdsBySourceId.values.map({ Api.InputMessage.inputMessageReplyTo(id: $0.id) }))) + signal = source.request(Api.functions.channels.getMessages(channel: inputChannel, id: messageIds.targetIdsBySourceId.values.map({ Api.InputMessage.inputMessageReplyTo(.init(id: $0.id)) }))) } } if let signal = signal { @@ -275,10 +275,10 @@ func withResolvedAssociatedMessages(postbox: Postbox, source: FetchMessageHis if let peer = transaction.getPeer(peerId) ?? parsedPeers.get(peerId) { var signal: Signal? if peerId.namespace == Namespaces.Peer.CloudUser || peerId.namespace == Namespaces.Peer.CloudGroup { - signal = source.request(Api.functions.messages.getMessages(id: messageIds.map({ Api.InputMessage.inputMessageID(id: $0.id) }))) + signal = source.request(Api.functions.messages.getMessages(id: messageIds.map({ Api.InputMessage.inputMessageID(.init(id: $0.id)) }))) } else if peerId.namespace == Namespaces.Peer.CloudChannel { if let inputChannel = apiInputChannel(peer) { - signal = source.request(Api.functions.channels.getMessages(channel: inputChannel, id: messageIds.map({ Api.InputMessage.inputMessageID(id: $0.id) }))) + signal = source.request(Api.functions.channels.getMessages(channel: inputChannel, id: messageIds.map({ Api.InputMessage.inputMessageID(.init(id: $0.id)) }))) } } if let signal = signal { @@ -1210,7 +1210,7 @@ func fetchCallListHole(network: Network, postbox: Postbox, accountPeerId: PeerId offset = single((holeIndex.timestamp, min(holeIndex.id.id, Int32.max - 1) + 1, Api.InputPeer.inputPeerEmpty), NoError.self) return offset |> mapToSignal { (timestamp, id, peer) -> Signal in - let searchResult = network.request(Api.functions.messages.search(flags: 0, peer: .inputPeerEmpty, q: "", fromId: nil, savedPeerId: nil, savedReaction: nil, topMsgId: nil, filter: .inputMessagesFilterPhoneCalls(flags: 0), minDate: 0, maxDate: holeIndex.timestamp, offsetId: 0, addOffset: 0, limit: limit, maxId: holeIndex.id.id, minId: 0, hash: 0)) + let searchResult = network.request(Api.functions.messages.search(flags: 0, peer: .inputPeerEmpty, q: "", fromId: nil, savedPeerId: nil, savedReaction: nil, topMsgId: nil, filter: .inputMessagesFilterPhoneCalls(.init(flags: 0)), minDate: 0, maxDate: holeIndex.timestamp, offsetId: 0, addOffset: 0, limit: limit, maxId: holeIndex.id.id, minId: 0, hash: 0)) |> retryRequest |> mapToSignal { result -> Signal in let messages: [Api.Message] diff --git a/submodules/TelegramCore/Sources/State/ManagedGlobalNotificationSettings.swift b/submodules/TelegramCore/Sources/State/ManagedGlobalNotificationSettings.swift index f76b368bd8..d468710edb 100644 --- a/submodules/TelegramCore/Sources/State/ManagedGlobalNotificationSettings.swift +++ b/submodules/TelegramCore/Sources/State/ManagedGlobalNotificationSettings.swift @@ -361,7 +361,7 @@ private func apiInputPeerNotifySettings(_ settings: MessageNotificationSettings) flags |= (1 << 8) } - return .inputPeerNotifySettings(flags: flags, showPreviews: settings.displayPreviews ? .boolTrue : .boolFalse, silent: nil, muteUntil: muteUntil, sound: sound, storiesMuted: storiesMuted, storiesHideSender: storiesHideSender, storiesSound: storiesSound) + return .inputPeerNotifySettings(.init(flags: flags, showPreviews: settings.displayPreviews ? .boolTrue : .boolFalse, silent: nil, muteUntil: muteUntil, sound: sound, storiesMuted: storiesMuted, storiesHideSender: storiesHideSender, storiesSound: storiesSound)) } private func pushedNotificationSettings(network: Network, settings: GlobalNotificationSettingsSet) -> Signal { diff --git a/submodules/TelegramCore/Sources/State/ManagedPendingPeerNotificationSettings.swift b/submodules/TelegramCore/Sources/State/ManagedPendingPeerNotificationSettings.swift index 8d251c6422..3c469253cd 100644 --- a/submodules/TelegramCore/Sources/State/ManagedPendingPeerNotificationSettings.swift +++ b/submodules/TelegramCore/Sources/State/ManagedPendingPeerNotificationSettings.swift @@ -162,8 +162,8 @@ func pushPeerNotificationSettings(postbox: Postbox, network: Network, peerId: Pe flags |= (1 << 8) } - let inputSettings = Api.InputPeerNotifySettings.inputPeerNotifySettings(flags: flags, showPreviews: showPreviews, silent: nil, muteUntil: muteUntil, sound: sound, storiesMuted: storiesMuted, storiesHideSender: storiesHideSender, storiesSound: storiesSound) - return network.request(Api.functions.account.updateNotifySettings(peer: .inputNotifyForumTopic(peer: inputPeer, topMsgId: Int32(clamping: threadId)), settings: inputSettings)) + let inputSettings = Api.InputPeerNotifySettings.inputPeerNotifySettings(.init(flags: flags, showPreviews: showPreviews, silent: nil, muteUntil: muteUntil, sound: sound, storiesMuted: storiesMuted, storiesHideSender: storiesHideSender, storiesSound: storiesSound)) + return network.request(Api.functions.account.updateNotifySettings(peer: .inputNotifyForumTopic(.init(peer: inputPeer, topMsgId: Int32(clamping: threadId))), settings: inputSettings)) |> `catch` { _ -> Signal in return .single(.boolFalse) } @@ -237,8 +237,8 @@ func pushPeerNotificationSettings(postbox: Postbox, network: Network, peerId: Pe flags |= (1 << 8) } - let inputSettings = Api.InputPeerNotifySettings.inputPeerNotifySettings(flags: flags, showPreviews: showPreviews, silent: nil, muteUntil: muteUntil, sound: sound, storiesMuted: storiesMuted, storiesHideSender: storiesHideSender, storiesSound: storiesSound) - return network.request(Api.functions.account.updateNotifySettings(peer: .inputNotifyPeer(peer: inputPeer), settings: inputSettings)) + let inputSettings = Api.InputPeerNotifySettings.inputPeerNotifySettings(.init(flags: flags, showPreviews: showPreviews, silent: nil, muteUntil: muteUntil, sound: sound, storiesMuted: storiesMuted, storiesHideSender: storiesHideSender, storiesSound: storiesSound)) + return network.request(Api.functions.account.updateNotifySettings(peer: .inputNotifyPeer(.init(peer: inputPeer)), settings: inputSettings)) |> `catch` { _ -> Signal in return .single(.boolFalse) } diff --git a/submodules/TelegramCore/Sources/State/ManagedSynchronizeChatInputStateOperations.swift b/submodules/TelegramCore/Sources/State/ManagedSynchronizeChatInputStateOperations.swift index 46ea7677de..e89b5ed0fa 100644 --- a/submodules/TelegramCore/Sources/State/ManagedSynchronizeChatInputStateOperations.swift +++ b/submodules/TelegramCore/Sources/State/ManagedSynchronizeChatInputStateOperations.swift @@ -215,17 +215,17 @@ private func synchronizeChatInputState(transaction: Transaction, postbox: Postbo innerFlags |= 1 << 6 } if !discard { - replyTo = .inputReplyToMessage(flags: innerFlags, replyToMsgId: replySubject.messageId.id, topMsgId: topMsgId, replyToPeerId: replyToPeer, quoteText: quoteText, quoteEntities: quoteEntities, quoteOffset: quoteOffset, monoforumPeerId: monoforumPeerId, todoItemId: replyTodoItemId) + replyTo = .inputReplyToMessage(.init(flags: innerFlags, replyToMsgId: replySubject.messageId.id, topMsgId: topMsgId, replyToPeerId: replyToPeer, quoteText: quoteText, quoteEntities: quoteEntities, quoteOffset: quoteOffset, monoforumPeerId: monoforumPeerId, todoItemId: replyTodoItemId)) } } else if let topMsgId { flags |= 1 << 0 var innerFlags: Int32 = 0 innerFlags |= 1 << 0 - replyTo = .inputReplyToMessage(flags: innerFlags, replyToMsgId: topMsgId, topMsgId: topMsgId, replyToPeerId: nil, quoteText: nil, quoteEntities: nil, quoteOffset: nil, monoforumPeerId: nil, todoItemId: nil) + replyTo = .inputReplyToMessage(.init(flags: innerFlags, replyToMsgId: topMsgId, topMsgId: topMsgId, replyToPeerId: nil, quoteText: nil, quoteEntities: nil, quoteOffset: nil, monoforumPeerId: nil, todoItemId: nil)) } else if let monoforumPeerId { flags |= 1 << 0 - replyTo = .inputReplyToMonoForum(monoforumPeerId: monoforumPeerId) + replyTo = .inputReplyToMonoForum(.init(monoforumPeerId: monoforumPeerId)) } let suggestedPost = inputState?.suggestedPost.flatMap { suggestedPost -> Api.SuggestedPost in diff --git a/submodules/TelegramCore/Sources/State/ManagedSynchronizeInstalledStickerPacksOperations.swift b/submodules/TelegramCore/Sources/State/ManagedSynchronizeInstalledStickerPacksOperations.swift index d45af15a8e..003fc4ce7e 100644 --- a/submodules/TelegramCore/Sources/State/ManagedSynchronizeInstalledStickerPacksOperations.swift +++ b/submodules/TelegramCore/Sources/State/ManagedSynchronizeInstalledStickerPacksOperations.swift @@ -143,7 +143,7 @@ private enum SynchronizeInstalledStickerPacksError { } private func fetchStickerPack(network: Network, info: StickerPackCollectionInfo) -> Signal<(StickerPackCollectionInfo, [ItemCollectionItem]), NoError> { - return network.request(Api.functions.messages.getStickerSet(stickerset: .inputStickerSetID(id: info.id.id, accessHash: info.accessHash), hash: 0)) + return network.request(Api.functions.messages.getStickerSet(stickerset: .inputStickerSetID(.init(id: info.id.id, accessHash: info.accessHash)), hash: 0)) |> map { result -> (StickerPackCollectionInfo, [ItemCollectionItem]) in var items: [ItemCollectionItem] = [] var updatedInfo = info @@ -228,7 +228,7 @@ private func resolveStickerPacks(network: Network, remoteInfos: [ItemCollectionI private func installRemoteStickerPacks(network: Network, infos: [StickerPackCollectionInfo]) -> Signal, NoError> { var signals: [Signal, NoError>] = [] for info in infos { - let install = network.request(Api.functions.messages.installStickerSet(stickerset: .inputStickerSetID(id: info.id.id, accessHash: info.accessHash), archived: .boolFalse)) + let install = network.request(Api.functions.messages.installStickerSet(stickerset: .inputStickerSetID(.init(id: info.id.id, accessHash: info.accessHash)), archived: .boolFalse)) |> map { result -> Set in switch result { case .stickerSetInstallResultSuccess: @@ -268,7 +268,7 @@ private func installRemoteStickerPacks(network: Network, infos: [StickerPackColl private func removeRemoteStickerPacks(network: Network, infos: [StickerPackCollectionInfo]) -> Signal { if infos.count > 0 { if infos.count > 1 { - return network.request(Api.functions.messages.toggleStickerSets(flags: 1 << 0, stickersets: infos.map { .inputStickerSetID(id: $0.id.id, accessHash: $0.accessHash) })) + return network.request(Api.functions.messages.toggleStickerSets(flags: 1 << 0, stickersets: infos.map { .inputStickerSetID(.init(id: $0.id.id, accessHash: $0.accessHash)) })) |> mapToSignal { _ -> Signal in return .single(Void()) } @@ -276,7 +276,7 @@ private func removeRemoteStickerPacks(network: Network, infos: [StickerPackColle return .single(Void()) } } else if let info = infos.first { - return network.request(Api.functions.messages.uninstallStickerSet(stickerset: .inputStickerSetID(id: info.id.id, accessHash: info.accessHash))) + return network.request(Api.functions.messages.uninstallStickerSet(stickerset: .inputStickerSetID(.init(id: info.id.id, accessHash: info.accessHash)))) |> mapToSignal { _ -> Signal in return .single(Void()) } @@ -291,7 +291,7 @@ private func removeRemoteStickerPacks(network: Network, infos: [StickerPackColle private func archiveRemoteStickerPacks(network: Network, infos: [StickerPackCollectionInfo]) -> Signal { if infos.count > 0 { if infos.count > 1 { - return network.request(Api.functions.messages.toggleStickerSets(flags: 1 << 1, stickersets: infos.map { .inputStickerSetID(id: $0.id.id, accessHash: $0.accessHash) })) + return network.request(Api.functions.messages.toggleStickerSets(flags: 1 << 1, stickersets: infos.map { .inputStickerSetID(.init(id: $0.id.id, accessHash: $0.accessHash)) })) |> mapToSignal { _ -> Signal in return .single(Void()) } @@ -299,7 +299,7 @@ private func archiveRemoteStickerPacks(network: Network, infos: [StickerPackColl return .single(Void()) } } else if let info = infos.first { - return network.request(Api.functions.messages.installStickerSet(stickerset: .inputStickerSetID(id: info.id.id, accessHash: info.accessHash), archived: .boolTrue)) + return network.request(Api.functions.messages.installStickerSet(stickerset: .inputStickerSetID(.init(id: info.id.id, accessHash: info.accessHash)), archived: .boolTrue)) |> mapToSignal { _ -> Signal in return .single(Void()) } diff --git a/submodules/TelegramCore/Sources/State/PendingMessageManager.swift b/submodules/TelegramCore/Sources/State/PendingMessageManager.swift index 869b2f9da0..a96031e512 100644 --- a/submodules/TelegramCore/Sources/State/PendingMessageManager.swift +++ b/submodules/TelegramCore/Sources/State/PendingMessageManager.swift @@ -1105,9 +1105,9 @@ public final class PendingMessageManager { var quickReplyShortcut: Api.InputQuickReplyShortcut? if let quickReply { if let threadId = messages[0].0.threadId { - quickReplyShortcut = .inputQuickReplyShortcutId(shortcutId: Int32(clamping: threadId)) + quickReplyShortcut = .inputQuickReplyShortcutId(.init(shortcutId: Int32(clamping: threadId))) } else { - quickReplyShortcut = .inputQuickReplyShortcut(shortcut: quickReply.shortcut) + quickReplyShortcut = .inputQuickReplyShortcut(.init(shortcut: quickReply.shortcut)) } flags |= 1 << 17 } @@ -1118,7 +1118,7 @@ public final class PendingMessageManager { var replyTo: Api.InputReplyTo? if let monoforumPeerId { - replyTo = .inputReplyToMonoForum(monoforumPeerId: monoforumPeerId) + replyTo = .inputReplyToMonoForum(.init(monoforumPeerId: monoforumPeerId)) flags |= 1 << 22 } @@ -1176,7 +1176,7 @@ public final class PendingMessageManager { singleFlags |= 1 << 0 } - singleMedias.append(.inputSingleMedia(flags: singleFlags, media: inputMedia, randomId: uniqueId, message: text, entities: messageEntities)) + singleMedias.append(.inputSingleMedia(.init(flags: singleFlags, media: inputMedia, randomId: uniqueId, message: text, entities: messageEntities))) default: return failMessages(postbox: postbox, ids: group.map { $0.0 }) } @@ -1253,23 +1253,23 @@ public final class PendingMessageManager { replyFlags |= 1 << 6 } - replyTo = .inputReplyToMessage(flags: replyFlags, replyToMsgId: replyMessageId, topMsgId: topMsgId, replyToPeerId: replyToPeerId, quoteText: quoteText, quoteEntities: quoteEntities, quoteOffset: quoteOffset, monoforumPeerId: monoforumPeerId, todoItemId: replyTodoItemId) + replyTo = .inputReplyToMessage(.init(flags: replyFlags, replyToMsgId: replyMessageId, topMsgId: topMsgId, replyToPeerId: replyToPeerId, quoteText: quoteText, quoteEntities: quoteEntities, quoteOffset: quoteOffset, monoforumPeerId: monoforumPeerId, todoItemId: replyTodoItemId)) } else if let replyToStoryId { if let inputPeer = transaction.getPeer(replyToStoryId.peerId).flatMap(apiInputPeer) { flags |= 1 << 0 - replyTo = .inputReplyToStory(peer: inputPeer, storyId: replyToStoryId.id) + replyTo = .inputReplyToStory(.init(peer: inputPeer, storyId: replyToStoryId.id)) } } else if let monoforumPeerId { flags |= 1 << 0 - replyTo = .inputReplyToMonoForum(monoforumPeerId: monoforumPeerId) + replyTo = .inputReplyToMonoForum(.init(monoforumPeerId: monoforumPeerId)) } var quickReplyShortcut: Api.InputQuickReplyShortcut? if let quickReply { if let threadId = messages[0].0.threadId { - quickReplyShortcut = .inputQuickReplyShortcutId(shortcutId: Int32(clamping: threadId)) + quickReplyShortcut = .inputQuickReplyShortcutId(.init(shortcutId: Int32(clamping: threadId))) } else { - quickReplyShortcut = .inputQuickReplyShortcut(shortcut: quickReply.shortcut) + quickReplyShortcut = .inputQuickReplyShortcut(.init(shortcut: quickReply.shortcut)) } flags |= 1 << 17 } @@ -1645,15 +1645,15 @@ public final class PendingMessageManager { if let _ = replyTodoItemId { replyFlags |= 1 << 6 } - replyTo = .inputReplyToMessage(flags: replyFlags, replyToMsgId: replyMessageId, topMsgId: topMsgId, replyToPeerId: replyToPeerId, quoteText: quoteText, quoteEntities: quoteEntities, quoteOffset: quoteOffset, monoforumPeerId: monoforumPeerId, todoItemId: replyTodoItemId) + replyTo = .inputReplyToMessage(.init(flags: replyFlags, replyToMsgId: replyMessageId, topMsgId: topMsgId, replyToPeerId: replyToPeerId, quoteText: quoteText, quoteEntities: quoteEntities, quoteOffset: quoteOffset, monoforumPeerId: monoforumPeerId, todoItemId: replyTodoItemId)) } else if let replyToStoryId = replyToStoryId { if let inputPeer = transaction.getPeer(replyToStoryId.peerId).flatMap(apiInputPeer) { flags |= 1 << 0 - replyTo = .inputReplyToStory(peer: inputPeer, storyId: replyToStoryId.id) + replyTo = .inputReplyToStory(.init(peer: inputPeer, storyId: replyToStoryId.id)) } } else if let monoforumPeerId { flags |= 1 << 0 - replyTo = .inputReplyToMonoForum(monoforumPeerId: monoforumPeerId) + replyTo = .inputReplyToMonoForum(.init(monoforumPeerId: monoforumPeerId)) } if let attribute = message.webpagePreviewAttribute { if attribute.leadingPreview { @@ -1667,9 +1667,9 @@ public final class PendingMessageManager { var quickReplyShortcut: Api.InputQuickReplyShortcut? if let quickReply { if let threadId = message.threadId { - quickReplyShortcut = .inputQuickReplyShortcutId(shortcutId: Int32(clamping: threadId)) + quickReplyShortcut = .inputQuickReplyShortcutId(.init(shortcutId: Int32(clamping: threadId))) } else { - quickReplyShortcut = .inputQuickReplyShortcut(shortcut: quickReply.shortcut) + quickReplyShortcut = .inputQuickReplyShortcut(.init(shortcut: quickReply.shortcut)) } flags |= 1 << 17 } @@ -1743,17 +1743,17 @@ public final class PendingMessageManager { if let _ = replyTodoItemId { replyFlags |= 1 << 6 } - replyTo = .inputReplyToMessage(flags: replyFlags, replyToMsgId: replyMessageId, topMsgId: topMsgId, replyToPeerId: replyToPeerId, quoteText: quoteText, quoteEntities: quoteEntities, quoteOffset: quoteOffset, monoforumPeerId: monoforumPeerId, todoItemId: replyTodoItemId) + replyTo = .inputReplyToMessage(.init(flags: replyFlags, replyToMsgId: replyMessageId, topMsgId: topMsgId, replyToPeerId: replyToPeerId, quoteText: quoteText, quoteEntities: quoteEntities, quoteOffset: quoteOffset, monoforumPeerId: monoforumPeerId, todoItemId: replyTodoItemId)) } else if let replyToStoryId = replyToStoryId { if let inputPeer = transaction.getPeer(replyToStoryId.peerId).flatMap(apiInputPeer) { flags |= 1 << 0 - replyTo = .inputReplyToStory(peer: inputPeer, storyId: replyToStoryId.id) + replyTo = .inputReplyToStory(.init(peer: inputPeer, storyId: replyToStoryId.id)) } } else if let monoforumPeerId { flags |= 1 << 0 - replyTo = .inputReplyToMonoForum(monoforumPeerId: monoforumPeerId) + replyTo = .inputReplyToMonoForum(.init(monoforumPeerId: monoforumPeerId)) } - + if let attribute = message.webpagePreviewAttribute { if attribute.leadingPreview { flags |= 1 << 16 @@ -1766,9 +1766,9 @@ public final class PendingMessageManager { var quickReplyShortcut: Api.InputQuickReplyShortcut? if let quickReply { if let threadId = message.threadId { - quickReplyShortcut = .inputQuickReplyShortcutId(shortcutId: Int32(clamping: threadId)) + quickReplyShortcut = .inputQuickReplyShortcutId(.init(shortcutId: Int32(clamping: threadId))) } else { - quickReplyShortcut = .inputQuickReplyShortcut(shortcut: quickReply.shortcut) + quickReplyShortcut = .inputQuickReplyShortcut(.init(shortcut: quickReply.shortcut)) } flags |= 1 << 17 } @@ -1805,9 +1805,9 @@ public final class PendingMessageManager { var quickReplyShortcut: Api.InputQuickReplyShortcut? if let quickReply { if let threadId = message.threadId { - quickReplyShortcut = .inputQuickReplyShortcutId(shortcutId: Int32(clamping: threadId)) + quickReplyShortcut = .inputQuickReplyShortcutId(.init(shortcutId: Int32(clamping: threadId))) } else { - quickReplyShortcut = .inputQuickReplyShortcut(shortcut: quickReply.shortcut) + quickReplyShortcut = .inputQuickReplyShortcut(.init(shortcut: quickReply.shortcut)) } flags |= 1 << 17 } @@ -1822,7 +1822,7 @@ public final class PendingMessageManager { var replyTo: Api.InputReplyTo? if let monoforumPeerId { - replyTo = .inputReplyToMonoForum(monoforumPeerId: monoforumPeerId) + replyTo = .inputReplyToMonoForum(.init(monoforumPeerId: monoforumPeerId)) flags |= 1 << 22 } @@ -1891,23 +1891,23 @@ public final class PendingMessageManager { if let _ = replyTodoItemId { replyFlags |= 1 << 6 } - replyTo = .inputReplyToMessage(flags: replyFlags, replyToMsgId: replyMessageId, topMsgId: message.threadId.flatMap(Int32.init(clamping:)), replyToPeerId: replyToPeerId, quoteText: quoteText, quoteEntities: quoteEntities, quoteOffset: quoteOffset, monoforumPeerId: monoforumPeerId, todoItemId: replyTodoItemId) + replyTo = .inputReplyToMessage(.init(flags: replyFlags, replyToMsgId: replyMessageId, topMsgId: message.threadId.flatMap(Int32.init(clamping:)), replyToPeerId: replyToPeerId, quoteText: quoteText, quoteEntities: quoteEntities, quoteOffset: quoteOffset, monoforumPeerId: monoforumPeerId, todoItemId: replyTodoItemId)) } else if let replyToStoryId = replyToStoryId { if let inputPeer = transaction.getPeer(replyToStoryId.peerId).flatMap(apiInputPeer) { flags |= 1 << 0 - replyTo = .inputReplyToStory(peer: inputPeer, storyId: replyToStoryId.id) + replyTo = .inputReplyToStory(.init(peer: inputPeer, storyId: replyToStoryId.id)) } } else if let monoforumPeerId { flags |= 1 << 0 - replyTo = .inputReplyToMonoForum(monoforumPeerId: monoforumPeerId) + replyTo = .inputReplyToMonoForum(.init(monoforumPeerId: monoforumPeerId)) } var quickReplyShortcut: Api.InputQuickReplyShortcut? if let quickReply { if let threadId = message.threadId { - quickReplyShortcut = .inputQuickReplyShortcutId(shortcutId: Int32(clamping: threadId)) + quickReplyShortcut = .inputQuickReplyShortcutId(.init(shortcutId: Int32(clamping: threadId))) } else { - quickReplyShortcut = .inputQuickReplyShortcut(shortcut: quickReply.shortcut) + quickReplyShortcut = .inputQuickReplyShortcut(.init(shortcut: quickReply.shortcut)) } flags |= 1 << 17 } @@ -1923,18 +1923,18 @@ public final class PendingMessageManager { if let replyMessageId = replyMessageId { let replyFlags: Int32 = 0 - replyTo = .inputReplyToMessage(flags: replyFlags, replyToMsgId: replyMessageId, topMsgId: nil, replyToPeerId: nil, quoteText: nil, quoteEntities: nil, quoteOffset: nil, monoforumPeerId: nil, todoItemId: nil) + replyTo = .inputReplyToMessage(.init(flags: replyFlags, replyToMsgId: replyMessageId, topMsgId: nil, replyToPeerId: nil, quoteText: nil, quoteEntities: nil, quoteOffset: nil, monoforumPeerId: nil, todoItemId: nil)) } else if let replyToStoryId = replyToStoryId { if let inputPeer = transaction.getPeer(replyToStoryId.peerId).flatMap(apiInputPeer) { flags |= 1 << 0 - replyTo = .inputReplyToStory(peer: inputPeer, storyId: replyToStoryId.id) + replyTo = .inputReplyToStory(.init(peer: inputPeer, storyId: replyToStoryId.id)) } else { let replyFlags: Int32 = 0 - replyTo = .inputReplyToMessage(flags: replyFlags, replyToMsgId: 0, topMsgId: nil, replyToPeerId: nil, quoteText: nil, quoteEntities: nil, quoteOffset: nil, monoforumPeerId: monoforumPeerId, todoItemId: nil) + replyTo = .inputReplyToMessage(.init(flags: replyFlags, replyToMsgId: 0, topMsgId: nil, replyToPeerId: nil, quoteText: nil, quoteEntities: nil, quoteOffset: nil, monoforumPeerId: monoforumPeerId, todoItemId: nil)) } } else { let replyFlags: Int32 = 0 - replyTo = .inputReplyToMessage(flags: replyFlags, replyToMsgId: 0, topMsgId: nil, replyToPeerId: nil, quoteText: nil, quoteEntities: nil, quoteOffset: nil, monoforumPeerId: monoforumPeerId, todoItemId: nil) + replyTo = .inputReplyToMessage(.init(flags: replyFlags, replyToMsgId: 0, topMsgId: nil, replyToPeerId: nil, quoteText: nil, quoteEntities: nil, quoteOffset: nil, monoforumPeerId: monoforumPeerId, todoItemId: nil)) } sendMessageRequest = network.request(Api.functions.messages.sendScreenshotNotification(peer: inputPeer, replyTo: replyTo, randomId: uniqueId)) diff --git a/submodules/TelegramCore/Sources/State/StickerManagement.swift b/submodules/TelegramCore/Sources/State/StickerManagement.swift index e159022381..605ed73a25 100644 --- a/submodules/TelegramCore/Sources/State/StickerManagement.swift +++ b/submodules/TelegramCore/Sources/State/StickerManagement.swift @@ -72,7 +72,7 @@ func resolveMissingStickerSets(network: Network, postbox: Postbox, stickerSets: continue } - missingSignals.append(network.request(Api.functions.messages.getStickerSet(stickerset: .inputStickerSetID(id: id, accessHash: accessHash), hash: 0)) + missingSignals.append(network.request(Api.functions.messages.getStickerSet(stickerset: .inputStickerSetID(.init(id: id, accessHash: accessHash)), hash: 0)) |> map(Optional.init) |> `catch` { _ -> Signal in return .single(nil) diff --git a/submodules/TelegramCore/Sources/State/SynchronizePeerReadState.swift b/submodules/TelegramCore/Sources/State/SynchronizePeerReadState.swift index 9acbf6629f..a236eca1ed 100644 --- a/submodules/TelegramCore/Sources/State/SynchronizePeerReadState.swift +++ b/submodules/TelegramCore/Sources/State/SynchronizePeerReadState.swift @@ -240,7 +240,8 @@ private func pushPeerReadState(network: Network, postbox: Postbox, stateManager: return inputPeer(postbox: postbox, peerId: peerId) |> mapToSignal { inputPeer -> Signal in switch inputPeer { - case let .inputPeerChannel(channelId, accessHash): + case let .inputPeerChannel(inputPeerChannelData): + let (channelId, accessHash) = (inputPeerChannelData.channelId, inputPeerChannelData.accessHash) switch readState { case let .idBased(maxIncomingReadId, _, _, _, markedUnread): var pushSignal: Signal = network.request(Api.functions.channels.readHistory(channel: Api.InputChannel.inputChannel(.init(channelId: channelId, accessHash: accessHash)), maxId: maxIncomingReadId)) diff --git a/submodules/TelegramCore/Sources/State/UpdatesApiUtils.swift b/submodules/TelegramCore/Sources/State/UpdatesApiUtils.swift index 17bf72db88..c023f3099f 100644 --- a/submodules/TelegramCore/Sources/State/UpdatesApiUtils.swift +++ b/submodules/TelegramCore/Sources/State/UpdatesApiUtils.swift @@ -641,20 +641,22 @@ extension Api.EncryptedMessage { extension Api.InputMedia { func withUpdatedStickers(_ stickers: [Api.InputDocument]?) -> Api.InputMedia { switch self { - case let .inputMediaUploadedDocument(flags, file, thumb, mimeType, attributes, _, videoCover, videoTimestamp, ttlSeconds): + case let .inputMediaUploadedDocument(inputMediaUploadedDocumentData): + let (flags, file, thumb, mimeType, attributes, videoCover, videoTimestamp, ttlSeconds) = (inputMediaUploadedDocumentData.flags, inputMediaUploadedDocumentData.file, inputMediaUploadedDocumentData.thumb, inputMediaUploadedDocumentData.mimeType, inputMediaUploadedDocumentData.attributes, inputMediaUploadedDocumentData.videoCover, inputMediaUploadedDocumentData.videoTimestamp, inputMediaUploadedDocumentData.ttlSeconds) var flags = flags var attributes = attributes if let _ = stickers { flags |= (1 << 0) attributes.append(.documentAttributeHasStickers) } - return .inputMediaUploadedDocument(flags: flags, file: file, thumb: thumb, mimeType: mimeType, attributes: attributes, stickers: stickers, videoCover: videoCover, videoTimestamp: videoTimestamp, ttlSeconds: ttlSeconds) - case let .inputMediaUploadedPhoto(flags, file, _, ttlSeconds): + return .inputMediaUploadedDocument(.init(flags: flags, file: file, thumb: thumb, mimeType: mimeType, attributes: attributes, stickers: stickers, videoCover: videoCover, videoTimestamp: videoTimestamp, ttlSeconds: ttlSeconds)) + case let .inputMediaUploadedPhoto(inputMediaUploadedPhotoData): + let (flags, file, ttlSeconds) = (inputMediaUploadedPhotoData.flags, inputMediaUploadedPhotoData.file, inputMediaUploadedPhotoData.ttlSeconds) var flags = flags if let _ = stickers { flags |= (1 << 0) } - return .inputMediaUploadedPhoto(flags: flags, file: file, stickers: stickers, ttlSeconds: ttlSeconds) + return .inputMediaUploadedPhoto(.init(flags: flags, file: file, stickers: stickers, ttlSeconds: ttlSeconds)) default: return self } diff --git a/submodules/TelegramCore/Sources/TelegramEngine/Calls/RateCall.swift b/submodules/TelegramCore/Sources/TelegramEngine/Calls/RateCall.swift index 4b09016718..f98c51110e 100644 --- a/submodules/TelegramCore/Sources/TelegramEngine/Calls/RateCall.swift +++ b/submodules/TelegramCore/Sources/TelegramEngine/Calls/RateCall.swift @@ -9,7 +9,7 @@ func _internal_rateCall(account: Account, callId: CallId, starsCount: Int32, com if userInitiated { flags |= (1 << 0) } - return account.network.request(Api.functions.phone.setCallRating(flags: flags, peer: Api.InputPhoneCall.inputPhoneCall(id: callId.id, accessHash: callId.accessHash), rating: starsCount, comment: comment)) + return account.network.request(Api.functions.phone.setCallRating(flags: flags, peer: Api.InputPhoneCall.inputPhoneCall(.init(id: callId.id, accessHash: callId.accessHash)), rating: starsCount, comment: comment)) |> retryRequest |> map { _ in } } @@ -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(.init(data: log)))) + return network.request(Api.functions.phone.saveCallDebug(peer: Api.InputPhoneCall.inputPhoneCall(.init(id: callId.id, accessHash: callId.accessHash)), debug: .dataJSON(.init(data: log)))) |> `catch` { _ -> Signal in return .single(.boolTrue) } @@ -72,7 +72,7 @@ func _internal_saveCompleteCallDebugLog(account: Account, callId: CallId, logPat case .progress: return .complete() case let .inputFile(inputFile): - return account.network.request(Api.functions.phone.saveCallLog(peer: Api.InputPhoneCall.inputPhoneCall(id: callId.id, accessHash: callId.accessHash), file: inputFile)) + return account.network.request(Api.functions.phone.saveCallLog(peer: Api.InputPhoneCall.inputPhoneCall(.init(id: callId.id, accessHash: callId.accessHash)), file: inputFile)) |> mapError { _ -> MultipartUploadError in return .generic } diff --git a/submodules/TelegramCore/Sources/TelegramEngine/Messages/BotWebView.swift b/submodules/TelegramCore/Sources/TelegramEngine/Messages/BotWebView.swift index 1cd6257b7f..c96e81b028 100644 --- a/submodules/TelegramCore/Sources/TelegramEngine/Messages/BotWebView.swift +++ b/submodules/TelegramCore/Sources/TelegramEngine/Messages/BotWebView.swift @@ -160,7 +160,7 @@ private func keepWebViewSignal(network: Network, stateManager: AccountStateManag replyFlags |= 1 << 0 topMsgId = Int32(clamping: threadId) } - replyTo = .inputReplyToMessage(flags: replyFlags, replyToMsgId: replyToMessageId.id, topMsgId: topMsgId, replyToPeerId: nil, quoteText: nil, quoteEntities: nil, quoteOffset: nil, monoforumPeerId: monoforumPeerId, todoItemId: nil) + replyTo = .inputReplyToMessage(.init(flags: replyFlags, replyToMsgId: replyToMessageId.id, topMsgId: topMsgId, replyToPeerId: nil, quoteText: nil, quoteEntities: nil, quoteOffset: nil, monoforumPeerId: monoforumPeerId, todoItemId: nil)) } let signal: Signal = network.request(Api.functions.messages.prolongWebView(flags: flags, peer: peer, bot: bot, queryId: queryId, replyTo: replyTo, sendAs: sendAs)) |> mapError { _ -> KeepWebViewError in @@ -248,9 +248,9 @@ func _internal_requestWebView(postbox: Postbox, network: Network, stateManager: } else if topMsgId != nil { replyFlags |= 1 << 0 } - replyTo = .inputReplyToMessage(flags: replyFlags, replyToMsgId: replyToMessageId.id, topMsgId: topMsgId, replyToPeerId: nil, quoteText: nil, quoteEntities: nil, quoteOffset: nil, monoforumPeerId: monoforumPeerId, todoItemId: nil) + replyTo = .inputReplyToMessage(.init(flags: replyFlags, replyToMsgId: replyToMessageId.id, topMsgId: topMsgId, replyToPeerId: nil, quoteText: nil, quoteEntities: nil, quoteOffset: nil, monoforumPeerId: monoforumPeerId, todoItemId: nil)) } else if let monoforumPeerId { - replyTo = .inputReplyToMonoForum(monoforumPeerId: monoforumPeerId) + replyTo = .inputReplyToMonoForum(.init(monoforumPeerId: monoforumPeerId)) } return network.request(Api.functions.messages.requestWebView(flags: flags, peer: inputPeer, bot: inputBot, url: url, startParam: payload, themeParams: serializedThemeParams, platform: botWebViewPlatform, replyTo: replyTo, sendAs: nil)) diff --git a/submodules/TelegramCore/Sources/TelegramEngine/Messages/ClearCloudDrafts.swift b/submodules/TelegramCore/Sources/TelegramEngine/Messages/ClearCloudDrafts.swift index 739d78daad..891896c7e1 100644 --- a/submodules/TelegramCore/Sources/TelegramEngine/Messages/ClearCloudDrafts.swift +++ b/submodules/TelegramCore/Sources/TelegramEngine/Messages/ClearCloudDrafts.swift @@ -55,10 +55,10 @@ func _internal_clearCloudDraftsInteractively(postbox: Postbox, network: Network, var innerFlags: Int32 = 0 innerFlags |= 1 << 0 - replyTo = .inputReplyToMessage(flags: innerFlags, replyToMsgId: 0, topMsgId: topMsgId, replyToPeerId: nil, quoteText: nil, quoteEntities: nil, quoteOffset: nil, monoforumPeerId: nil, todoItemId: nil) + replyTo = .inputReplyToMessage(.init(flags: innerFlags, replyToMsgId: 0, topMsgId: topMsgId, replyToPeerId: nil, quoteText: nil, quoteEntities: nil, quoteOffset: nil, monoforumPeerId: nil, todoItemId: nil)) } else if let monoforumPeerId { flags |= (1 << 0) - replyTo = .inputReplyToMonoForum(monoforumPeerId: monoforumPeerId) + replyTo = .inputReplyToMonoForum(.init(monoforumPeerId: monoforumPeerId)) } signals.append(network.request(Api.functions.messages.saveDraft(flags: flags, replyTo: replyTo, peer: inputPeer, message: "", entities: nil, media: nil, effect: nil, suggestedPost: nil)) |> `catch` { _ -> Signal in diff --git a/submodules/TelegramCore/Sources/TelegramEngine/Messages/LoadMessagesIfNecessary.swift b/submodules/TelegramCore/Sources/TelegramEngine/Messages/LoadMessagesIfNecessary.swift index 279d59e0f9..22b044f3cd 100644 --- a/submodules/TelegramCore/Sources/TelegramEngine/Messages/LoadMessagesIfNecessary.swift +++ b/submodules/TelegramCore/Sources/TelegramEngine/Messages/LoadMessagesIfNecessary.swift @@ -61,10 +61,10 @@ func _internal_getMessagesLoadIfNecessary(_ messageIds: [MessageId], postbox: Po if let peer = supportPeers[peerId] { var signal: Signal? if peerId.namespace == Namespaces.Peer.CloudUser || peerId.namespace == Namespaces.Peer.CloudGroup { - signal = network.request(Api.functions.messages.getMessages(id: messageIds.map({ Api.InputMessage.inputMessageID(id: $0.id) }))) + signal = network.request(Api.functions.messages.getMessages(id: messageIds.map({ Api.InputMessage.inputMessageID(.init(id: $0.id)) }))) } else if peerId.namespace == Namespaces.Peer.CloudChannel { if let inputChannel = apiInputChannel(peer) { - signal = network.request(Api.functions.channels.getMessages(channel: inputChannel, id: messageIds.map({ Api.InputMessage.inputMessageID(id: $0.id) }))) + signal = network.request(Api.functions.channels.getMessages(channel: inputChannel, id: messageIds.map({ Api.InputMessage.inputMessageID(.init(id: $0.id)) }))) } } if let signal = signal { diff --git a/submodules/TelegramCore/Sources/TelegramEngine/Messages/Polls.swift b/submodules/TelegramCore/Sources/TelegramEngine/Messages/Polls.swift index 519eac4269..ce58ef76b2 100644 --- a/submodules/TelegramCore/Sources/TelegramEngine/Messages/Polls.swift +++ b/submodules/TelegramCore/Sources/TelegramEngine/Messages/Polls.swift @@ -142,7 +142,7 @@ func _internal_requestClosePoll(postbox: Postbox, network: Network, stateManager pollMediaFlags |= 1 << 1 } - return network.request(Api.functions.messages.editMessage(flags: flags, peer: inputPeer, id: messageId.id, message: nil, media: .inputMediaPoll(flags: pollMediaFlags, poll: .poll(id: poll.pollId.id, flags: pollFlags, question: .textWithEntities(text: poll.text, entities: apiEntitiesFromMessageTextEntities(poll.textEntities, associatedPeers: SimpleDictionary())), answers: poll.options.map({ $0.apiOption }), closePeriod: poll.deadlineTimeout, closeDate: nil), correctAnswers: correctAnswers, solution: mappedSolution, solutionEntities: mappedSolutionEntities), replyMarkup: nil, entities: nil, scheduleDate: nil, scheduleRepeatPeriod: nil, quickReplyShortcutId: nil)) + return network.request(Api.functions.messages.editMessage(flags: flags, peer: inputPeer, id: messageId.id, message: nil, media: .inputMediaPoll(.init(flags: pollMediaFlags, poll: .poll(.init(id: poll.pollId.id, flags: pollFlags, question: .textWithEntities(.init(text: poll.text, entities: apiEntitiesFromMessageTextEntities(poll.textEntities, associatedPeers: SimpleDictionary()))), answers: poll.options.map({ $0.apiOption }), closePeriod: poll.deadlineTimeout, closeDate: nil)), correctAnswers: correctAnswers, solution: mappedSolution, solutionEntities: mappedSolutionEntities)), replyMarkup: nil, entities: nil, scheduleDate: nil, scheduleRepeatPeriod: nil, quickReplyShortcutId: nil)) |> map(Optional.init) |> `catch` { _ -> Signal in return .single(nil) diff --git a/submodules/TelegramCore/Sources/TelegramEngine/Messages/SearchMessages.swift b/submodules/TelegramCore/Sources/TelegramEngine/Messages/SearchMessages.swift index 8d1bccd111..fd05a6a523 100644 --- a/submodules/TelegramCore/Sources/TelegramEngine/Messages/SearchMessages.swift +++ b/submodules/TelegramCore/Sources/TelegramEngine/Messages/SearchMessages.swift @@ -673,12 +673,12 @@ func _internal_downloadMessage(accountPeerId: PeerId, postbox: Postbox, network: let signal: Signal if messageId.peerId.namespace == Namespaces.Peer.CloudChannel { if let channel = apiInputChannel(peer) { - signal = network.request(Api.functions.channels.getMessages(channel: channel, id: [Api.InputMessage.inputMessageID(id: messageId.id)])) + signal = network.request(Api.functions.channels.getMessages(channel: channel, id: [Api.InputMessage.inputMessageID(.init(id: messageId.id))])) } else { signal = .complete() } } else { - signal = network.request(Api.functions.messages.getMessages(id: [Api.InputMessage.inputMessageID(id: messageId.id)])) + signal = network.request(Api.functions.messages.getMessages(id: [Api.InputMessage.inputMessageID(.init(id: messageId.id))])) } return signal @@ -762,12 +762,12 @@ func fetchRemoteMessage(accountPeerId: PeerId, postbox: Postbox, source: FetchMe } } else if id.peerId.namespace == Namespaces.Peer.CloudChannel { if let channel = peer.inputChannel { - signal = source.request(Api.functions.channels.getMessages(channel: channel, id: [Api.InputMessage.inputMessageID(id: id.id)])) + signal = source.request(Api.functions.channels.getMessages(channel: channel, id: [Api.InputMessage.inputMessageID(.init(id: id.id))])) } else { signal = .fail(MTRpcError(errorCode: 400, errorDescription: "Peer Not Found")) } } else if id.peerId.namespace == Namespaces.Peer.CloudUser || id.peerId.namespace == Namespaces.Peer.CloudGroup { - signal = source.request(Api.functions.messages.getMessages(id: [Api.InputMessage.inputMessageID(id: id.id)])) + signal = source.request(Api.functions.messages.getMessages(id: [Api.InputMessage.inputMessageID(.init(id: id.id))])) } else { signal = .fail(MTRpcError(errorCode: 400, errorDescription: "Invalid Peer")) } diff --git a/submodules/TelegramCore/Sources/TelegramEngine/Messages/Stories.swift b/submodules/TelegramCore/Sources/TelegramEngine/Messages/Stories.swift index b063a5cda2..89358a7d9c 100644 --- a/submodules/TelegramCore/Sources/TelegramEngine/Messages/Stories.swift +++ b/submodules/TelegramCore/Sources/TelegramEngine/Messages/Stories.swift @@ -980,7 +980,7 @@ private func apiInputPrivacyRules(privacy: EngineStoryPrivacy, transaction: Tran privacyRules = [.inputPrivacyValueAllowCloseFriends] case .nobody: if privacy.additionallyIncludePeers.isEmpty { - privacyRules = [.inputPrivacyValueAllowUsers(users: [.inputUserSelf])] + privacyRules = [.inputPrivacyValueAllowUsers(.init(users: [.inputUserSelf]))] } else { privacyRules = [] } @@ -1000,15 +1000,15 @@ private func apiInputPrivacyRules(privacy: EngineStoryPrivacy, transaction: Tran } if !privacyUsers.isEmpty { if case .contacts = privacy.base { - privacyRules.append(.inputPrivacyValueDisallowUsers(users: privacyUsers)) + privacyRules.append(.inputPrivacyValueDisallowUsers(.init(users: privacyUsers))) } else if case .everyone = privacy.base { - privacyRules.append(.inputPrivacyValueDisallowUsers(users: privacyUsers)) + privacyRules.append(.inputPrivacyValueDisallowUsers(.init(users: privacyUsers))) } else { - privacyRules.append(.inputPrivacyValueAllowUsers(users: privacyUsers)) + privacyRules.append(.inputPrivacyValueAllowUsers(.init(users: privacyUsers))) } } if !privacyChats.isEmpty { - privacyRules.append(.inputPrivacyValueAllowChatParticipants(chats: privacyChats)) + privacyRules.append(.inputPrivacyValueAllowChatParticipants(.init(chats: privacyChats))) } return privacyRules } @@ -1592,10 +1592,10 @@ func _internal_deleteBotPreviews(account: Account, peerId: PeerId, language: Str var inputMedia: [Api.InputMedia] = [] for item in media { if let image = item as? TelegramMediaImage, let resource = image.representations.last?.resource as? CloudPhotoSizeMediaResource { - inputMedia.append(.inputMediaPhoto(flags: 0, id: .inputPhoto(id: resource.photoId, accessHash: resource.accessHash, fileReference: Buffer(data: resource.fileReference)), ttlSeconds: nil)) - inputMedia.append(Api.InputMedia.inputMediaPhoto(flags: 0, id: Api.InputPhoto.inputPhoto(id: resource.photoId, accessHash: resource.accessHash, fileReference: Buffer(data: resource.fileReference)), ttlSeconds: nil)) + inputMedia.append(.inputMediaPhoto(.init(flags: 0, id: .inputPhoto(.init(id: resource.photoId, accessHash: resource.accessHash, fileReference: Buffer(data: resource.fileReference))), ttlSeconds: nil))) + inputMedia.append(Api.InputMedia.inputMediaPhoto(.init(flags: 0, id: Api.InputPhoto.inputPhoto(.init(id: resource.photoId, accessHash: resource.accessHash, fileReference: Buffer(data: resource.fileReference))), ttlSeconds: nil))) } else if let file = item as? TelegramMediaFile, let resource = file.resource as? CloudDocumentMediaResource { - inputMedia.append(.inputMediaDocument(flags: 0, id: .inputDocument(.init(id: resource.fileId, accessHash: resource.accessHash, fileReference: Buffer(data: resource.fileReference ?? Data()))), videoCover: nil, videoTimestamp: nil, ttlSeconds: nil, query: nil)) + inputMedia.append(.inputMediaDocument(.init(flags: 0, id: .inputDocument(.init(id: resource.fileId, accessHash: resource.accessHash, fileReference: Buffer(data: resource.fileReference ?? Data()))), videoCover: nil, videoTimestamp: nil, ttlSeconds: nil, query: nil))) } } if language == nil { @@ -1650,10 +1650,10 @@ func _internal_deleteBotPreviewsLanguage(account: Account, peerId: PeerId, langu var inputMedia: [Api.InputMedia] = [] for item in media { if let image = item as? TelegramMediaImage, let resource = image.representations.last?.resource as? CloudPhotoSizeMediaResource { - inputMedia.append(.inputMediaPhoto(flags: 0, id: .inputPhoto(id: resource.photoId, accessHash: resource.accessHash, fileReference: Buffer(data: resource.fileReference)), ttlSeconds: nil)) - inputMedia.append(Api.InputMedia.inputMediaPhoto(flags: 0, id: Api.InputPhoto.inputPhoto(id: resource.photoId, accessHash: resource.accessHash, fileReference: Buffer(data: resource.fileReference)), ttlSeconds: nil)) + inputMedia.append(.inputMediaPhoto(.init(flags: 0, id: .inputPhoto(.init(id: resource.photoId, accessHash: resource.accessHash, fileReference: Buffer(data: resource.fileReference))), ttlSeconds: nil))) + inputMedia.append(Api.InputMedia.inputMediaPhoto(.init(flags: 0, id: Api.InputPhoto.inputPhoto(.init(id: resource.photoId, accessHash: resource.accessHash, fileReference: Buffer(data: resource.fileReference))), ttlSeconds: nil))) } else if let file = item as? TelegramMediaFile, let resource = file.resource as? CloudDocumentMediaResource { - inputMedia.append(.inputMediaDocument(flags: 0, id: .inputDocument(.init(id: resource.fileId, accessHash: resource.accessHash, fileReference: Buffer(data: resource.fileReference ?? Data()))), videoCover: nil, videoTimestamp: nil, ttlSeconds: nil, query: nil)) + inputMedia.append(.inputMediaDocument(.init(flags: 0, id: .inputDocument(.init(id: resource.fileId, accessHash: resource.accessHash, fileReference: Buffer(data: resource.fileReference ?? Data()))), videoCover: nil, videoTimestamp: nil, ttlSeconds: nil, query: nil))) } } transaction.updatePeerCachedData(peerIds: Set([peerId]), update: { _, current -> CachedPeerData? in @@ -1718,7 +1718,7 @@ func _internal_editStory(account: Account, peerId: PeerId, id: Int32, media: Eng if let result = result, case let .content(uploadedContent) = result, case let .media(media, _) = uploadedContent.content { inputMedia = media } else if case let .existing(media) = media, let file = media as? TelegramMediaFile, let resource = file.resource as? CloudDocumentMediaResource { - inputMedia = .inputMediaUploadedDocument(flags: 0, file: .inputFileStoryDocument(.init(id: .inputDocument(.init(id: resource.fileId, accessHash: resource.accessHash, fileReference: Buffer(data: resource.fileReference))))), thumb: nil, mimeType: file.mimeType, attributes: inputDocumentAttributesFromFileAttributes(file.attributes), stickers: nil, videoCover: nil, videoTimestamp: nil, ttlSeconds: nil) + inputMedia = .inputMediaUploadedDocument(.init(flags: 0, file: .inputFileStoryDocument(.init(id: .inputDocument(.init(id: resource.fileId, accessHash: resource.accessHash, fileReference: Buffer(data: resource.fileReference))))), thumb: nil, mimeType: file.mimeType, attributes: inputDocumentAttributesFromFileAttributes(file.attributes), stickers: nil, videoCover: nil, videoTimestamp: nil, ttlSeconds: nil)) updatingCoverTime = true } else { inputMedia = nil diff --git a/submodules/TelegramCore/Sources/TelegramEngine/Messages/StoryListContext.swift b/submodules/TelegramCore/Sources/TelegramEngine/Messages/StoryListContext.swift index e9d84239aa..8e56aba9fc 100644 --- a/submodules/TelegramCore/Sources/TelegramEngine/Messages/StoryListContext.swift +++ b/submodules/TelegramCore/Sources/TelegramEngine/Messages/StoryListContext.swift @@ -3374,8 +3374,8 @@ public final class BotPreviewStoryListContext: StoryListContext { var inputMedia: [Api.InputMedia] = [] for item in media { if let image = item as? TelegramMediaImage, let resource = image.representations.last?.resource as? CloudPhotoSizeMediaResource { - inputMedia.append(.inputMediaPhoto(flags: 0, id: .inputPhoto(id: resource.photoId, accessHash: resource.accessHash, fileReference: Buffer(data: resource.fileReference)), ttlSeconds: nil)) - inputMedia.append(Api.InputMedia.inputMediaPhoto(flags: 0, id: Api.InputPhoto.inputPhoto(id: resource.photoId, accessHash: resource.accessHash, fileReference: Buffer(data: resource.fileReference)), ttlSeconds: nil)) + inputMedia.append(.inputMediaPhoto(flags: 0, id: .inputPhoto(.init(id: resource.photoId, accessHash: resource.accessHash, fileReference: Buffer(data: resource.fileReference))), ttlSeconds: nil)) + inputMedia.append(Api.InputMedia.inputMediaPhoto(flags: 0, id: Api.InputPhoto.inputPhoto(.init(id: resource.photoId, accessHash: resource.accessHash, fileReference: Buffer(data: resource.fileReference))), ttlSeconds: nil)) } else if let file = item as? TelegramMediaFile, let resource = file.resource as? CloudDocumentMediaResource { inputMedia.append(.inputMediaDocument(flags: 0, id: .inputDocument(.init(id: resource.fileId, accessHash: resource.accessHash, fileReference: Buffer(data: resource.fileReference ?? Data()))), videoCover: nil, videoTimestamp: nil, ttlSeconds: nil, query: nil)) } diff --git a/submodules/TelegramCore/Sources/TelegramEngine/Payments/AppStore.swift b/submodules/TelegramCore/Sources/TelegramEngine/Payments/AppStore.swift index 9276796244..1ce6bd38cc 100644 --- a/submodules/TelegramCore/Sources/TelegramEngine/Payments/AppStore.swift +++ b/submodules/TelegramCore/Sources/TelegramEngine/Payments/AppStore.swift @@ -35,14 +35,14 @@ private func apiInputStorePaymentPurpose(postbox: Postbox, purpose: AppStoreTran default: break } - return .single(.inputStorePaymentPremiumSubscription(flags: flags)) + return .single(.inputStorePaymentPremiumSubscription(.init(flags: flags))) case let .gift(peerId, currency, amount): return postbox.loadedPeerWithId(peerId) |> mapToSignal { peer -> Signal in guard let inputUser = apiInputUser(peer) else { return .complete() } - return .single(.inputStorePaymentGiftPremium(userId: inputUser, currency: currency, amount: amount)) + return .single(.inputStorePaymentGiftPremium(.init(userId: inputUser, currency: currency, amount: amount))) } case let .giftCode(peerIds, boostPeerId, currency, amount, text, entities): return postbox.transaction { transaction -> Api.InputStorePaymentPurpose in @@ -67,7 +67,7 @@ private func apiInputStorePaymentPurpose(postbox: Postbox, purpose: AppStoreTran message = .textWithEntities(text: text, entities: entities.flatMap { apiEntitiesFromMessageTextEntities($0, associatedPeers: SimpleDictionary()) } ?? []) } - return .inputStorePaymentPremiumGiftCode(flags: flags, users: apiInputUsers, boostPeer: apiBoostPeer, currency: currency, amount: amount, message: message) + return .inputStorePaymentPremiumGiftCode(.init(flags: flags, users: apiInputUsers, boostPeer: apiBoostPeer, currency: currency, amount: amount, message: message)) } case let .giveaway(boostPeerId, additionalPeerIds, countries, onlyNewSubscribers, showWinners, prizeDescription, randomId, untilDate, currency, amount): return postbox.transaction { transaction -> Signal in @@ -96,7 +96,7 @@ private func apiInputStorePaymentPurpose(postbox: Postbox, purpose: AppStoreTran if let _ = prizeDescription { flags |= (1 << 4) } - return .single(.inputStorePaymentPremiumGiveaway(flags: flags, boostPeer: apiBoostPeer, additionalPeers: additionalPeers, countriesIso2: countries, prizeDescription: prizeDescription, randomId: randomId, untilDate: untilDate, currency: currency, amount: amount)) + return .single(.inputStorePaymentPremiumGiveaway(.init(flags: flags, boostPeer: apiBoostPeer, additionalPeers: additionalPeers, countriesIso2: countries, prizeDescription: prizeDescription, randomId: randomId, untilDate: untilDate, currency: currency, amount: amount))) } |> switchToLatest case let .stars(count, currency, amount, peerId): @@ -115,7 +115,7 @@ private func apiInputStorePaymentPurpose(postbox: Postbox, purpose: AppStoreTran if let _ = spendPurposePeer { flags |= (1 << 0) } - return .inputStorePaymentStarsTopup(flags: flags, stars: count, currency: currency, amount: amount, spendPurposePeer: spendPurposePeer) + return .inputStorePaymentStarsTopup(.init(flags: flags, stars: count, currency: currency, amount: amount, spendPurposePeer: spendPurposePeer)) } case let .starsGift(peerId, count, currency, amount): return postbox.loadedPeerWithId(peerId) @@ -123,7 +123,7 @@ private func apiInputStorePaymentPurpose(postbox: Postbox, purpose: AppStoreTran guard let inputUser = apiInputUser(peer) else { return .complete() } - return .single(.inputStorePaymentStarsGift(userId: inputUser, stars: count, currency: currency, amount: amount)) + return .single(.inputStorePaymentStarsGift(.init(userId: inputUser, stars: count, currency: currency, amount: amount))) } case let .starsGiveaway(stars, boostPeerId, additionalPeerIds, countries, onlyNewSubscribers, showWinners, prizeDescription, randomId, untilDate, currency, amount, users): return postbox.transaction { transaction -> Signal in @@ -152,7 +152,7 @@ private func apiInputStorePaymentPurpose(postbox: Postbox, purpose: AppStoreTran if let _ = prizeDescription { flags |= (1 << 4) } - return .single(.inputStorePaymentStarsGiveaway(flags: flags, stars: stars, boostPeer: apiBoostPeer, additionalPeers: additionalPeers, countriesIso2: countries, prizeDescription: prizeDescription, randomId: randomId, untilDate: untilDate, currency: currency, amount: amount, users: users)) + return .single(.inputStorePaymentStarsGiveaway(.init(flags: flags, stars: stars, boostPeer: apiBoostPeer, additionalPeers: additionalPeers, countriesIso2: countries, prizeDescription: prizeDescription, randomId: randomId, untilDate: untilDate, currency: currency, amount: amount, users: users))) } |> switchToLatest case let .authCode(restore, phoneNumber, phoneCodeHash, currency, amount): @@ -160,7 +160,7 @@ private func apiInputStorePaymentPurpose(postbox: Postbox, purpose: AppStoreTran if restore { flags |= (1 << 0) } - return .single(.inputStorePaymentAuthCode(flags: flags, phoneNumber: phoneNumber, phoneCodeHash: phoneCodeHash, currency: currency, amount: amount)) + return .single(.inputStorePaymentAuthCode(.init(flags: flags, phoneNumber: phoneNumber, phoneCodeHash: phoneCodeHash, currency: currency, amount: amount))) } } diff --git a/submodules/TelegramCore/Sources/TelegramEngine/Payments/BotPaymentForm.swift b/submodules/TelegramCore/Sources/TelegramEngine/Payments/BotPaymentForm.swift index 7767fa494d..5b6761188c 100644 --- a/submodules/TelegramCore/Sources/TelegramEngine/Payments/BotPaymentForm.swift +++ b/submodules/TelegramCore/Sources/TelegramEngine/Payments/BotPaymentForm.swift @@ -253,9 +253,9 @@ func _internal_parseInputInvoice(transaction: Transaction, source: BotPaymentInv guard let inputPeer = transaction.getPeer(messageId.peerId).flatMap(apiInputPeer) else { return nil } - return .inputInvoiceMessage(peer: inputPeer, msgId: messageId.id) + return .inputInvoiceMessage(.init(peer: inputPeer, msgId: messageId.id)) case let .slug(slug): - return .inputInvoiceSlug(slug: slug) + return .inputInvoiceSlug(.init(slug: slug)) case let .premiumGiveaway(boostPeerId, additionalPeerIds, countries, onlyNewSubscribers, showWinners, prizeDescription, randomId, untilDate, currency, amount, option): guard let peer = transaction.getPeer(boostPeerId), let apiBoostPeer = apiInputPeer(peer) else { return nil @@ -283,7 +283,7 @@ func _internal_parseInputInvoice(transaction: Transaction, source: BotPaymentInv flags |= (1 << 4) } - let inputPurpose: Api.InputStorePaymentPurpose = .inputStorePaymentPremiumGiveaway(flags: flags, boostPeer: apiBoostPeer, additionalPeers: additionalPeers, countriesIso2: countries, prizeDescription: prizeDescription, randomId: randomId, untilDate: untilDate, currency: currency, amount: amount) + let inputPurpose: Api.InputStorePaymentPurpose = .inputStorePaymentPremiumGiveaway(.init(flags: flags, boostPeer: apiBoostPeer, additionalPeers: additionalPeers, countriesIso2: countries, prizeDescription: prizeDescription, randomId: randomId, untilDate: untilDate, currency: currency, amount: amount)) flags = 0 @@ -296,7 +296,7 @@ func _internal_parseInputInvoice(transaction: Transaction, source: BotPaymentInv let option: Api.PremiumGiftCodeOption = .premiumGiftCodeOption(flags: flags, users: option.users, months: option.months, storeProduct: option.storeProductId, storeQuantity: option.storeQuantity, currency: option.currency, amount: option.amount) - return .inputInvoicePremiumGiftCode(purpose: inputPurpose, option: option) + return .inputInvoicePremiumGiftCode(.init(purpose: inputPurpose, option: option)) case let .giftCode(users, currency, amount, option, text, entities): var inputUsers: [Api.InputUser] = [] if !users.isEmpty { @@ -314,7 +314,7 @@ func _internal_parseInputInvoice(transaction: Transaction, source: BotPaymentInv message = .textWithEntities(text: text, entities: entities.flatMap { apiEntitiesFromMessageTextEntities($0, associatedPeers: SimpleDictionary()) } ?? []) } - let inputPurpose: Api.InputStorePaymentPurpose = .inputStorePaymentPremiumGiftCode(flags: inputPurposeFlags, users: inputUsers, boostPeer: nil, currency: currency, amount: amount, message: message) + let inputPurpose: Api.InputStorePaymentPurpose = .inputStorePaymentPremiumGiftCode(.init(flags: inputPurposeFlags, users: inputUsers, boostPeer: nil, currency: currency, amount: amount, message: message)) var flags: Int32 = 0 if let _ = option.storeProductId { @@ -326,7 +326,7 @@ func _internal_parseInputInvoice(transaction: Transaction, source: BotPaymentInv let option: Api.PremiumGiftCodeOption = .premiumGiftCodeOption(flags: flags, users: option.users, months: option.months, storeProduct: option.storeProductId, storeQuantity: option.storeQuantity, currency: option.currency, amount: option.amount) - return .inputInvoicePremiumGiftCode(purpose: inputPurpose, option: option) + return .inputInvoicePremiumGiftCode(.init(purpose: inputPurpose, option: option)) case let .stars(option, peerId): var flags: Int32 = 0 var spendPurposePeer: Api.InputPeer? @@ -334,14 +334,14 @@ func _internal_parseInputInvoice(transaction: Transaction, source: BotPaymentInv flags |= (1 << 0) spendPurposePeer = inputPeer } - return .inputInvoiceStars(purpose: .inputStorePaymentStarsTopup(flags: flags, stars: option.count, currency: option.currency, amount: option.amount, spendPurposePeer: spendPurposePeer)) + return .inputInvoiceStars(.init(purpose: .inputStorePaymentStarsTopup(.init(flags: flags, stars: option.count, currency: option.currency, amount: option.amount, spendPurposePeer: spendPurposePeer)))) case let .starsGift(peerId, count, currency, amount): guard let peer = transaction.getPeer(peerId), let inputUser = apiInputUser(peer) else { return nil } - return .inputInvoiceStars(purpose: .inputStorePaymentStarsGift(userId: inputUser, stars: count, currency: currency, amount: amount)) + return .inputInvoiceStars(.init(purpose: .inputStorePaymentStarsGift(.init(userId: inputUser, stars: count, currency: currency, amount: amount)))) case let .starsChatSubscription(hash): - return .inputInvoiceChatInviteSubscription(hash: hash) + return .inputInvoiceChatInviteSubscription(.init(hash: hash)) case let .starsGiveaway(stars, boostPeerId, additionalPeerIds, countries, onlyNewSubscribers, showWinners, prizeDescription, randomId, untilDate, currency, amount, users): guard let peer = transaction.getPeer(boostPeerId), let apiBoostPeer = apiInputPeer(peer) else { return nil @@ -368,7 +368,7 @@ func _internal_parseInputInvoice(transaction: Transaction, source: BotPaymentInv if let _ = prizeDescription { flags |= (1 << 4) } - return .inputInvoiceStars(purpose: .inputStorePaymentStarsGiveaway(flags: flags, stars: stars, boostPeer: apiBoostPeer, additionalPeers: additionalPeers, countriesIso2: countries, prizeDescription: prizeDescription, randomId: randomId, untilDate: untilDate, currency: currency, amount: amount, users: users)) + return .inputInvoiceStars(.init(purpose: .inputStorePaymentStarsGiveaway(.init(flags: flags, stars: stars, boostPeer: apiBoostPeer, additionalPeers: additionalPeers, countriesIso2: countries, prizeDescription: prizeDescription, randomId: randomId, untilDate: untilDate, currency: currency, amount: amount, users: users)))) case let .starGift(hideName, includeUpgrade, peerId, giftId, text, entities): guard let peer = transaction.getPeer(peerId), let inputPeer = apiInputPeer(peer) else { return nil @@ -385,18 +385,18 @@ func _internal_parseInputInvoice(transaction: Transaction, source: BotPaymentInv flags |= (1 << 1) message = .textWithEntities(text: text, entities: entities.flatMap { apiEntitiesFromMessageTextEntities($0, associatedPeers: SimpleDictionary()) } ?? []) } - return .inputInvoiceStarGift(flags: flags, peer: inputPeer, giftId: giftId, message: message) + return .inputInvoiceStarGift(.init(flags: flags, peer: inputPeer, giftId: giftId, message: message)) case let .starGiftUpgrade(keepOriginalInfo, reference): var flags: Int32 = 0 if keepOriginalInfo { flags |= (1 << 0) } - return reference.apiStarGiftReference(transaction: transaction).flatMap { .inputInvoiceStarGiftUpgrade(flags: flags, stargift: $0) } + return reference.apiStarGiftReference(transaction: transaction).flatMap { .inputInvoiceStarGiftUpgrade(.init(flags: flags, stargift: $0)) } case let .starGiftTransfer(reference, toPeerId): guard let peer = transaction.getPeer(toPeerId), let inputPeer = apiInputPeer(peer) else { return nil } - return reference.apiStarGiftReference(transaction: transaction).flatMap { .inputInvoiceStarGiftTransfer(stargift: $0, toId: inputPeer) } + return reference.apiStarGiftReference(transaction: transaction).flatMap { .inputInvoiceStarGiftTransfer(.init(stargift: $0, toId: inputPeer)) } case let .premiumGift(peerId, option, text, entities): guard let peer = transaction.getPeer(peerId), let inputUser = apiInputUser(peer) else { return nil @@ -407,7 +407,7 @@ func _internal_parseInputInvoice(transaction: Transaction, source: BotPaymentInv flags |= (1 << 0) message = .textWithEntities(text: text, entities: entities.flatMap { apiEntitiesFromMessageTextEntities($0, associatedPeers: SimpleDictionary()) } ?? []) } - return .inputInvoicePremiumGiftStars(flags: flags, userId: inputUser, months: option.months, message: message) + return .inputInvoicePremiumGiftStars(.init(flags: flags, userId: inputUser, months: option.months, message: message)) case let .starGiftResale(slug, toPeerId, ton): guard let peer = transaction.getPeer(toPeerId), let inputPeer = apiInputPeer(peer) else { return nil @@ -416,14 +416,14 @@ func _internal_parseInputInvoice(transaction: Transaction, source: BotPaymentInv if ton { flags |= 1 << 0 } - return .inputInvoiceStarGiftResale(flags: flags, slug: slug, toId: inputPeer) + return .inputInvoiceStarGiftResale(.init(flags: flags, slug: slug, toId: inputPeer)) case let .starGiftPrepaidUpgrade(peerId, hash): guard let peer = transaction.getPeer(peerId), let inputPeer = apiInputPeer(peer) else { return nil } - return .inputInvoiceStarGiftPrepaidUpgrade(peer: inputPeer, hash: hash) + return .inputInvoiceStarGiftPrepaidUpgrade(.init(peer: inputPeer, hash: hash)) case let .starGiftDropOriginalDetails(reference): - return reference.apiStarGiftReference(transaction: transaction).flatMap { .inputInvoiceStarGiftDropOriginalDetails(stargift: $0) } + return reference.apiStarGiftReference(transaction: transaction).flatMap { .inputInvoiceStarGiftDropOriginalDetails(.init(stargift: $0)) } case let .starGiftAuctionBid(update, hideName, peerId, giftId, bidAmount, text, entities): var flags: Int32 = 0 @@ -448,7 +448,7 @@ func _internal_parseInputInvoice(transaction: Transaction, source: BotPaymentInv message = .textWithEntities(text: text, entities: entities.flatMap { apiEntitiesFromMessageTextEntities($0, associatedPeers: SimpleDictionary()) } ?? []) } } - return .inputInvoiceStarGiftAuctionBid(flags: flags, peer: inputPeer, giftId: giftId, bidAmount: bidAmount, message: message) + return .inputInvoiceStarGiftAuctionBid(.init(flags: flags, peer: inputPeer, giftId: giftId, bidAmount: bidAmount, message: message)) } } @@ -722,11 +722,11 @@ func _internal_sendBotPaymentForm(account: Account, formId: Int64, source: BotPa if saveOnServer { credentialsFlags |= (1 << 0) } - apiCredentials = .inputPaymentCredentials(flags: credentialsFlags, data: .dataJSON(.init(data: data))) + apiCredentials = .inputPaymentCredentials(.init(flags: credentialsFlags, data: .dataJSON(.init(data: data)))) case let .saved(id, tempPassword): - apiCredentials = .inputPaymentCredentialsSaved(id: id, tmpPassword: Buffer(data: tempPassword)) + apiCredentials = .inputPaymentCredentialsSaved(.init(id: id, tmpPassword: Buffer(data: tempPassword))) case let .applePay(data): - apiCredentials = .inputPaymentCredentialsApplePay(paymentData: .dataJSON(.init(data: data))) + apiCredentials = .inputPaymentCredentialsApplePay(.init(paymentData: .dataJSON(.init(data: data)))) } var flags: Int32 = 0 if validatedInfoId != nil { diff --git a/submodules/TelegramCore/Sources/TelegramEngine/Payments/GiftCodes.swift b/submodules/TelegramCore/Sources/TelegramEngine/Payments/GiftCodes.swift index d5a9b8e415..a7bf110480 100644 --- a/submodules/TelegramCore/Sources/TelegramEngine/Payments/GiftCodes.swift +++ b/submodules/TelegramCore/Sources/TelegramEngine/Payments/GiftCodes.swift @@ -349,9 +349,9 @@ func _internal_launchPrepaidGiveaway(account: Account, peerId: EnginePeer.Id, pu let inputPurpose: Api.InputStorePaymentPurpose switch purpose { case let .stars(stars, users): - inputPurpose = .inputStorePaymentStarsGiveaway(flags: flags, stars: stars, boostPeer: inputPeer, additionalPeers: additionalPeers, countriesIso2: countries, prizeDescription: prizeDescription, randomId: randomId, untilDate: untilDate, currency: "", amount: 0, users: users) + inputPurpose = .inputStorePaymentStarsGiveaway(.init(flags: flags, stars: stars, boostPeer: inputPeer, additionalPeers: additionalPeers, countriesIso2: countries, prizeDescription: prizeDescription, randomId: randomId, untilDate: untilDate, currency: "", amount: 0, users: users)) case .premium: - inputPurpose = .inputStorePaymentPremiumGiveaway(flags: flags, boostPeer: inputPeer, additionalPeers: additionalPeers, countriesIso2: countries, prizeDescription: prizeDescription, randomId: randomId, untilDate: untilDate, currency: "", amount: 0) + inputPurpose = .inputStorePaymentPremiumGiveaway(.init(flags: flags, boostPeer: inputPeer, additionalPeers: additionalPeers, countriesIso2: countries, prizeDescription: prizeDescription, randomId: randomId, untilDate: untilDate, currency: "", amount: 0)) } return account.network.request(Api.functions.payments.launchPrepaidGiveaway(peer: inputPeer, giveawayId: id, purpose: inputPurpose)) diff --git a/submodules/TelegramCore/Sources/TelegramEngine/Payments/StarGifts.swift b/submodules/TelegramCore/Sources/TelegramEngine/Payments/StarGifts.swift index aa4e5027a1..5a32bfb71a 100644 --- a/submodules/TelegramCore/Sources/TelegramEngine/Payments/StarGifts.swift +++ b/submodules/TelegramCore/Sources/TelegramEngine/Payments/StarGifts.swift @@ -3535,14 +3535,14 @@ extension StarGiftReference { func apiStarGiftReference(transaction: Transaction) -> Api.InputSavedStarGift? { switch self { case let .message(messageId): - return .inputSavedStarGiftUser(msgId: messageId.id) + return .inputSavedStarGiftUser(.init(msgId: messageId.id)) case let .peer(peerId, id): guard let inputPeer = transaction.getPeer(peerId).flatMap({ apiInputPeer($0) }) else { return nil } - return .inputSavedStarGiftChat(peer: inputPeer, savedId: id) + return .inputSavedStarGiftChat(.init(peer: inputPeer, savedId: id)) case let .slug(slug): - return .inputSavedStarGiftSlug(slug: slug) + return .inputSavedStarGiftSlug(.init(slug: slug)) } } } diff --git a/submodules/TelegramCore/Sources/TelegramEngine/Payments/StarGiftsAuctions.swift b/submodules/TelegramCore/Sources/TelegramEngine/Payments/StarGiftsAuctions.swift index 8aaf4dbebb..c5e3c63b6a 100644 --- a/submodules/TelegramCore/Sources/TelegramEngine/Payments/StarGiftsAuctions.swift +++ b/submodules/TelegramCore/Sources/TelegramEngine/Payments/StarGiftsAuctions.swift @@ -11,9 +11,9 @@ public enum StarGiftAuctionReference: Equatable { var apiAuction: Api.InputStarGiftAuction { switch self { case let .giftId(giftId): - return .inputStarGiftAuction(giftId: giftId) + return .init(inputStarGiftAuction: .init(giftId: giftId)) case let .slug(slug): - return .inputStarGiftAuctionSlug(slug: slug) + return .init(inputStarGiftAuctionSlug: .init(slug: slug)) } } } diff --git a/submodules/TelegramCore/Sources/TelegramEngine/Payments/Stars.swift b/submodules/TelegramCore/Sources/TelegramEngine/Payments/Stars.swift index 39639d9908..5eb8b3411a 100644 --- a/submodules/TelegramCore/Sources/TelegramEngine/Payments/Stars.swift +++ b/submodules/TelegramCore/Sources/TelegramEngine/Payments/Stars.swift @@ -1748,7 +1748,7 @@ func _internal_getStarsTransaction(accountPeerId: PeerId, postbox: Postbox, netw Api.functions.payments.getStarsTransactionsByID( flags: transactionReference.ton ? 1 << 0 : 0, peer: inputPeer, - id: [.inputStarsTransaction(flags: transactionReference.isRefund ? (1 << 0) : 0, id: transactionReference.id)] + id: [.inputStarsTransaction(.init(flags: transactionReference.isRefund ? (1 << 0) : 0, id: transactionReference.id))] ) ) |> map(Optional.init) diff --git a/submodules/TelegramCore/Sources/TelegramEngine/Peers/AddressNames.swift b/submodules/TelegramCore/Sources/TelegramEngine/Peers/AddressNames.swift index e7c6a79502..08cb774d19 100644 --- a/submodules/TelegramCore/Sources/TelegramEngine/Peers/AddressNames.swift +++ b/submodules/TelegramCore/Sources/TelegramEngine/Peers/AddressNames.swift @@ -177,7 +177,7 @@ func _internal_updateAddressName(account: Account, domain: AddressNameDomain, na return .fail(.generic) case let .theme(theme): let flags: Int32 = 1 << 0 - return account.network.request(Api.functions.account.updateTheme(flags: flags, format: telegramThemeFormat, theme: .inputTheme(id: theme.id, accessHash: theme.accessHash), slug: nil, title: nil, document: nil, settings: nil)) + return account.network.request(Api.functions.account.updateTheme(flags: flags, format: telegramThemeFormat, theme: .inputTheme(.init(id: theme.id, accessHash: theme.accessHash)), slug: nil, title: nil, document: nil, settings: nil)) |> mapError { _ -> UpdateAddressNameError in return .generic } diff --git a/submodules/TelegramCore/Sources/TelegramEngine/Peers/ChatListFiltering.swift b/submodules/TelegramCore/Sources/TelegramEngine/Peers/ChatListFiltering.swift index 782a7ce582..8897e2e435 100644 --- a/submodules/TelegramCore/Sources/TelegramEngine/Peers/ChatListFiltering.swift +++ b/submodules/TelegramCore/Sources/TelegramEngine/Peers/ChatListFiltering.swift @@ -364,22 +364,28 @@ extension ChatListFilter { excludeArchived: (flags & (1 << 13)) != 0, includePeers: ChatListFilterIncludePeers(rawPeers: includePeers.compactMap { peer -> PeerId? in switch peer { - case let .inputPeerUser(userId, _): + case let .inputPeerUser(inputPeerUserData): + let userId = inputPeerUserData.userId return PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt64Value(userId)) - case let .inputPeerChat(chatId): + case let .inputPeerChat(inputPeerChatData): + let chatId = inputPeerChatData.chatId return PeerId(namespace: Namespaces.Peer.CloudGroup, id: PeerId.Id._internalFromInt64Value(chatId)) - case let .inputPeerChannel(channelId, _): + case let .inputPeerChannel(inputPeerChannelData): + let channelId = inputPeerChannelData.channelId return PeerId(namespace: Namespaces.Peer.CloudChannel, id: PeerId.Id._internalFromInt64Value(channelId)) default: return nil } }, rawPinnedPeers: pinnedPeers.compactMap { peer -> PeerId? in switch peer { - case let .inputPeerUser(userId, _): + case let .inputPeerUser(inputPeerUserData): + let userId = inputPeerUserData.userId return PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt64Value(userId)) - case let .inputPeerChat(chatId): + case let .inputPeerChat(inputPeerChatData): + let chatId = inputPeerChatData.chatId return PeerId(namespace: Namespaces.Peer.CloudGroup, id: PeerId.Id._internalFromInt64Value(chatId)) - case let .inputPeerChannel(channelId, _): + case let .inputPeerChannel(inputPeerChannelData): + let channelId = inputPeerChannelData.channelId return PeerId(namespace: Namespaces.Peer.CloudChannel, id: PeerId.Id._internalFromInt64Value(channelId)) default: return nil @@ -387,11 +393,14 @@ extension ChatListFilter { }), excludePeers: excludePeers.compactMap { peer -> PeerId? in switch peer { - case let .inputPeerUser(userId, _): + case let .inputPeerUser(inputPeerUserData): + let userId = inputPeerUserData.userId return PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt64Value(userId)) - case let .inputPeerChat(chatId): + case let .inputPeerChat(inputPeerChatData): + let chatId = inputPeerChatData.chatId return PeerId(namespace: Namespaces.Peer.CloudGroup, id: PeerId.Id._internalFromInt64Value(chatId)) - case let .inputPeerChannel(channelId, _): + case let .inputPeerChannel(inputPeerChannelData): + let channelId = inputPeerChannelData.channelId return PeerId(namespace: Namespaces.Peer.CloudChannel, id: PeerId.Id._internalFromInt64Value(channelId)) default: return nil @@ -424,22 +433,28 @@ extension ChatListFilter { excludeArchived: false, includePeers: ChatListFilterIncludePeers(rawPeers: includePeers.compactMap { peer -> PeerId? in switch peer { - case let .inputPeerUser(userId, _): + case let .inputPeerUser(inputPeerUserData): + let userId = inputPeerUserData.userId return PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt64Value(userId)) - case let .inputPeerChat(chatId): + case let .inputPeerChat(inputPeerChatData): + let chatId = inputPeerChatData.chatId return PeerId(namespace: Namespaces.Peer.CloudGroup, id: PeerId.Id._internalFromInt64Value(chatId)) - case let .inputPeerChannel(channelId, _): + case let .inputPeerChannel(inputPeerChannelData): + let channelId = inputPeerChannelData.channelId return PeerId(namespace: Namespaces.Peer.CloudChannel, id: PeerId.Id._internalFromInt64Value(channelId)) default: return nil } }, rawPinnedPeers: pinnedPeers.compactMap { peer -> PeerId? in switch peer { - case let .inputPeerUser(userId, _): + case let .inputPeerUser(inputPeerUserData): + let userId = inputPeerUserData.userId return PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt64Value(userId)) - case let .inputPeerChat(chatId): + case let .inputPeerChat(inputPeerChatData): + let chatId = inputPeerChatData.chatId return PeerId(namespace: Namespaces.Peer.CloudGroup, id: PeerId.Id._internalFromInt64Value(chatId)) - case let .inputPeerChannel(channelId, _): + case let .inputPeerChannel(inputPeerChannelData): + let channelId = inputPeerChannelData.channelId return PeerId(namespace: Namespaces.Peer.CloudChannel, id: PeerId.Id._internalFromInt64Value(channelId)) default: return nil @@ -451,7 +466,7 @@ extension ChatListFilter { ) } } - + func apiFilter(transaction: Transaction) -> Api.DialogFilter? { switch self { case .allChats: @@ -581,11 +596,14 @@ private func requestChatListFilters(accountPeerId: PeerId, postbox: Postbox, net for peer in pinnedPeers + includePeers + excludePeers { var peerId: PeerId? switch peer { - case let .inputPeerUser(userId, _): + case let .inputPeerUser(inputPeerUserData): + let userId = inputPeerUserData.userId peerId = PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt64Value(userId)) - case let .inputPeerChat(chatId): + case let .inputPeerChat(inputPeerChatData): + let chatId = inputPeerChatData.chatId peerId = PeerId(namespace: Namespaces.Peer.CloudGroup, id: PeerId.Id._internalFromInt64Value(chatId)) - case let .inputPeerChannel(channelId, _): + case let .inputPeerChannel(inputPeerChannelData): + let channelId = inputPeerChannelData.channelId peerId = PeerId(namespace: Namespaces.Peer.CloudChannel, id: PeerId.Id._internalFromInt64Value(channelId)) default: break @@ -597,15 +615,18 @@ private func requestChatListFilters(accountPeerId: PeerId, postbox: Postbox, net } } } - + for peer in pinnedPeers { var peerId: PeerId? switch peer { - case let .inputPeerUser(userId, _): + case let .inputPeerUser(inputPeerUserData): + let userId = inputPeerUserData.userId peerId = PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt64Value(userId)) - case let .inputPeerChat(chatId): + case let .inputPeerChat(inputPeerChatData): + let chatId = inputPeerChatData.chatId peerId = PeerId(namespace: Namespaces.Peer.CloudGroup, id: PeerId.Id._internalFromInt64Value(chatId)) - case let .inputPeerChannel(channelId, _): + case let .inputPeerChannel(inputPeerChannelData): + let channelId = inputPeerChannelData.channelId peerId = PeerId(namespace: Namespaces.Peer.CloudChannel, id: PeerId.Id._internalFromInt64Value(channelId)) default: break @@ -622,11 +643,14 @@ private func requestChatListFilters(accountPeerId: PeerId, postbox: Postbox, net for peer in pinnedPeers + includePeers { var peerId: PeerId? switch peer { - case let .inputPeerUser(userId, _): + case let .inputPeerUser(inputPeerUserData): + let userId = inputPeerUserData.userId peerId = PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt64Value(userId)) - case let .inputPeerChat(chatId): + case let .inputPeerChat(inputPeerChatData): + let chatId = inputPeerChatData.chatId peerId = PeerId(namespace: Namespaces.Peer.CloudGroup, id: PeerId.Id._internalFromInt64Value(chatId)) - case let .inputPeerChannel(channelId, _): + case let .inputPeerChannel(inputPeerChannelData): + let channelId = inputPeerChannelData.channelId peerId = PeerId(namespace: Namespaces.Peer.CloudChannel, id: PeerId.Id._internalFromInt64Value(channelId)) default: break @@ -638,15 +662,18 @@ private func requestChatListFilters(accountPeerId: PeerId, postbox: Postbox, net } } } - + for peer in pinnedPeers { var peerId: PeerId? switch peer { - case let .inputPeerUser(userId, _): + case let .inputPeerUser(inputPeerUserData): + let userId = inputPeerUserData.userId peerId = PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt64Value(userId)) - case let .inputPeerChat(chatId): + case let .inputPeerChat(inputPeerChatData): + let chatId = inputPeerChatData.chatId peerId = PeerId(namespace: Namespaces.Peer.CloudGroup, id: PeerId.Id._internalFromInt64Value(chatId)) - case let .inputPeerChannel(channelId, _): + case let .inputPeerChannel(inputPeerChannelData): + let channelId = inputPeerChannelData.channelId peerId = PeerId(namespace: Namespaces.Peer.CloudChannel, id: PeerId.Id._internalFromInt64Value(channelId)) default: break @@ -672,13 +699,16 @@ private func requestChatListFilters(accountPeerId: PeerId, postbox: Postbox, net var missingGroups: [Int64] = [] for peer in missingPeers { switch peer { - case let .inputPeerUser(userId, accessHash): - missingUsers.append(.inputUser(userId: userId, accessHash: accessHash)) + case let .inputPeerUser(inputPeerUserData): + let (userId, accessHash) = (inputPeerUserData.userId, inputPeerUserData.accessHash) + missingUsers.append(.inputUser(.init(userId: userId, accessHash: accessHash))) case .inputPeerSelf: missingUsers.append(.inputUserSelf) - case let .inputPeerChannel(channelId, accessHash): + case let .inputPeerChannel(inputPeerChannelData): + let (channelId, accessHash) = (inputPeerChannelData.channelId, inputPeerChannelData.accessHash) missingChannels.append(.inputChannel(.init(channelId: channelId, accessHash: accessHash))) - case let .inputPeerChat(id): + case let .inputPeerChat(inputPeerChatData): + let id = inputPeerChatData.chatId missingGroups.append(id) case .inputPeerEmpty: break diff --git a/submodules/TelegramCore/Sources/TelegramEngine/Peers/PeerPhotoUpdater.swift b/submodules/TelegramCore/Sources/TelegramEngine/Peers/PeerPhotoUpdater.swift index 5c38466e3f..9dcfd7d226 100644 --- a/submodules/TelegramCore/Sources/TelegramEngine/Peers/PeerPhotoUpdater.swift +++ b/submodules/TelegramCore/Sources/TelegramEngine/Peers/PeerPhotoUpdater.swift @@ -573,7 +573,7 @@ func _internal_updatePeerPhotoInternal(postbox: Postbox, network: Network, state func _internal_updatePeerPhotoExisting(network: Network, reference: TelegramMediaImageReference) -> Signal { switch reference { case let .cloud(imageId, accessHash, fileReference): - return network.request(Api.functions.photos.updateProfilePhoto(flags: 0, bot: nil, id: .inputPhoto(id: imageId, accessHash: accessHash, fileReference: Buffer(data: fileReference)))) + return network.request(Api.functions.photos.updateProfilePhoto(flags: 0, bot: nil, id: .inputPhoto(.init(id: imageId, accessHash: accessHash, fileReference: Buffer(data: fileReference))))) |> `catch` { _ -> Signal in return .complete() } @@ -592,7 +592,7 @@ func _internal_removeAccountPhoto(account: Account, reference: TelegramMediaImag switch reference { case let .cloud(imageId, accessHash, fileReference): if let fileReference = fileReference { - return account.network.request(Api.functions.photos.deletePhotos(id: [.inputPhoto(id: imageId, accessHash: accessHash, fileReference: Buffer(data: fileReference))])) + return account.network.request(Api.functions.photos.deletePhotos(id: [.inputPhoto(.init(id: imageId, accessHash: accessHash, fileReference: Buffer(data: fileReference)))])) |> `catch` { _ -> Signal<[Int64], NoError> in return .single([]) } diff --git a/submodules/TelegramCore/Sources/TelegramEngine/Peers/UpdateGroupSpecificStickerset.swift b/submodules/TelegramCore/Sources/TelegramEngine/Peers/UpdateGroupSpecificStickerset.swift index 047910c571..42cd78ee0a 100644 --- a/submodules/TelegramCore/Sources/TelegramEngine/Peers/UpdateGroupSpecificStickerset.swift +++ b/submodules/TelegramCore/Sources/TelegramEngine/Peers/UpdateGroupSpecificStickerset.swift @@ -14,7 +14,7 @@ func _internal_updateGroupSpecificStickerset(postbox: Postbox, network: Network, |> mapToSignal { peer -> Signal in let inputStickerset: Api.InputStickerSet if let info = info { - inputStickerset = Api.InputStickerSet.inputStickerSetShortName(shortName: info.shortName) + inputStickerset = Api.InputStickerSet.inputStickerSetShortName(.init(shortName: info.shortName)) } else { inputStickerset = Api.InputStickerSet.inputStickerSetEmpty } @@ -52,7 +52,7 @@ func _internal_updateGroupSpecificEmojiset(postbox: Postbox, network: Network, p |> mapToSignal { peer -> Signal in let inputStickerset: Api.InputStickerSet if let info = info { - inputStickerset = Api.InputStickerSet.inputStickerSetShortName(shortName: info.shortName) + inputStickerset = Api.InputStickerSet.inputStickerSetShortName(.init(shortName: info.shortName)) } else { inputStickerset = Api.InputStickerSet.inputStickerSetEmpty } diff --git a/submodules/TelegramCore/Sources/TelegramEngine/Privacy/UpdatedAccountPrivacySettings.swift b/submodules/TelegramCore/Sources/TelegramEngine/Privacy/UpdatedAccountPrivacySettings.swift index 1bcc1abb9f..09e668f5cc 100644 --- a/submodules/TelegramCore/Sources/TelegramEngine/Privacy/UpdatedAccountPrivacySettings.swift +++ b/submodules/TelegramCore/Sources/TelegramEngine/Privacy/UpdatedAccountPrivacySettings.swift @@ -533,10 +533,10 @@ func _internal_updateSelectiveAccountPrivacySettings(account: Account, type: Upd let enablePeers = apiUserAndGroupIds(peerIds: enableFor) if !enablePeers.users.isEmpty { - rules.append(Api.InputPrivacyRule.inputPrivacyValueAllowUsers(users: apiInputUsers(transaction: transaction, peerIds: enablePeers.users))) + rules.append(Api.InputPrivacyRule.inputPrivacyValueAllowUsers(.init(users: apiInputUsers(transaction: transaction, peerIds: enablePeers.users)))) } if !enablePeers.groups.isEmpty { - rules.append(Api.InputPrivacyRule.inputPrivacyValueAllowChatParticipants(chats: enablePeers.groups.map({ $0.id._internalGetInt64Value() }))) + rules.append(Api.InputPrivacyRule.inputPrivacyValueAllowChatParticipants(.init(chats: enablePeers.groups.map({ $0.id._internalGetInt64Value() })))) } rules.append(Api.InputPrivacyRule.inputPrivacyValueDisallowAll) @@ -554,17 +554,17 @@ func _internal_updateSelectiveAccountPrivacySettings(account: Account, type: Upd let disablePeers = apiUserAndGroupIds(peerIds: disableFor) if !enablePeers.users.isEmpty { - rules.append(Api.InputPrivacyRule.inputPrivacyValueAllowUsers(users: apiInputUsers(transaction: transaction, peerIds: enablePeers.users))) + rules.append(Api.InputPrivacyRule.inputPrivacyValueAllowUsers(.init(users: apiInputUsers(transaction: transaction, peerIds: enablePeers.users)))) } if !enablePeers.groups.isEmpty { - rules.append(Api.InputPrivacyRule.inputPrivacyValueAllowChatParticipants(chats: enablePeers.groups.map({ $0.id._internalGetInt64Value() }))) + rules.append(Api.InputPrivacyRule.inputPrivacyValueAllowChatParticipants(.init(chats: enablePeers.groups.map({ $0.id._internalGetInt64Value() })))) } if !disablePeers.users.isEmpty { - rules.append(Api.InputPrivacyRule.inputPrivacyValueDisallowUsers(users: apiInputUsers(transaction: transaction, peerIds: disablePeers.users))) + rules.append(Api.InputPrivacyRule.inputPrivacyValueDisallowUsers(.init(users: apiInputUsers(transaction: transaction, peerIds: disablePeers.users)))) } if !disablePeers.groups.isEmpty { - rules.append(Api.InputPrivacyRule.inputPrivacyValueDisallowChatParticipants(chats: disablePeers.groups.map({ $0.id._internalGetInt64Value() }))) + rules.append(Api.InputPrivacyRule.inputPrivacyValueDisallowChatParticipants(.init(chats: disablePeers.groups.map({ $0.id._internalGetInt64Value() })))) } rules.append(Api.InputPrivacyRule.inputPrivacyValueAllowContacts) @@ -578,10 +578,10 @@ func _internal_updateSelectiveAccountPrivacySettings(account: Account, type: Upd let disablePeers = apiUserAndGroupIds(peerIds: disableFor) if !disablePeers.users.isEmpty { - rules.append(Api.InputPrivacyRule.inputPrivacyValueDisallowUsers(users: apiInputUsers(transaction: transaction, peerIds: disablePeers.users))) + rules.append(Api.InputPrivacyRule.inputPrivacyValueDisallowUsers(.init(users: apiInputUsers(transaction: transaction, peerIds: disablePeers.users)))) } if !disablePeers.groups.isEmpty { - rules.append(Api.InputPrivacyRule.inputPrivacyValueDisallowChatParticipants(chats: disablePeers.groups.map({ $0.id._internalGetInt64Value() }))) + rules.append(Api.InputPrivacyRule.inputPrivacyValueDisallowChatParticipants(.init(chats: disablePeers.groups.map({ $0.id._internalGetInt64Value() })))) } rules.append(Api.InputPrivacyRule.inputPrivacyValueAllowAll) diff --git a/submodules/TelegramCore/Sources/TelegramEngine/SecureId/SaveSecureIdValue.swift b/submodules/TelegramCore/Sources/TelegramEngine/SecureId/SaveSecureIdValue.swift index e92a226ac5..a3341c2550 100644 --- a/submodules/TelegramCore/Sources/TelegramEngine/SecureId/SaveSecureIdValue.swift +++ b/submodules/TelegramCore/Sources/TelegramEngine/SecureId/SaveSecureIdValue.swift @@ -89,9 +89,9 @@ func decryptedSecureValueData(context: SecureIdValueAccessContext, encryptedData private func apiInputSecretFile(_ file: SecureIdVerificationDocumentReference) -> Api.InputSecureFile { switch file { case let .remote(file): - return Api.InputSecureFile.inputSecureFile(id: file.id, accessHash: file.accessHash) + return Api.InputSecureFile.inputSecureFile(.init(id: file.id, accessHash: file.accessHash)) case let .uploaded(file): - return Api.InputSecureFile.inputSecureFileUploaded(id: file.id, parts: file.parts, md5Checksum: file.md5Checksum, fileHash: Buffer(data: file.fileHash), secret: Buffer(data: file.encryptedSecret)) + return Api.InputSecureFile.inputSecureFileUploaded(.init(id: file.id, parts: file.parts, md5Checksum: file.md5Checksum, fileHash: Buffer(data: file.fileHash), secret: Buffer(data: file.encryptedSecret))) } } @@ -205,7 +205,7 @@ private func makeInputSecureValue(context: SecureIdAccessContext, value: SecureI flags |= 1 << 5 } - return Api.InputSecureValue.inputSecureValue(flags: flags, type: inputData.type, data: secureData, frontSide: inputData.frontSideReference.flatMap(apiInputSecretFile), reverseSide: inputData.backSideReference.flatMap(apiInputSecretFile), selfie: inputData.selfieReference.flatMap(apiInputSecretFile), translation: translations, files: files, plainData: inputData.publicData) + return Api.InputSecureValue.inputSecureValue(.init(flags: flags, type: inputData.type, data: secureData, frontSide: inputData.frontSideReference.flatMap(apiInputSecretFile), reverseSide: inputData.backSideReference.flatMap(apiInputSecretFile), selfie: inputData.selfieReference.flatMap(apiInputSecretFile), translation: translations, files: files, plainData: inputData.publicData)) } public func saveSecureIdValue(postbox: Postbox, network: Network, context: SecureIdAccessContext, value: SecureIdValue, uploadedFiles: [Data: Data]) -> Signal { diff --git a/submodules/TelegramCore/Sources/TelegramEngine/Stickers/ArchivedStickerPacks.swift b/submodules/TelegramCore/Sources/TelegramEngine/Stickers/ArchivedStickerPacks.swift index e9743b26ee..0a031666ce 100644 --- a/submodules/TelegramCore/Sources/TelegramEngine/Stickers/ArchivedStickerPacks.swift +++ b/submodules/TelegramCore/Sources/TelegramEngine/Stickers/ArchivedStickerPacks.swift @@ -55,7 +55,7 @@ func _internal_archivedStickerPacks(account: Account, namespace: ArchivedSticker } func _internal_removeArchivedStickerPack(account: Account, info: StickerPackCollectionInfo) -> Signal { - return account.network.request(Api.functions.messages.uninstallStickerSet(stickerset: Api.InputStickerSet.inputStickerSetID(id: info.id.id, accessHash: info.accessHash))) + return account.network.request(Api.functions.messages.uninstallStickerSet(stickerset: Api.InputStickerSet.inputStickerSetID(.init(id: info.id.id, accessHash: info.accessHash)))) |> `catch` { _ -> Signal in return .single(.boolFalse) } diff --git a/submodules/TelegramCore/Sources/TelegramEngine/Stickers/ImportStickers.swift b/submodules/TelegramCore/Sources/TelegramEngine/Stickers/ImportStickers.swift index 4771d3e311..ed42424f46 100644 --- a/submodules/TelegramCore/Sources/TelegramEngine/Stickers/ImportStickers.swift +++ b/submodules/TelegramCore/Sources/TelegramEngine/Stickers/ImportStickers.swift @@ -83,7 +83,7 @@ func _internal_uploadSticker(account: Account, peer: Peer, resource: MediaResour attributes.append(.documentAttributeVideo(.init(flags: 0, duration: duration, w: dimensions.width, h: dimensions.height, preloadPrefixSize: nil, videoStartTs: nil, videoCodec: nil))) } 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))) + return account.network.request(Api.functions.messages.uploadMedia(flags: 0, businessConnectionId: nil, peer: inputPeer, media: Api.InputMedia.inputMediaUploadedDocument(.init(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 in switch media { @@ -388,7 +388,7 @@ func _internal_addStickerToStickerSet(account: Account, packReference: StickerPa if sticker.keywords.count > 0 { flags |= (1 << 1) } - let inputSticker: Api.InputStickerSetItem = .inputStickerSetItem(flags: flags, document: .inputDocument(.init(id: resource.fileId, accessHash: resource.accessHash, fileReference: Buffer(data: resource.fileReference ?? Data()))), emoji: sticker.emojis.joined(), maskCoords: nil, keywords: sticker.keywords) + let inputSticker: Api.InputStickerSetItem = .inputStickerSetItem(.init(flags: flags, document: .inputDocument(.init(id: resource.fileId, accessHash: resource.accessHash, fileReference: Buffer(data: resource.fileReference ?? Data()))), emoji: sticker.emojis.joined(), maskCoords: nil, keywords: sticker.keywords)) return account.network.request(Api.functions.stickers.addStickerToSet(stickerset: packReference.apiInputStickerSet, sticker: inputSticker)) |> `catch` { error -> Signal in if error.errorDescription == "FILE_REFERENCE_EXPIRED" { @@ -401,7 +401,7 @@ func _internal_addStickerToStickerSet(account: Account, packReference: StickerPa return .fail(MTRpcError(errorCode: 500, errorDescription: "Internal")) } - let inputSticker: Api.InputStickerSetItem = .inputStickerSetItem(flags: flags, document: .inputDocument(.init(id: resource.fileId, accessHash: resource.accessHash, fileReference: Buffer(data: resource.fileReference))), emoji: sticker.emojis.joined(), maskCoords: nil, keywords: sticker.keywords) + let inputSticker: Api.InputStickerSetItem = .inputStickerSetItem(.init(flags: flags, document: .inputDocument(.init(id: resource.fileId, accessHash: resource.accessHash, fileReference: Buffer(data: resource.fileReference))), emoji: sticker.emojis.joined(), maskCoords: nil, keywords: sticker.keywords)) return account.network.request(Api.functions.stickers.addStickerToSet(stickerset: packReference.apiInputStickerSet, sticker: inputSticker)) } @@ -508,7 +508,7 @@ func _internal_replaceSticker(account: Account, previousSticker: FileMediaRefere if sticker.keywords.count > 0 { flags |= (1 << 1) } - let inputSticker: Api.InputStickerSetItem = .inputStickerSetItem(flags: flags, document: .inputDocument(.init(id: resource.fileId, accessHash: resource.accessHash, fileReference: Buffer(data: resource.fileReference ?? Data()))), emoji: sticker.emojis.joined(), maskCoords: nil, keywords: sticker.keywords) + let inputSticker: Api.InputStickerSetItem = .inputStickerSetItem(.init(flags: flags, document: .inputDocument(.init(id: resource.fileId, accessHash: resource.accessHash, fileReference: Buffer(data: resource.fileReference ?? Data()))), emoji: sticker.emojis.joined(), maskCoords: nil, keywords: sticker.keywords)) return revalidatedSticker(account: account, sticker: previousSticker, signal: { previousResource in return account.network.request(Api.functions.stickers.replaceSticker(sticker: .inputDocument(.init(id: previousResource.fileId, accessHash: previousResource.accessHash, fileReference: Buffer(data: previousResource.fileReference))), newSticker: inputSticker)) }) diff --git a/submodules/TelegramCore/Sources/TelegramEngine/Stickers/LoadedStickerPack.swift b/submodules/TelegramCore/Sources/TelegramEngine/Stickers/LoadedStickerPack.swift index b4be25de9d..5dd36380ff 100644 --- a/submodules/TelegramCore/Sources/TelegramEngine/Stickers/LoadedStickerPack.swift +++ b/submodules/TelegramCore/Sources/TelegramEngine/Stickers/LoadedStickerPack.swift @@ -11,13 +11,13 @@ extension StickerPackReference { var apiInputStickerSet: Api.InputStickerSet { switch self { case let .id(id, accessHash): - return .inputStickerSetID(id: id, accessHash: accessHash) + return .inputStickerSetID(.init(id: id, accessHash: accessHash)) case let .name(name): - return .inputStickerSetShortName(shortName: name) + return .inputStickerSetShortName(.init(shortName: name)) case .animatedEmoji: return .inputStickerSetAnimatedEmoji case let .dice(emoji): - return .inputStickerSetDice(emoticon: emoji) + return .inputStickerSetDice(.init(emoticon: emoji)) case .animatedEmojiAnimations: return .inputStickerSetAnimatedEmojiAnimations case .premiumGifts: diff --git a/submodules/TelegramCore/Sources/TelegramEngine/Stickers/StickerPack.swift b/submodules/TelegramCore/Sources/TelegramEngine/Stickers/StickerPack.swift index a18cf731eb..ce1b30bce3 100644 --- a/submodules/TelegramCore/Sources/TelegramEngine/Stickers/StickerPack.swift +++ b/submodules/TelegramCore/Sources/TelegramEngine/Stickers/StickerPack.swift @@ -82,10 +82,10 @@ func _internal_stickerPacksAttachedToMedia(account: Account, media: AnyMediaRefe let inputMedia: Api.InputStickeredMedia let resourceReference: MediaResourceReference if let imageReference = media.concrete(TelegramMediaImage.self), let reference = imageReference.media.reference, case let .cloud(imageId, accessHash, fileReference) = reference, let representation = largestImageRepresentation(imageReference.media.representations) { - inputMedia = .inputStickeredMediaPhoto(id: Api.InputPhoto.inputPhoto(id: imageId, accessHash: accessHash, fileReference: Buffer(data: fileReference ?? Data()))) + inputMedia = .inputStickeredMediaPhoto(.init(id: Api.InputPhoto.inputPhoto(.init(id: imageId, accessHash: accessHash, fileReference: Buffer(data: fileReference ?? Data()))))) resourceReference = imageReference.resourceReference(representation.resource) } else if let fileReference = media.concrete(TelegramMediaFile.self), let resource = fileReference.media.resource as? CloudDocumentMediaResource { - inputMedia = .inputStickeredMediaDocument(id: Api.InputDocument.inputDocument(.init(id: resource.fileId, accessHash: resource.accessHash, fileReference: Buffer(data: resource.fileReference ?? Data())))) + inputMedia = .inputStickeredMediaDocument(.init(id: Api.InputDocument.inputDocument(.init(id: resource.fileId, accessHash: resource.accessHash, fileReference: Buffer(data: resource.fileReference ?? Data()))))) resourceReference = fileReference.resourceReference(fileReference.media.resource) } else { return .single([]) @@ -101,9 +101,9 @@ func _internal_stickerPacksAttachedToMedia(account: Account, media: AnyMediaRefe let inputMedia: Api.InputStickeredMedia if let resource = reference.updatedResource as? TelegramCloudMediaResourceWithFileReference, let updatedReference = resource.fileReference { if let imageReference = media.concrete(TelegramMediaImage.self), let reference = imageReference.media.reference, case let .cloud(imageId, accessHash, _) = reference, let _ = largestImageRepresentation(imageReference.media.representations) { - inputMedia = .inputStickeredMediaPhoto(id: Api.InputPhoto.inputPhoto(id: imageId, accessHash: accessHash, fileReference: Buffer(data: updatedReference))) + inputMedia = .inputStickeredMediaPhoto(.init(id: Api.InputPhoto.inputPhoto(.init(id: imageId, accessHash: accessHash, fileReference: Buffer(data: updatedReference))))) } else if let fileReference = media.concrete(TelegramMediaFile.self), let resource = fileReference.media.resource as? CloudDocumentMediaResource { - inputMedia = .inputStickeredMediaDocument(id: Api.InputDocument.inputDocument(.init(id: resource.fileId, accessHash: resource.accessHash, fileReference: Buffer(data: updatedReference)))) + inputMedia = .inputStickeredMediaDocument(.init(id: Api.InputDocument.inputDocument(.init(id: resource.fileId, accessHash: resource.accessHash, fileReference: Buffer(data: updatedReference))))) } else { return .single([]) } diff --git a/submodules/TelegramCore/Sources/TelegramEngine/Stickers/StickerSetInstallation.swift b/submodules/TelegramCore/Sources/TelegramEngine/Stickers/StickerSetInstallation.swift index a806edfb7c..fc392653af 100644 --- a/submodules/TelegramCore/Sources/TelegramEngine/Stickers/StickerSetInstallation.swift +++ b/submodules/TelegramCore/Sources/TelegramEngine/Stickers/StickerSetInstallation.swift @@ -30,16 +30,16 @@ func _internal_requestStickerSet(postbox: Postbox, network: Network, reference: switch reference { case let .name(name): collectionId = nil - input = .inputStickerSetShortName(shortName: name) + input = .inputStickerSetShortName(.init(shortName: name)) case let .id(id, accessHash): collectionId = ItemCollectionId(namespace: Namespaces.ItemCollection.CloudStickerPacks, id: id) - input = .inputStickerSetID(id: id, accessHash: accessHash) + input = .inputStickerSetID(.init(id: id, accessHash: accessHash)) case .animatedEmoji: collectionId = nil input = .inputStickerSetAnimatedEmoji case let .dice(emoji): collectionId = nil - input = .inputStickerSetDice(emoticon: emoji) + input = .inputStickerSetDice(.init(emoticon: emoji)) case .animatedEmojiAnimations: collectionId = nil input = .inputStickerSetAnimatedEmojiAnimations @@ -170,7 +170,7 @@ public final class CoveredStickerSet : Equatable { } func _internal_installStickerSetInteractively(account: Account, info: StickerPackCollectionInfo, items: [ItemCollectionItem]) -> Signal { - return account.network.request(Api.functions.messages.installStickerSet(stickerset: .inputStickerSetID(id: info.id.id, accessHash: info.accessHash), archived: .boolFalse)) |> mapError { _ -> InstallStickerSetError in + return account.network.request(Api.functions.messages.installStickerSet(stickerset: .inputStickerSetID(.init(id: info.id.id, accessHash: info.accessHash)), archived: .boolFalse)) |> mapError { _ -> InstallStickerSetError in return .generic } |> mapToSignal { result -> Signal in @@ -243,7 +243,7 @@ func _internal_installStickerSetInteractively(account: Account, info: StickerPac func _internal_uninstallStickerSetInteractively(account: Account, info: StickerPackCollectionInfo) -> Signal { - return account.network.request(Api.functions.messages.uninstallStickerSet(stickerset: .inputStickerSetID(id: info.id.id, accessHash: info.accessHash))) + return account.network.request(Api.functions.messages.uninstallStickerSet(stickerset: .inputStickerSetID(.init(id: info.id.id, accessHash: info.accessHash)))) |> `catch` { _ -> Signal in return .single(.boolFalse) }