From dc3d2dc7895a79007ae129a14ca60e7bbafbc553 Mon Sep 17 00:00:00 2001 From: Isaac <> Date: Fri, 16 Jan 2026 01:14:05 +0800 Subject: [PATCH] Refactor Api types 53-59 to use struct-wrapped constructors Co-Authored-By: Claude Opus 4.5 --- submodules/TelegramApi/Sources/Api4.swift | 208 +++++++++++++++++- submodules/TelegramApi/Sources/Api5.swift | 56 ++++- .../ApiUtils/CachedGroupParticipants.swift | 9 +- .../TelegramChannelBannedRights.swift | 5 +- .../Peers/ChannelBlacklist.swift | 2 +- .../Peers/ChatOnlineMembers.swift | 3 +- .../Peers/InvitationLinks.swift | 6 +- .../TelegramEngine/Peers/JoinLink.swift | 11 +- .../Peers/UpdateCachedPeerData.swift | 12 +- 9 files changed, 283 insertions(+), 29 deletions(-) diff --git a/submodules/TelegramApi/Sources/Api4.swift b/submodules/TelegramApi/Sources/Api4.swift index 1a27055a8e..7613460406 100644 --- a/submodules/TelegramApi/Sources/Api4.swift +++ b/submodules/TelegramApi/Sources/Api4.swift @@ -587,7 +587,17 @@ public extension Api { } public extension Api { enum ChatAdminWithInvites: TypeConstructorDescription { - case chatAdminWithInvites(adminId: Int64, invitesCount: Int32, revokedInvitesCount: Int32) + public class Cons_chatAdminWithInvites { + public var adminId: Int64 + public var invitesCount: Int32 + public var revokedInvitesCount: Int32 + public init(adminId: Int64, invitesCount: Int32, revokedInvitesCount: Int32) { + self.adminId = adminId + self.invitesCount = invitesCount + self.revokedInvitesCount = revokedInvitesCount + } + } + case chatAdminWithInvites(Cons_chatAdminWithInvites) public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) { #if DEBUG @@ -616,7 +626,15 @@ public extension Api { } public extension Api { enum ChatBannedRights: TypeConstructorDescription { - case chatBannedRights(flags: Int32, untilDate: Int32) + public class Cons_chatBannedRights { + public var flags: Int32 + public var untilDate: Int32 + public init(flags: Int32, untilDate: Int32) { + self.flags = flags + self.untilDate = untilDate + } + } + case chatBannedRights(Cons_chatBannedRights) public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) { #if DEBUG @@ -645,8 +663,146 @@ public extension Api { } public extension Api { enum ChatFull: TypeConstructorDescription { - case channelFull(flags: Int32, flags2: Int32, id: Int64, about: String, participantsCount: Int32?, adminsCount: Int32?, kickedCount: Int32?, bannedCount: Int32?, onlineCount: Int32?, readInboxMaxId: Int32, readOutboxMaxId: Int32, unreadCount: Int32, chatPhoto: Api.Photo, notifySettings: Api.PeerNotifySettings, exportedInvite: Api.ExportedChatInvite?, botInfo: [Api.BotInfo], migratedFromChatId: Int64?, migratedFromMaxId: Int32?, pinnedMsgId: Int32?, stickerset: Api.StickerSet?, availableMinId: Int32?, folderId: Int32?, linkedChatId: Int64?, location: Api.ChannelLocation?, slowmodeSeconds: Int32?, slowmodeNextSendDate: Int32?, statsDc: Int32?, pts: Int32, call: Api.InputGroupCall?, ttlPeriod: Int32?, pendingSuggestions: [String]?, groupcallDefaultJoinAs: Api.Peer?, themeEmoticon: String?, requestsPending: Int32?, recentRequesters: [Int64]?, defaultSendAs: Api.Peer?, availableReactions: Api.ChatReactions?, reactionsLimit: Int32?, stories: Api.PeerStories?, wallpaper: Api.WallPaper?, boostsApplied: Int32?, boostsUnrestrict: Int32?, emojiset: Api.StickerSet?, botVerification: Api.BotVerification?, stargiftsCount: Int32?, sendPaidMessagesStars: Int64?, mainTab: Api.ProfileTab?) - case chatFull(flags: Int32, id: Int64, about: String, participants: Api.ChatParticipants, chatPhoto: Api.Photo?, notifySettings: Api.PeerNotifySettings, exportedInvite: Api.ExportedChatInvite?, botInfo: [Api.BotInfo]?, pinnedMsgId: Int32?, folderId: Int32?, call: Api.InputGroupCall?, ttlPeriod: Int32?, groupcallDefaultJoinAs: Api.Peer?, themeEmoticon: String?, requestsPending: Int32?, recentRequesters: [Int64]?, availableReactions: Api.ChatReactions?, reactionsLimit: Int32?) + public class Cons_channelFull { + public var flags: Int32 + public var flags2: Int32 + public var id: Int64 + public var about: String + public var participantsCount: Int32? + public var adminsCount: Int32? + public var kickedCount: Int32? + public var bannedCount: Int32? + public var onlineCount: Int32? + public var readInboxMaxId: Int32 + public var readOutboxMaxId: Int32 + public var unreadCount: Int32 + public var chatPhoto: Api.Photo + public var notifySettings: Api.PeerNotifySettings + public var exportedInvite: Api.ExportedChatInvite? + public var botInfo: [Api.BotInfo] + public var migratedFromChatId: Int64? + public var migratedFromMaxId: Int32? + public var pinnedMsgId: Int32? + public var stickerset: Api.StickerSet? + public var availableMinId: Int32? + public var folderId: Int32? + public var linkedChatId: Int64? + public var location: Api.ChannelLocation? + public var slowmodeSeconds: Int32? + public var slowmodeNextSendDate: Int32? + public var statsDc: Int32? + public var pts: Int32 + public var call: Api.InputGroupCall? + public var ttlPeriod: Int32? + public var pendingSuggestions: [String]? + public var groupcallDefaultJoinAs: Api.Peer? + public var themeEmoticon: String? + public var requestsPending: Int32? + public var recentRequesters: [Int64]? + public var defaultSendAs: Api.Peer? + public var availableReactions: Api.ChatReactions? + public var reactionsLimit: Int32? + public var stories: Api.PeerStories? + public var wallpaper: Api.WallPaper? + public var boostsApplied: Int32? + public var boostsUnrestrict: Int32? + public var emojiset: Api.StickerSet? + public var botVerification: Api.BotVerification? + public var stargiftsCount: Int32? + public var sendPaidMessagesStars: Int64? + public var mainTab: Api.ProfileTab? + public init(flags: Int32, flags2: Int32, id: Int64, about: String, participantsCount: Int32?, adminsCount: Int32?, kickedCount: Int32?, bannedCount: Int32?, onlineCount: Int32?, readInboxMaxId: Int32, readOutboxMaxId: Int32, unreadCount: Int32, chatPhoto: Api.Photo, notifySettings: Api.PeerNotifySettings, exportedInvite: Api.ExportedChatInvite?, botInfo: [Api.BotInfo], migratedFromChatId: Int64?, migratedFromMaxId: Int32?, pinnedMsgId: Int32?, stickerset: Api.StickerSet?, availableMinId: Int32?, folderId: Int32?, linkedChatId: Int64?, location: Api.ChannelLocation?, slowmodeSeconds: Int32?, slowmodeNextSendDate: Int32?, statsDc: Int32?, pts: Int32, call: Api.InputGroupCall?, ttlPeriod: Int32?, pendingSuggestions: [String]?, groupcallDefaultJoinAs: Api.Peer?, themeEmoticon: String?, requestsPending: Int32?, recentRequesters: [Int64]?, defaultSendAs: Api.Peer?, availableReactions: Api.ChatReactions?, reactionsLimit: Int32?, stories: Api.PeerStories?, wallpaper: Api.WallPaper?, boostsApplied: Int32?, boostsUnrestrict: Int32?, emojiset: Api.StickerSet?, botVerification: Api.BotVerification?, stargiftsCount: Int32?, sendPaidMessagesStars: Int64?, mainTab: Api.ProfileTab?) { + self.flags = flags + self.flags2 = flags2 + self.id = id + self.about = about + self.participantsCount = participantsCount + self.adminsCount = adminsCount + self.kickedCount = kickedCount + self.bannedCount = bannedCount + self.onlineCount = onlineCount + self.readInboxMaxId = readInboxMaxId + self.readOutboxMaxId = readOutboxMaxId + self.unreadCount = unreadCount + self.chatPhoto = chatPhoto + self.notifySettings = notifySettings + self.exportedInvite = exportedInvite + self.botInfo = botInfo + self.migratedFromChatId = migratedFromChatId + self.migratedFromMaxId = migratedFromMaxId + self.pinnedMsgId = pinnedMsgId + self.stickerset = stickerset + self.availableMinId = availableMinId + self.folderId = folderId + self.linkedChatId = linkedChatId + self.location = location + self.slowmodeSeconds = slowmodeSeconds + self.slowmodeNextSendDate = slowmodeNextSendDate + self.statsDc = statsDc + self.pts = pts + self.call = call + self.ttlPeriod = ttlPeriod + self.pendingSuggestions = pendingSuggestions + self.groupcallDefaultJoinAs = groupcallDefaultJoinAs + self.themeEmoticon = themeEmoticon + self.requestsPending = requestsPending + self.recentRequesters = recentRequesters + self.defaultSendAs = defaultSendAs + self.availableReactions = availableReactions + self.reactionsLimit = reactionsLimit + self.stories = stories + self.wallpaper = wallpaper + self.boostsApplied = boostsApplied + self.boostsUnrestrict = boostsUnrestrict + self.emojiset = emojiset + self.botVerification = botVerification + self.stargiftsCount = stargiftsCount + self.sendPaidMessagesStars = sendPaidMessagesStars + self.mainTab = mainTab + } + } + public class Cons_chatFull { + public var flags: Int32 + public var id: Int64 + public var about: String + public var participants: Api.ChatParticipants + public var chatPhoto: Api.Photo? + public var notifySettings: Api.PeerNotifySettings + public var exportedInvite: Api.ExportedChatInvite? + public var botInfo: [Api.BotInfo]? + public var pinnedMsgId: Int32? + public var folderId: Int32? + public var call: Api.InputGroupCall? + public var ttlPeriod: Int32? + public var groupcallDefaultJoinAs: Api.Peer? + public var themeEmoticon: String? + public var requestsPending: Int32? + public var recentRequesters: [Int64]? + public var availableReactions: Api.ChatReactions? + public var reactionsLimit: Int32? + public init(flags: Int32, id: Int64, about: String, participants: Api.ChatParticipants, chatPhoto: Api.Photo?, notifySettings: Api.PeerNotifySettings, exportedInvite: Api.ExportedChatInvite?, botInfo: [Api.BotInfo]?, pinnedMsgId: Int32?, folderId: Int32?, call: Api.InputGroupCall?, ttlPeriod: Int32?, groupcallDefaultJoinAs: Api.Peer?, themeEmoticon: String?, requestsPending: Int32?, recentRequesters: [Int64]?, availableReactions: Api.ChatReactions?, reactionsLimit: Int32?) { + self.flags = flags + self.id = id + self.about = about + self.participants = participants + self.chatPhoto = chatPhoto + self.notifySettings = notifySettings + self.exportedInvite = exportedInvite + self.botInfo = botInfo + self.pinnedMsgId = pinnedMsgId + self.folderId = folderId + self.call = call + self.ttlPeriod = ttlPeriod + self.groupcallDefaultJoinAs = groupcallDefaultJoinAs + self.themeEmoticon = themeEmoticon + self.requestsPending = requestsPending + self.recentRequesters = recentRequesters + self.availableReactions = availableReactions + self.reactionsLimit = reactionsLimit + } + } + case channelFull(Cons_channelFull) + case chatFull(Cons_chatFull) public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) { #if DEBUG @@ -682,9 +838,47 @@ public extension Api { } public extension Api { indirect enum ChatInvite: TypeConstructorDescription { - case chatInvite(flags: Int32, title: String, about: String?, photo: Api.Photo, participantsCount: Int32, participants: [Api.User]?, color: Int32, subscriptionPricing: Api.StarsSubscriptionPricing?, subscriptionFormId: Int64?, botVerification: Api.BotVerification?) - case chatInviteAlready(chat: Api.Chat) - case chatInvitePeek(chat: Api.Chat, expires: Int32) + public class Cons_chatInvite { + public var flags: Int32 + public var title: String + public var about: String? + public var photo: Api.Photo + public var participantsCount: Int32 + public var participants: [Api.User]? + public var color: Int32 + public var subscriptionPricing: Api.StarsSubscriptionPricing? + public var subscriptionFormId: Int64? + public var botVerification: Api.BotVerification? + public init(flags: Int32, title: String, about: String?, photo: Api.Photo, participantsCount: Int32, participants: [Api.User]?, color: Int32, subscriptionPricing: Api.StarsSubscriptionPricing?, subscriptionFormId: Int64?, botVerification: Api.BotVerification?) { + self.flags = flags + self.title = title + self.about = about + self.photo = photo + self.participantsCount = participantsCount + self.participants = participants + self.color = color + self.subscriptionPricing = subscriptionPricing + self.subscriptionFormId = subscriptionFormId + self.botVerification = botVerification + } + } + public class Cons_chatInviteAlready { + public var chat: Api.Chat + public init(chat: Api.Chat) { + self.chat = chat + } + } + public class Cons_chatInvitePeek { + public var chat: Api.Chat + public var expires: Int32 + public init(chat: Api.Chat, expires: Int32) { + self.chat = chat + self.expires = expires + } + } + case chatInvite(Cons_chatInvite) + case chatInviteAlready(Cons_chatInviteAlready) + case chatInvitePeek(Cons_chatInvitePeek) public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) { #if DEBUG diff --git a/submodules/TelegramApi/Sources/Api5.swift b/submodules/TelegramApi/Sources/Api5.swift index 3654a16b86..f450c5b81a 100644 --- a/submodules/TelegramApi/Sources/Api5.swift +++ b/submodules/TelegramApi/Sources/Api5.swift @@ -1,6 +1,20 @@ public extension Api { enum ChatInviteImporter: TypeConstructorDescription { - case chatInviteImporter(flags: Int32, userId: Int64, date: Int32, about: String?, approvedBy: Int64?) + public class Cons_chatInviteImporter { + public var flags: Int32 + public var userId: Int64 + public var date: Int32 + public var about: String? + public var approvedBy: Int64? + public init(flags: Int32, userId: Int64, date: Int32, about: String?, approvedBy: Int64?) { + self.flags = flags + self.userId = userId + self.date = date + self.about = about + self.approvedBy = approvedBy + } + } + case chatInviteImporter(Cons_chatInviteImporter) public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) { #if DEBUG @@ -29,7 +43,13 @@ public extension Api { } public extension Api { enum ChatOnlines: TypeConstructorDescription { - case chatOnlines(onlines: Int32) + public class Cons_chatOnlines { + public var onlines: Int32 + public init(onlines: Int32) { + self.onlines = onlines + } + } + case chatOnlines(Cons_chatOnlines) public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) { #if DEBUG @@ -58,9 +78,35 @@ public extension Api { } public extension Api { enum ChatParticipant: TypeConstructorDescription { - case chatParticipant(userId: Int64, inviterId: Int64, date: Int32) - case chatParticipantAdmin(userId: Int64, inviterId: Int64, date: Int32) - case chatParticipantCreator(userId: Int64) + public class Cons_chatParticipant { + public var userId: Int64 + public var inviterId: Int64 + public var date: Int32 + public init(userId: Int64, inviterId: Int64, date: Int32) { + self.userId = userId + self.inviterId = inviterId + self.date = date + } + } + public class Cons_chatParticipantAdmin { + public var userId: Int64 + public var inviterId: Int64 + public var date: Int32 + public init(userId: Int64, inviterId: Int64, date: Int32) { + self.userId = userId + self.inviterId = inviterId + self.date = date + } + } + public class Cons_chatParticipantCreator { + public var userId: Int64 + public init(userId: Int64) { + self.userId = userId + } + } + case chatParticipant(Cons_chatParticipant) + case chatParticipantAdmin(Cons_chatParticipantAdmin) + case chatParticipantCreator(Cons_chatParticipantCreator) public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) { #if DEBUG diff --git a/submodules/TelegramCore/Sources/ApiUtils/CachedGroupParticipants.swift b/submodules/TelegramCore/Sources/ApiUtils/CachedGroupParticipants.swift index 3dc2195436..82afdc8967 100644 --- a/submodules/TelegramCore/Sources/ApiUtils/CachedGroupParticipants.swift +++ b/submodules/TelegramCore/Sources/ApiUtils/CachedGroupParticipants.swift @@ -6,11 +6,14 @@ import TelegramApi extension GroupParticipant { init(apiParticipant: Api.ChatParticipant) { switch apiParticipant { - case let .chatParticipantCreator(userId): + case let .chatParticipantCreator(chatParticipantCreatorData): + let userId = chatParticipantCreatorData.userId self = .creator(id: PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt64Value(userId))) - case let .chatParticipantAdmin(userId, inviterId, date): + case let .chatParticipantAdmin(chatParticipantAdminData): + let (userId, inviterId, date) = (chatParticipantAdminData.userId, chatParticipantAdminData.inviterId, chatParticipantAdminData.date) self = .admin(id: PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt64Value(userId)), invitedBy: PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt64Value(inviterId)), invitedAt: date) - case let .chatParticipant(userId, inviterId, date): + case let .chatParticipant(chatParticipantData): + let (userId, inviterId, date) = (chatParticipantData.userId, chatParticipantData.inviterId, chatParticipantData.date) self = .member(id: PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt64Value(userId)), invitedBy: PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt64Value(inviterId)), invitedAt: date) } } diff --git a/submodules/TelegramCore/Sources/ApiUtils/TelegramChannelBannedRights.swift b/submodules/TelegramCore/Sources/ApiUtils/TelegramChannelBannedRights.swift index 8e2a362c9b..0565841ab3 100644 --- a/submodules/TelegramCore/Sources/ApiUtils/TelegramChannelBannedRights.swift +++ b/submodules/TelegramCore/Sources/ApiUtils/TelegramChannelBannedRights.swift @@ -5,7 +5,8 @@ import TelegramApi extension TelegramChatBannedRights { init(apiBannedRights: Api.ChatBannedRights) { switch apiBannedRights { - case let .chatBannedRights(flags, untilDate): + case let .chatBannedRights(chatBannedRightsData): + let (flags, untilDate) = (chatBannedRightsData.flags, chatBannedRightsData.untilDate) var effectiveFlags = TelegramChatBannedRightsFlags(rawValue: flags) effectiveFlags.remove(.banSendMedia) effectiveFlags.remove(TelegramChatBannedRightsFlags(rawValue: 1 << 1)) @@ -18,6 +19,6 @@ extension TelegramChatBannedRights { effectiveFlags.remove(.banSendMedia) effectiveFlags.remove(TelegramChatBannedRightsFlags(rawValue: 1 << 1)) - return .chatBannedRights(flags: effectiveFlags.rawValue, untilDate: self.untilDate) + return .chatBannedRights(.init(flags: effectiveFlags.rawValue, untilDate: self.untilDate)) } } diff --git a/submodules/TelegramCore/Sources/TelegramEngine/Peers/ChannelBlacklist.swift b/submodules/TelegramCore/Sources/TelegramEngine/Peers/ChannelBlacklist.swift index 516d812df2..0630e1db6f 100644 --- a/submodules/TelegramCore/Sources/TelegramEngine/Peers/ChannelBlacklist.swift +++ b/submodules/TelegramCore/Sources/TelegramEngine/Peers/ChannelBlacklist.swift @@ -32,7 +32,7 @@ func _internal_updateChannelMemberBannedRights(account: Account, peerId: PeerId, if let rights = rights, !rights.flags.isEmpty { apiRights = rights.apiBannedRights } else { - apiRights = .chatBannedRights(flags: 0, untilDate: 0) + apiRights = .chatBannedRights(.init(flags: 0, untilDate: 0)) } return account.network.request(Api.functions.channels.editBanned(channel: inputChannel, participant: inputPeer, bannedRights: apiRights)) diff --git a/submodules/TelegramCore/Sources/TelegramEngine/Peers/ChatOnlineMembers.swift b/submodules/TelegramCore/Sources/TelegramEngine/Peers/ChatOnlineMembers.swift index aeb9e8593e..12eecda1a6 100644 --- a/submodules/TelegramCore/Sources/TelegramEngine/Peers/ChatOnlineMembers.swift +++ b/submodules/TelegramCore/Sources/TelegramEngine/Peers/ChatOnlineMembers.swift @@ -14,7 +14,8 @@ func _internal_chatOnlineMembers(postbox: Postbox, network: Network, peerId: Pee return network.request(Api.functions.messages.getOnlines(peer: inputPeer)) |> map { value -> Int32 in switch value { - case let .chatOnlines(onlines): + case let .chatOnlines(chatOnlinesData): + let onlines = chatOnlinesData.onlines return onlines } } diff --git a/submodules/TelegramCore/Sources/TelegramEngine/Peers/InvitationLinks.swift b/submodules/TelegramCore/Sources/TelegramEngine/Peers/InvitationLinks.swift index 5f4e7797d9..c82dc21ffd 100644 --- a/submodules/TelegramCore/Sources/TelegramEngine/Peers/InvitationLinks.swift +++ b/submodules/TelegramCore/Sources/TelegramEngine/Peers/InvitationLinks.swift @@ -958,7 +958,8 @@ private final class PeerInvitationImportersContextImpl { let approvedBy: PeerId? let joinedViaFolderLink: Bool switch importer { - case let .chatInviteImporter(flags, userId, dateValue, aboutValue, approvedByValue): + case let .chatInviteImporter(chatInviteImporterData): + let (flags, userId, dateValue, aboutValue, approvedByValue) = (chatInviteImporterData.flags, chatInviteImporterData.userId, chatInviteImporterData.date, chatInviteImporterData.about, chatInviteImporterData.approvedBy) joinedViaFolderLink = (flags & (1 << 3)) != 0 peerId = PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt64Value(userId)) date = dateValue @@ -1168,7 +1169,8 @@ func _internal_peerExportedInvitationsCreators(account: Account, peerId: PeerId) for admin in admins { switch admin { - case let .chatAdminWithInvites(adminId, invitesCount, revokedInvitesCount): + case let .chatAdminWithInvites(chatAdminWithInvitesData): + let (adminId, invitesCount, revokedInvitesCount) = (chatAdminWithInvitesData.adminId, chatAdminWithInvitesData.invitesCount, chatAdminWithInvitesData.revokedInvitesCount) let peerId = PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt64Value(adminId)) if let peer = parsedPeers.get(peerId), peerId != account.peerId { creators.append(ExportedInvitationCreator(peer: RenderedPeer(peer: peer), count: invitesCount, revokedCount: revokedInvitesCount)) diff --git a/submodules/TelegramCore/Sources/TelegramEngine/Peers/JoinLink.swift b/submodules/TelegramCore/Sources/TelegramEngine/Peers/JoinLink.swift index ea763de6f6..1270d05863 100644 --- a/submodules/TelegramCore/Sources/TelegramEngine/Peers/JoinLink.swift +++ b/submodules/TelegramCore/Sources/TelegramEngine/Peers/JoinLink.swift @@ -110,11 +110,13 @@ func _internal_joinLinkInformation(_ hash: String, account: Account) -> Signal mapToSignal { result -> Signal in if let result = result { switch result { - case let .chatInvite(flags, title, about, invitePhoto, participantsCount, participants, nameColor, subscriptionPricing, subscriptionFormId, verification): + case let .chatInvite(chatInviteData): + let (apiFlags, title, about, invitePhoto, participantsCount, participants, nameColor, subscriptionPricing, subscriptionFormId, verification) = (chatInviteData.flags, chatInviteData.title, chatInviteData.about, chatInviteData.photo, chatInviteData.participantsCount, chatInviteData.participants, chatInviteData.color, chatInviteData.subscriptionPricing, chatInviteData.subscriptionFormId, chatInviteData.botVerification) let photo = telegramMediaImageFromApiPhoto(invitePhoto).flatMap({ smallestImageRepresentation($0.representations) }) - let flags: ExternalJoiningChatState.Invite.Flags = .init(isChannel: (flags & (1 << 0)) != 0, isBroadcast: (flags & (1 << 1)) != 0, isPublic: (flags & (1 << 2)) != 0, isMegagroup: (flags & (1 << 3)) != 0, requestNeeded: (flags & (1 << 6)) != 0, isVerified: (flags & (1 << 7)) != 0, isScam: (flags & (1 << 8)) != 0, isFake: (flags & (1 << 9)) != 0, canRefulfillSubscription: (flags & (1 << 11)) != 0) + let flags: ExternalJoiningChatState.Invite.Flags = .init(isChannel: (apiFlags & (1 << 0)) != 0, isBroadcast: (apiFlags & (1 << 1)) != 0, isPublic: (apiFlags & (1 << 2)) != 0, isMegagroup: (apiFlags & (1 << 3)) != 0, requestNeeded: (apiFlags & (1 << 6)) != 0, isVerified: (apiFlags & (1 << 7)) != 0, isScam: (apiFlags & (1 << 8)) != 0, isFake: (apiFlags & (1 << 9)) != 0, canRefulfillSubscription: (apiFlags & (1 << 11)) != 0) return .single(.invite(ExternalJoiningChatState.Invite(flags: flags, title: title, about: about, photoRepresentation: photo, participantsCount: participantsCount, participants: participants?.map({ EnginePeer(TelegramUser(user: $0)) }), nameColor: PeerNameColor(rawValue: nameColor), subscriptionPricing: subscriptionPricing.flatMap { StarsSubscriptionPricing(apiStarsSubscriptionPricing: $0) }, subscriptionFormId: subscriptionFormId, verification: verification.flatMap { PeerVerification(apiBotVerification: $0) }))) - case let .chatInviteAlready(chat): + case let .chatInviteAlready(chatInviteAlreadyData): + let chat = chatInviteAlreadyData.chat if let peer = parseTelegramGroupOrChannel(chat: chat) { return account.postbox.transaction({ (transaction) -> ExternalJoiningChatState in let parsedPeers = AccumulatedPeers(transaction: transaction, chats: [chat], users: []) @@ -124,7 +126,8 @@ func _internal_joinLinkInformation(_ hash: String, account: Account) -> Signal castError(JoinLinkInfoError.self) } return .single(.invalidHash) - case let .chatInvitePeek(chat, expires): + case let .chatInvitePeek(chatInvitePeekData): + let (chat, expires) = (chatInvitePeekData.chat, chatInvitePeekData.expires) if let peer = parseTelegramGroupOrChannel(chat: chat) { return account.postbox.transaction({ (transaction) -> ExternalJoiningChatState in let parsedPeers = AccumulatedPeers(transaction: transaction, chats: [chat], users: []) diff --git a/submodules/TelegramCore/Sources/TelegramEngine/Peers/UpdateCachedPeerData.swift b/submodules/TelegramCore/Sources/TelegramEngine/Peers/UpdateCachedPeerData.swift index 79a1421c50..23d2749168 100644 --- a/submodules/TelegramCore/Sources/TelegramEngine/Peers/UpdateCachedPeerData.swift +++ b/submodules/TelegramCore/Sources/TelegramEngine/Peers/UpdateCachedPeerData.swift @@ -489,14 +489,16 @@ func _internal_fetchAndUpdateCachedPeerData(accountPeerId: PeerId, peerId rawPee switch result { case let .chatFull(fullChat, chats, users): switch fullChat { - case let .chatFull(_, _, _, _, _, notifySettings, _, _, _, _, _, _, _, _, _, _, _, _): + case let .chatFull(chatFullData): + let (notifySettings) = (chatFullData.notifySettings) transaction.updateCurrentPeerNotificationSettings([peerId: TelegramPeerNotificationSettings(apiSettings: notifySettings)]) case .channelFull: break } switch fullChat { - case let .chatFull(chatFullFlags, _, chatFullAbout, chatFullParticipants, chatFullChatPhoto, _, chatFullExportedInvite, chatFullBotInfo, chatFullPinnedMsgId, _, chatFullCall, chatTtlPeriod, chatFullGroupcallDefaultJoinAs, chatFullThemeEmoticon, chatFullRequestsPending, _, allowedReactions, reactionsLimit): + case let .chatFull(chatFullData): + let (chatFullFlags, chatFullAbout, chatFullParticipants, chatFullChatPhoto, chatFullExportedInvite, chatFullBotInfo, chatFullPinnedMsgId, chatFullCall, chatTtlPeriod, chatFullGroupcallDefaultJoinAs, chatFullThemeEmoticon, chatFullRequestsPending, allowedReactions, reactionsLimit) = (chatFullData.flags, chatFullData.about, chatFullData.participants, chatFullData.chatPhoto, chatFullData.exportedInvite, chatFullData.botInfo, chatFullData.pinnedMsgId, chatFullData.call, chatFullData.ttlPeriod, chatFullData.groupcallDefaultJoinAs, chatFullData.themeEmoticon, chatFullData.requestsPending, chatFullData.availableReactions, chatFullData.reactionsLimit) var botInfos: [CachedPeerBotInfo] = [] for botInfo in chatFullBotInfo ?? [] { switch botInfo { @@ -633,14 +635,16 @@ func _internal_fetchAndUpdateCachedPeerData(accountPeerId: PeerId, peerId rawPee switch result { case let .chatFull(fullChat, chats, users): switch fullChat { - case let .channelFull(_, _, _, _, _, _, _, _, _, _, _, _, _, notifySettings, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _): + case let .channelFull(channelFullData): + let notifySettings = channelFullData.notifySettings transaction.updateCurrentPeerNotificationSettings([peerId: TelegramPeerNotificationSettings(apiSettings: notifySettings)]) case .chatFull: break } switch fullChat { - case let .channelFull(flags, flags2, _, about, participantsCount, adminsCount, kickedCount, bannedCount, _, _, _, _, chatPhoto, _, apiExportedInvite, apiBotInfos, migratedFromChatId, migratedFromMaxId, pinnedMsgId, stickerSet, minAvailableMsgId, _, linkedChatId, location, slowmodeSeconds, slowmodeNextSendDate, statsDc, _, inputCall, ttl, pendingSuggestions, groupcallDefaultJoinAs, themeEmoticon, requestsPending, _, defaultSendAs, allowedReactions, reactionsLimit, _, wallpaper, appliedBoosts, boostsUnrestrict, emojiSet, verification, starGiftsCount, sendPaidMessageStars, mainTab): + case let .channelFull(channelFullData): + let (flags, flags2, about, participantsCount, adminsCount, kickedCount, bannedCount, chatPhoto, apiExportedInvite, apiBotInfos, migratedFromChatId, migratedFromMaxId, pinnedMsgId, stickerSet, minAvailableMsgId, linkedChatId, location, slowmodeSeconds, slowmodeNextSendDate, statsDc, inputCall, ttl, pendingSuggestions, groupcallDefaultJoinAs, themeEmoticon, requestsPending, defaultSendAs, allowedReactions, reactionsLimit, wallpaper, appliedBoosts, boostsUnrestrict, emojiSet, verification, starGiftsCount, sendPaidMessageStars, mainTab) = (channelFullData.flags, channelFullData.flags2, channelFullData.about, channelFullData.participantsCount, channelFullData.adminsCount, channelFullData.kickedCount, channelFullData.bannedCount, channelFullData.chatPhoto, channelFullData.exportedInvite, channelFullData.botInfo, channelFullData.migratedFromChatId, channelFullData.migratedFromMaxId, channelFullData.pinnedMsgId, channelFullData.stickerset, channelFullData.availableMinId, channelFullData.linkedChatId, channelFullData.location, channelFullData.slowmodeSeconds, channelFullData.slowmodeNextSendDate, channelFullData.statsDc, channelFullData.call, channelFullData.ttlPeriod, channelFullData.pendingSuggestions, channelFullData.groupcallDefaultJoinAs, channelFullData.themeEmoticon, channelFullData.requestsPending, channelFullData.defaultSendAs, channelFullData.availableReactions, channelFullData.reactionsLimit, channelFullData.wallpaper, channelFullData.boostsApplied, channelFullData.boostsUnrestrict, channelFullData.emojiset, channelFullData.botVerification, channelFullData.stargiftsCount, channelFullData.sendPaidMessagesStars, channelFullData.mainTab) var channelFlags = CachedChannelFlags() if (flags & (1 << 3)) != 0 { channelFlags.insert(.canDisplayParticipants)