diff --git a/.bazelrc b/.bazelrc index c695ce1357..c4cde87693 100644 --- a/.bazelrc +++ b/.bazelrc @@ -16,4 +16,4 @@ build --strategy=Genrule=standalone build --spawn_strategy=standalone build --strategy=SwiftCompile=standalone -build --define RULES_SWIFT_BUILD_DUMMY_WORKER=1 \ No newline at end of file +build --define RULES_SWIFT_BUILD_DUMMY_WORKER=1 diff --git a/Telegram/NotificationService/NotificationServiceObjC/Sources/Serialization.m b/Telegram/NotificationService/NotificationServiceObjC/Sources/Serialization.m index eef89382ce..5352a36622 100644 --- a/Telegram/NotificationService/NotificationServiceObjC/Sources/Serialization.m +++ b/Telegram/NotificationService/NotificationServiceObjC/Sources/Serialization.m @@ -3,7 +3,7 @@ @implementation Serialization - (NSUInteger)currentLayer { - return 132; + return 133; } - (id _Nullable)parseMessage:(NSData * _Nullable)data { @@ -16,7 +16,7 @@ }; } -- (NSData * _Nonnull)importAuthorization:(int32_t)authId bytes:(NSData * _Nonnull)bytes { +- (NSData * _Nonnull)importAuthorization:(int64_t)authId bytes:(NSData * _Nonnull)bytes { return [NSData data]; } diff --git a/Telegram/SiriIntents/IntentContacts.swift b/Telegram/SiriIntents/IntentContacts.swift index a1c0baab37..dc338bef52 100644 --- a/Telegram/SiriIntents/IntentContacts.swift +++ b/Telegram/SiriIntents/IntentContacts.swift @@ -33,8 +33,8 @@ private func parseAppSpecificContactReference(_ value: String) -> PeerId? { return nil } let idString = String(value[value.index(value.startIndex, offsetBy: phonebookUsernamePrefix.count)...]) - if let id = Int32(idString) { - return PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt32Value(id)) + if let id = Int64(idString) { + return PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt64Value(id)) } return nil } diff --git a/Telegram/SiriIntents/IntentMessages.swift b/Telegram/SiriIntents/IntentMessages.swift index 4e925f0c2f..fc3287b7ae 100644 --- a/Telegram/SiriIntents/IntentMessages.swift +++ b/Telegram/SiriIntents/IntentMessages.swift @@ -165,7 +165,7 @@ private func callWithTelegramMessage(_ telegramMessage: Message, account: Accoun @available(iOSApplicationExtension 10.0, iOS 10.0, *) private func messageWithTelegramMessage(_ telegramMessage: Message) -> INMessage? { - guard let author = telegramMessage.author, let user = telegramMessage.peers[author.id] as? TelegramUser, user.id.id._internalGetInt32Value() != 777000 else { + guard let author = telegramMessage.author, let user = telegramMessage.peers[author.id] as? TelegramUser, user.id.id._internalGetInt64Value() != 777000 else { return nil } diff --git a/Telegram/Watch/WatchCommonWatch/TGBridgeContext.h b/Telegram/Watch/WatchCommonWatch/TGBridgeContext.h index 45225a04f6..cdea027feb 100644 --- a/Telegram/Watch/WatchCommonWatch/TGBridgeContext.h +++ b/Telegram/Watch/WatchCommonWatch/TGBridgeContext.h @@ -3,7 +3,7 @@ @interface TGBridgeContext : NSObject @property (nonatomic, readonly) bool authorized; -@property (nonatomic, readonly) int32_t userId; +@property (nonatomic, readonly) int64_t userId; @property (nonatomic, readonly) bool micAccessAllowed; @property (nonatomic, readonly) NSDictionary *preheatData; @property (nonatomic, readonly) NSInteger preheatVersion; diff --git a/Telegram/Watch/WatchCommonWatch/TGBridgeContext.m b/Telegram/Watch/WatchCommonWatch/TGBridgeContext.m index 4b0600e2fc..df70505a06 100644 --- a/Telegram/Watch/WatchCommonWatch/TGBridgeContext.m +++ b/Telegram/Watch/WatchCommonWatch/TGBridgeContext.m @@ -40,7 +40,7 @@ NSString *const TGBridgeContextStartupDataVersion = @"version"; return dictionary; } -- (TGBridgeContext *)updatedWithAuthorized:(bool)authorized peerId:(int32_t)peerId +- (TGBridgeContext *)updatedWithAuthorized:(bool)authorized peerId:(int64_t)peerId { TGBridgeContext *context = [[TGBridgeContext alloc] init]; context->_authorized = authorized; diff --git a/submodules/AccountContext/Sources/AccountContext.swift b/submodules/AccountContext/Sources/AccountContext.swift index c510a9f3c0..6b8267c11a 100644 --- a/submodules/AccountContext/Sources/AccountContext.swift +++ b/submodules/AccountContext/Sources/AccountContext.swift @@ -501,7 +501,7 @@ public enum ChatListSearchFilter: Equatable { case peer(PeerId, Bool, String, String) case date(Int32?, Int32, String) - public var id: Int32 { + public var id: Int64 { switch self { case .chats: return 0 @@ -516,9 +516,9 @@ public enum ChatListSearchFilter: Equatable { case .voice: return 5 case let .peer(peerId, _, _, _): - return peerId.id._internalGetInt32Value() + return peerId.id._internalGetInt64Value() case let .date(_, date, _): - return date + return Int64(date) } } } diff --git a/submodules/AccountContext/Sources/DeviceContactData.swift b/submodules/AccountContext/Sources/DeviceContactData.swift index d9351befda..fe5aca7de9 100644 --- a/submodules/AccountContext/Sources/DeviceContactData.swift +++ b/submodules/AccountContext/Sources/DeviceContactData.swift @@ -200,8 +200,8 @@ public func parseAppSpecificContactReference(_ value: String) -> PeerId? { return nil } let idString = String(value[value.index(value.startIndex, offsetBy: phonebookUsernamePrefix.count)...]) - if let id = Int32(idString) { - return PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt32Value(id)) + if let id = Int64(idString) { + return PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt64Value(id)) } return nil } diff --git a/submodules/AccountContext/Sources/OpenChatMessage.swift b/submodules/AccountContext/Sources/OpenChatMessage.swift index fff0a235f0..57da66c17d 100644 --- a/submodules/AccountContext/Sources/OpenChatMessage.swift +++ b/submodules/AccountContext/Sources/OpenChatMessage.swift @@ -6,6 +6,7 @@ import SwiftSignalKit import Display import AsyncDisplayKit import UniversalMediaPlayer +import TelegramPresentationData public enum ChatControllerInteractionOpenMessageMode { case `default` @@ -18,6 +19,7 @@ public enum ChatControllerInteractionOpenMessageMode { public final class OpenChatMessageParams { public let context: AccountContext + public let updatedPresentationData: (initial: PresentationData, signal: Signal)? public let chatLocation: ChatLocation? public let chatLocationContextHolder: Atomic? public let message: Message @@ -44,6 +46,7 @@ public final class OpenChatMessageParams { public init( context: AccountContext, + updatedPresentationData: (initial: PresentationData, signal: Signal)? = nil, chatLocation: ChatLocation?, chatLocationContextHolder: Atomic?, message: Message, @@ -69,6 +72,7 @@ public final class OpenChatMessageParams { centralItemUpdated: ((MessageId) -> Void)? = nil ) { self.context = context + self.updatedPresentationData = updatedPresentationData self.chatLocation = chatLocation self.chatLocationContextHolder = chatLocationContextHolder self.message = message diff --git a/submodules/AvatarNode/Sources/AvatarNode.swift b/submodules/AvatarNode/Sources/AvatarNode.swift index c0cfad6ed2..38608a14e7 100644 --- a/submodules/AvatarNode/Sources/AvatarNode.swift +++ b/submodules/AvatarNode/Sources/AvatarNode.swift @@ -454,7 +454,7 @@ public final class AvatarNode: ASDisplayNode { if peerId.namespace == .max { colorIndex = -1 } else { - colorIndex = abs(Int(clamping: peerId.id._internalGetInt32Value())) + colorIndex = abs(Int(clamping: peerId.id._internalGetInt64Value())) } } else { colorIndex = -1 @@ -633,7 +633,7 @@ public func drawPeerAvatarLetters(context: CGContext, size: CGSize, round: Bool if peerId.namespace == .max { colorIndex = -1 } else { - colorIndex = Int(abs(peerId.id._internalGetInt32Value())) + colorIndex = Int(clamping: abs(peerId.id._internalGetInt64Value())) } let colorsArray: NSArray diff --git a/submodules/ChatListUI/Sources/ChatContextMenus.swift b/submodules/ChatListUI/Sources/ChatContextMenus.swift index 7fb0f8adc7..52f12478f7 100644 --- a/submodules/ChatListUI/Sources/ChatContextMenus.swift +++ b/submodules/ChatListUI/Sources/ChatContextMenus.swift @@ -271,7 +271,7 @@ func chatContextMenuItems(context: AccountContext, peerId: PeerId, promoInfo: Ch }))) } - let archiveEnabled = !isSavedMessages && peerId != PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt32Value(777000)) && peerId == context.account.peerId + let archiveEnabled = !isSavedMessages && peerId != PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt64Value(777000)) && peerId == context.account.peerId if let (group, _) = groupAndIndex { if archiveEnabled { let isArchived = group == Namespaces.PeerGroup.archive diff --git a/submodules/ChatListUI/Sources/ChatListController.swift b/submodules/ChatListUI/Sources/ChatListController.swift index 0971c9c5b7..5e20fd528e 100644 --- a/submodules/ChatListUI/Sources/ChatListController.swift +++ b/submodules/ChatListUI/Sources/ChatListController.swift @@ -927,7 +927,7 @@ public class ChatListControllerImpl: TelegramBaseController, ChatListController } if archiveEnabled { for peerId in peerIds { - if peerId == PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt32Value(777000)) { + if peerId == PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt64Value(777000)) { archiveEnabled = false break } else if peerId == strongSelf.context.account.peerId { diff --git a/submodules/ChatListUI/Sources/ChatListControllerNode.swift b/submodules/ChatListUI/Sources/ChatListControllerNode.swift index abb2350bed..6ff6c48ad8 100644 --- a/submodules/ChatListUI/Sources/ChatListControllerNode.swift +++ b/submodules/ChatListUI/Sources/ChatListControllerNode.swift @@ -178,7 +178,7 @@ private final class ChatListShimmerNode: ASDisplayNode { let chatListPresentationData = ChatListPresentationData(theme: presentationData.theme, fontSize: presentationData.chatFontSize, strings: presentationData.strings, dateTimeFormat: presentationData.dateTimeFormat, nameSortOrder: presentationData.nameSortOrder, nameDisplayOrder: presentationData.nameDisplayOrder, disableAnimations: true) - let peer1 = TelegramUser(id: PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt32Value(0)), accessHash: nil, firstName: "FirstName", lastName: nil, username: nil, phone: nil, photo: [], botInfo: nil, restrictionInfo: nil, flags: []) + let peer1 = TelegramUser(id: PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt64Value(0)), accessHash: nil, firstName: "FirstName", lastName: nil, username: nil, phone: nil, photo: [], botInfo: nil, restrictionInfo: nil, flags: []) let timestamp1: Int32 = 100000 let peers = SimpleDictionary() let interaction = ChatListNodeInteraction(activateSearch: {}, peerSelected: { _, _, _ in }, disabledPeerSelected: { _ in }, togglePeerSelected: { _ in }, togglePeersSelection: { _, _ in }, additionalCategorySelected: { _ in diff --git a/submodules/ChatListUI/Sources/ChatListSearchFiltersContainerNode.swift b/submodules/ChatListUI/Sources/ChatListSearchFiltersContainerNode.swift index 7d7b51f020..d3ccd0b522 100644 --- a/submodules/ChatListUI/Sources/ChatListSearchFiltersContainerNode.swift +++ b/submodules/ChatListUI/Sources/ChatListSearchFiltersContainerNode.swift @@ -150,7 +150,7 @@ private final class ItemNode: ASDisplayNode { } enum ChatListSearchFilterEntryId: Hashable { - case filter(Int32) + case filter(Int64) } enum ChatListSearchFilterEntry: Equatable { diff --git a/submodules/ChatListUI/Sources/ChatListSearchListPaneNode.swift b/submodules/ChatListUI/Sources/ChatListSearchListPaneNode.swift index 04cc6fd186..30b18e6ca3 100644 --- a/submodules/ChatListUI/Sources/ChatListSearchListPaneNode.swift +++ b/submodules/ChatListUI/Sources/ChatListSearchListPaneNode.swift @@ -2329,7 +2329,7 @@ private final class ChatListSearchShimmerNode: ASDisplayNode { let chatListPresentationData = ChatListPresentationData(theme: presentationData.theme, fontSize: presentationData.chatFontSize, strings: presentationData.strings, dateTimeFormat: presentationData.dateTimeFormat, nameSortOrder: presentationData.nameSortOrder, nameDisplayOrder: presentationData.nameDisplayOrder, disableAnimations: true) - let peer1 = TelegramUser(id: PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt32Value(0)), accessHash: nil, firstName: "FirstName", lastName: nil, username: nil, phone: nil, photo: [], botInfo: nil, restrictionInfo: nil, flags: []) + let peer1 = TelegramUser(id: PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt64Value(0)), accessHash: nil, firstName: "FirstName", lastName: nil, username: nil, phone: nil, photo: [], botInfo: nil, restrictionInfo: nil, flags: []) let timestamp1: Int32 = 100000 var peers = SimpleDictionary() peers[peer1.id] = peer1 diff --git a/submodules/ChatListUI/Sources/Node/ChatListItem.swift b/submodules/ChatListUI/Sources/Node/ChatListItem.swift index c32eb1d010..3cce18b827 100644 --- a/submodules/ChatListUI/Sources/Node/ChatListItem.swift +++ b/submodules/ChatListUI/Sources/Node/ChatListItem.swift @@ -196,7 +196,7 @@ private enum RevealOptionKey: Int32 { } private func canArchivePeer(id: PeerId, accountPeerId: PeerId) -> Bool { - if id.namespace == Namespaces.Peer.CloudUser && id.id._internalGetInt32Value() == 777000 { + if id.namespace == Namespaces.Peer.CloudUser && id.id._internalGetInt64Value() == 777000 { return false } if id == accountPeerId { diff --git a/submodules/ChatTitleActivityNode/Sources/ChatChoosingStickerActivityContentNode.swift b/submodules/ChatTitleActivityNode/Sources/ChatChoosingStickerActivityContentNode.swift index db171d3143..4542fbae9d 100644 --- a/submodules/ChatTitleActivityNode/Sources/ChatChoosingStickerActivityContentNode.swift +++ b/submodules/ChatTitleActivityNode/Sources/ChatChoosingStickerActivityContentNode.swift @@ -101,7 +101,7 @@ class ChatChoosingStickerActivityContentNode: ChatTitleActivityContentNode { self.indicatorNode = ChatChoosingStickerActivityIndicatorNode(color: color) var text = text - self.advanced = text.string == "choosing sticker" + self.advanced = text.string == "choosing a sticker" if self.advanced { let mutable = text.mutableCopy() as? NSMutableAttributedString mutable?.replaceCharacters(in: NSMakeRange(2, 2), with: " ") diff --git a/submodules/ContactListUI/Sources/InviteContactsControllerNode.swift b/submodules/ContactListUI/Sources/InviteContactsControllerNode.swift index 93df9f8c64..13c1fc2757 100644 --- a/submodules/ContactListUI/Sources/InviteContactsControllerNode.swift +++ b/submodules/ContactListUI/Sources/InviteContactsControllerNode.swift @@ -57,7 +57,7 @@ private enum InviteContactsEntry: Comparable, Identifiable { } else { status = .none } - let peer = TelegramUser(id: PeerId(namespace: .max, id: PeerId.Id._internalFromInt32Value(0)), accessHash: nil, firstName: contact.firstName, lastName: contact.lastName, username: nil, phone: nil, photo: [], botInfo: nil, restrictionInfo: nil, flags: []) + let peer = TelegramUser(id: PeerId(namespace: .max, id: PeerId.Id._internalFromInt64Value(0)), accessHash: nil, firstName: contact.firstName, lastName: contact.lastName, username: nil, phone: nil, photo: [], botInfo: nil, restrictionInfo: nil, flags: []) return ContactsPeerItem(presentationData: ItemListPresentationData(presentationData), sortOrder: nameSortOrder, displayOrder: nameDisplayOrder, context: context, peerMode: .peer, peer: .peer(peer: peer, chatPeer: peer), status: status, enabled: true, selection: selection, editing: ContactsPeerItemEditing(editable: false, editing: false, revealed: false), index: nil, header: ChatListSearchItemHeader(type: .contacts, theme: theme, strings: strings, actionTitle: nil, action: nil), action: { _ in interaction.toggleContact(id) }) diff --git a/submodules/Emoji/Sources/EmojiUtils.swift b/submodules/Emoji/Sources/EmojiUtils.swift index 893bae47e8..58ba322f87 100644 --- a/submodules/Emoji/Sources/EmojiUtils.swift +++ b/submodules/Emoji/Sources/EmojiUtils.swift @@ -136,7 +136,7 @@ public extension String { continue } string.unicodeScalars.append(scalar) - if scalar.value == 0x2764, self.unicodeScalars.count > 1, self.emojis.count == 1 { + if scalar.value == 0x2764 && self.unicodeScalars.count < 3 { break } } diff --git a/submodules/InstantPageUI/Sources/InstantPageControllerNode.swift b/submodules/InstantPageUI/Sources/InstantPageControllerNode.swift index f8439221e5..50b71f819d 100644 --- a/submodules/InstantPageUI/Sources/InstantPageControllerNode.swift +++ b/submodules/InstantPageUI/Sources/InstantPageControllerNode.swift @@ -1276,7 +1276,7 @@ final class InstantPageControllerNode: ASDisplayNode, UIScrollViewDelegate { }, openUrl: { _ in }, openPeer: { _ in }, showAll: false) - let peer = TelegramUser(id: PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt32Value(0)), accessHash: nil, firstName: "", lastName: nil, username: nil, phone: nil, photo: [], botInfo: nil, restrictionInfo: nil, flags: []) + let peer = TelegramUser(id: PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt64Value(0)), accessHash: nil, firstName: "", lastName: nil, username: nil, phone: nil, photo: [], botInfo: nil, restrictionInfo: nil, flags: []) let message = Message(stableId: 0, stableVersion: 0, id: MessageId(peerId: peer.id, namespace: 0, id: 0), globallyUniqueId: nil, groupingKey: nil, groupInfo: nil, threadId: nil, timestamp: 0, flags: [], tags: [], globalTags: [], localTags: [], forwardInfo: nil, author: peer, text: "", attributes: [], media: [map], peers: SimpleDictionary(), associatedMessages: SimpleDictionary(), associatedMessageIds: []) let controller = LocationViewController(context: self.context, subject: message, params: controllerParams) diff --git a/submodules/InviteLinksUI/Sources/InviteLinkViewController.swift b/submodules/InviteLinksUI/Sources/InviteLinkViewController.swift index 32adcc7444..48214031d8 100644 --- a/submodules/InviteLinksUI/Sources/InviteLinkViewController.swift +++ b/submodules/InviteLinksUI/Sources/InviteLinkViewController.swift @@ -597,7 +597,7 @@ public final class InviteLinkViewController: ViewController { if state.importers.isEmpty && state.isLoadingMore { count = min(4, state.count) loading = true - let fakeUser = TelegramUser(id: PeerId(namespace: .max, id: PeerId.Id._internalFromInt32Value(0)), accessHash: nil, firstName: "", lastName: "", username: nil, phone: nil, photo: [], botInfo: nil, restrictionInfo: nil, flags: []) + let fakeUser = TelegramUser(id: PeerId(namespace: .max, id: PeerId.Id._internalFromInt64Value(0)), accessHash: nil, firstName: "", lastName: "", username: nil, phone: nil, photo: [], botInfo: nil, restrictionInfo: nil, flags: []) for i in 0 ..< count { entries.append(.importer(Int32(i), presentationData.theme, presentationData.dateTimeFormat, fakeUser, 0, true)) } diff --git a/submodules/LegacyComponents/PublicHeaders/LegacyComponents/HPGrowingTextView.h b/submodules/LegacyComponents/PublicHeaders/LegacyComponents/HPGrowingTextView.h index f5f84d3e67..1916a3f9fe 100644 --- a/submodules/LegacyComponents/PublicHeaders/LegacyComponents/HPGrowingTextView.h +++ b/submodules/LegacyComponents/PublicHeaders/LegacyComponents/HPGrowingTextView.h @@ -110,7 +110,7 @@ extern NSString *TGMentionBoldAttributeName; - (NSString *)textWithEntities:(__autoreleasing NSArray **)entities; -+ (void)replaceMention:(NSString *)mention inputField:(HPGrowingTextView *)inputField username:(bool)username userId:(int32_t)userId; ++ (void)replaceMention:(NSString *)mention inputField:(HPGrowingTextView *)inputField username:(bool)username userId:(int64_t)userId; + (void)replaceHashtag:(NSString *)hashtag inputField:(HPGrowingTextView *)inputField; @end diff --git a/submodules/LegacyComponents/PublicHeaders/LegacyComponents/TGLetteredAvatarView.h b/submodules/LegacyComponents/PublicHeaders/LegacyComponents/TGLetteredAvatarView.h index 4c3cc4a574..cb8f25175f 100644 --- a/submodules/LegacyComponents/PublicHeaders/LegacyComponents/TGLetteredAvatarView.h +++ b/submodules/LegacyComponents/PublicHeaders/LegacyComponents/TGLetteredAvatarView.h @@ -9,7 +9,7 @@ - (void)setTitleNeedsDisplay; -- (void)loadUserPlaceholderWithSize:(CGSize)size uid:(int)uid firstName:(NSString *)firstName lastName:(NSString *)lastName placeholder:(UIImage *)placeholder; +- (void)loadUserPlaceholderWithSize:(CGSize)size uid:(int64_t)uid firstName:(NSString *)firstName lastName:(NSString *)lastName placeholder:(UIImage *)placeholder; - (void)loadGroupPlaceholderWithSize:(CGSize)size conversationId:(int64_t)conversationId title:(NSString *)title placeholder:(UIImage *)placeholder; - (void)loadSavedMessagesWithSize:(CGSize)size placeholder:(UIImage *)placeholder; diff --git a/submodules/LegacyComponents/PublicHeaders/LegacyComponents/TGMediaOriginInfo.h b/submodules/LegacyComponents/PublicHeaders/LegacyComponents/TGMediaOriginInfo.h index 1a8f563283..bc8dc3ab2c 100644 --- a/submodules/LegacyComponents/PublicHeaders/LegacyComponents/TGMediaOriginInfo.h +++ b/submodules/LegacyComponents/PublicHeaders/LegacyComponents/TGMediaOriginInfo.h @@ -55,7 +55,7 @@ typedef enum { + (instancetype)mediaOriginInfoForFavoriteStickerWithFileReference:(NSData *)fileReference fileReferences:(NSDictionary *)fileReferences; + (instancetype)mediaOriginInfoForRecentGifWithFileReference:(NSData *)fileReference fileReferences:(NSDictionary *)fileReferences; + (instancetype)mediaOriginInfoForRecentMaskWithFileReference:(NSData *)fileReference fileReferences:(NSDictionary *)fileReferences; -+ (instancetype)mediaOriginInfoWithFileReference:(NSData *)fileReference fileReferences:(NSDictionary *)fileReferences userId:(int32_t)userId offset:(int32_t)offset; ++ (instancetype)mediaOriginInfoWithFileReference:(NSData *)fileReference fileReferences:(NSDictionary *)fileReferences userId:(int64_t)userId offset:(int32_t)offset; + (instancetype)mediaOriginInfoWithFileReference:(NSData *)fileReference fileReferences:(NSDictionary *)fileReferences url:(NSString *)url; + (instancetype)mediaOriginInfoWithFileReference:(NSData *)fileReference fileReferences:(NSDictionary *)fileReferences peerId:(int64_t)peerId; + (instancetype)mediaOriginInfoWithFileReferences:(NSDictionary *)fileReferences wallpaperId:(int32_t)wallpaperId; diff --git a/submodules/LegacyComponents/PublicHeaders/LegacyComponents/TGMediaPickerCaptionInputPanel.h b/submodules/LegacyComponents/PublicHeaders/LegacyComponents/TGMediaPickerCaptionInputPanel.h index 3f8530a4b6..d58441d07a 100644 --- a/submodules/LegacyComponents/PublicHeaders/LegacyComponents/TGMediaPickerCaptionInputPanel.h +++ b/submodules/LegacyComponents/PublicHeaders/LegacyComponents/TGMediaPickerCaptionInputPanel.h @@ -22,7 +22,7 @@ - (void)setCollapsed:(bool)collapsed animated:(bool)animated; - (void)replaceMention:(NSString *)mention; -- (void)replaceMention:(NSString *)mention username:(bool)username userId:(int32_t)userId; +- (void)replaceMention:(NSString *)mention username:(bool)username userId:(int64_t)userId; - (void)replaceHashtag:(NSString *)hashtag; - (void)adjustForOrientation:(UIInterfaceOrientation)orientation keyboardHeight:(CGFloat)keyboardHeight duration:(NSTimeInterval)duration animationCurve:(NSInteger)animationCurve; diff --git a/submodules/LegacyComponents/PublicHeaders/LegacyComponents/TGUser.h b/submodules/LegacyComponents/PublicHeaders/LegacyComponents/TGUser.h index 8a23f9cf54..09ba58b166 100644 --- a/submodules/LegacyComponents/PublicHeaders/LegacyComponents/TGUser.h +++ b/submodules/LegacyComponents/PublicHeaders/LegacyComponents/TGUser.h @@ -66,7 +66,7 @@ typedef enum { @interface TGUser : NSObject -@property (nonatomic) int uid; +@property (nonatomic) int64_t uid; @property (nonatomic, strong) NSString *phoneNumber; @property (nonatomic) int64_t phoneNumberHash; @property (nonatomic, strong) NSString *firstName; diff --git a/submodules/LegacyComponents/Sources/HPGrowingTextView.m b/submodules/LegacyComponents/Sources/HPGrowingTextView.m index 99e53f2370..bb93dba309 100644 --- a/submodules/LegacyComponents/Sources/HPGrowingTextView.m +++ b/submodules/LegacyComponents/Sources/HPGrowingTextView.m @@ -805,7 +805,7 @@ NSString *TGMentionBoldAttributeName = @"TGMentionBoldAttributeName"; return string.string; } -+ (void)replaceMention:(NSString *)mention inputField:(HPGrowingTextView *)inputField username:(bool)username userId:(int32_t)userId ++ (void)replaceMention:(NSString *)mention inputField:(HPGrowingTextView *)inputField username:(bool)username userId:(int64_t)userId { NSString *replacementText = [mention stringByAppendingString:@" "]; diff --git a/submodules/LegacyComponents/Sources/TGLetteredAvatarView.m b/submodules/LegacyComponents/Sources/TGLetteredAvatarView.m index fcdc4ea406..8bfa451d48 100644 --- a/submodules/LegacyComponents/Sources/TGLetteredAvatarView.m +++ b/submodules/LegacyComponents/Sources/TGLetteredAvatarView.m @@ -158,7 +158,7 @@ static bool isEmojiCharacter(NSString *singleChar) _label.hidden = true; } -- (void)loadUserPlaceholderWithSize:(CGSize)size uid:(int)uid firstName:(NSString *)firstName lastName:(NSString *)lastName placeholder:(UIImage *)placeholder +- (void)loadUserPlaceholderWithSize:(CGSize)size uid:(int64_t)uid firstName:(NSString *)firstName lastName:(NSString *)lastName placeholder:(UIImage *)placeholder { _label.font = _doubleFont; _usingSingleFont = false; diff --git a/submodules/LegacyComponents/Sources/TGMediaOriginInfo.m b/submodules/LegacyComponents/Sources/TGMediaOriginInfo.m index b7b62db4d2..0a62731f5f 100644 --- a/submodules/LegacyComponents/Sources/TGMediaOriginInfo.m +++ b/submodules/LegacyComponents/Sources/TGMediaOriginInfo.m @@ -275,7 +275,7 @@ return info; } -+ (instancetype)mediaOriginInfoWithFileReference:(NSData *)fileReference fileReferences:(NSDictionary *)fileReferences userId:(int32_t)userId offset:(int32_t)offset ++ (instancetype)mediaOriginInfoWithFileReference:(NSData *)fileReference fileReferences:(NSDictionary *)fileReferences userId:(int64_t)userId offset:(int32_t)offset { TGMediaOriginInfo *info = [[TGMediaOriginInfo alloc] init]; info->_type = TGMediaOriginTypeProfilePhoto; diff --git a/submodules/LegacyComponents/Sources/TGMediaPickerCaptionInputPanel.m b/submodules/LegacyComponents/Sources/TGMediaPickerCaptionInputPanel.m index 446bccd311..de6fc90aa8 100644 --- a/submodules/LegacyComponents/Sources/TGMediaPickerCaptionInputPanel.m +++ b/submodules/LegacyComponents/Sources/TGMediaPickerCaptionInputPanel.m @@ -815,7 +815,7 @@ static void setViewFrame(UIView *view, CGRect frame) [HPGrowingTextView replaceMention:mention inputField:_inputField username:true userId:0]; } -- (void)replaceMention:(NSString *)mention username:(bool)username userId:(int32_t)userId { +- (void)replaceMention:(NSString *)mention username:(bool)username userId:(int64_t)userId { [HPGrowingTextView replaceMention:mention inputField:_inputField username:username userId:userId]; } diff --git a/submodules/LegacyMediaPickerUI/Sources/LegacySuggestionContext.swift b/submodules/LegacyMediaPickerUI/Sources/LegacySuggestionContext.swift index 04ae6c6b7a..d2803cf30e 100644 --- a/submodules/LegacyMediaPickerUI/Sources/LegacySuggestionContext.swift +++ b/submodules/LegacyMediaPickerUI/Sources/LegacySuggestionContext.swift @@ -18,7 +18,7 @@ public func legacySuggestionContext(context: AccountContext, peerId: PeerId, cha for peer in peers { if case let .user(peer) = peer { let user = TGUser() - user.uid = peer.id.id._internalGetInt32Value() + user.uid = peer.id.id._internalGetInt64Value() user.firstName = peer.firstName user.lastName = peer.lastName user.userName = peer.addressName diff --git a/submodules/LegacyUI/Sources/LegacyPeerAvatarPlaceholderDataSource.swift b/submodules/LegacyUI/Sources/LegacyPeerAvatarPlaceholderDataSource.swift index b3342df14a..847b4f7b92 100644 --- a/submodules/LegacyUI/Sources/LegacyPeerAvatarPlaceholderDataSource.swift +++ b/submodules/LegacyUI/Sources/LegacyPeerAvatarPlaceholderDataSource.swift @@ -62,10 +62,10 @@ final class LegacyPeerAvatarPlaceholderDataSource: TGImageDataSource { var peerId = PeerId(0) - if let uid = args["uid"] as? String, let nUid = Int32(uid) { - peerId = PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt32Value(nUid)) - } else if let cid = args["cid"] as? String, let nCid = Int32(cid) { - peerId = PeerId(namespace: Namespaces.Peer.CloudGroup, id: PeerId.Id._internalFromInt32Value(nCid)) + if let uid = args["uid"] as? String, let nUid = Int64(uid) { + peerId = PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt64Value(nUid)) + } else if let cid = args["cid"] as? String, let nCid = Int64(cid) { + peerId = PeerId(namespace: Namespaces.Peer.CloudGroup, id: PeerId.Id._internalFromInt64Value(nCid)) } let image = generateImage(CGSize(width: CGFloat(width), height: CGFloat(height)), rotatedContext: { size, context in @@ -76,10 +76,10 @@ final class LegacyPeerAvatarPlaceholderDataSource: TGImageDataSource { context.clip() let colorIndex: Int - if peerId.id._internalGetInt32Value() == 0 { + if peerId.id._internalGetInt64Value() == 0 { colorIndex = -1 } else { - colorIndex = abs(Int(account.peerId.id._internalGetInt32Value() &+ peerId.id._internalGetInt32Value())) + colorIndex = abs(Int(clamping: account.peerId.id._internalGetInt64Value() &+ peerId.id._internalGetInt64Value())) } let colorsArray: NSArray diff --git a/submodules/LocationUI/Sources/LocationPickerController.swift b/submodules/LocationUI/Sources/LocationPickerController.swift index 9219dbf559..e6848a0c04 100644 --- a/submodules/LocationUI/Sources/LocationPickerController.swift +++ b/submodules/LocationUI/Sources/LocationPickerController.swift @@ -70,11 +70,11 @@ public final class LocationPickerController: ViewController { private var interaction: LocationPickerInteraction? - public init(context: AccountContext, mode: LocationPickerMode, completion: @escaping (TelegramMediaMap, String?) -> Void) { + public init(context: AccountContext, updatedPresentationData: (initial: PresentationData, signal: Signal)? = nil, mode: LocationPickerMode, completion: @escaping (TelegramMediaMap, String?) -> Void) { self.context = context self.mode = mode self.completion = completion - self.presentationData = context.sharedContext.currentPresentationData.with { $0 } + self.presentationData = updatedPresentationData?.initial ?? context.sharedContext.currentPresentationData.with { $0 } super.init(navigationBarPresentationData: NavigationBarPresentationData(theme: NavigationBarTheme(rootControllerTheme: self.presentationData.theme).withUpdatedSeparatorColor(.clear), strings: NavigationBarStrings(presentationStrings: self.presentationData.strings))) @@ -85,7 +85,7 @@ public final class LocationPickerController: ViewController { self.navigationItem.rightBarButtonItem = UIBarButtonItem(image: PresentationResourcesRootController.navigationCompactSearchIcon(self.presentationData.theme), style: .plain, target: self, action: #selector(self.searchPressed)) self.navigationItem.rightBarButtonItem?.accessibilityLabel = self.presentationData.strings.Common_Search - self.presentationDataDisposable = (context.sharedContext.presentationData + self.presentationDataDisposable = ((updatedPresentationData?.signal ?? context.sharedContext.presentationData) |> deliverOnMainQueue).start(next: { [weak self] presentationData in guard let strongSelf = self, strongSelf.presentationData.theme !== presentationData.theme else { return diff --git a/submodules/LocationUI/Sources/LocationViewController.swift b/submodules/LocationUI/Sources/LocationViewController.swift index 8f212aeed8..081f6a936b 100644 --- a/submodules/LocationUI/Sources/LocationViewController.swift +++ b/submodules/LocationUI/Sources/LocationViewController.swift @@ -85,12 +85,12 @@ public final class LocationViewController: ViewController { private var rightBarButtonAction: LocationViewRightBarButton = .none - public init(context: AccountContext, subject: Message, params: LocationViewParams) { + public init(context: AccountContext, updatedPresentationData: (initial: PresentationData, signal: Signal)? = nil, subject: Message, params: LocationViewParams) { self.context = context self.subject = subject self.showAll = params.showAll - self.presentationData = context.sharedContext.currentPresentationData.with { $0 } + self.presentationData = updatedPresentationData?.initial ?? context.sharedContext.currentPresentationData.with { $0 } super.init(navigationBarPresentationData: NavigationBarPresentationData(theme: NavigationBarTheme(rootControllerTheme: self.presentationData.theme).withUpdatedSeparatorColor(.clear), strings: NavigationBarStrings(presentationStrings: self.presentationData.strings))) @@ -99,7 +99,7 @@ public final class LocationViewController: ViewController { self.title = self.presentationData.strings.Map_LocationTitle self.navigationItem.leftBarButtonItem = UIBarButtonItem(title: self.presentationData.strings.Common_Close, style: .plain, target: self, action: #selector(self.cancelPressed)) - self.presentationDataDisposable = (context.sharedContext.presentationData + self.presentationDataDisposable = ((updatedPresentationData?.signal ?? context.sharedContext.presentationData) |> deliverOnMainQueue).start(next: { [weak self] presentationData in guard let strongSelf = self, strongSelf.presentationData.theme !== presentationData.theme else { return diff --git a/submodules/MediaResources/Sources/CachedResourceRepresentations.swift b/submodules/MediaResources/Sources/CachedResourceRepresentations.swift index 54f11eb402..d087dc0340 100644 --- a/submodules/MediaResources/Sources/CachedResourceRepresentations.swift +++ b/submodules/MediaResources/Sources/CachedResourceRepresentations.swift @@ -293,3 +293,22 @@ public final class CachedAnimatedStickerRepresentation: CachedMediaResourceRepre } } } + +public final class CachedPreparedPatternWallpaperRepresentation: CachedMediaResourceRepresentation { + public let keepDuration: CachedMediaRepresentationKeepDuration = .general + + public var uniqueId: String { + return "prepared-pattern-wallpaper" + } + + public init() { + } + + public func isEqual(to: CachedMediaResourceRepresentation) -> Bool { + if to is CachedPreparedPatternWallpaperRepresentation { + return true + } else { + return false + } + } +} diff --git a/submodules/MtProtoKit/PublicHeaders/MtProtoKit/MTExportedAuthorizationData.h b/submodules/MtProtoKit/PublicHeaders/MtProtoKit/MTExportedAuthorizationData.h index e22992dc38..5570ba9f47 100644 --- a/submodules/MtProtoKit/PublicHeaders/MtProtoKit/MTExportedAuthorizationData.h +++ b/submodules/MtProtoKit/PublicHeaders/MtProtoKit/MTExportedAuthorizationData.h @@ -3,8 +3,8 @@ @interface MTExportedAuthorizationData : NSObject @property (nonatomic, strong, readonly) NSData *authorizationBytes; -@property (nonatomic, readonly) int32_t authorizationId; +@property (nonatomic, readonly) int64_t authorizationId; -- (instancetype)initWithAuthorizationBytes:(NSData *)authorizationBytes authorizationId:(int32_t)authorizationId; +- (instancetype)initWithAuthorizationBytes:(NSData *)authorizationBytes authorizationId:(int64_t)authorizationId; @end diff --git a/submodules/MtProtoKit/PublicHeaders/MtProtoKit/MTSerialization.h b/submodules/MtProtoKit/PublicHeaders/MtProtoKit/MTSerialization.h index bc197ee876..d08cd0faf0 100644 --- a/submodules/MtProtoKit/PublicHeaders/MtProtoKit/MTSerialization.h +++ b/submodules/MtProtoKit/PublicHeaders/MtProtoKit/MTSerialization.h @@ -18,7 +18,7 @@ typedef id (^MTRequestNoopParser)(NSData *); - (id)parseMessage:(NSData *)data; - (MTExportAuthorizationResponseParser)exportAuthorization:(int32_t)datacenterId data:(__autoreleasing NSData **)data; -- (NSData *)importAuthorization:(int32_t)authId bytes:(NSData *)bytes; +- (NSData *)importAuthorization:(int64_t)authId bytes:(NSData *)bytes; - (MTRequestDatacenterAddressListParser)requestDatacenterAddressWithData:(__autoreleasing NSData **)data; - (MTRequestNoopParser)requestNoop:(__autoreleasing NSData **)data; diff --git a/submodules/MtProtoKit/Sources/AFHTTPRequestOperation.m b/submodules/MtProtoKit/Sources/AFHTTPRequestOperation.m index 325f4928a9..3fb45e3f85 100644 --- a/submodules/MtProtoKit/Sources/AFHTTPRequestOperation.m +++ b/submodules/MtProtoKit/Sources/AFHTTPRequestOperation.m @@ -113,7 +113,7 @@ static NSString * AFStringFromIndexSet(NSIndexSet *indexSet) { } - (BOOL)hasAcceptableStatusCode { - return !self.acceptableStatusCodes || [self.acceptableStatusCodes containsIndex:[self.response statusCode]]; + return !self.acceptableStatusCodes || [self.acceptableStatusCodes containsIndex:(NSUInteger)[self.response statusCode]]; } - (BOOL)hasAcceptableContentType { diff --git a/submodules/MtProtoKit/Sources/MTBindKeyMessageService.m b/submodules/MtProtoKit/Sources/MTBindKeyMessageService.m index 96d723d844..54eef47d40 100644 --- a/submodules/MtProtoKit/Sources/MTBindKeyMessageService.m +++ b/submodules/MtProtoKit/Sources/MTBindKeyMessageService.m @@ -10,6 +10,8 @@ #import #import #import +#import +#import #import "MTInternalMessageParser.h" #import "MTRpcResultMessage.h" #import "MTBuffer.h" @@ -142,6 +144,14 @@ if (rpcResultMessage.data.length >= 4) { uint32_t signature = 0; [rpcResultMessage.data getBytes:&signature range:NSMakeRange(0, 4)]; + + id parsedMessage = [MTInternalMessageParser parseMessage:rpcResultMessage.data]; + if ([parsedMessage isKindOfClass:[MTRpcError class]]) { + if (MTLogEnabled()) { + MTRpcError *rpcError = (MTRpcError *)parsedMessage; + MTLog(@"[MTRequestMessageService#%p response for %" PRId64 " is error: %d: %@]", self, _currentMessageId, (int)rpcError.errorCode, rpcError.errorDescription); + } + } //boolTrue#997275b5 = Bool; if (signature == 0x997275b5U) { diff --git a/submodules/MtProtoKit/Sources/MTDatacenterTransferAuthAction.m b/submodules/MtProtoKit/Sources/MTDatacenterTransferAuthAction.m index 9cfccea07d..cf1740f7af 100644 --- a/submodules/MtProtoKit/Sources/MTDatacenterTransferAuthAction.m +++ b/submodules/MtProtoKit/Sources/MTDatacenterTransferAuthAction.m @@ -116,7 +116,7 @@ [requestService addRequest:request]; } -- (void)beginTransferWithId:(int32_t)dataId data:(NSData *)authData +- (void)beginTransferWithId:(int64_t)dataId data:(NSData *)authData { [_sourceDatacenterMtProto stop]; _sourceDatacenterMtProto = nil; diff --git a/submodules/MtProtoKit/Sources/MTExportedAuthorizationData.m b/submodules/MtProtoKit/Sources/MTExportedAuthorizationData.m index 9b4933d791..9cdc6fd3cd 100644 --- a/submodules/MtProtoKit/Sources/MTExportedAuthorizationData.m +++ b/submodules/MtProtoKit/Sources/MTExportedAuthorizationData.m @@ -2,7 +2,7 @@ @implementation MTExportedAuthorizationData -- (instancetype)initWithAuthorizationBytes:(NSData *)authorizationBytes authorizationId:(int32_t)authorizationId +- (instancetype)initWithAuthorizationBytes:(NSData *)authorizationBytes authorizationId:(int64_t)authorizationId { self = [super init]; if (self != nil) diff --git a/submodules/MurMurHash32/Sources/MurMurHash32.m b/submodules/MurMurHash32/Sources/MurMurHash32.m index 9096171c74..afbf1d2f83 100644 --- a/submodules/MurMurHash32/Sources/MurMurHash32.m +++ b/submodules/MurMurHash32/Sources/MurMurHash32.m @@ -28,7 +28,7 @@ static FORCE_INLINE uint32_t fmix ( uint32_t h ) return h; } -static void murMurHash32Impl(const void *key, int len, uint32_t seed, void *out) +static void murMurHash32Impl(const void *key, uint32_t len, uint32_t seed, void *out) { const uint8_t * data = (const uint8_t*)key; const int nblocks = len / 4; diff --git a/submodules/PeerAvatarGalleryUI/Sources/PeerAvatarImageGalleryItem.swift b/submodules/PeerAvatarGalleryUI/Sources/PeerAvatarImageGalleryItem.swift index 8018f2d404..7c878bf1f2 100644 --- a/submodules/PeerAvatarGalleryUI/Sources/PeerAvatarImageGalleryItem.swift +++ b/submodules/PeerAvatarGalleryUI/Sources/PeerAvatarImageGalleryItem.swift @@ -256,7 +256,7 @@ final class PeerAvatarImageGalleryItemNode: ZoomableContentGalleryItemNode { id = mediaId.id category = categoryValue } else { - id = Int64(entry.peer?.id.id._internalGetInt32Value() ?? 0) + id = Int64(entry.peer?.id.id._internalGetInt64Value() ?? 0) if let resource = entry.videoRepresentations.first?.representation.resource as? CloudPhotoSizeMediaResource { id = id &+ resource.photoId } diff --git a/submodules/PeerInfoAvatarListNode/Sources/PeerInfoAvatarListNode.swift b/submodules/PeerInfoAvatarListNode/Sources/PeerInfoAvatarListNode.swift index 3e155545cf..a65e7a42bb 100644 --- a/submodules/PeerInfoAvatarListNode/Sources/PeerInfoAvatarListNode.swift +++ b/submodules/PeerInfoAvatarListNode/Sources/PeerInfoAvatarListNode.swift @@ -379,7 +379,7 @@ public final class PeerInfoAvatarListItemNode: ASDisplayNode { representations = topRepresentations videoRepresentations = videoRepresentationsValue immediateThumbnailData = immediateThumbnail - id = Int64(self.peer.id.id._internalGetInt32Value()) + id = self.peer.id.id._internalGetInt64Value() if let resource = videoRepresentations.first?.representation.resource as? CloudPhotoSizeMediaResource { id = id &+ resource.photoId } @@ -390,7 +390,7 @@ public final class PeerInfoAvatarListItemNode: ASDisplayNode { if case let .cloud(imageId, _, _) = reference { id = imageId } else { - id = Int64(self.peer.id.id._internalGetInt32Value()) + id = self.peer.id.id._internalGetInt64Value() } } self.imageNode.setSignal(chatAvatarGalleryPhoto(account: self.context.account, representations: representations, immediateThumbnailData: immediateThumbnailData, autoFetchFullSize: true, attemptSynchronously: synchronous, skipThumbnail: fullSizeOnly), attemptSynchronously: synchronous, dispatchOnDisplayLink: false) diff --git a/submodules/PeerInfoUI/Sources/DeviceContactInfoController.swift b/submodules/PeerInfoUI/Sources/DeviceContactInfoController.swift index 66ab2bbe42..1ea61bf2a2 100644 --- a/submodules/PeerInfoUI/Sources/DeviceContactInfoController.swift +++ b/submodules/PeerInfoUI/Sources/DeviceContactInfoController.swift @@ -652,7 +652,7 @@ private func deviceContactInfoEntries(account: Account, presentationData: Presen firstName = presentationData.strings.Message_Contact } - entries.append(.info(entries.count, presentationData.theme, presentationData.strings, presentationData.dateTimeFormat, peer: peer ?? TelegramUser(id: PeerId(namespace: .max, id: PeerId.Id._internalFromInt32Value(0)), accessHash: nil, firstName: firstName, lastName: isOrganization ? nil : personName.1, username: nil, phone: nil, photo: [], botInfo: nil, restrictionInfo: nil, flags: []), state: ItemListAvatarAndNameInfoItemState(editingName: editingName, updatingName: nil), job: isOrganization ? nil : jobSummary, isPlain: !isShare)) + entries.append(.info(entries.count, presentationData.theme, presentationData.strings, presentationData.dateTimeFormat, peer: peer ?? TelegramUser(id: PeerId(namespace: .max, id: PeerId.Id._internalFromInt64Value(0)), accessHash: nil, firstName: firstName, lastName: isOrganization ? nil : personName.1, username: nil, phone: nil, photo: [], botInfo: nil, restrictionInfo: nil, flags: []), state: ItemListAvatarAndNameInfoItemState(editingName: editingName, updatingName: nil), job: isOrganization ? nil : jobSummary, isPlain: !isShare)) if !selecting { if let _ = peer { diff --git a/submodules/Postbox/Sources/Peer.swift b/submodules/Postbox/Sources/Peer.swift index 3e8d30c338..6082c19029 100644 --- a/submodules/Postbox/Sources/Peer.swift +++ b/submodules/Postbox/Sources/Peer.swift @@ -60,7 +60,7 @@ public struct PeerId: Hashable, CustomStringConvertible, Comparable, Codable { return Id(rawValue: 0x000000007fffffff) } - fileprivate var rawValue: Int32 + fileprivate var rawValue: Int64 var predecessor: Id { if self.rawValue != 0 { @@ -82,17 +82,21 @@ public struct PeerId: Hashable, CustomStringConvertible, Comparable, Codable { return "\(self.rawValue)" } - fileprivate init(rawValue: Int32) { - //precondition((rawValue | 0x000FFFFFFFFFFFFF) == 0x000FFFFFFFFFFFFF) + fileprivate init(rawValue: Int64) { + if rawValue < 0 { + assert(abs(rawValue) == (abs(rawValue) & 0x007fffffffffffff)) + } else { + assert(abs(rawValue) == (abs(rawValue) & 0x00ffffffffffffff)) + } self.rawValue = rawValue } - public static func _internalFromInt32Value(_ value: Int32) -> Id { + public static func _internalFromInt64Value(_ value: Int64) -> Id { return Id(rawValue: value) } - public func _internalGetInt32Value() -> Int32 { + public func _internalGetInt64Value() -> Int64 { return self.rawValue } @@ -144,21 +148,37 @@ public struct PeerId: Hashable, CustomStringConvertible, Comparable, Codable { public init(_ n: Int64) { let data = UInt64(bitPattern: n) + // Bits: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + // |___________________________|__| |______________________________| + // id high bits (29) ns id low bits (32) + let legacyNamespaceBits = ((data >> 32) & 0xffffffff) let idLowBits = data & 0xffffffff if legacyNamespaceBits == 0x7fffffff && idLowBits == 0 { self.namespace = .max - self.id = Id(rawValue: Int32(bitPattern: UInt32(clamping: idLowBits))) + self.id = Id(rawValue: Int64(bitPattern: UInt64(clamping: idLowBits))) } else { + // 0x7 == 0b111 let namespaceBits = ((data >> 32) & 0x7) self.namespace = Namespace(rawValue: UInt32(namespaceBits)) - //let idHighBits = (data >> (32 + 3)) & 0xffffffff - //assert(idHighBits == 0) + let offsetIdHighBits = (data >> (32 + 3)) & 0xffffffff + let idHighBits = offsetIdHighBits << 32 - self.id = Id(rawValue: Int32(bitPattern: UInt32(clamping: idLowBits))) + if idHighBits == 0 { + if let uint32Value = UInt32(exactly: idLowBits) { + self.id = Id(rawValue: Int64(Int32(bitPattern: uint32Value))) + } else { + preconditionFailure() + } + } else { + let idAbs: UInt64 = idHighBits | idLowBits + self.id = Id(rawValue: Int64(bitPattern: idAbs)) + } } + + assert(self._toInt64() == n) } public init(from decoder: Decoder) throws { @@ -173,7 +193,26 @@ public struct PeerId: Hashable, CustomStringConvertible, Comparable, Codable { } public func toInt64() -> Int64 { - let idLowBits = UInt32(bitPattern: self.id.rawValue) + let result = self._toInt64() + assert(PeerId(result) == self) + return result + } + + private func _toInt64() -> Int64 { + let data: UInt64 + + if self.id.rawValue < 0 { + if let int32Value = Int32(exactly: self.id.rawValue) { + data = UInt64(UInt32(bitPattern: int32Value)) + } else { + preconditionFailure() + } + } else { + data = UInt64(bitPattern: self.id.rawValue) + } + + let idLowBits = data & 0xffffffff + let idHighBits = (data >> 32) & 0xffffffff let result: Int64 if self.namespace == .max && self.id.rawValue == 0 { @@ -181,25 +220,20 @@ public struct PeerId: Hashable, CustomStringConvertible, Comparable, Codable { let namespaceBits: UInt64 = 0x7fffffff data |= namespaceBits << 32 - - data |= UInt64(idLowBits) + data |= idLowBits result = Int64(bitPattern: data) } else { var data: UInt64 = 0 - data |= UInt64(self.namespace.rawValue) << 32 - - let idValue = UInt32(bitPattern: self.id.rawValue) - let idHighBits = (idValue >> 32) & 0x3FFFFFFF - assert(idHighBits == 0) - - data |= UInt64(idLowBits) + assert(self.namespace.rawValue & 0x7 == self.namespace.rawValue) + let offsetIdHighBits = idHighBits << (32 + 3) + data |= UInt64(self.namespace.rawValue & 0x7) << 32 + data |= offsetIdHighBits + data |= idLowBits result = Int64(bitPattern: data) } - assert(PeerId(result) == self) - return result } diff --git a/submodules/Postbox/Sources/PeerNotificationSettings.swift b/submodules/Postbox/Sources/PeerNotificationSettings.swift index f924ffbdd5..f7cd2d7b80 100644 --- a/submodules/Postbox/Sources/PeerNotificationSettings.swift +++ b/submodules/Postbox/Sources/PeerNotificationSettings.swift @@ -1,14 +1,6 @@ import Foundation -public class PeerNotificationSettingsDecodeHelper { - public let decode: (_ data: Data) -> PeerNotificationSettings? - - public init(decode: @escaping (_ data: Data) -> PeerNotificationSettings?) { - self.decode = decode - } -} - -public enum PeerNotificationSettingsBehavior { +public enum PeerNotificationSettingsBehavior: PostboxCoding { enum CodingKeys: String, CodingKey { case _case = "_v" case toValue @@ -18,14 +10,12 @@ public enum PeerNotificationSettingsBehavior { case none case reset(atTimestamp: Int32, toValue: PeerNotificationSettings) - public init(from decoder: Decoder, helper: PeerNotificationSettingsDecodeHelper) throws { - let container = try decoder.container(keyedBy: StringCodingKey.self) - + public init(decoder: PostboxDecoder) { switch decoder.decodeInt32ForKey("_v", orElse: 0) { case 0: self = .none case 1: - if let toValue = helper.decode(PeerNotificationSettings.self, forKey: "toValue") { + if let toValue = decoder.decodeObjectForKey("toValue") as? PeerNotificationSettings { self = .reset(atTimestamp: decoder.decodeInt32ForKey("atTimestamp", orElse: 0), toValue: toValue) } else { assertionFailure() @@ -44,15 +34,17 @@ public enum PeerNotificationSettingsBehavior { case let .reset(atTimestamp, toValue): encoder.encodeInt32(1, forKey: "_v") encoder.encodeInt32(atTimestamp, forKey: "atTimestamp") - encoder.encode(toValue, forKey: "toValue") + encoder.encodeObject(toValue, forKey: "toValue") } } } -public protocol PeerNotificationSettings: Codable { +public protocol PeerNotificationSettings: PostboxCoding { func isRemovedFromTotalUnreadCount(`default`: Bool) -> Bool var behavior: PeerNotificationSettingsBehavior { get } + + func isEqual(to other: PeerNotificationSettings) -> Bool } public final class PostboxGlobalNotificationSettings { diff --git a/submodules/SettingsUI/Sources/BubbleSettings/BubbleSettingsController.swift b/submodules/SettingsUI/Sources/BubbleSettings/BubbleSettingsController.swift index d49b8588aa..2c1ebf9cd2 100644 --- a/submodules/SettingsUI/Sources/BubbleSettings/BubbleSettingsController.swift +++ b/submodules/SettingsUI/Sources/BubbleSettings/BubbleSettingsController.swift @@ -159,7 +159,7 @@ private final class BubbleSettingsControllerNode: ASDisplayNode, UIScrollViewDel let headerItem = self.context.sharedContext.makeChatMessageDateHeaderItem(context: self.context, timestamp: self.referenceTimestamp, theme: self.presentationData.theme, strings: self.presentationData.strings, wallpaper: self.presentationData.chatWallpaper, fontSize: self.presentationData.chatFontSize, chatBubbleCorners: self.presentationData.chatBubbleCorners, dateTimeFormat: self.presentationData.dateTimeFormat, nameOrder: self.presentationData.nameDisplayOrder) var items: [ListViewItem] = [] - let peerId = PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt32Value(1)) + let peerId = PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt64Value(1)) let otherPeerId = self.context.account.peerId var peers = SimpleDictionary() var messages = SimpleDictionary() diff --git a/submodules/SettingsUI/Sources/Privacy and Security/ForwardPrivacyChatPreviewItem.swift b/submodules/SettingsUI/Sources/Privacy and Security/ForwardPrivacyChatPreviewItem.swift index 828478a78a..e9413858f4 100644 --- a/submodules/SettingsUI/Sources/Privacy and Security/ForwardPrivacyChatPreviewItem.swift +++ b/submodules/SettingsUI/Sources/Privacy and Security/ForwardPrivacyChatPreviewItem.swift @@ -140,7 +140,7 @@ class ForwardPrivacyChatPreviewItemNode: ListViewItemNode { let insets: UIEdgeInsets let separatorHeight = UIScreenPixel - let peerId = PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt32Value(1)) + let peerId = PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt64Value(1)) var peers = SimpleDictionary() let messages = SimpleDictionary() diff --git a/submodules/SettingsUI/Sources/Text Size/TextSizeSelectionController.swift b/submodules/SettingsUI/Sources/Text Size/TextSizeSelectionController.swift index ceefe04ed2..a72209d63b 100644 --- a/submodules/SettingsUI/Sources/Text Size/TextSizeSelectionController.swift +++ b/submodules/SettingsUI/Sources/Text Size/TextSizeSelectionController.swift @@ -220,13 +220,13 @@ private final class TextSizeSelectionControllerNode: ASDisplayNode, UIScrollView let peers = SimpleDictionary() let messages = SimpleDictionary() let selfPeer = TelegramUser(id: self.context.account.peerId, accessHash: nil, firstName: nil, lastName: nil, username: nil, phone: nil, photo: [], botInfo: nil, restrictionInfo: nil, flags: []) - let peer1 = TelegramUser(id: PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt32Value(1)), accessHash: nil, firstName: self.presentationData.strings.Appearance_ThemePreview_ChatList_1_Name, lastName: nil, username: nil, phone: nil, photo: [], botInfo: nil, restrictionInfo: nil, flags: []) - let peer2 = TelegramUser(id: PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt32Value(2)), accessHash: nil, firstName: self.presentationData.strings.Appearance_ThemePreview_ChatList_2_Name, lastName: nil, username: nil, phone: nil, photo: [], botInfo: nil, restrictionInfo: nil, flags: []) - let peer3 = TelegramChannel(id: PeerId(namespace: Namespaces.Peer.CloudChannel, id: PeerId.Id._internalFromInt32Value(3)), accessHash: nil, title: self.presentationData.strings.Appearance_ThemePreview_ChatList_3_Name, username: nil, photo: [], creationDate: 0, version: 0, participationStatus: .member, info: .group(.init(flags: [])), flags: [], restrictionInfo: nil, adminRights: nil, bannedRights: nil, defaultBannedRights: nil) - let peer3Author = TelegramUser(id: PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt32Value(4)), accessHash: nil, firstName: self.presentationData.strings.Appearance_ThemePreview_ChatList_3_AuthorName, lastName: nil, username: nil, phone: nil, photo: [], botInfo: nil, restrictionInfo: nil, flags: []) - let peer4 = TelegramUser(id: PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt32Value(4)), accessHash: nil, firstName: self.presentationData.strings.Appearance_ThemePreview_ChatList_4_Name, lastName: nil, username: nil, phone: nil, photo: [], botInfo: nil, restrictionInfo: nil, flags: []) - let peer5 = TelegramChannel(id: PeerId(namespace: Namespaces.Peer.CloudChannel, id: PeerId.Id._internalFromInt32Value(5)), accessHash: nil, title: self.presentationData.strings.Appearance_ThemePreview_ChatList_5_Name, username: nil, photo: [], creationDate: 0, version: 0, participationStatus: .member, info: .broadcast(.init(flags: [])), flags: [], restrictionInfo: nil, adminRights: nil, bannedRights: nil, defaultBannedRights: nil) - let peer6 = TelegramUser(id: PeerId(namespace: Namespaces.Peer.SecretChat, id: PeerId.Id._internalFromInt32Value(5)), accessHash: nil, firstName: self.presentationData.strings.Appearance_ThemePreview_ChatList_6_Name, lastName: nil, username: nil, phone: nil, photo: [], botInfo: nil, restrictionInfo: nil, flags: []) + let peer1 = TelegramUser(id: PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt64Value(1)), accessHash: nil, firstName: self.presentationData.strings.Appearance_ThemePreview_ChatList_1_Name, lastName: nil, username: nil, phone: nil, photo: [], botInfo: nil, restrictionInfo: nil, flags: []) + let peer2 = TelegramUser(id: PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt64Value(2)), accessHash: nil, firstName: self.presentationData.strings.Appearance_ThemePreview_ChatList_2_Name, lastName: nil, username: nil, phone: nil, photo: [], botInfo: nil, restrictionInfo: nil, flags: []) + let peer3 = TelegramChannel(id: PeerId(namespace: Namespaces.Peer.CloudChannel, id: PeerId.Id._internalFromInt64Value(3)), accessHash: nil, title: self.presentationData.strings.Appearance_ThemePreview_ChatList_3_Name, username: nil, photo: [], creationDate: 0, version: 0, participationStatus: .member, info: .group(.init(flags: [])), flags: [], restrictionInfo: nil, adminRights: nil, bannedRights: nil, defaultBannedRights: nil) + let peer3Author = TelegramUser(id: PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt64Value(4)), accessHash: nil, firstName: self.presentationData.strings.Appearance_ThemePreview_ChatList_3_AuthorName, lastName: nil, username: nil, phone: nil, photo: [], botInfo: nil, restrictionInfo: nil, flags: []) + let peer4 = TelegramUser(id: PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt64Value(4)), accessHash: nil, firstName: self.presentationData.strings.Appearance_ThemePreview_ChatList_4_Name, lastName: nil, username: nil, phone: nil, photo: [], botInfo: nil, restrictionInfo: nil, flags: []) + let peer5 = TelegramChannel(id: PeerId(namespace: Namespaces.Peer.CloudChannel, id: PeerId.Id._internalFromInt64Value(5)), accessHash: nil, title: self.presentationData.strings.Appearance_ThemePreview_ChatList_5_Name, username: nil, photo: [], creationDate: 0, version: 0, participationStatus: .member, info: .broadcast(.init(flags: [])), flags: [], restrictionInfo: nil, adminRights: nil, bannedRights: nil, defaultBannedRights: nil) + let peer6 = TelegramUser(id: PeerId(namespace: Namespaces.Peer.SecretChat, id: PeerId.Id._internalFromInt64Value(5)), accessHash: nil, firstName: self.presentationData.strings.Appearance_ThemePreview_ChatList_6_Name, lastName: nil, username: nil, phone: nil, photo: [], botInfo: nil, restrictionInfo: nil, flags: []) let timestamp = self.referenceTimestamp @@ -304,7 +304,7 @@ private final class TextSizeSelectionControllerNode: ASDisplayNode, UIScrollView let headerItem = self.context.sharedContext.makeChatMessageDateHeaderItem(context: self.context, timestamp: self.referenceTimestamp, theme: self.presentationData.theme, strings: self.presentationData.strings, wallpaper: self.presentationData.chatWallpaper, fontSize: self.presentationData.chatFontSize, chatBubbleCorners: self.presentationData.chatBubbleCorners, dateTimeFormat: self.presentationData.dateTimeFormat, nameOrder: self.presentationData.nameDisplayOrder) var items: [ListViewItem] = [] - let peerId = PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt32Value(1)) + let peerId = PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt64Value(1)) let otherPeerId = self.context.account.peerId var peers = SimpleDictionary() var messages = SimpleDictionary() diff --git a/submodules/SettingsUI/Sources/Themes/ThemeAccentColorControllerNode.swift b/submodules/SettingsUI/Sources/Themes/ThemeAccentColorControllerNode.swift index 78e5ea4337..0c4c034718 100644 --- a/submodules/SettingsUI/Sources/Themes/ThemeAccentColorControllerNode.swift +++ b/submodules/SettingsUI/Sources/Themes/ThemeAccentColorControllerNode.swift @@ -818,11 +818,11 @@ final class ThemeAccentColorControllerNode: ASDisplayNode, UIScrollViewDelegate let peers = SimpleDictionary() let messages = SimpleDictionary() let selfPeer = TelegramUser(id: self.context.account.peerId, accessHash: nil, firstName: nil, lastName: nil, username: nil, phone: nil, photo: [], botInfo: nil, restrictionInfo: nil, flags: []) - let peer1 = TelegramUser(id: PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt32Value(1)), accessHash: nil, firstName: self.presentationData.strings.Appearance_ThemePreview_ChatList_1_Name, lastName: nil, username: nil, phone: nil, photo: [], botInfo: nil, restrictionInfo: nil, flags: []) - let peer2 = TelegramUser(id: PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt32Value(2)), accessHash: nil, firstName: self.presentationData.strings.Appearance_ThemePreview_ChatList_2_Name, lastName: nil, username: nil, phone: nil, photo: [], botInfo: nil, restrictionInfo: nil, flags: []) - let peer3 = TelegramChannel(id: PeerId(namespace: Namespaces.Peer.CloudChannel, id: PeerId.Id._internalFromInt32Value(3)), accessHash: nil, title: self.presentationData.strings.Appearance_ThemePreview_ChatList_3_Name, username: nil, photo: [], creationDate: 0, version: 0, participationStatus: .member, info: .group(.init(flags: [])), flags: [], restrictionInfo: nil, adminRights: nil, bannedRights: nil, defaultBannedRights: nil) - let peer3Author = TelegramUser(id: PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt32Value(4)), accessHash: nil, firstName: self.presentationData.strings.Appearance_ThemePreview_ChatList_3_AuthorName, lastName: nil, username: nil, phone: nil, photo: [], botInfo: nil, restrictionInfo: nil, flags: []) - let peer4 = TelegramUser(id: PeerId(namespace: Namespaces.Peer.SecretChat, id: PeerId.Id._internalFromInt32Value(4)), accessHash: nil, firstName: self.presentationData.strings.Appearance_ThemePreview_ChatList_4_Name, lastName: nil, username: nil, phone: nil, photo: [], botInfo: nil, restrictionInfo: nil, flags: []) + let peer1 = TelegramUser(id: PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt64Value(1)), accessHash: nil, firstName: self.presentationData.strings.Appearance_ThemePreview_ChatList_1_Name, lastName: nil, username: nil, phone: nil, photo: [], botInfo: nil, restrictionInfo: nil, flags: []) + let peer2 = TelegramUser(id: PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt64Value(2)), accessHash: nil, firstName: self.presentationData.strings.Appearance_ThemePreview_ChatList_2_Name, lastName: nil, username: nil, phone: nil, photo: [], botInfo: nil, restrictionInfo: nil, flags: []) + let peer3 = TelegramChannel(id: PeerId(namespace: Namespaces.Peer.CloudChannel, id: PeerId.Id._internalFromInt64Value(3)), accessHash: nil, title: self.presentationData.strings.Appearance_ThemePreview_ChatList_3_Name, username: nil, photo: [], creationDate: 0, version: 0, participationStatus: .member, info: .group(.init(flags: [])), flags: [], restrictionInfo: nil, adminRights: nil, bannedRights: nil, defaultBannedRights: nil) + let peer3Author = TelegramUser(id: PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt64Value(4)), accessHash: nil, firstName: self.presentationData.strings.Appearance_ThemePreview_ChatList_3_AuthorName, lastName: nil, username: nil, phone: nil, photo: [], botInfo: nil, restrictionInfo: nil, flags: []) + let peer4 = TelegramUser(id: PeerId(namespace: Namespaces.Peer.SecretChat, id: PeerId.Id._internalFromInt64Value(4)), accessHash: nil, firstName: self.presentationData.strings.Appearance_ThemePreview_ChatList_4_Name, lastName: nil, username: nil, phone: nil, photo: [], botInfo: nil, restrictionInfo: nil, flags: []) let timestamp = self.referenceTimestamp @@ -884,7 +884,7 @@ final class ThemeAccentColorControllerNode: ASDisplayNode, UIScrollViewDelegate let headerItem = self.context.sharedContext.makeChatMessageDateHeaderItem(context: self.context, timestamp: self.referenceTimestamp, theme: self.theme, strings: self.presentationData.strings, wallpaper: self.wallpaper, fontSize: self.presentationData.chatFontSize, chatBubbleCorners: self.presentationData.chatBubbleCorners, dateTimeFormat: self.presentationData.dateTimeFormat, nameOrder: self.presentationData.nameDisplayOrder) var items: [ListViewItem] = [] - let peerId = PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt32Value(1)) + let peerId = PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt64Value(1)) let otherPeerId = self.context.account.peerId var peers = SimpleDictionary() var messages = SimpleDictionary() diff --git a/submodules/SettingsUI/Sources/Themes/ThemePreviewControllerNode.swift b/submodules/SettingsUI/Sources/Themes/ThemePreviewControllerNode.swift index 3cf8104a6d..270c9d715f 100644 --- a/submodules/SettingsUI/Sources/Themes/ThemePreviewControllerNode.swift +++ b/submodules/SettingsUI/Sources/Themes/ThemePreviewControllerNode.swift @@ -365,14 +365,14 @@ final class ThemePreviewControllerNode: ASDisplayNode, UIScrollViewDelegate { let peers = SimpleDictionary() let messages = SimpleDictionary() let selfPeer = TelegramUser(id: self.context.account.peerId, accessHash: nil, firstName: nil, lastName: nil, username: nil, phone: nil, photo: [], botInfo: nil, restrictionInfo: nil, flags: []) - let peer1 = TelegramUser(id: PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt32Value(1)), accessHash: nil, firstName: self.presentationData.strings.Appearance_ThemePreview_ChatList_1_Name, lastName: nil, username: nil, phone: nil, photo: [], botInfo: nil, restrictionInfo: nil, flags: []) - let peer2 = TelegramUser(id: PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt32Value(2)), accessHash: nil, firstName: self.presentationData.strings.Appearance_ThemePreview_ChatList_2_Name, lastName: nil, username: nil, phone: nil, photo: [], botInfo: nil, restrictionInfo: nil, flags: []) - let peer3 = TelegramChannel(id: PeerId(namespace: Namespaces.Peer.CloudChannel, id: PeerId.Id._internalFromInt32Value(3)), accessHash: nil, title: self.presentationData.strings.Appearance_ThemePreview_ChatList_3_Name, username: nil, photo: [], creationDate: 0, version: 0, participationStatus: .member, info: .group(.init(flags: [])), flags: [], restrictionInfo: nil, adminRights: nil, bannedRights: nil, defaultBannedRights: nil) - let peer3Author = TelegramUser(id: PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt32Value(4)), accessHash: nil, firstName: self.presentationData.strings.Appearance_ThemePreview_ChatList_3_AuthorName, lastName: nil, username: nil, phone: nil, photo: [], botInfo: nil, restrictionInfo: nil, flags: []) - let peer4 = TelegramUser(id: PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt32Value(4)), accessHash: nil, firstName: self.presentationData.strings.Appearance_ThemePreview_ChatList_4_Name, lastName: nil, username: nil, phone: nil, photo: [], botInfo: nil, restrictionInfo: nil, flags: []) - let peer5 = TelegramChannel(id: PeerId(namespace: Namespaces.Peer.CloudChannel, id: PeerId.Id._internalFromInt32Value(5)), accessHash: nil, title: self.presentationData.strings.Appearance_ThemePreview_ChatList_5_Name, username: nil, photo: [], creationDate: 0, version: 0, participationStatus: .member, info: .broadcast(.init(flags: [])), flags: [], restrictionInfo: nil, adminRights: nil, bannedRights: nil, defaultBannedRights: nil) - let peer6 = TelegramUser(id: PeerId(namespace: Namespaces.Peer.SecretChat, id: PeerId.Id._internalFromInt32Value(5)), accessHash: nil, firstName: self.presentationData.strings.Appearance_ThemePreview_ChatList_6_Name, lastName: nil, username: nil, phone: nil, photo: [], botInfo: nil, restrictionInfo: nil, flags: []) - let peer7 = TelegramUser(id: PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt32Value(6)), accessHash: nil, firstName: self.presentationData.strings.Appearance_ThemePreview_ChatList_7_Name, lastName: nil, username: nil, phone: nil, photo: [], botInfo: nil, restrictionInfo: nil, flags: []) + let peer1 = TelegramUser(id: PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt64Value(1)), accessHash: nil, firstName: self.presentationData.strings.Appearance_ThemePreview_ChatList_1_Name, lastName: nil, username: nil, phone: nil, photo: [], botInfo: nil, restrictionInfo: nil, flags: []) + let peer2 = TelegramUser(id: PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt64Value(2)), accessHash: nil, firstName: self.presentationData.strings.Appearance_ThemePreview_ChatList_2_Name, lastName: nil, username: nil, phone: nil, photo: [], botInfo: nil, restrictionInfo: nil, flags: []) + let peer3 = TelegramChannel(id: PeerId(namespace: Namespaces.Peer.CloudChannel, id: PeerId.Id._internalFromInt64Value(3)), accessHash: nil, title: self.presentationData.strings.Appearance_ThemePreview_ChatList_3_Name, username: nil, photo: [], creationDate: 0, version: 0, participationStatus: .member, info: .group(.init(flags: [])), flags: [], restrictionInfo: nil, adminRights: nil, bannedRights: nil, defaultBannedRights: nil) + let peer3Author = TelegramUser(id: PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt64Value(4)), accessHash: nil, firstName: self.presentationData.strings.Appearance_ThemePreview_ChatList_3_AuthorName, lastName: nil, username: nil, phone: nil, photo: [], botInfo: nil, restrictionInfo: nil, flags: []) + let peer4 = TelegramUser(id: PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt64Value(4)), accessHash: nil, firstName: self.presentationData.strings.Appearance_ThemePreview_ChatList_4_Name, lastName: nil, username: nil, phone: nil, photo: [], botInfo: nil, restrictionInfo: nil, flags: []) + let peer5 = TelegramChannel(id: PeerId(namespace: Namespaces.Peer.CloudChannel, id: PeerId.Id._internalFromInt64Value(5)), accessHash: nil, title: self.presentationData.strings.Appearance_ThemePreview_ChatList_5_Name, username: nil, photo: [], creationDate: 0, version: 0, participationStatus: .member, info: .broadcast(.init(flags: [])), flags: [], restrictionInfo: nil, adminRights: nil, bannedRights: nil, defaultBannedRights: nil) + let peer6 = TelegramUser(id: PeerId(namespace: Namespaces.Peer.SecretChat, id: PeerId.Id._internalFromInt64Value(5)), accessHash: nil, firstName: self.presentationData.strings.Appearance_ThemePreview_ChatList_6_Name, lastName: nil, username: nil, phone: nil, photo: [], botInfo: nil, restrictionInfo: nil, flags: []) + let peer7 = TelegramUser(id: PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt64Value(6)), accessHash: nil, firstName: self.presentationData.strings.Appearance_ThemePreview_ChatList_7_Name, lastName: nil, username: nil, phone: nil, photo: [], botInfo: nil, restrictionInfo: nil, flags: []) let timestamp = self.referenceTimestamp @@ -452,7 +452,7 @@ final class ThemePreviewControllerNode: ASDisplayNode, UIScrollViewDelegate { let headerItem = self.context.sharedContext.makeChatMessageDateHeaderItem(context: self.context, timestamp: self.referenceTimestamp, theme: self.previewTheme, strings: self.presentationData.strings, wallpaper: self.presentationData.chatWallpaper, fontSize: self.presentationData.chatFontSize, chatBubbleCorners: self.presentationData.chatBubbleCorners, dateTimeFormat: self.presentationData.dateTimeFormat, nameOrder: self.presentationData.nameDisplayOrder) var items: [ListViewItem] = [] - let peerId = PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt32Value(1)) + let peerId = PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt64Value(1)) let otherPeerId = self.context.account.peerId var peers = SimpleDictionary() var messages = SimpleDictionary() diff --git a/submodules/SettingsUI/Sources/Themes/ThemeSettingsChatPreviewItem.swift b/submodules/SettingsUI/Sources/Themes/ThemeSettingsChatPreviewItem.swift index e115dc5dc7..f1fa0b89e8 100644 --- a/submodules/SettingsUI/Sources/Themes/ThemeSettingsChatPreviewItem.swift +++ b/submodules/SettingsUI/Sources/Themes/ThemeSettingsChatPreviewItem.swift @@ -146,8 +146,8 @@ class ThemeSettingsChatPreviewItemNode: ListViewItemNode { let insets: UIEdgeInsets let separatorHeight = UIScreenPixel - let peerId = PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt32Value(1)) - let otherPeerId = PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt32Value(2)) + let peerId = PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt64Value(1)) + let otherPeerId = PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt64Value(2)) var items: [ListViewItem] = [] for messageItem in item.messageItems.reversed() { var peers = SimpleDictionary() diff --git a/submodules/SettingsUI/Sources/Themes/WallpaperGalleryItem.swift b/submodules/SettingsUI/Sources/Themes/WallpaperGalleryItem.swift index a2ffa742fa..55a93b4304 100644 --- a/submodules/SettingsUI/Sources/Themes/WallpaperGalleryItem.swift +++ b/submodules/SettingsUI/Sources/Themes/WallpaperGalleryItem.swift @@ -1029,7 +1029,7 @@ final class WallpaperGalleryItemNode: GalleryItemNode { } var items: [ListViewItem] = [] - let peerId = PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt32Value(1)) + let peerId = PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt64Value(1)) let otherPeerId = self.context.account.peerId var peers = SimpleDictionary() let messages = SimpleDictionary() diff --git a/submodules/ShareController/Sources/ShareController.swift b/submodules/ShareController/Sources/ShareController.swift index 8535b77020..04e456cfdd 100644 --- a/submodules/ShareController/Sources/ShareController.swift +++ b/submodules/ShareController/Sources/ShareController.swift @@ -329,11 +329,11 @@ public final class ShareController: ViewController { public var debugAction: (() -> Void)? - public convenience init(context: AccountContext, subject: ShareControllerSubject, presetText: String? = nil, preferredAction: ShareControllerPreferredAction = .default, showInChat: ((Message) -> Void)? = nil, fromForeignApp: Bool = false, segmentedValues: [ShareControllerSegmentedValue]? = nil, externalShare: Bool = true, immediateExternalShare: Bool = false, switchableAccounts: [AccountWithInfo] = [], immediatePeerId: PeerId? = nil, forceTheme: PresentationTheme? = nil, forcedActionTitle: String? = nil) { - self.init(sharedContext: context.sharedContext, currentContext: context, subject: subject, presetText: presetText, preferredAction: preferredAction, showInChat: showInChat, fromForeignApp: fromForeignApp, segmentedValues: segmentedValues, externalShare: externalShare, immediateExternalShare: immediateExternalShare, switchableAccounts: switchableAccounts, immediatePeerId: immediatePeerId, forceTheme: forceTheme, forcedActionTitle: forcedActionTitle) + public convenience init(context: AccountContext, subject: ShareControllerSubject, presetText: String? = nil, preferredAction: ShareControllerPreferredAction = .default, showInChat: ((Message) -> Void)? = nil, fromForeignApp: Bool = false, segmentedValues: [ShareControllerSegmentedValue]? = nil, externalShare: Bool = true, immediateExternalShare: Bool = false, switchableAccounts: [AccountWithInfo] = [], immediatePeerId: PeerId? = nil, updatedPresentationData: (initial: PresentationData, signal: Signal)? = nil, forceTheme: PresentationTheme? = nil, forcedActionTitle: String? = nil) { + self.init(sharedContext: context.sharedContext, currentContext: context, subject: subject, presetText: presetText, preferredAction: preferredAction, showInChat: showInChat, fromForeignApp: fromForeignApp, segmentedValues: segmentedValues, externalShare: externalShare, immediateExternalShare: immediateExternalShare, switchableAccounts: switchableAccounts, immediatePeerId: immediatePeerId, updatedPresentationData: updatedPresentationData, forceTheme: forceTheme, forcedActionTitle: forcedActionTitle) } - public init(sharedContext: SharedAccountContext, currentContext: AccountContext, subject: ShareControllerSubject, presetText: String? = nil, preferredAction: ShareControllerPreferredAction = .default, showInChat: ((Message) -> Void)? = nil, fromForeignApp: Bool = false, segmentedValues: [ShareControllerSegmentedValue]? = nil, externalShare: Bool = true, immediateExternalShare: Bool = false, switchableAccounts: [AccountWithInfo] = [], immediatePeerId: PeerId? = nil, forceTheme: PresentationTheme? = nil, forcedActionTitle: String? = nil) { + public init(sharedContext: SharedAccountContext, currentContext: AccountContext, subject: ShareControllerSubject, presetText: String? = nil, preferredAction: ShareControllerPreferredAction = .default, showInChat: ((Message) -> Void)? = nil, fromForeignApp: Bool = false, segmentedValues: [ShareControllerSegmentedValue]? = nil, externalShare: Bool = true, immediateExternalShare: Bool = false, switchableAccounts: [AccountWithInfo] = [], immediatePeerId: PeerId? = nil, updatedPresentationData: (initial: PresentationData, signal: Signal)? = nil, forceTheme: PresentationTheme? = nil, forcedActionTitle: String? = nil) { self.sharedContext = sharedContext self.currentContext = currentContext self.currentAccount = currentContext.account @@ -347,7 +347,7 @@ public final class ShareController: ViewController { self.segmentedValues = segmentedValues self.forceTheme = forceTheme - self.presentationData = self.sharedContext.currentPresentationData.with { $0 } + self.presentationData = updatedPresentationData?.initial ?? sharedContext.currentPresentationData.with { $0 } if let forceTheme = self.forceTheme { self.presentationData = self.presentationData.withUpdated(theme: forceTheme) } @@ -463,7 +463,7 @@ public final class ShareController: ViewController { }) } - self.presentationDataDisposable = (self.sharedContext.presentationData + self.presentationDataDisposable = ((updatedPresentationData?.signal ?? self.sharedContext.presentationData) |> deliverOnMainQueue).start(next: { [weak self] presentationData in if let strongSelf = self, strongSelf.isNodeLoaded { strongSelf.controllerNode.updatePresentationData(presentationData) @@ -484,7 +484,7 @@ public final class ShareController: ViewController { } override public func loadDisplayNode() { - self.displayNode = ShareControllerNode(sharedContext: self.sharedContext, presetText: self.presetText, defaultAction: self.defaultAction, requestLayout: { [weak self] transition in + self.displayNode = ShareControllerNode(sharedContext: self.sharedContext, presentationData: self.presentationData, presetText: self.presetText, defaultAction: self.defaultAction, requestLayout: { [weak self] transition in self?.requestLayout(transition: transition) }, presentError: { [weak self] title, text in guard let strongSelf = self else { diff --git a/submodules/ShareController/Sources/ShareControllerNode.swift b/submodules/ShareController/Sources/ShareControllerNode.swift index 04ff60d6e8..46ce491d0e 100644 --- a/submodules/ShareController/Sources/ShareControllerNode.swift +++ b/submodules/ShareController/Sources/ShareControllerNode.swift @@ -80,9 +80,9 @@ final class ShareControllerNode: ViewControllerTracingNode, UIScrollViewDelegate private let presetText: String? - init(sharedContext: SharedAccountContext, presetText: String?, defaultAction: ShareControllerAction?, requestLayout: @escaping (ContainedViewLayoutTransition) -> Void, presentError: @escaping (String?, String) -> Void, externalShare: Bool, immediateExternalShare: Bool, immediatePeerId: PeerId?, fromForeignApp: Bool, forceTheme: PresentationTheme?, segmentedValues: [ShareControllerSegmentedValue]?) { + init(sharedContext: SharedAccountContext, presentationData: PresentationData, presetText: String?, defaultAction: ShareControllerAction?, requestLayout: @escaping (ContainedViewLayoutTransition) -> Void, presentError: @escaping (String?, String) -> Void, externalShare: Bool, immediateExternalShare: Bool, immediatePeerId: PeerId?, fromForeignApp: Bool, forceTheme: PresentationTheme?, segmentedValues: [ShareControllerSegmentedValue]?) { self.sharedContext = sharedContext - self.presentationData = sharedContext.currentPresentationData.with { $0 } + self.presentationData = presentationData self.forceTheme = forceTheme self.externalShare = externalShare self.immediateExternalShare = immediateExternalShare diff --git a/submodules/Svg/PublicHeaders/Svg/Svg.h b/submodules/Svg/PublicHeaders/Svg/Svg.h index 306ee15fc0..952fecb850 100755 --- a/submodules/Svg/PublicHeaders/Svg/Svg.h +++ b/submodules/Svg/PublicHeaders/Svg/Svg.h @@ -4,6 +4,9 @@ #import #import +NSData * _Nullable prepareSvgImage(NSData * _Nonnull data); +UIImage * _Nullable renderPreparedImage(NSData * _Nonnull data, CGSize size); + UIImage * _Nullable drawSvgImage(NSData * _Nonnull data, CGSize size, UIColor * _Nullable backgroundColor, UIColor * _Nullable foregroundColor); #endif /* Lottie_h */ diff --git a/submodules/Svg/Sources/Svg.m b/submodules/Svg/Sources/Svg.m index eb56cc50cd..2e8e07a2ee 100755 --- a/submodules/Svg/Sources/Svg.m +++ b/submodules/Svg/Sources/Svg.m @@ -229,3 +229,431 @@ UIImage * _Nullable drawSvgImage(NSData * _Nonnull data, CGSize size, UIColor *b return resultImage; } + + +@interface CGContextCoder : NSObject { + NSMutableData *_data; +} + +@property (nonatomic, readonly) NSData *data; + +@end + +@implementation CGContextCoder + +- (instancetype)initWithSize:(CGSize)size { + self = [super init]; + if (self != nil) { + _data = [[NSMutableData alloc] init]; + + int32_t intWidth = size.width; + int32_t intHeight = size.height; + [_data appendBytes:&intWidth length:sizeof(intWidth)]; + [_data appendBytes:&intHeight length:sizeof(intHeight)]; + } + return self; +} + +- (void)setFillColorWithOpacity:(CGFloat)opacity { + uint8_t command = 1; + [_data appendBytes:&command length:sizeof(command)]; + + uint8_t intOpacity = opacity * 255.0; + [_data appendBytes:&intOpacity length:sizeof(intOpacity)]; +} + +- (void)setupStrokeOpacity:(CGFloat)opacity mitterLimit:(CGFloat)mitterLimit lineWidth:(CGFloat)lineWidth lineCap:(CGLineCap)lineCap lineJoin:(CGLineJoin)lineJoin { + uint8_t command = 2; + [_data appendBytes:&command length:sizeof(command)]; + + uint8_t intOpacity = opacity * 255.0; + [_data appendBytes:&intOpacity length:sizeof(intOpacity)]; + + float floatMitterLimit = mitterLimit; + [_data appendBytes:&floatMitterLimit length:sizeof(floatMitterLimit)]; + + float floatLineWidth = lineWidth; + [_data appendBytes:&floatLineWidth length:sizeof(floatLineWidth)]; + + uint8_t intLineCap = lineCap; + [_data appendBytes:&intLineCap length:sizeof(intLineCap)]; + + uint8_t intLineJoin = lineJoin; + [_data appendBytes:&intLineJoin length:sizeof(intLineJoin)]; +} + +- (void)beginPath { + uint8_t command = 3; + [_data appendBytes:&command length:sizeof(command)]; +} + +- (void)moveToPoint:(CGPoint)point { + uint8_t command = 4; + [_data appendBytes:&command length:sizeof(command)]; + + float floatX = point.x; + [_data appendBytes:&floatX length:sizeof(floatX)]; + + float floatY = point.y; + [_data appendBytes:&floatY length:sizeof(floatY)]; +} + +- (void)addLineToPoint:(CGPoint)point { + uint8_t command = 5; + [_data appendBytes:&command length:sizeof(command)]; + + float floatX = point.x; + [_data appendBytes:&floatX length:sizeof(floatX)]; + + float floatY = point.y; + [_data appendBytes:&floatY length:sizeof(floatY)]; +} + +- (void)addCurveToPoint:(CGPoint)p1 p2:(CGPoint)p2 p3:(CGPoint)p3 { + uint8_t command = 6; + [_data appendBytes:&command length:sizeof(command)]; + + float floatX1 = p1.x; + [_data appendBytes:&floatX1 length:sizeof(floatX1)]; + + float floatY1 = p1.y; + [_data appendBytes:&floatY1 length:sizeof(floatY1)]; + + float floatX2 = p2.x; + [_data appendBytes:&floatX2 length:sizeof(floatX2)]; + + float floatY2 = p2.y; + [_data appendBytes:&floatY2 length:sizeof(floatY2)]; + + float floatX3 = p3.x; + [_data appendBytes:&floatX3 length:sizeof(floatX3)]; + + float floatY3 = p3.y; + [_data appendBytes:&floatY3 length:sizeof(floatY3)]; +} + +- (void)closePath { + uint8_t command = 7; + [_data appendBytes:&command length:sizeof(command)]; +} + +- (void)eoFillPath { + uint8_t command = 8; + [_data appendBytes:&command length:sizeof(command)]; +} + +- (void)fillPath { + uint8_t command = 9; + [_data appendBytes:&command length:sizeof(command)]; +} + +- (void)strokePath { + uint8_t command = 10; + [_data appendBytes:&command length:sizeof(command)]; +} + +@end + +UIImage * _Nullable renderPreparedImage(NSData * _Nonnull data, CGSize size) { + NSDate *startTime = [NSDate date]; + + UIColor *foregroundColor = [UIColor whiteColor]; + UIColor *backgroundColor = [UIColor blackColor]; + + int32_t ptr = 0; + int32_t width; + int32_t height; + + [data getBytes:&width range:NSMakeRange(ptr, sizeof(width))]; + ptr += sizeof(width); + [data getBytes:&height range:NSMakeRange(ptr, sizeof(height))]; + ptr += sizeof(height); + + UIGraphicsBeginImageContextWithOptions(size, true, 1.0); + CGContextRef context = UIGraphicsGetCurrentContext(); + CGContextSetFillColorWithColor(context, backgroundColor.CGColor); + CGContextFillRect(context, CGRectMake(0.0f, 0.0f, size.width, size.height)); + + CGSize svgSize = CGSizeMake(width, height); + CGSize drawingSize = aspectFillSize(svgSize, size); + + CGFloat scale = MAX(size.width / MAX(1.0, svgSize.width), size.height / MAX(1.0, svgSize.height)); + + CGContextScaleCTM(context, scale, scale); + CGContextTranslateCTM(context, (size.width - drawingSize.width) / 2.0, (size.height - drawingSize.height) / 2.0); + + while (ptr < data.length) { + uint8_t cmd; + [data getBytes:&cmd range:NSMakeRange(ptr, sizeof(cmd))]; + ptr += sizeof(cmd); + + switch (cmd) { + case 1: + { + uint8_t opacity; + [data getBytes:&opacity range:NSMakeRange(ptr, sizeof(opacity))]; + ptr += sizeof(opacity); + CGContextSetFillColorWithColor(context, [foregroundColor colorWithAlphaComponent:opacity / 255.0].CGColor); + } + break; + + case 2: + { + uint8_t opacity; + [data getBytes:&opacity range:NSMakeRange(ptr, sizeof(opacity))]; + ptr += sizeof(opacity); + CGContextSetStrokeColorWithColor(context, [foregroundColor colorWithAlphaComponent:opacity / 255.0].CGColor); + + float mitterLimit; + [data getBytes:&mitterLimit range:NSMakeRange(ptr, sizeof(mitterLimit))]; + ptr += sizeof(mitterLimit); + CGContextSetMiterLimit(context, mitterLimit); + + float lineWidth; + [data getBytes:&lineWidth range:NSMakeRange(ptr, sizeof(lineWidth))]; + ptr += sizeof(lineWidth); + CGContextSetLineWidth(context, lineWidth); + + uint8_t lineCap; + [data getBytes:&lineCap range:NSMakeRange(ptr, sizeof(lineCap))]; + ptr += sizeof(lineCap); + CGContextSetLineCap(context, lineCap); + + uint8_t lineJoin; + [data getBytes:&lineJoin range:NSMakeRange(ptr, sizeof(lineJoin))]; + ptr += sizeof(lineJoin); + CGContextSetLineCap(context, lineJoin); + } + break; + + case 3: + { + CGContextBeginPath(context); + } + break; + + case 4: + { + float x; + [data getBytes:&x range:NSMakeRange(ptr, sizeof(x))]; + ptr += sizeof(x); + + float y; + [data getBytes:&y range:NSMakeRange(ptr, sizeof(y))]; + ptr += sizeof(y); + + CGContextMoveToPoint(context, x, y); + } + break; + + case 5: + { + float x; + [data getBytes:&x range:NSMakeRange(ptr, sizeof(x))]; + ptr += sizeof(x); + + float y; + [data getBytes:&y range:NSMakeRange(ptr, sizeof(y))]; + ptr += sizeof(y); + + CGContextAddLineToPoint(context, x, y); + } + break; + + case 6: + { + float x1; + [data getBytes:&x1 range:NSMakeRange(ptr, sizeof(x1))]; + ptr += sizeof(x1); + + float y1; + [data getBytes:&y1 range:NSMakeRange(ptr, sizeof(y1))]; + ptr += sizeof(y1); + + float x2; + [data getBytes:&x2 range:NSMakeRange(ptr, sizeof(x2))]; + ptr += sizeof(x2); + + float y2; + [data getBytes:&y2 range:NSMakeRange(ptr, sizeof(y2))]; + ptr += sizeof(y2); + + float x3; + [data getBytes:&x3 range:NSMakeRange(ptr, sizeof(x3))]; + ptr += sizeof(x3); + + float y3; + [data getBytes:&y3 range:NSMakeRange(ptr, sizeof(y3))]; + ptr += sizeof(y3); + + CGContextAddCurveToPoint(context, x1, y1, x2, y2, x3, y3); + } + break; + + case 7: + { + CGContextClosePath(context); + } + break; + + case 8: + { + CGContextEOFillPath(context); + } + break; + + case 9: + { + CGContextFillPath(context); + } + break; + + case 10: + { + CGContextStrokePath(context); + } + break; + + default: + break; + } + } + + UIImage *resultImage = UIGraphicsGetImageFromCurrentImageContext(); + UIGraphicsEndImageContext(); + + double deltaTime = -1.0f * [startTime timeIntervalSinceNow]; + printf("drawingTime %fx%f = %f\n", size.width, size.height, deltaTime); + + return resultImage; +} + +NSData * _Nullable prepareSvgImage(NSData * _Nonnull data) { + NSDate *startTime = [NSDate date]; + + NSXMLParser *parser = [[NSXMLParser alloc] initWithData:data]; + if (parser == nil) { + return nil; + } + SvgXMLParsingDelegate *delegate = [[SvgXMLParsingDelegate alloc] init]; + parser.delegate = delegate; + [parser parse]; + + NSMutableString *xmlString = [[NSMutableString alloc] initWithData:data encoding:NSUTF8StringEncoding]; + if (xmlString == nil) { + return nil; + } + + for (NSString *styleName in delegate.styles) { + NSString *styleValue = delegate.styles[styleName]; + [xmlString replaceOccurrencesOfString:[NSString stringWithFormat:@"class=\"%@\"", styleName] withString:[NSString stringWithFormat:@"style=\"%@\"", styleValue] options:0 range:NSMakeRange(0, xmlString.length)]; + } + + const char *zeroTerminatedData = xmlString.UTF8String; + + NSVGimage *image = nsvgParse((char *)zeroTerminatedData, "px", 96); + if (image == nil || image->width < 1.0f || image->height < 1.0f) { + return nil; + } + + double deltaTime = -1.0f * [startTime timeIntervalSinceNow]; + printf("parseTime = %f\n", deltaTime); + + startTime = [NSDate date]; + + CGContextCoder *context = [[CGContextCoder alloc] initWithSize:CGSizeMake(image->width, image->height)]; + + for (NSVGshape *shape = image->shapes; shape != NULL; shape = shape->next) { + if (!(shape->flags & NSVG_FLAGS_VISIBLE)) { + continue; + } + + if (shape->fill.type != NSVG_PAINT_NONE) { + [context setFillColorWithOpacity:shape->opacity]; + + bool isFirst = true; + bool hasStartPoint = false; + CGPoint startPoint; + for (NSVGpath *path = shape->paths; path != NULL; path = path->next) { + if (isFirst) { + [context beginPath]; + + isFirst = false; + hasStartPoint = true; + startPoint.x = path->pts[0]; + startPoint.y = path->pts[1]; + } + [context moveToPoint:CGPointMake(path->pts[0], path->pts[1])]; + for (int i = 0; i < path->npts - 1; i += 3) { + float *p = &path->pts[i * 2]; + [context addCurveToPoint:CGPointMake(p[2], p[3]) p2:CGPointMake(p[4], p[5]) p3:CGPointMake(p[6], p[7])]; + } + + if (path->closed) { + if (hasStartPoint) { + hasStartPoint = false; + [context addLineToPoint:startPoint]; + } + } + } + switch (shape->fillRule) { + case NSVG_FILLRULE_EVENODD: + [context eoFillPath]; + break; + default: + [context fillPath]; + break; + } + } + + if (shape->stroke.type != NSVG_PAINT_NONE) { + CGLineCap lineCap = kCGLineCapButt; + CGLineJoin lineJoin = kCGLineJoinMiter; + switch (shape->strokeLineCap) { + case NSVG_CAP_BUTT: + lineCap = kCGLineCapButt; + break; + case NSVG_CAP_ROUND: + lineCap = kCGLineCapRound; + break; + case NSVG_CAP_SQUARE: + lineCap = kCGLineCapSquare; + break; + default: + break; + } + switch (shape->strokeLineJoin) { + case NSVG_JOIN_BEVEL: + lineJoin = kCGLineJoinBevel; + break; + case NSVG_JOIN_MITER: + lineJoin = kCGLineJoinMiter; + break; + case NSVG_JOIN_ROUND: + lineJoin = kCGLineJoinRound; + break; + default: + break; + } + + [context setupStrokeOpacity:shape->opacity mitterLimit:shape->miterLimit lineWidth:shape->strokeWidth lineCap:lineCap lineJoin:lineJoin]; + + for (NSVGpath *path = shape->paths; path != NULL; path = path->next) { + [context beginPath]; + [context moveToPoint:CGPointMake(path->pts[0], path->pts[1])]; + for (int i = 0; i < path->npts - 1; i += 3) { + float *p = &path->pts[i * 2]; + [context addCurveToPoint:CGPointMake(p[2], p[3]) p2:CGPointMake(p[4], p[5]) p3:CGPointMake(p[6], p[7])]; + } + + if (path->closed) { + [context closePath]; + } + [context strokePath]; + } + } + } + + nsvgDelete(image); + return context.data; +} diff --git a/submodules/TelegramApi/Sources/Api0.swift b/submodules/TelegramApi/Sources/Api0.swift index 2ed896fbec..8fb8cf30f4 100644 --- a/submodules/TelegramApi/Sources/Api0.swift +++ b/submodules/TelegramApi/Sources/Api0.swift @@ -11,12 +11,12 @@ fileprivate let parsers: [Int32 : (BufferReader) -> Any?] = { dict[-457104426] = { return Api.InputGeoPoint.parse_inputGeoPointEmpty($0) } dict[1210199983] = { return Api.InputGeoPoint.parse_inputGeoPoint($0) } dict[-784000893] = { return Api.payments.ValidatedRequestedInfo.parse_validatedRequestedInfo($0) } - dict[1235264985] = { return Api.ChatFull.parse_chatFull($0) } - dict[793980732] = { return Api.ChatFull.parse_channelFull($0) } - dict[-1159937629] = { return Api.PollResults.parse_pollResults($0) } - dict[-925415106] = { return Api.ChatParticipant.parse_chatParticipant($0) } - dict[-636267638] = { return Api.ChatParticipant.parse_chatParticipantCreator($0) } - dict[-489233354] = { return Api.ChatParticipant.parse_chatParticipantAdmin($0) } + dict[1304281241] = { return Api.ChatFull.parse_chatFull($0) } + dict[-374179305] = { return Api.ChatFull.parse_channelFull($0) } + dict[-591909213] = { return Api.PollResults.parse_pollResults($0) } + dict[-1070776313] = { return Api.ChatParticipant.parse_chatParticipant($0) } + dict[-462696732] = { return Api.ChatParticipant.parse_chatParticipantCreator($0) } + dict[-1600962725] = { return Api.ChatParticipant.parse_chatParticipantAdmin($0) } dict[1567990072] = { return Api.updates.Difference.parse_differenceEmpty($0) } dict[16030880] = { return Api.updates.Difference.parse_difference($0) } dict[-1459938943] = { return Api.updates.Difference.parse_differenceSlice($0) } @@ -65,11 +65,11 @@ fileprivate let parsers: [Int32 : (BufferReader) -> Any?] = { dict[-1715350371] = { return Api.JSONValue.parse_jsonObject($0) } dict[590459437] = { return Api.Photo.parse_photoEmpty($0) } dict[-82216347] = { return Api.Photo.parse_photo($0) } - dict[-1683826688] = { return Api.Chat.parse_chatEmpty($0) } - dict[1004149726] = { return Api.Chat.parse_chat($0) } - dict[120753115] = { return Api.Chat.parse_chatForbidden($0) } - dict[-753232354] = { return Api.Chat.parse_channel($0) } - dict[681420594] = { return Api.Chat.parse_channelForbidden($0) } + dict[693512293] = { return Api.Chat.parse_chatEmpty($0) } + dict[1103884886] = { return Api.Chat.parse_chat($0) } + dict[1704108455] = { return Api.Chat.parse_chatForbidden($0) } + dict[-2107528095] = { return Api.Chat.parse_channel($0) } + dict[399807445] = { return Api.Chat.parse_channelForbidden($0) } dict[1202287072] = { return Api.StatsURL.parse_statsURL($0) } dict[1516793212] = { return Api.ChatInvite.parse_chatInviteAlready($0) } dict[-540871282] = { return Api.ChatInvite.parse_chatInvite($0) } @@ -83,8 +83,8 @@ fileprivate let parsers: [Int32 : (BufferReader) -> Any?] = { dict[1678812626] = { return Api.StickerSetCovered.parse_stickerSetCovered($0) } dict[872932635] = { return Api.StickerSetCovered.parse_stickerSetMultiCovered($0) } dict[1189204285] = { return Api.RecentMeUrl.parse_recentMeUrlUnknown($0) } - dict[-1917045962] = { return Api.RecentMeUrl.parse_recentMeUrlUser($0) } - dict[-1608834311] = { return Api.RecentMeUrl.parse_recentMeUrlChat($0) } + dict[-1188296222] = { return Api.RecentMeUrl.parse_recentMeUrlUser($0) } + dict[-1294306862] = { return Api.RecentMeUrl.parse_recentMeUrlChat($0) } dict[-347535331] = { return Api.RecentMeUrl.parse_recentMeUrlChatInvite($0) } dict[-1140172836] = { return Api.RecentMeUrl.parse_recentMeUrlStickerSet($0) } dict[-797791052] = { return Api.RestrictionReason.parse_restrictionReason($0) } @@ -108,8 +108,8 @@ fileprivate let parsers: [Int32 : (BufferReader) -> Any?] = { dict[894777186] = { return Api.RichText.parse_textAnchor($0) } dict[-694681851] = { return Api.UserFull.parse_userFull($0) } dict[-292807034] = { return Api.InputChannel.parse_inputChannelEmpty($0) } - dict[-1343524562] = { return Api.InputChannel.parse_inputChannel($0) } - dict[707290417] = { return Api.InputChannel.parse_inputChannelFromMessage($0) } + dict[-212145112] = { return Api.InputChannel.parse_inputChannel($0) } + dict[1536380829] = { return Api.InputChannel.parse_inputChannelFromMessage($0) } dict[414687501] = { return Api.DcOption.parse_dcOption($0) } dict[997055186] = { return Api.PollAnswerVoters.parse_pollAnswerVoters($0) } dict[-1705233435] = { return Api.account.PasswordSettings.parse_passwordSettings($0) } @@ -121,7 +121,7 @@ fileprivate let parsers: [Int32 : (BufferReader) -> Any?] = { dict[-209337866] = { return Api.LangPackDifference.parse_langPackDifference($0) } dict[499236004] = { return Api.WallPaperSettings.parse_wallPaperSettings($0) } dict[-1519029347] = { return Api.EmojiURL.parse_emojiURL($0) } - dict[1611985938] = { return Api.StatsGroupTopAdmin.parse_statsGroupTopAdmin($0) } + dict[-682079097] = { return Api.StatsGroupTopAdmin.parse_statsGroupTopAdmin($0) } dict[-541588713] = { return Api.channels.ChannelParticipant.parse_channelParticipant($0) } dict[-1736378792] = { return Api.InputCheckPasswordSRP.parse_inputCheckPasswordEmpty($0) } dict[-763367294] = { return Api.InputCheckPasswordSRP.parse_inputCheckPasswordSRP($0) } @@ -151,9 +151,9 @@ fileprivate let parsers: [Int32 : (BufferReader) -> Any?] = { dict[1148485274] = { return Api.auth.Authorization.parse_authorizationSignUpRequired($0) } dict[-181407105] = { return Api.InputFile.parse_inputFile($0) } dict[-95482955] = { return Api.InputFile.parse_inputFileBig($0) } - dict[-1649296275] = { return Api.Peer.parse_peerUser($0) } - dict[-1160714821] = { return Api.Peer.parse_peerChat($0) } - dict[-1109531342] = { return Api.Peer.parse_peerChannel($0) } + dict[1498486562] = { return Api.Peer.parse_peerUser($0) } + dict[918946202] = { return Api.Peer.parse_peerChat($0) } + dict[-1566230754] = { return Api.Peer.parse_peerChannel($0) } dict[410107472] = { return Api.messages.ExportedChatInvite.parse_exportedChatInvite($0) } dict[572915951] = { return Api.messages.ExportedChatInvite.parse_exportedChatInviteReplaced($0) } dict[-1868808300] = { return Api.PaymentRequestedInfo.parse_paymentRequestedInfo($0) } @@ -193,64 +193,64 @@ fileprivate let parsers: [Int32 : (BufferReader) -> Any?] = { dict[522914557] = { return Api.Update.parse_updateNewMessage($0) } dict[1318109142] = { return Api.Update.parse_updateMessageID($0) } dict[-1576161051] = { return Api.Update.parse_updateDeleteMessages($0) } - dict[1548249383] = { return Api.Update.parse_updateUserTyping($0) } - dict[-2033525908] = { return Api.Update.parse_updateChatUserTyping($0) } + dict[-1071741569] = { return Api.Update.parse_updateUserTyping($0) } + dict[-2092401936] = { return Api.Update.parse_updateChatUserTyping($0) } dict[125178264] = { return Api.Update.parse_updateChatParticipants($0) } - dict[469489699] = { return Api.Update.parse_updateUserStatus($0) } - dict[-1489818765] = { return Api.Update.parse_updateUserName($0) } - dict[-1791935732] = { return Api.Update.parse_updateUserPhoto($0) } + dict[-440534818] = { return Api.Update.parse_updateUserStatus($0) } + dict[-1007549728] = { return Api.Update.parse_updateUserName($0) } + dict[-232290676] = { return Api.Update.parse_updateUserPhoto($0) } dict[314359194] = { return Api.Update.parse_updateNewEncryptedMessage($0) } dict[386986326] = { return Api.Update.parse_updateEncryptedChatTyping($0) } dict[-1264392051] = { return Api.Update.parse_updateEncryption($0) } dict[956179895] = { return Api.Update.parse_updateEncryptedMessagesRead($0) } - dict[-364179876] = { return Api.Update.parse_updateChatParticipantAdd($0) } - dict[1851755554] = { return Api.Update.parse_updateChatParticipantDelete($0) } + dict[1037718609] = { return Api.Update.parse_updateChatParticipantAdd($0) } + dict[-483443337] = { return Api.Update.parse_updateChatParticipantDelete($0) } dict[-1906403213] = { return Api.Update.parse_updateDcOptions($0) } dict[-1094555409] = { return Api.Update.parse_updateNotifySettings($0) } dict[-337352679] = { return Api.Update.parse_updateServiceNotification($0) } dict[-298113238] = { return Api.Update.parse_updatePrivacy($0) } - dict[314130811] = { return Api.Update.parse_updateUserPhone($0) } + dict[88680979] = { return Api.Update.parse_updateUserPhone($0) } dict[-1667805217] = { return Api.Update.parse_updateReadHistoryInbox($0) } dict[791617983] = { return Api.Update.parse_updateReadHistoryOutbox($0) } dict[2139689491] = { return Api.Update.parse_updateWebPage($0) } dict[1757493555] = { return Api.Update.parse_updateReadMessagesContents($0) } - dict[-352032773] = { return Api.Update.parse_updateChannelTooLong($0) } - dict[-1227598250] = { return Api.Update.parse_updateChannel($0) } + dict[277713951] = { return Api.Update.parse_updateChannelTooLong($0) } + dict[1666927625] = { return Api.Update.parse_updateChannel($0) } dict[1656358105] = { return Api.Update.parse_updateNewChannelMessage($0) } - dict[856380452] = { return Api.Update.parse_updateReadChannelInbox($0) } - dict[-1015733815] = { return Api.Update.parse_updateDeleteChannelMessages($0) } - dict[-1734268085] = { return Api.Update.parse_updateChannelMessageViews($0) } - dict[-1232070311] = { return Api.Update.parse_updateChatParticipantAdmin($0) } + dict[-1842450928] = { return Api.Update.parse_updateReadChannelInbox($0) } + dict[-1020437742] = { return Api.Update.parse_updateDeleteChannelMessages($0) } + dict[-232346616] = { return Api.Update.parse_updateChannelMessageViews($0) } + dict[-674602590] = { return Api.Update.parse_updateChatParticipantAdmin($0) } dict[1753886890] = { return Api.Update.parse_updateNewStickerSet($0) } dict[196268545] = { return Api.Update.parse_updateStickerSetsOrder($0) } dict[1135492588] = { return Api.Update.parse_updateStickerSets($0) } dict[-1821035490] = { return Api.Update.parse_updateSavedGifs($0) } - dict[1059076315] = { return Api.Update.parse_updateBotInlineQuery($0) } - dict[239663460] = { return Api.Update.parse_updateBotInlineSend($0) } + dict[1232025500] = { return Api.Update.parse_updateBotInlineQuery($0) } + dict[317794823] = { return Api.Update.parse_updateBotInlineSend($0) } dict[457133559] = { return Api.Update.parse_updateEditChannelMessage($0) } - dict[-415938591] = { return Api.Update.parse_updateBotCallbackQuery($0) } + dict[-1177566067] = { return Api.Update.parse_updateBotCallbackQuery($0) } dict[-469536605] = { return Api.Update.parse_updateEditMessage($0) } - dict[-103646630] = { return Api.Update.parse_updateInlineBotCallbackQuery($0) } - dict[634833351] = { return Api.Update.parse_updateReadChannelOutbox($0) } + dict[1763610706] = { return Api.Update.parse_updateInlineBotCallbackQuery($0) } + dict[-1218471511] = { return Api.Update.parse_updateReadChannelOutbox($0) } dict[-299124375] = { return Api.Update.parse_updateDraftMessage($0) } dict[1461528386] = { return Api.Update.parse_updateReadFeaturedStickers($0) } dict[-1706939360] = { return Api.Update.parse_updateRecentStickers($0) } dict[-1574314746] = { return Api.Update.parse_updateConfig($0) } dict[861169551] = { return Api.Update.parse_updatePtsChanged($0) } - dict[1081547008] = { return Api.Update.parse_updateChannelWebPage($0) } + dict[791390623] = { return Api.Update.parse_updateChannelWebPage($0) } dict[1852826908] = { return Api.Update.parse_updateDialogPinned($0) } dict[-99664734] = { return Api.Update.parse_updatePinnedDialogs($0) } dict[-2095595325] = { return Api.Update.parse_updateBotWebhookJSON($0) } dict[-1684914010] = { return Api.Update.parse_updateBotWebhookJSONQuery($0) } - dict[-523384512] = { return Api.Update.parse_updateBotShippingQuery($0) } - dict[1563376297] = { return Api.Update.parse_updateBotPrecheckoutQuery($0) } + dict[-1246823043] = { return Api.Update.parse_updateBotShippingQuery($0) } + dict[-1934976362] = { return Api.Update.parse_updateBotPrecheckoutQuery($0) } dict[-1425052898] = { return Api.Update.parse_updatePhoneCall($0) } dict[1180041828] = { return Api.Update.parse_updateLangPackTooLong($0) } dict[1442983757] = { return Api.Update.parse_updateLangPack($0) } dict[-451831443] = { return Api.Update.parse_updateFavedStickers($0) } - dict[-1987495099] = { return Api.Update.parse_updateChannelReadMessagesContents($0) } + dict[1153291573] = { return Api.Update.parse_updateChannelReadMessagesContents($0) } dict[1887741886] = { return Api.Update.parse_updateContactsReset($0) } - dict[1893427255] = { return Api.Update.parse_updateChannelAvailableMessages($0) } + dict[-1304443240] = { return Api.Update.parse_updateChannelAvailableMessages($0) } dict[-513517117] = { return Api.Update.parse_updateDialogUnreadMark($0) } dict[-1398708869] = { return Api.Update.parse_updateMessagePoll($0) } dict[1421875280] = { return Api.Update.parse_updateChatDefaultBannedRights($0) } @@ -262,40 +262,40 @@ fileprivate let parsers: [Int32 : (BufferReader) -> Any?] = { dict[-2112423005] = { return Api.Update.parse_updateTheme($0) } dict[-2027964103] = { return Api.Update.parse_updateGeoLiveViewed($0) } dict[1448076945] = { return Api.Update.parse_updateLoginToken($0) } - dict[938909451] = { return Api.Update.parse_updateMessagePollVote($0) } + dict[274961865] = { return Api.Update.parse_updateMessagePollVote($0) } dict[654302845] = { return Api.Update.parse_updateDialogFilter($0) } dict[-1512627963] = { return Api.Update.parse_updateDialogFilterOrder($0) } dict[889491791] = { return Api.Update.parse_updateDialogFilters($0) } dict[643940105] = { return Api.Update.parse_updatePhoneCallSignalingData($0) } - dict[1854571743] = { return Api.Update.parse_updateChannelMessageForwards($0) } - dict[482860628] = { return Api.Update.parse_updateReadChannelDiscussionInbox($0) } - dict[1178116716] = { return Api.Update.parse_updateReadChannelDiscussionOutbox($0) } + dict[-761649164] = { return Api.Update.parse_updateChannelMessageForwards($0) } + dict[-693004986] = { return Api.Update.parse_updateReadChannelDiscussionInbox($0) } + dict[1767677564] = { return Api.Update.parse_updateReadChannelDiscussionOutbox($0) } dict[610945826] = { return Api.Update.parse_updatePeerBlocked($0) } - dict[1796675352] = { return Api.Update.parse_updateChannelUserTyping($0) } + dict[-1937192669] = { return Api.Update.parse_updateChannelUserTyping($0) } dict[-309990731] = { return Api.Update.parse_updatePinnedMessages($0) } - dict[-2054649973] = { return Api.Update.parse_updatePinnedChannelMessages($0) } - dict[321954198] = { return Api.Update.parse_updateChat($0) } + dict[1538885128] = { return Api.Update.parse_updatePinnedChannelMessages($0) } + dict[-124097970] = { return Api.Update.parse_updateChat($0) } dict[-219423922] = { return Api.Update.parse_updateGroupCallParticipants($0) } - dict[-1537295973] = { return Api.Update.parse_updateGroupCall($0) } + dict[347227392] = { return Api.Update.parse_updateGroupCall($0) } dict[-1147422299] = { return Api.Update.parse_updatePeerHistoryTTL($0) } - dict[-206342113] = { return Api.Update.parse_updateChatParticipant($0) } - dict[2146218476] = { return Api.Update.parse_updateChannelParticipant($0) } - dict[133777546] = { return Api.Update.parse_updateBotStopped($0) } + dict[-796432838] = { return Api.Update.parse_updateChatParticipant($0) } + dict[-1738720581] = { return Api.Update.parse_updateChannelParticipant($0) } + dict[-997782967] = { return Api.Update.parse_updateBotStopped($0) } dict[192428418] = { return Api.Update.parse_updateGroupCallConnection($0) } - dict[-813823885] = { return Api.Update.parse_updateBotCommands($0) } + dict[1299263278] = { return Api.Update.parse_updateBotCommands($0) } dict[136574537] = { return Api.messages.VotesList.parse_votesList($0) } dict[1558266229] = { return Api.PopularContact.parse_popularContact($0) } dict[-592373577] = { return Api.GroupCallParticipantVideoSourceGroup.parse_groupCallParticipantVideoSourceGroup($0) } dict[-373643672] = { return Api.FolderPeer.parse_folderPeer($0) } - dict[367766557] = { return Api.ChannelParticipant.parse_channelParticipant($0) } - dict[-1557620115] = { return Api.ChannelParticipant.parse_channelParticipantSelf($0) } - dict[1149094475] = { return Api.ChannelParticipant.parse_channelParticipantCreator($0) } - dict[-859915345] = { return Api.ChannelParticipant.parse_channelParticipantAdmin($0) } - dict[1352785878] = { return Api.ChannelParticipant.parse_channelParticipantBanned($0) } + dict[-1072953408] = { return Api.ChannelParticipant.parse_channelParticipant($0) } + dict[682146919] = { return Api.ChannelParticipant.parse_channelParticipantSelf($0) } + dict[803602899] = { return Api.ChannelParticipant.parse_channelParticipantCreator($0) } + dict[885242707] = { return Api.ChannelParticipant.parse_channelParticipantAdmin($0) } + dict[1844969806] = { return Api.ChannelParticipant.parse_channelParticipantBanned($0) } dict[453242886] = { return Api.ChannelParticipant.parse_channelParticipantLeft($0) } - dict[-1567730343] = { return Api.MessageUserVote.parse_messageUserVote($0) } - dict[909603888] = { return Api.MessageUserVote.parse_messageUserVoteInputOption($0) } - dict[244310238] = { return Api.MessageUserVote.parse_messageUserVoteMultiple($0) } + dict[886196148] = { return Api.MessageUserVote.parse_messageUserVote($0) } + dict[1017491692] = { return Api.MessageUserVote.parse_messageUserVoteInputOption($0) } + dict[-1973033641] = { return Api.MessageUserVote.parse_messageUserVoteMultiple($0) } dict[182326673] = { return Api.contacts.Blocked.parse_blocked($0) } dict[-513392236] = { return Api.contacts.Blocked.parse_blockedSlice($0) } dict[-55902537] = { return Api.InputDialogPeer.parse_inputDialogPeer($0) } @@ -311,11 +311,11 @@ fileprivate let parsers: [Int32 : (BufferReader) -> Any?] = { dict[280464681] = { return Api.KeyboardButton.parse_keyboardButtonUrlAuth($0) } dict[-802258988] = { return Api.KeyboardButton.parse_inputKeyboardButtonUrlAuth($0) } dict[-1144565411] = { return Api.KeyboardButton.parse_keyboardButtonRequestPoll($0) } - dict[-748155807] = { return Api.ContactStatus.parse_contactStatus($0) } + dict[383348795] = { return Api.ContactStatus.parse_contactStatus($0) } dict[1679398724] = { return Api.SecureFile.parse_secureFileEmpty($0) } dict[-534283678] = { return Api.SecureFile.parse_secureFile($0) } dict[-199313886] = { return Api.account.Themes.parse_themesNotModified($0) } - dict[2137482273] = { return Api.account.Themes.parse_themes($0) } + dict[-1707242387] = { return Api.account.Themes.parse_themes($0) } dict[236446268] = { return Api.PhotoSize.parse_photoSizeEmpty($0) } dict[1976012384] = { return Api.PhotoSize.parse_photoSize($0) } dict[35527382] = { return Api.PhotoSize.parse_photoCachedSize($0) } @@ -323,13 +323,13 @@ fileprivate let parsers: [Int32 : (BufferReader) -> Any?] = { dict[-96535659] = { return Api.PhotoSize.parse_photoSizeProgressive($0) } dict[-668906175] = { return Api.PhotoSize.parse_photoPathSize($0) } dict[-244016606] = { return Api.messages.Stickers.parse_stickersNotModified($0) } - dict[-463889475] = { return Api.messages.Stickers.parse_stickers($0) } + dict[816245886] = { return Api.messages.Stickers.parse_stickers($0) } dict[-1096616924] = { return Api.GlobalPrivacySettings.parse_globalPrivacySettings($0) } dict[1008755359] = { return Api.InlineBotSwitchPM.parse_inlineBotSwitchPM($0) } dict[223655517] = { return Api.messages.FoundStickerSets.parse_foundStickerSetsNotModified($0) } - dict[1359533640] = { return Api.messages.FoundStickerSets.parse_foundStickerSets($0) } + dict[-1963942446] = { return Api.messages.FoundStickerSets.parse_foundStickerSets($0) } dict[471437699] = { return Api.account.WallPapers.parse_wallPapersNotModified($0) } - dict[1881892265] = { return Api.account.WallPapers.parse_wallPapers($0) } + dict[-842824308] = { return Api.account.WallPapers.parse_wallPapers($0) } dict[1012306921] = { return Api.InputTheme.parse_inputTheme($0) } dict[-175567375] = { return Api.InputTheme.parse_inputThemeSlug($0) } dict[-2032041631] = { return Api.Poll.parse_poll($0) } @@ -376,7 +376,7 @@ fileprivate let parsers: [Int32 : (BufferReader) -> Any?] = { dict[-353862078] = { return Api.contacts.Contacts.parse_contacts($0) } dict[-1798033689] = { return Api.ChannelMessagesFilter.parse_channelMessagesFilterEmpty($0) } dict[-847783593] = { return Api.ChannelMessagesFilter.parse_channelMessagesFilter($0) } - dict[-539872497] = { return Api.ChatAdminWithInvites.parse_chatAdminWithInvites($0) } + dict[-219353309] = { return Api.ChatAdminWithInvites.parse_chatAdminWithInvites($0) } dict[2004110666] = { return Api.DialogFilterSuggested.parse_dialogFilterSuggested($0) } dict[326715557] = { return Api.auth.PasswordRecovery.parse_passwordRecovery($0) } dict[-1803769784] = { return Api.messages.BotResults.parse_botResults($0) } @@ -402,13 +402,13 @@ fileprivate let parsers: [Int32 : (BufferReader) -> Any?] = { dict[-428884101] = { return Api.InputMedia.parse_inputMediaDice($0) } dict[2134579434] = { return Api.InputPeer.parse_inputPeerEmpty($0) } dict[2107670217] = { return Api.InputPeer.parse_inputPeerSelf($0) } - dict[396093539] = { return Api.InputPeer.parse_inputPeerChat($0) } - dict[2072935910] = { return Api.InputPeer.parse_inputPeerUser($0) } - dict[548253432] = { return Api.InputPeer.parse_inputPeerChannel($0) } - dict[398123750] = { return Api.InputPeer.parse_inputPeerUserFromMessage($0) } - dict[-1667893317] = { return Api.InputPeer.parse_inputPeerChannelFromMessage($0) } + dict[900291769] = { return Api.InputPeer.parse_inputPeerChat($0) } + dict[-571955892] = { return Api.InputPeer.parse_inputPeerUser($0) } + dict[666680316] = { return Api.InputPeer.parse_inputPeerChannel($0) } + dict[-1468331492] = { return Api.InputPeer.parse_inputPeerUserFromMessage($0) } + dict[-1121318848] = { return Api.InputPeer.parse_inputPeerChannelFromMessage($0) } dict[568808380] = { return Api.upload.WebFile.parse_webFile($0) } - dict[-116274796] = { return Api.Contact.parse_contact($0) } + dict[341499403] = { return Api.Contact.parse_contact($0) } dict[-1078332329] = { return Api.help.PassportConfig.parse_passportConfigNotModified($0) } dict[-1600596305] = { return Api.help.PassportConfig.parse_passportConfig($0) } dict[1648543603] = { return Api.FileHash.parse_fileHash($0) } @@ -429,8 +429,8 @@ fileprivate let parsers: [Int32 : (BufferReader) -> Any?] = { dict[195371015] = { return Api.InputPrivacyRule.parse_inputPrivacyValueDisallowContacts($0) } dict[-697604407] = { return Api.InputPrivacyRule.parse_inputPrivacyValueDisallowAll($0) } dict[-1877932953] = { return Api.InputPrivacyRule.parse_inputPrivacyValueDisallowUsers($0) } - dict[1283572154] = { return Api.InputPrivacyRule.parse_inputPrivacyValueAllowChatParticipants($0) } - dict[-668769361] = { return Api.InputPrivacyRule.parse_inputPrivacyValueDisallowChatParticipants($0) } + dict[-2079962673] = { return Api.InputPrivacyRule.parse_inputPrivacyValueAllowChatParticipants($0) } + dict[-380694650] = { return Api.InputPrivacyRule.parse_inputPrivacyValueDisallowChatParticipants($0) } dict[-1058912715] = { return Api.messages.DhConfig.parse_dhConfigNotModified($0) } dict[740433629] = { return Api.messages.DhConfig.parse_dhConfig($0) } dict[-421545947] = { return Api.ChannelAdminLogEventAction.parse_channelAdminLogEventActionChangeTitle($0) } @@ -451,7 +451,7 @@ fileprivate let parsers: [Int32 : (BufferReader) -> Any?] = { dict[1599903217] = { return Api.ChannelAdminLogEventAction.parse_channelAdminLogEventActionTogglePreHistoryHidden($0) } dict[771095562] = { return Api.ChannelAdminLogEventAction.parse_channelAdminLogEventActionDefaultBannedRights($0) } dict[-1895328189] = { return Api.ChannelAdminLogEventAction.parse_channelAdminLogEventActionStopPoll($0) } - dict[-1569748965] = { return Api.ChannelAdminLogEventAction.parse_channelAdminLogEventActionChangeLinkedChat($0) } + dict[84703944] = { return Api.ChannelAdminLogEventAction.parse_channelAdminLogEventActionChangeLinkedChat($0) } dict[241923758] = { return Api.ChannelAdminLogEventAction.parse_channelAdminLogEventActionChangeLocation($0) } dict[1401984889] = { return Api.ChannelAdminLogEventAction.parse_channelAdminLogEventActionToggleSlowMode($0) } dict[589338437] = { return Api.ChannelAdminLogEventAction.parse_channelAdminLogEventActionStartGroupCall($0) } @@ -466,7 +466,7 @@ fileprivate let parsers: [Int32 : (BufferReader) -> Any?] = { dict[1048537159] = { return Api.ChannelAdminLogEventAction.parse_channelAdminLogEventActionParticipantVolume($0) } dict[1855199800] = { return Api.ChannelAdminLogEventAction.parse_channelAdminLogEventActionChangeHistoryTTL($0) } dict[-26672755] = { return Api.ChannelAdminLogEventAction.parse_channelAdminLogEventActionChangeTheme($0) } - dict[-543777747] = { return Api.auth.ExportedAuthorization.parse_exportedAuthorization($0) } + dict[-1271602504] = { return Api.auth.ExportedAuthorization.parse_exportedAuthorization($0) } dict[2103482845] = { return Api.SecurePlainData.parse_securePlainPhone($0) } dict[569137759] = { return Api.SecurePlainData.parse_securePlainEmail($0) } dict[-1269012015] = { return Api.messages.AffectedHistory.parse_affectedHistory($0) } @@ -501,7 +501,7 @@ fileprivate let parsers: [Int32 : (BufferReader) -> Any?] = { dict[453805082] = { return Api.DraftMessage.parse_draftMessageEmpty($0) } dict[-40996577] = { return Api.DraftMessage.parse_draftMessage($0) } dict[-1014526429] = { return Api.help.Country.parse_country($0) } - dict[418631927] = { return Api.StatsGroupTopPoster.parse_statsGroupTopPoster($0) } + dict[-1660637285] = { return Api.StatsGroupTopPoster.parse_statsGroupTopPoster($0) } dict[-2128640689] = { return Api.account.SentEmailCode.parse_sentEmailCode($0) } dict[-1038136962] = { return Api.EncryptedFile.parse_encryptedFileEmpty($0) } dict[1248893260] = { return Api.EncryptedFile.parse_encryptedFile($0) } @@ -537,7 +537,7 @@ fileprivate let parsers: [Int32 : (BufferReader) -> Any?] = { dict[-2049074735] = { return Api.ReplyMarkup.parse_replyKeyboardMarkup($0) } dict[1218642516] = { return Api.ReplyMarkup.parse_replyInlineMarkup($0) } dict[1556570557] = { return Api.EmojiKeywordsDifference.parse_emojiKeywordsDifference($0) } - dict[1493171408] = { return Api.HighScore.parse_highScore($0) } + dict[1940093419] = { return Api.HighScore.parse_highScore($0) } dict[-305282981] = { return Api.TopPeer.parse_topPeer($0) } dict[-1495959709] = { return Api.MessageReplyHeader.parse_messageReplyHeader($0) } dict[411017418] = { return Api.SecureValue.parse_secureValue($0) } @@ -549,8 +549,8 @@ fileprivate let parsers: [Int32 : (BufferReader) -> Any?] = { dict[-386039788] = { return Api.PeerBlocked.parse_peerBlocked($0) } dict[-1182234929] = { return Api.InputUser.parse_inputUserEmpty($0) } dict[-138301121] = { return Api.InputUser.parse_inputUserSelf($0) } - dict[-668391402] = { return Api.InputUser.parse_inputUser($0) } - dict[756118935] = { return Api.InputUser.parse_inputUserFromMessage($0) } + dict[-233744186] = { return Api.InputUser.parse_inputUser($0) } + dict[497305826] = { return Api.InputUser.parse_inputUserFromMessage($0) } dict[-1738178803] = { return Api.Page.parse_page($0) } dict[871426631] = { return Api.SecureCredentialsEncrypted.parse_secureCredentialsEncrypted($0) } dict[-875679776] = { return Api.StatsPercentValue.parse_statsPercentValue($0) } @@ -574,12 +574,12 @@ fileprivate let parsers: [Int32 : (BufferReader) -> Any?] = { dict[-1032140601] = { return Api.BotCommand.parse_botCommand($0) } dict[1474462241] = { return Api.account.ContentSettings.parse_contentSettings($0) } dict[-193506890] = { return Api.phone.GroupParticipants.parse_groupParticipants($0) } - dict[507405952] = { return Api.ChatInviteImporter.parse_chatInviteImporter($0) } + dict[190633460] = { return Api.ChatInviteImporter.parse_chatInviteImporter($0) } dict[-2066640507] = { return Api.messages.AffectedMessages.parse_affectedMessages($0) } dict[-402498398] = { return Api.messages.SavedGifs.parse_savedGifsNotModified($0) } - dict[772213157] = { return Api.messages.SavedGifs.parse_savedGifs($0) } + dict[-2069878259] = { return Api.messages.SavedGifs.parse_savedGifs($0) } dict[-914167110] = { return Api.CdnPublicKey.parse_cdnPublicKey($0) } - dict[1093204652] = { return Api.MessageReplies.parse_messageReplies($0) } + dict[-2083123262] = { return Api.MessageReplies.parse_messageReplies($0) } dict[53231223] = { return Api.InputGame.parse_inputGameID($0) } dict[-1020139510] = { return Api.InputGame.parse_inputGameShortName($0) } dict[1107543535] = { return Api.help.CountryCode.parse_countryCode($0) } @@ -618,8 +618,8 @@ fileprivate let parsers: [Int32 : (BufferReader) -> Any?] = { dict[-1387279939] = { return Api.MessageInteractionCounters.parse_messageInteractionCounters($0) } dict[-1107852396] = { return Api.stats.BroadcastStats.parse_broadcastStats($0) } dict[-484987010] = { return Api.Updates.parse_updatesTooLong($0) } - dict[-84936653] = { return Api.Updates.parse_updateShortMessage($0) } - dict[290961496] = { return Api.Updates.parse_updateShortChatMessage($0) } + dict[826001400] = { return Api.Updates.parse_updateShortMessage($0) } + dict[1299050149] = { return Api.Updates.parse_updateShortChatMessage($0) } dict[2027216577] = { return Api.Updates.parse_updateShort($0) } dict[1918567619] = { return Api.Updates.parse_updatesCombined($0) } dict[1957577280] = { return Api.Updates.parse_updates($0) } @@ -629,7 +629,7 @@ fileprivate let parsers: [Int32 : (BufferReader) -> Any?] = { dict[1038967584] = { return Api.MessageMedia.parse_messageMediaEmpty($0) } dict[1766936791] = { return Api.MessageMedia.parse_messageMediaPhoto($0) } dict[1457575028] = { return Api.MessageMedia.parse_messageMediaGeo($0) } - dict[-873313984] = { return Api.MessageMedia.parse_messageMediaContact($0) } + dict[1882335561] = { return Api.MessageMedia.parse_messageMediaContact($0) } dict[-1618676578] = { return Api.MessageMedia.parse_messageMediaUnsupported($0) } dict[-1666158377] = { return Api.MessageMedia.parse_messageMediaDocument($0) } dict[-1557277184] = { return Api.MessageMedia.parse_messageMediaWebPage($0) } @@ -656,8 +656,8 @@ fileprivate let parsers: [Int32 : (BufferReader) -> Any?] = { dict[935395612] = { return Api.ChatPhoto.parse_chatPhotoEmpty($0) } dict[476978193] = { return Api.ChatPhoto.parse_chatPhoto($0) } dict[1869903447] = { return Api.PageCaption.parse_pageCaption($0) } - dict[-1928649707] = { return Api.payments.PaymentForm.parse_paymentForm($0) } - dict[280319440] = { return Api.payments.PaymentReceipt.parse_paymentReceipt($0) } + dict[378828315] = { return Api.payments.PaymentForm.parse_paymentForm($0) } + dict[1891958275] = { return Api.payments.PaymentReceipt.parse_paymentReceipt($0) } dict[863093588] = { return Api.messages.PeerDialogs.parse_peerDialogs($0) } dict[-1831650802] = { return Api.UrlAuthResult.parse_urlAuthResultRequest($0) } dict[-1886646706] = { return Api.UrlAuthResult.parse_urlAuthResultAccepted($0) } @@ -668,17 +668,17 @@ fileprivate let parsers: [Int32 : (BufferReader) -> Any?] = { dict[42402760] = { return Api.InputStickerSet.parse_inputStickerSetAnimatedEmoji($0) } dict[-427863538] = { return Api.InputStickerSet.parse_inputStickerSetDice($0) } dict[-1231326505] = { return Api.messages.ChatAdminsWithInvites.parse_chatAdminsWithInvites($0) } - dict[-1729618630] = { return Api.BotInfo.parse_botInfo($0) } + dict[460632885] = { return Api.BotInfo.parse_botInfo($0) } dict[-2046910401] = { return Api.stickers.SuggestedShortName.parse_suggestedShortName($0) } dict[-1519637954] = { return Api.updates.State.parse_state($0) } - dict[537022650] = { return Api.User.parse_userEmpty($0) } - dict[-1820043071] = { return Api.User.parse_user($0) } + dict[-742634630] = { return Api.User.parse_userEmpty($0) } + dict[1073147056] = { return Api.User.parse_user($0) } dict[-1868117372] = { return Api.Message.parse_messageEmpty($0) } - dict[-1125940270] = { return Api.Message.parse_message($0) } + dict[-2049520670] = { return Api.Message.parse_message($0) } dict[721967202] = { return Api.Message.parse_messageService($0) } - dict[831924812] = { return Api.StatsGroupTopInviter.parse_statsGroupTopInviter($0) } + dict[1398765469] = { return Api.StatsGroupTopInviter.parse_statsGroupTopInviter($0) } dict[186120336] = { return Api.messages.RecentStickers.parse_recentStickersNotModified($0) } - dict[586395571] = { return Api.messages.RecentStickers.parse_recentStickers($0) } + dict[-1999405994] = { return Api.messages.RecentStickers.parse_recentStickers($0) } dict[-539317279] = { return Api.InputFileLocation.parse_inputFileLocation($0) } dict[-182231723] = { return Api.InputFileLocation.parse_inputEncryptedFileLocation($0) } dict[-1160743548] = { return Api.InputFileLocation.parse_inputDocumentFileLocation($0) } @@ -694,8 +694,8 @@ fileprivate let parsers: [Int32 : (BufferReader) -> Any?] = { dict[506920429] = { return Api.InputPhoneCall.parse_inputPhoneCall($0) } dict[541839704] = { return Api.phone.ExportedGroupCallInvite.parse_exportedGroupCallInvite($0) } dict[-1551583367] = { return Api.ReceivedNotifyMessage.parse_receivedNotifyMessage($0) } - dict[-57668565] = { return Api.ChatParticipants.parse_chatParticipantsForbidden($0) } - dict[1061556205] = { return Api.ChatParticipants.parse_chatParticipants($0) } + dict[-2023500831] = { return Api.ChatParticipants.parse_chatParticipantsForbidden($0) } + dict[1018991608] = { return Api.ChatParticipants.parse_chatParticipants($0) } dict[1949890536] = { return Api.DialogFilter.parse_dialogFilter($0) } dict[-1056001329] = { return Api.InputPaymentCredentials.parse_inputPaymentCredentialsSaved($0) } dict[873977640] = { return Api.InputPaymentCredentials.parse_inputPaymentCredentials($0) } @@ -715,7 +715,7 @@ fileprivate let parsers: [Int32 : (BufferReader) -> Any?] = { dict[70813275] = { return Api.InputStickeredMedia.parse_inputStickeredMediaDocument($0) } dict[1421174295] = { return Api.WebPageAttribute.parse_webPageAttributeTheme($0) } dict[-958657434] = { return Api.messages.FeaturedStickers.parse_featuredStickersNotModified($0) } - dict[-1230257343] = { return Api.messages.FeaturedStickers.parse_featuredStickers($0) } + dict[-2067782896] = { return Api.messages.FeaturedStickers.parse_featuredStickers($0) } dict[-318022605] = { return Api.ChatTheme.parse_chatTheme($0) } dict[-2048646399] = { return Api.PhoneCallDiscardReason.parse_phoneCallDiscardReasonMissed($0) } dict[-527056480] = { return Api.PhoneCallDiscardReason.parse_phoneCallDiscardReasonDisconnect($0) } @@ -728,7 +728,7 @@ fileprivate let parsers: [Int32 : (BufferReader) -> Any?] = { dict[2010127419] = { return Api.contacts.ImportedContacts.parse_importedContacts($0) } dict[-1678949555] = { return Api.InputWebDocument.parse_inputWebDocument($0) } dict[-326966976] = { return Api.phone.PhoneCall.parse_phoneCall($0) } - dict[995769920] = { return Api.ChannelAdminLogEvent.parse_channelAdminLogEvent($0) } + dict[531458253] = { return Api.ChannelAdminLogEvent.parse_channelAdminLogEvent($0) } dict[-1132882121] = { return Api.Bool.parse_boolFalse($0) } dict[-1720552011] = { return Api.Bool.parse_boolTrue($0) } dict[-892239370] = { return Api.LangPackString.parse_langPackString($0) } @@ -779,13 +779,13 @@ fileprivate let parsers: [Int32 : (BufferReader) -> Any?] = { dict[894081801] = { return Api.BotInlineMessage.parse_botInlineMessageMediaInvoice($0) } dict[-1673717362] = { return Api.InputPeerNotifySettings.parse_inputPeerNotifySettings($0) } dict[-1634752813] = { return Api.messages.FavedStickers.parse_favedStickersNotModified($0) } - dict[-209768682] = { return Api.messages.FavedStickers.parse_favedStickers($0) } - dict[1847917725] = { return Api.ExportedChatInvite.parse_chatInviteExported($0) } + dict[750063767] = { return Api.messages.FavedStickers.parse_favedStickers($0) } + dict[-1316944408] = { return Api.ExportedChatInvite.parse_chatInviteExported($0) } dict[-1389486888] = { return Api.account.AuthorizationForm.parse_authorizationForm($0) } dict[-1392388579] = { return Api.Authorization.parse_authorization($0) } dict[-1361650766] = { return Api.MaskCoords.parse_maskCoords($0) } dict[-395967805] = { return Api.messages.AllStickers.parse_allStickersNotModified($0) } - dict[-302170017] = { return Api.messages.AllStickers.parse_allStickers($0) } + dict[-843329861] = { return Api.messages.AllStickers.parse_allStickers($0) } dict[-1655957568] = { return Api.PhoneConnection.parse_phoneConnection($0) } dict[1667228533] = { return Api.PhoneConnection.parse_phoneConnectionWebrtc($0) } dict[-206688531] = { return Api.help.UserInfo.parse_userInfoEmpty($0) } @@ -814,23 +814,23 @@ fileprivate let parsers: [Int32 : (BufferReader) -> Any?] = { dict[1352683077] = { return Api.account.PrivacyRules.parse_privacyRules($0) } dict[-123988] = { return Api.PrivacyRule.parse_privacyValueAllowContacts($0) } dict[1698855810] = { return Api.PrivacyRule.parse_privacyValueAllowAll($0) } - dict[1297858060] = { return Api.PrivacyRule.parse_privacyValueAllowUsers($0) } + dict[-1198497870] = { return Api.PrivacyRule.parse_privacyValueAllowUsers($0) } dict[-125240806] = { return Api.PrivacyRule.parse_privacyValueDisallowContacts($0) } dict[-1955338397] = { return Api.PrivacyRule.parse_privacyValueDisallowAll($0) } - dict[209668535] = { return Api.PrivacyRule.parse_privacyValueDisallowUsers($0) } - dict[415136107] = { return Api.PrivacyRule.parse_privacyValueAllowChatParticipants($0) } - dict[-1397881200] = { return Api.PrivacyRule.parse_privacyValueDisallowChatParticipants($0) } + dict[-463335103] = { return Api.PrivacyRule.parse_privacyValueDisallowUsers($0) } + dict[1796427406] = { return Api.PrivacyRule.parse_privacyValueAllowChatParticipants($0) } + dict[1103656293] = { return Api.PrivacyRule.parse_privacyValueDisallowChatParticipants($0) } dict[-1230047312] = { return Api.MessageAction.parse_messageActionEmpty($0) } - dict[-1503425638] = { return Api.MessageAction.parse_messageActionChatCreate($0) } + dict[-1119368275] = { return Api.MessageAction.parse_messageActionChatCreate($0) } dict[-1247687078] = { return Api.MessageAction.parse_messageActionChatEditTitle($0) } dict[2144015272] = { return Api.MessageAction.parse_messageActionChatEditPhoto($0) } dict[-1780220945] = { return Api.MessageAction.parse_messageActionChatDeletePhoto($0) } - dict[1217033015] = { return Api.MessageAction.parse_messageActionChatAddUser($0) } - dict[-1297179892] = { return Api.MessageAction.parse_messageActionChatDeleteUser($0) } - dict[-123931160] = { return Api.MessageAction.parse_messageActionChatJoinedByLink($0) } + dict[365886720] = { return Api.MessageAction.parse_messageActionChatAddUser($0) } + dict[-1539362612] = { return Api.MessageAction.parse_messageActionChatDeleteUser($0) } + dict[51520707] = { return Api.MessageAction.parse_messageActionChatJoinedByLink($0) } dict[-1781355374] = { return Api.MessageAction.parse_messageActionChannelCreate($0) } - dict[1371385889] = { return Api.MessageAction.parse_messageActionChatMigrateTo($0) } - dict[-1336546578] = { return Api.MessageAction.parse_messageActionChannelMigrateFrom($0) } + dict[-519864430] = { return Api.MessageAction.parse_messageActionChatMigrateTo($0) } + dict[-365344535] = { return Api.MessageAction.parse_messageActionChannelMigrateFrom($0) } dict[-1799538451] = { return Api.MessageAction.parse_messageActionPinMessage($0) } dict[-1615153660] = { return Api.MessageAction.parse_messageActionHistoryClear($0) } dict[-1834538890] = { return Api.MessageAction.parse_messageActionGameScore($0) } @@ -845,15 +845,15 @@ fileprivate let parsers: [Int32 : (BufferReader) -> Any?] = { dict[-202219658] = { return Api.MessageAction.parse_messageActionContactSignUp($0) } dict[-1730095465] = { return Api.MessageAction.parse_messageActionGeoProximityReached($0) } dict[2047704898] = { return Api.MessageAction.parse_messageActionGroupCall($0) } - dict[1991897370] = { return Api.MessageAction.parse_messageActionInviteToGroupCall($0) } + dict[1345295095] = { return Api.MessageAction.parse_messageActionInviteToGroupCall($0) } dict[-1441072131] = { return Api.MessageAction.parse_messageActionSetMessagesTTL($0) } dict[-1281329567] = { return Api.MessageAction.parse_messageActionGroupCallScheduled($0) } dict[-1434950843] = { return Api.MessageAction.parse_messageActionSetChatTheme($0) } dict[1399245077] = { return Api.PhoneCall.parse_phoneCallEmpty($0) } - dict[462375633] = { return Api.PhoneCall.parse_phoneCallWaiting($0) } - dict[-2014659757] = { return Api.PhoneCall.parse_phoneCallRequested($0) } - dict[-1719909046] = { return Api.PhoneCall.parse_phoneCallAccepted($0) } - dict[-2025673089] = { return Api.PhoneCall.parse_phoneCall($0) } + dict[-987599081] = { return Api.PhoneCall.parse_phoneCallWaiting($0) } + dict[347139340] = { return Api.PhoneCall.parse_phoneCallRequested($0) } + dict[912311057] = { return Api.PhoneCall.parse_phoneCallAccepted($0) } + dict[-1770029977] = { return Api.PhoneCall.parse_phoneCall($0) } dict[1355435489] = { return Api.PhoneCall.parse_phoneCallDiscarded($0) } dict[-483352705] = { return Api.help.TermsOfServiceUpdate.parse_termsOfServiceUpdateEmpty($0) } dict[686618977] = { return Api.help.TermsOfServiceUpdate.parse_termsOfServiceUpdate($0) } @@ -868,6 +868,7 @@ fileprivate let parsers: [Int32 : (BufferReader) -> Any?] = { dict[-1917524116] = { return Api.ThemeSettings.parse_themeSettings($0) } dict[-1353671392] = { return Api.PeerNotifySettings.parse_peerNotifySettings($0) } dict[-1995686519] = { return Api.InputBotInlineMessageID.parse_inputBotInlineMessageID($0) } + dict[-1227287081] = { return Api.InputBotInlineMessageID.parse_inputBotInlineMessageID64($0) } dict[-1282352120] = { return Api.PageRelatedArticle.parse_pageRelatedArticle($0) } dict[313694676] = { return Api.StickerPack.parse_stickerPack($0) } dict[1326562017] = { return Api.UserProfilePhoto.parse_userProfilePhotoEmpty($0) } @@ -892,7 +893,7 @@ fileprivate let parsers: [Int32 : (BufferReader) -> Any?] = { dict[681706865] = { return Api.MessageEntity.parse_messageEntityCode($0) } dict[1938967520] = { return Api.MessageEntity.parse_messageEntityPre($0) } dict[1990644519] = { return Api.MessageEntity.parse_messageEntityTextUrl($0) } - dict[892193368] = { return Api.MessageEntity.parse_messageEntityMentionName($0) } + dict[-595914432] = { return Api.MessageEntity.parse_messageEntityMentionName($0) } dict[546203849] = { return Api.MessageEntity.parse_inputMessageEntityMentionName($0) } dict[-1687559349] = { return Api.MessageEntity.parse_messageEntityPhone($0) } dict[1280209983] = { return Api.MessageEntity.parse_messageEntityCashtag($0) } @@ -912,17 +913,17 @@ fileprivate let parsers: [Int32 : (BufferReader) -> Any?] = { dict[1577484359] = { return Api.PageListOrderedItem.parse_pageListOrderedItemText($0) } dict[-1730311882] = { return Api.PageListOrderedItem.parse_pageListOrderedItemBlocks($0) } dict[-1417756512] = { return Api.EncryptedChat.parse_encryptedChatEmpty($0) } - dict[1006044124] = { return Api.EncryptedChat.parse_encryptedChatWaiting($0) } - dict[1651608194] = { return Api.EncryptedChat.parse_encryptedChatRequested($0) } - dict[-94974410] = { return Api.EncryptedChat.parse_encryptedChat($0) } + dict[1722964307] = { return Api.EncryptedChat.parse_encryptedChatWaiting($0) } + dict[1223809356] = { return Api.EncryptedChat.parse_encryptedChatRequested($0) } + dict[1643173063] = { return Api.EncryptedChat.parse_encryptedChat($0) } dict[505183301] = { return Api.EncryptedChat.parse_encryptedChatDiscarded($0) } dict[-901375139] = { return Api.PeerLocated.parse_peerLocated($0) } dict[-118740917] = { return Api.PeerLocated.parse_peerSelfLocated($0) } dict[922273905] = { return Api.Document.parse_documentEmpty($0) } dict[512177195] = { return Api.Document.parse_document($0) } dict[-1707344487] = { return Api.messages.HighScores.parse_highScores($0) } - dict[-892779534] = { return Api.WebAuthorization.parse_webAuthorization($0) } - dict[-805141448] = { return Api.ImportedContact.parse_importedContact($0) } + dict[-1493633966] = { return Api.WebAuthorization.parse_webAuthorization($0) } + dict[-1052885936] = { return Api.ImportedContact.parse_importedContact($0) } dict[1042605427] = { return Api.payments.BankCardData.parse_bankCardData($0) } return dict }() diff --git a/submodules/TelegramApi/Sources/Api1.swift b/submodules/TelegramApi/Sources/Api1.swift index d4a842370f..288997a593 100644 --- a/submodules/TelegramApi/Sources/Api1.swift +++ b/submodules/TelegramApi/Sources/Api1.swift @@ -368,7 +368,7 @@ public struct messages { } public enum Stickers: TypeConstructorDescription { case stickersNotModified - case stickers(hash: Int32, stickers: [Api.Document]) + case stickers(hash: Int64, stickers: [Api.Document]) public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) { switch self { @@ -380,9 +380,9 @@ public struct messages { break case .stickers(let hash, let stickers): if boxed { - buffer.appendInt32(-463889475) + buffer.appendInt32(816245886) } - serializeInt32(hash, buffer: buffer, boxed: false) + serializeInt64(hash, buffer: buffer, boxed: false) buffer.appendInt32(481674261) buffer.appendInt32(Int32(stickers.count)) for item in stickers { @@ -405,8 +405,8 @@ public struct messages { return Api.messages.Stickers.stickersNotModified } public static func parse_stickers(_ reader: BufferReader) -> Stickers? { - var _1: Int32? - _1 = reader.readInt32() + var _1: Int64? + _1 = reader.readInt64() var _2: [Api.Document]? if let _ = reader.readInt32() { _2 = Api.parseVector(reader, elementSignature: 0, elementType: Api.Document.self) @@ -424,7 +424,7 @@ public struct messages { } public enum FoundStickerSets: TypeConstructorDescription { case foundStickerSetsNotModified - case foundStickerSets(hash: Int32, sets: [Api.StickerSetCovered]) + case foundStickerSets(hash: Int64, sets: [Api.StickerSetCovered]) public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) { switch self { @@ -436,9 +436,9 @@ public struct messages { break case .foundStickerSets(let hash, let sets): if boxed { - buffer.appendInt32(1359533640) + buffer.appendInt32(-1963942446) } - serializeInt32(hash, buffer: buffer, boxed: false) + serializeInt64(hash, buffer: buffer, boxed: false) buffer.appendInt32(481674261) buffer.appendInt32(Int32(sets.count)) for item in sets { @@ -461,8 +461,8 @@ public struct messages { return Api.messages.FoundStickerSets.foundStickerSetsNotModified } public static func parse_foundStickerSets(_ reader: BufferReader) -> FoundStickerSets? { - var _1: Int32? - _1 = reader.readInt32() + var _1: Int64? + _1 = reader.readInt64() var _2: [Api.StickerSetCovered]? if let _ = reader.readInt32() { _2 = Api.parseVector(reader, elementSignature: 0, elementType: Api.StickerSetCovered.self) @@ -1286,7 +1286,7 @@ public struct messages { } public enum SavedGifs: TypeConstructorDescription { case savedGifsNotModified - case savedGifs(hash: Int32, gifs: [Api.Document]) + case savedGifs(hash: Int64, gifs: [Api.Document]) public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) { switch self { @@ -1298,9 +1298,9 @@ public struct messages { break case .savedGifs(let hash, let gifs): if boxed { - buffer.appendInt32(772213157) + buffer.appendInt32(-2069878259) } - serializeInt32(hash, buffer: buffer, boxed: false) + serializeInt64(hash, buffer: buffer, boxed: false) buffer.appendInt32(481674261) buffer.appendInt32(Int32(gifs.count)) for item in gifs { @@ -1323,8 +1323,8 @@ public struct messages { return Api.messages.SavedGifs.savedGifsNotModified } public static func parse_savedGifs(_ reader: BufferReader) -> SavedGifs? { - var _1: Int32? - _1 = reader.readInt32() + var _1: Int64? + _1 = reader.readInt64() var _2: [Api.Document]? if let _ = reader.readInt32() { _2 = Api.parseVector(reader, elementSignature: 0, elementType: Api.Document.self) @@ -1852,7 +1852,7 @@ public struct messages { } public enum RecentStickers: TypeConstructorDescription { case recentStickersNotModified - case recentStickers(hash: Int32, packs: [Api.StickerPack], stickers: [Api.Document], dates: [Int32]) + case recentStickers(hash: Int64, packs: [Api.StickerPack], stickers: [Api.Document], dates: [Int32]) public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) { switch self { @@ -1864,9 +1864,9 @@ public struct messages { break case .recentStickers(let hash, let packs, let stickers, let dates): if boxed { - buffer.appendInt32(586395571) + buffer.appendInt32(-1999405994) } - serializeInt32(hash, buffer: buffer, boxed: false) + serializeInt64(hash, buffer: buffer, boxed: false) buffer.appendInt32(481674261) buffer.appendInt32(Int32(packs.count)) for item in packs { @@ -1899,8 +1899,8 @@ public struct messages { return Api.messages.RecentStickers.recentStickersNotModified } public static func parse_recentStickers(_ reader: BufferReader) -> RecentStickers? { - var _1: Int32? - _1 = reader.readInt32() + var _1: Int64? + _1 = reader.readInt64() var _2: [Api.StickerPack]? if let _ = reader.readInt32() { _2 = Api.parseVector(reader, elementSignature: 0, elementType: Api.StickerPack.self) @@ -1928,7 +1928,7 @@ public struct messages { } public enum FeaturedStickers: TypeConstructorDescription { case featuredStickersNotModified(count: Int32) - case featuredStickers(hash: Int32, count: Int32, sets: [Api.StickerSetCovered], unread: [Int64]) + case featuredStickers(hash: Int64, count: Int32, sets: [Api.StickerSetCovered], unread: [Int64]) public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) { switch self { @@ -1940,9 +1940,9 @@ public struct messages { break case .featuredStickers(let hash, let count, let sets, let unread): if boxed { - buffer.appendInt32(-1230257343) + buffer.appendInt32(-2067782896) } - serializeInt32(hash, buffer: buffer, boxed: false) + serializeInt64(hash, buffer: buffer, boxed: false) serializeInt32(count, buffer: buffer, boxed: false) buffer.appendInt32(481674261) buffer.appendInt32(Int32(sets.count)) @@ -1979,8 +1979,8 @@ public struct messages { } } public static func parse_featuredStickers(_ reader: BufferReader) -> FeaturedStickers? { - var _1: Int32? - _1 = reader.readInt32() + var _1: Int64? + _1 = reader.readInt64() var _2: Int32? _2 = reader.readInt32() var _3: [Api.StickerSetCovered]? @@ -2156,7 +2156,7 @@ public struct messages { } public enum FavedStickers: TypeConstructorDescription { case favedStickersNotModified - case favedStickers(hash: Int32, packs: [Api.StickerPack], stickers: [Api.Document]) + case favedStickers(hash: Int64, packs: [Api.StickerPack], stickers: [Api.Document]) public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) { switch self { @@ -2168,9 +2168,9 @@ public struct messages { break case .favedStickers(let hash, let packs, let stickers): if boxed { - buffer.appendInt32(-209768682) + buffer.appendInt32(750063767) } - serializeInt32(hash, buffer: buffer, boxed: false) + serializeInt64(hash, buffer: buffer, boxed: false) buffer.appendInt32(481674261) buffer.appendInt32(Int32(packs.count)) for item in packs { @@ -2198,8 +2198,8 @@ public struct messages { return Api.messages.FavedStickers.favedStickersNotModified } public static func parse_favedStickers(_ reader: BufferReader) -> FavedStickers? { - var _1: Int32? - _1 = reader.readInt32() + var _1: Int64? + _1 = reader.readInt64() var _2: [Api.StickerPack]? if let _ = reader.readInt32() { _2 = Api.parseVector(reader, elementSignature: 0, elementType: Api.StickerPack.self) @@ -2222,7 +2222,7 @@ public struct messages { } public enum AllStickers: TypeConstructorDescription { case allStickersNotModified - case allStickers(hash: Int32, sets: [Api.StickerSet]) + case allStickers(hash: Int64, sets: [Api.StickerSet]) public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) { switch self { @@ -2234,9 +2234,9 @@ public struct messages { break case .allStickers(let hash, let sets): if boxed { - buffer.appendInt32(-302170017) + buffer.appendInt32(-843329861) } - serializeInt32(hash, buffer: buffer, boxed: false) + serializeInt64(hash, buffer: buffer, boxed: false) buffer.appendInt32(481674261) buffer.appendInt32(Int32(sets.count)) for item in sets { @@ -2259,8 +2259,8 @@ public struct messages { return Api.messages.AllStickers.allStickersNotModified } public static func parse_allStickers(_ reader: BufferReader) -> AllStickers? { - var _1: Int32? - _1 = reader.readInt32() + var _1: Int64? + _1 = reader.readInt64() var _2: [Api.StickerSet]? if let _ = reader.readInt32() { _2 = Api.parseVector(reader, elementSignature: 0, elementType: Api.StickerSet.self) diff --git a/submodules/TelegramApi/Sources/Api2.swift b/submodules/TelegramApi/Sources/Api2.swift index bb90f1e4f4..219e684a9f 100644 --- a/submodules/TelegramApi/Sources/Api2.swift +++ b/submodules/TelegramApi/Sources/Api2.swift @@ -160,17 +160,17 @@ public extension Api { } public enum ChatFull: TypeConstructorDescription { - case chatFull(flags: Int32, id: Int32, 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?) - case channelFull(flags: Int32, id: Int32, 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: Int32?, migratedFromMaxId: Int32?, pinnedMsgId: Int32?, stickerset: Api.StickerSet?, availableMinId: Int32?, folderId: Int32?, linkedChatId: Int32?, location: Api.ChannelLocation?, slowmodeSeconds: Int32?, slowmodeNextSendDate: Int32?, statsDc: Int32?, pts: Int32, call: Api.InputGroupCall?, ttlPeriod: Int32?, pendingSuggestions: [String]?, groupcallDefaultJoinAs: Api.Peer?, themeEmoticon: String?) + 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?) + case channelFull(flags: 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?) public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) { switch self { case .chatFull(let flags, let id, let about, let participants, let chatPhoto, let notifySettings, let exportedInvite, let botInfo, let pinnedMsgId, let folderId, let call, let ttlPeriod, let groupcallDefaultJoinAs, let themeEmoticon): if boxed { - buffer.appendInt32(1235264985) + buffer.appendInt32(1304281241) } serializeInt32(flags, buffer: buffer, boxed: false) - serializeInt32(id, buffer: buffer, boxed: false) + serializeInt64(id, buffer: buffer, boxed: false) serializeString(about, buffer: buffer, boxed: false) participants.serialize(buffer, true) if Int(flags) & Int(1 << 2) != 0 {chatPhoto!.serialize(buffer, true)} @@ -190,10 +190,10 @@ public extension Api { break case .channelFull(let flags, let id, let about, let participantsCount, let adminsCount, let kickedCount, let bannedCount, let onlineCount, let readInboxMaxId, let readOutboxMaxId, let unreadCount, let chatPhoto, let notifySettings, let exportedInvite, let botInfo, let migratedFromChatId, let migratedFromMaxId, let pinnedMsgId, let stickerset, let availableMinId, let folderId, let linkedChatId, let location, let slowmodeSeconds, let slowmodeNextSendDate, let statsDc, let pts, let call, let ttlPeriod, let pendingSuggestions, let groupcallDefaultJoinAs, let themeEmoticon): if boxed { - buffer.appendInt32(793980732) + buffer.appendInt32(-374179305) } serializeInt32(flags, buffer: buffer, boxed: false) - serializeInt32(id, buffer: buffer, boxed: false) + serializeInt64(id, buffer: buffer, boxed: false) serializeString(about, buffer: buffer, boxed: false) if Int(flags) & Int(1 << 0) != 0 {serializeInt32(participantsCount!, buffer: buffer, boxed: false)} if Int(flags) & Int(1 << 1) != 0 {serializeInt32(adminsCount!, buffer: buffer, boxed: false)} @@ -211,13 +211,13 @@ public extension Api { for item in botInfo { item.serialize(buffer, true) } - if Int(flags) & Int(1 << 4) != 0 {serializeInt32(migratedFromChatId!, buffer: buffer, boxed: false)} + if Int(flags) & Int(1 << 4) != 0 {serializeInt64(migratedFromChatId!, buffer: buffer, boxed: false)} if Int(flags) & Int(1 << 4) != 0 {serializeInt32(migratedFromMaxId!, buffer: buffer, boxed: false)} if Int(flags) & Int(1 << 5) != 0 {serializeInt32(pinnedMsgId!, buffer: buffer, boxed: false)} if Int(flags) & Int(1 << 8) != 0 {stickerset!.serialize(buffer, true)} if Int(flags) & Int(1 << 9) != 0 {serializeInt32(availableMinId!, buffer: buffer, boxed: false)} if Int(flags) & Int(1 << 11) != 0 {serializeInt32(folderId!, buffer: buffer, boxed: false)} - if Int(flags) & Int(1 << 14) != 0 {serializeInt32(linkedChatId!, buffer: buffer, boxed: false)} + if Int(flags) & Int(1 << 14) != 0 {serializeInt64(linkedChatId!, buffer: buffer, boxed: false)} if Int(flags) & Int(1 << 15) != 0 {location!.serialize(buffer, true)} if Int(flags) & Int(1 << 17) != 0 {serializeInt32(slowmodeSeconds!, buffer: buffer, boxed: false)} if Int(flags) & Int(1 << 18) != 0 {serializeInt32(slowmodeNextSendDate!, buffer: buffer, boxed: false)} @@ -248,8 +248,8 @@ public extension Api { public static func parse_chatFull(_ reader: BufferReader) -> ChatFull? { var _1: Int32? _1 = reader.readInt32() - var _2: Int32? - _2 = reader.readInt32() + var _2: Int64? + _2 = reader.readInt64() var _3: String? _3 = parseString(reader) var _4: Api.ChatParticipants? @@ -312,8 +312,8 @@ public extension Api { public static func parse_channelFull(_ reader: BufferReader) -> ChatFull? { var _1: Int32? _1 = reader.readInt32() - var _2: Int32? - _2 = reader.readInt32() + var _2: Int64? + _2 = reader.readInt64() var _3: String? _3 = parseString(reader) var _4: Int32? @@ -348,8 +348,8 @@ public extension Api { if let _ = reader.readInt32() { _15 = Api.parseVector(reader, elementSignature: 0, elementType: Api.BotInfo.self) } - var _16: Int32? - if Int(_1!) & Int(1 << 4) != 0 {_16 = reader.readInt32() } + var _16: Int64? + if Int(_1!) & Int(1 << 4) != 0 {_16 = reader.readInt64() } var _17: Int32? if Int(_1!) & Int(1 << 4) != 0 {_17 = reader.readInt32() } var _18: Int32? @@ -362,8 +362,8 @@ public extension Api { if Int(_1!) & Int(1 << 9) != 0 {_20 = reader.readInt32() } var _21: Int32? if Int(_1!) & Int(1 << 11) != 0 {_21 = reader.readInt32() } - var _22: Int32? - if Int(_1!) & Int(1 << 14) != 0 {_22 = reader.readInt32() } + var _22: Int64? + if Int(_1!) & Int(1 << 14) != 0 {_22 = reader.readInt64() } var _23: Api.ChannelLocation? if Int(_1!) & Int(1 << 15) != 0 {if let signature = reader.readInt32() { _23 = Api.parse(reader, signature: signature) as? Api.ChannelLocation @@ -434,13 +434,13 @@ public extension Api { } public enum PollResults: TypeConstructorDescription { - case pollResults(flags: Int32, results: [Api.PollAnswerVoters]?, totalVoters: Int32?, recentVoters: [Int32]?, solution: String?, solutionEntities: [Api.MessageEntity]?) + case pollResults(flags: Int32, results: [Api.PollAnswerVoters]?, totalVoters: Int32?, recentVoters: [Int64]?, solution: String?, solutionEntities: [Api.MessageEntity]?) public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) { switch self { case .pollResults(let flags, let results, let totalVoters, let recentVoters, let solution, let solutionEntities): if boxed { - buffer.appendInt32(-1159937629) + buffer.appendInt32(-591909213) } serializeInt32(flags, buffer: buffer, boxed: false) if Int(flags) & Int(1 << 1) != 0 {buffer.appendInt32(481674261) @@ -452,7 +452,7 @@ public extension Api { if Int(flags) & Int(1 << 3) != 0 {buffer.appendInt32(481674261) buffer.appendInt32(Int32(recentVoters!.count)) for item in recentVoters! { - serializeInt32(item, buffer: buffer, boxed: false) + serializeInt64(item, buffer: buffer, boxed: false) }} if Int(flags) & Int(1 << 4) != 0 {serializeString(solution!, buffer: buffer, boxed: false)} if Int(flags) & Int(1 << 4) != 0 {buffer.appendInt32(481674261) @@ -480,9 +480,9 @@ public extension Api { } } var _3: Int32? if Int(_1!) & Int(1 << 2) != 0 {_3 = reader.readInt32() } - var _4: [Int32]? + var _4: [Int64]? if Int(_1!) & Int(1 << 3) != 0 {if let _ = reader.readInt32() { - _4 = Api.parseVector(reader, elementSignature: -1471112230, elementType: Int32.self) + _4 = Api.parseVector(reader, elementSignature: 570911930, elementType: Int64.self) } } var _5: String? if Int(_1!) & Int(1 << 4) != 0 {_5 = parseString(reader) } @@ -506,32 +506,32 @@ public extension Api { } public enum ChatParticipant: TypeConstructorDescription { - case chatParticipant(userId: Int32, inviterId: Int32, date: Int32) - case chatParticipantCreator(userId: Int32) - case chatParticipantAdmin(userId: Int32, inviterId: Int32, date: Int32) + case chatParticipant(userId: Int64, inviterId: Int64, date: Int32) + case chatParticipantCreator(userId: Int64) + case chatParticipantAdmin(userId: Int64, inviterId: Int64, date: Int32) public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) { switch self { case .chatParticipant(let userId, let inviterId, let date): if boxed { - buffer.appendInt32(-925415106) + buffer.appendInt32(-1070776313) } - serializeInt32(userId, buffer: buffer, boxed: false) - serializeInt32(inviterId, buffer: buffer, boxed: false) + serializeInt64(userId, buffer: buffer, boxed: false) + serializeInt64(inviterId, buffer: buffer, boxed: false) serializeInt32(date, buffer: buffer, boxed: false) break case .chatParticipantCreator(let userId): if boxed { - buffer.appendInt32(-636267638) + buffer.appendInt32(-462696732) } - serializeInt32(userId, buffer: buffer, boxed: false) + serializeInt64(userId, buffer: buffer, boxed: false) break case .chatParticipantAdmin(let userId, let inviterId, let date): if boxed { - buffer.appendInt32(-489233354) + buffer.appendInt32(-1600962725) } - serializeInt32(userId, buffer: buffer, boxed: false) - serializeInt32(inviterId, buffer: buffer, boxed: false) + serializeInt64(userId, buffer: buffer, boxed: false) + serializeInt64(inviterId, buffer: buffer, boxed: false) serializeInt32(date, buffer: buffer, boxed: false) break } @@ -549,10 +549,10 @@ public extension Api { } public static func parse_chatParticipant(_ reader: BufferReader) -> ChatParticipant? { - var _1: Int32? - _1 = reader.readInt32() - var _2: Int32? - _2 = reader.readInt32() + var _1: Int64? + _1 = reader.readInt64() + var _2: Int64? + _2 = reader.readInt64() var _3: Int32? _3 = reader.readInt32() let _c1 = _1 != nil @@ -566,8 +566,8 @@ public extension Api { } } public static func parse_chatParticipantCreator(_ reader: BufferReader) -> ChatParticipant? { - var _1: Int32? - _1 = reader.readInt32() + var _1: Int64? + _1 = reader.readInt64() let _c1 = _1 != nil if _c1 { return Api.ChatParticipant.chatParticipantCreator(userId: _1!) @@ -577,10 +577,10 @@ public extension Api { } } public static func parse_chatParticipantAdmin(_ reader: BufferReader) -> ChatParticipant? { - var _1: Int32? - _1 = reader.readInt32() - var _2: Int32? - _2 = reader.readInt32() + var _1: Int64? + _1 = reader.readInt64() + var _2: Int64? + _2 = reader.readInt64() var _3: Int32? _3 = reader.readInt32() let _c1 = _1 != nil @@ -1752,26 +1752,26 @@ public extension Api { } public enum Chat: TypeConstructorDescription { - case chatEmpty(id: Int32) - case chat(flags: Int32, id: Int32, title: String, photo: Api.ChatPhoto, participantsCount: Int32, date: Int32, version: Int32, migratedTo: Api.InputChannel?, adminRights: Api.ChatAdminRights?, defaultBannedRights: Api.ChatBannedRights?) - case chatForbidden(id: Int32, title: String) - case channel(flags: Int32, id: Int32, accessHash: Int64?, title: String, username: String?, photo: Api.ChatPhoto, date: Int32, version: Int32, restrictionReason: [Api.RestrictionReason]?, adminRights: Api.ChatAdminRights?, bannedRights: Api.ChatBannedRights?, defaultBannedRights: Api.ChatBannedRights?, participantsCount: Int32?) - case channelForbidden(flags: Int32, id: Int32, accessHash: Int64, title: String, untilDate: Int32?) + case chatEmpty(id: Int64) + case chat(flags: Int32, id: Int64, title: String, photo: Api.ChatPhoto, participantsCount: Int32, date: Int32, version: Int32, migratedTo: Api.InputChannel?, adminRights: Api.ChatAdminRights?, defaultBannedRights: Api.ChatBannedRights?) + case chatForbidden(id: Int64, title: String) + case channel(flags: Int32, id: Int64, accessHash: Int64?, title: String, username: String?, photo: Api.ChatPhoto, date: Int32, restrictionReason: [Api.RestrictionReason]?, adminRights: Api.ChatAdminRights?, bannedRights: Api.ChatBannedRights?, defaultBannedRights: Api.ChatBannedRights?, participantsCount: Int32?) + case channelForbidden(flags: Int32, id: Int64, accessHash: Int64, title: String, untilDate: Int32?) public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) { switch self { case .chatEmpty(let id): if boxed { - buffer.appendInt32(-1683826688) + buffer.appendInt32(693512293) } - serializeInt32(id, buffer: buffer, boxed: false) + serializeInt64(id, buffer: buffer, boxed: false) break case .chat(let flags, let id, let title, let photo, let participantsCount, let date, let version, let migratedTo, let adminRights, let defaultBannedRights): if boxed { - buffer.appendInt32(1004149726) + buffer.appendInt32(1103884886) } serializeInt32(flags, buffer: buffer, boxed: false) - serializeInt32(id, buffer: buffer, boxed: false) + serializeInt64(id, buffer: buffer, boxed: false) serializeString(title, buffer: buffer, boxed: false) photo.serialize(buffer, true) serializeInt32(participantsCount, buffer: buffer, boxed: false) @@ -1783,23 +1783,22 @@ public extension Api { break case .chatForbidden(let id, let title): if boxed { - buffer.appendInt32(120753115) + buffer.appendInt32(1704108455) } - serializeInt32(id, buffer: buffer, boxed: false) + serializeInt64(id, buffer: buffer, boxed: false) serializeString(title, buffer: buffer, boxed: false) break - case .channel(let flags, let id, let accessHash, let title, let username, let photo, let date, let version, let restrictionReason, let adminRights, let bannedRights, let defaultBannedRights, let participantsCount): + case .channel(let flags, let id, let accessHash, let title, let username, let photo, let date, let restrictionReason, let adminRights, let bannedRights, let defaultBannedRights, let participantsCount): if boxed { - buffer.appendInt32(-753232354) + buffer.appendInt32(-2107528095) } serializeInt32(flags, buffer: buffer, boxed: false) - serializeInt32(id, buffer: buffer, boxed: false) + serializeInt64(id, buffer: buffer, boxed: false) if Int(flags) & Int(1 << 13) != 0 {serializeInt64(accessHash!, buffer: buffer, boxed: false)} serializeString(title, buffer: buffer, boxed: false) if Int(flags) & Int(1 << 6) != 0 {serializeString(username!, buffer: buffer, boxed: false)} photo.serialize(buffer, true) serializeInt32(date, buffer: buffer, boxed: false) - serializeInt32(version, buffer: buffer, boxed: false) if Int(flags) & Int(1 << 9) != 0 {buffer.appendInt32(481674261) buffer.appendInt32(Int32(restrictionReason!.count)) for item in restrictionReason! { @@ -1812,10 +1811,10 @@ public extension Api { break case .channelForbidden(let flags, let id, let accessHash, let title, let untilDate): if boxed { - buffer.appendInt32(681420594) + buffer.appendInt32(399807445) } serializeInt32(flags, buffer: buffer, boxed: false) - serializeInt32(id, buffer: buffer, boxed: false) + serializeInt64(id, buffer: buffer, boxed: false) serializeInt64(accessHash, buffer: buffer, boxed: false) serializeString(title, buffer: buffer, boxed: false) if Int(flags) & Int(1 << 16) != 0 {serializeInt32(untilDate!, buffer: buffer, boxed: false)} @@ -1831,16 +1830,16 @@ public extension Api { return ("chat", [("flags", flags), ("id", id), ("title", title), ("photo", photo), ("participantsCount", participantsCount), ("date", date), ("version", version), ("migratedTo", migratedTo), ("adminRights", adminRights), ("defaultBannedRights", defaultBannedRights)]) case .chatForbidden(let id, let title): return ("chatForbidden", [("id", id), ("title", title)]) - case .channel(let flags, let id, let accessHash, let title, let username, let photo, let date, let version, let restrictionReason, let adminRights, let bannedRights, let defaultBannedRights, let participantsCount): - return ("channel", [("flags", flags), ("id", id), ("accessHash", accessHash), ("title", title), ("username", username), ("photo", photo), ("date", date), ("version", version), ("restrictionReason", restrictionReason), ("adminRights", adminRights), ("bannedRights", bannedRights), ("defaultBannedRights", defaultBannedRights), ("participantsCount", participantsCount)]) + case .channel(let flags, let id, let accessHash, let title, let username, let photo, let date, let restrictionReason, let adminRights, let bannedRights, let defaultBannedRights, let participantsCount): + return ("channel", [("flags", flags), ("id", id), ("accessHash", accessHash), ("title", title), ("username", username), ("photo", photo), ("date", date), ("restrictionReason", restrictionReason), ("adminRights", adminRights), ("bannedRights", bannedRights), ("defaultBannedRights", defaultBannedRights), ("participantsCount", participantsCount)]) case .channelForbidden(let flags, let id, let accessHash, let title, let untilDate): return ("channelForbidden", [("flags", flags), ("id", id), ("accessHash", accessHash), ("title", title), ("untilDate", untilDate)]) } } public static func parse_chatEmpty(_ reader: BufferReader) -> Chat? { - var _1: Int32? - _1 = reader.readInt32() + var _1: Int64? + _1 = reader.readInt64() let _c1 = _1 != nil if _c1 { return Api.Chat.chatEmpty(id: _1!) @@ -1852,8 +1851,8 @@ public extension Api { public static func parse_chat(_ reader: BufferReader) -> Chat? { var _1: Int32? _1 = reader.readInt32() - var _2: Int32? - _2 = reader.readInt32() + var _2: Int64? + _2 = reader.readInt64() var _3: String? _3 = parseString(reader) var _4: Api.ChatPhoto? @@ -1896,8 +1895,8 @@ public extension Api { } } public static func parse_chatForbidden(_ reader: BufferReader) -> Chat? { - var _1: Int32? - _1 = reader.readInt32() + var _1: Int64? + _1 = reader.readInt64() var _2: String? _2 = parseString(reader) let _c1 = _1 != nil @@ -1912,8 +1911,8 @@ public extension Api { public static func parse_channel(_ reader: BufferReader) -> Chat? { var _1: Int32? _1 = reader.readInt32() - var _2: Int32? - _2 = reader.readInt32() + var _2: Int64? + _2 = reader.readInt64() var _3: Int64? if Int(_1!) & Int(1 << 13) != 0 {_3 = reader.readInt64() } var _4: String? @@ -1926,26 +1925,24 @@ public extension Api { } var _7: Int32? _7 = reader.readInt32() - var _8: Int32? - _8 = reader.readInt32() - var _9: [Api.RestrictionReason]? + var _8: [Api.RestrictionReason]? if Int(_1!) & Int(1 << 9) != 0 {if let _ = reader.readInt32() { - _9 = Api.parseVector(reader, elementSignature: 0, elementType: Api.RestrictionReason.self) + _8 = Api.parseVector(reader, elementSignature: 0, elementType: Api.RestrictionReason.self) } } - var _10: Api.ChatAdminRights? + var _9: Api.ChatAdminRights? if Int(_1!) & Int(1 << 14) != 0 {if let signature = reader.readInt32() { - _10 = Api.parse(reader, signature: signature) as? Api.ChatAdminRights + _9 = Api.parse(reader, signature: signature) as? Api.ChatAdminRights + } } + var _10: Api.ChatBannedRights? + if Int(_1!) & Int(1 << 15) != 0 {if let signature = reader.readInt32() { + _10 = Api.parse(reader, signature: signature) as? Api.ChatBannedRights } } var _11: Api.ChatBannedRights? - if Int(_1!) & Int(1 << 15) != 0 {if let signature = reader.readInt32() { + if Int(_1!) & Int(1 << 18) != 0 {if let signature = reader.readInt32() { _11 = Api.parse(reader, signature: signature) as? Api.ChatBannedRights } } - var _12: Api.ChatBannedRights? - if Int(_1!) & Int(1 << 18) != 0 {if let signature = reader.readInt32() { - _12 = Api.parse(reader, signature: signature) as? Api.ChatBannedRights - } } - var _13: Int32? - if Int(_1!) & Int(1 << 17) != 0 {_13 = reader.readInt32() } + var _12: Int32? + if Int(_1!) & Int(1 << 17) != 0 {_12 = reader.readInt32() } let _c1 = _1 != nil let _c2 = _2 != nil let _c3 = (Int(_1!) & Int(1 << 13) == 0) || _3 != nil @@ -1953,14 +1950,13 @@ public extension Api { let _c5 = (Int(_1!) & Int(1 << 6) == 0) || _5 != nil let _c6 = _6 != nil let _c7 = _7 != nil - let _c8 = _8 != nil - let _c9 = (Int(_1!) & Int(1 << 9) == 0) || _9 != nil - let _c10 = (Int(_1!) & Int(1 << 14) == 0) || _10 != nil - let _c11 = (Int(_1!) & Int(1 << 15) == 0) || _11 != nil - let _c12 = (Int(_1!) & Int(1 << 18) == 0) || _12 != nil - let _c13 = (Int(_1!) & Int(1 << 17) == 0) || _13 != nil - if _c1 && _c2 && _c3 && _c4 && _c5 && _c6 && _c7 && _c8 && _c9 && _c10 && _c11 && _c12 && _c13 { - return Api.Chat.channel(flags: _1!, id: _2!, accessHash: _3, title: _4!, username: _5, photo: _6!, date: _7!, version: _8!, restrictionReason: _9, adminRights: _10, bannedRights: _11, defaultBannedRights: _12, participantsCount: _13) + let _c8 = (Int(_1!) & Int(1 << 9) == 0) || _8 != nil + let _c9 = (Int(_1!) & Int(1 << 14) == 0) || _9 != nil + let _c10 = (Int(_1!) & Int(1 << 15) == 0) || _10 != nil + let _c11 = (Int(_1!) & Int(1 << 18) == 0) || _11 != nil + let _c12 = (Int(_1!) & Int(1 << 17) == 0) || _12 != nil + if _c1 && _c2 && _c3 && _c4 && _c5 && _c6 && _c7 && _c8 && _c9 && _c10 && _c11 && _c12 { + return Api.Chat.channel(flags: _1!, id: _2!, accessHash: _3, title: _4!, username: _5, photo: _6!, date: _7!, restrictionReason: _8, adminRights: _9, bannedRights: _10, defaultBannedRights: _11, participantsCount: _12) } else { return nil @@ -1969,8 +1965,8 @@ public extension Api { public static func parse_channelForbidden(_ reader: BufferReader) -> Chat? { var _1: Int32? _1 = reader.readInt32() - var _2: Int32? - _2 = reader.readInt32() + var _2: Int64? + _2 = reader.readInt64() var _3: Int64? _3 = reader.readInt64() var _4: String? @@ -2331,8 +2327,8 @@ public extension Api { } public enum RecentMeUrl: TypeConstructorDescription { case recentMeUrlUnknown(url: String) - case recentMeUrlUser(url: String, userId: Int32) - case recentMeUrlChat(url: String, chatId: Int32) + case recentMeUrlUser(url: String, userId: Int64) + case recentMeUrlChat(url: String, chatId: Int64) case recentMeUrlChatInvite(url: String, chatInvite: Api.ChatInvite) case recentMeUrlStickerSet(url: String, set: Api.StickerSetCovered) @@ -2346,17 +2342,17 @@ public extension Api { break case .recentMeUrlUser(let url, let userId): if boxed { - buffer.appendInt32(-1917045962) + buffer.appendInt32(-1188296222) } serializeString(url, buffer: buffer, boxed: false) - serializeInt32(userId, buffer: buffer, boxed: false) + serializeInt64(userId, buffer: buffer, boxed: false) break case .recentMeUrlChat(let url, let chatId): if boxed { - buffer.appendInt32(-1608834311) + buffer.appendInt32(-1294306862) } serializeString(url, buffer: buffer, boxed: false) - serializeInt32(chatId, buffer: buffer, boxed: false) + serializeInt64(chatId, buffer: buffer, boxed: false) break case .recentMeUrlChatInvite(let url, let chatInvite): if boxed { @@ -2404,8 +2400,8 @@ public extension Api { public static func parse_recentMeUrlUser(_ reader: BufferReader) -> RecentMeUrl? { var _1: String? _1 = parseString(reader) - var _2: Int32? - _2 = reader.readInt32() + var _2: Int64? + _2 = reader.readInt64() let _c1 = _1 != nil let _c2 = _2 != nil if _c1 && _c2 { @@ -2418,8 +2414,8 @@ public extension Api { public static func parse_recentMeUrlChat(_ reader: BufferReader) -> RecentMeUrl? { var _1: String? _1 = parseString(reader) - var _2: Int32? - _2 = reader.readInt32() + var _2: Int64? + _2 = reader.readInt64() let _c1 = _1 != nil let _c2 = _2 != nil if _c1 && _c2 { @@ -2979,8 +2975,8 @@ public extension Api { } public enum InputChannel: TypeConstructorDescription { case inputChannelEmpty - case inputChannel(channelId: Int32, accessHash: Int64) - case inputChannelFromMessage(peer: Api.InputPeer, msgId: Int32, channelId: Int32) + case inputChannel(channelId: Int64, accessHash: Int64) + case inputChannelFromMessage(peer: Api.InputPeer, msgId: Int32, channelId: Int64) public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) { switch self { @@ -2992,18 +2988,18 @@ public extension Api { break case .inputChannel(let channelId, let accessHash): if boxed { - buffer.appendInt32(-1343524562) + buffer.appendInt32(-212145112) } - serializeInt32(channelId, buffer: buffer, boxed: false) + serializeInt64(channelId, buffer: buffer, boxed: false) serializeInt64(accessHash, buffer: buffer, boxed: false) break case .inputChannelFromMessage(let peer, let msgId, let channelId): if boxed { - buffer.appendInt32(707290417) + buffer.appendInt32(1536380829) } peer.serialize(buffer, true) serializeInt32(msgId, buffer: buffer, boxed: false) - serializeInt32(channelId, buffer: buffer, boxed: false) + serializeInt64(channelId, buffer: buffer, boxed: false) break } } @@ -3023,8 +3019,8 @@ public extension Api { return Api.InputChannel.inputChannelEmpty } public static func parse_inputChannel(_ reader: BufferReader) -> InputChannel? { - var _1: Int32? - _1 = reader.readInt32() + var _1: Int64? + _1 = reader.readInt64() var _2: Int64? _2 = reader.readInt64() let _c1 = _1 != nil @@ -3043,8 +3039,8 @@ public extension Api { } var _2: Int32? _2 = reader.readInt32() - var _3: Int32? - _3 = reader.readInt32() + var _3: Int64? + _3 = reader.readInt64() let _c1 = _1 != nil let _c2 = _2 != nil let _c3 = _3 != nil @@ -3414,15 +3410,15 @@ public extension Api { } public enum StatsGroupTopAdmin: TypeConstructorDescription { - case statsGroupTopAdmin(userId: Int32, deleted: Int32, kicked: Int32, banned: Int32) + case statsGroupTopAdmin(userId: Int64, deleted: Int32, kicked: Int32, banned: Int32) public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) { switch self { case .statsGroupTopAdmin(let userId, let deleted, let kicked, let banned): if boxed { - buffer.appendInt32(1611985938) + buffer.appendInt32(-682079097) } - serializeInt32(userId, buffer: buffer, boxed: false) + serializeInt64(userId, buffer: buffer, boxed: false) serializeInt32(deleted, buffer: buffer, boxed: false) serializeInt32(kicked, buffer: buffer, boxed: false) serializeInt32(banned, buffer: buffer, boxed: false) @@ -3438,8 +3434,8 @@ public extension Api { } public static func parse_statsGroupTopAdmin(_ reader: BufferReader) -> StatsGroupTopAdmin? { - var _1: Int32? - _1 = reader.readInt32() + var _1: Int64? + _1 = reader.readInt64() var _2: Int32? _2 = reader.readInt32() var _3: Int32? @@ -3858,29 +3854,29 @@ public extension Api { } public enum Peer: TypeConstructorDescription { - case peerUser(userId: Int32) - case peerChat(chatId: Int32) - case peerChannel(channelId: Int32) + case peerUser(userId: Int64) + case peerChat(chatId: Int64) + case peerChannel(channelId: Int64) public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) { switch self { case .peerUser(let userId): if boxed { - buffer.appendInt32(-1649296275) + buffer.appendInt32(1498486562) } - serializeInt32(userId, buffer: buffer, boxed: false) + serializeInt64(userId, buffer: buffer, boxed: false) break case .peerChat(let chatId): if boxed { - buffer.appendInt32(-1160714821) + buffer.appendInt32(918946202) } - serializeInt32(chatId, buffer: buffer, boxed: false) + serializeInt64(chatId, buffer: buffer, boxed: false) break case .peerChannel(let channelId): if boxed { - buffer.appendInt32(-1109531342) + buffer.appendInt32(-1566230754) } - serializeInt32(channelId, buffer: buffer, boxed: false) + serializeInt64(channelId, buffer: buffer, boxed: false) break } } @@ -3897,8 +3893,8 @@ public extension Api { } public static func parse_peerUser(_ reader: BufferReader) -> Peer? { - var _1: Int32? - _1 = reader.readInt32() + var _1: Int64? + _1 = reader.readInt64() let _c1 = _1 != nil if _c1 { return Api.Peer.peerUser(userId: _1!) @@ -3908,8 +3904,8 @@ public extension Api { } } public static func parse_peerChat(_ reader: BufferReader) -> Peer? { - var _1: Int32? - _1 = reader.readInt32() + var _1: Int64? + _1 = reader.readInt64() let _c1 = _1 != nil if _c1 { return Api.Peer.peerChat(chatId: _1!) @@ -3919,8 +3915,8 @@ public extension Api { } } public static func parse_peerChannel(_ reader: BufferReader) -> Peer? { - var _1: Int32? - _1 = reader.readInt32() + var _1: Int64? + _1 = reader.readInt64() let _c1 = _1 != nil if _c1 { return Api.Peer.peerChannel(channelId: _1!) @@ -4633,64 +4629,64 @@ public extension Api { case updateNewMessage(message: Api.Message, pts: Int32, ptsCount: Int32) case updateMessageID(id: Int32, randomId: Int64) case updateDeleteMessages(messages: [Int32], pts: Int32, ptsCount: Int32) - case updateUserTyping(userId: Int32, action: Api.SendMessageAction) - case updateChatUserTyping(chatId: Int32, fromId: Api.Peer, action: Api.SendMessageAction) + case updateUserTyping(userId: Int64, action: Api.SendMessageAction) + case updateChatUserTyping(chatId: Int64, fromId: Api.Peer, action: Api.SendMessageAction) case updateChatParticipants(participants: Api.ChatParticipants) - case updateUserStatus(userId: Int32, status: Api.UserStatus) - case updateUserName(userId: Int32, firstName: String, lastName: String, username: String) - case updateUserPhoto(userId: Int32, date: Int32, photo: Api.UserProfilePhoto, previous: Api.Bool) + case updateUserStatus(userId: Int64, status: Api.UserStatus) + case updateUserName(userId: Int64, firstName: String, lastName: String, username: String) + case updateUserPhoto(userId: Int64, date: Int32, photo: Api.UserProfilePhoto, previous: Api.Bool) case updateNewEncryptedMessage(message: Api.EncryptedMessage, qts: Int32) case updateEncryptedChatTyping(chatId: Int32) case updateEncryption(chat: Api.EncryptedChat, date: Int32) case updateEncryptedMessagesRead(chatId: Int32, maxDate: Int32, date: Int32) - case updateChatParticipantAdd(chatId: Int32, userId: Int32, inviterId: Int32, date: Int32, version: Int32) - case updateChatParticipantDelete(chatId: Int32, userId: Int32, version: Int32) + case updateChatParticipantAdd(chatId: Int64, userId: Int64, inviterId: Int64, date: Int32, version: Int32) + case updateChatParticipantDelete(chatId: Int64, userId: Int64, version: Int32) case updateDcOptions(dcOptions: [Api.DcOption]) case updateNotifySettings(peer: Api.NotifyPeer, notifySettings: Api.PeerNotifySettings) case updateServiceNotification(flags: Int32, inboxDate: Int32?, type: String, message: String, media: Api.MessageMedia, entities: [Api.MessageEntity]) case updatePrivacy(key: Api.PrivacyKey, rules: [Api.PrivacyRule]) - case updateUserPhone(userId: Int32, phone: String) + case updateUserPhone(userId: Int64, phone: String) case updateReadHistoryInbox(flags: Int32, folderId: Int32?, peer: Api.Peer, maxId: Int32, stillUnreadCount: Int32, pts: Int32, ptsCount: Int32) case updateReadHistoryOutbox(peer: Api.Peer, maxId: Int32, pts: Int32, ptsCount: Int32) case updateWebPage(webpage: Api.WebPage, pts: Int32, ptsCount: Int32) case updateReadMessagesContents(messages: [Int32], pts: Int32, ptsCount: Int32) - case updateChannelTooLong(flags: Int32, channelId: Int32, pts: Int32?) - case updateChannel(channelId: Int32) + case updateChannelTooLong(flags: Int32, channelId: Int64, pts: Int32?) + case updateChannel(channelId: Int64) case updateNewChannelMessage(message: Api.Message, pts: Int32, ptsCount: Int32) - case updateReadChannelInbox(flags: Int32, folderId: Int32?, channelId: Int32, maxId: Int32, stillUnreadCount: Int32, pts: Int32) - case updateDeleteChannelMessages(channelId: Int32, messages: [Int32], pts: Int32, ptsCount: Int32) - case updateChannelMessageViews(channelId: Int32, id: Int32, views: Int32) - case updateChatParticipantAdmin(chatId: Int32, userId: Int32, isAdmin: Api.Bool, version: Int32) + case updateReadChannelInbox(flags: Int32, folderId: Int32?, channelId: Int64, maxId: Int32, stillUnreadCount: Int32, pts: Int32) + case updateDeleteChannelMessages(channelId: Int64, messages: [Int32], pts: Int32, ptsCount: Int32) + case updateChannelMessageViews(channelId: Int64, id: Int32, views: Int32) + case updateChatParticipantAdmin(chatId: Int64, userId: Int64, isAdmin: Api.Bool, version: Int32) case updateNewStickerSet(stickerset: Api.messages.StickerSet) case updateStickerSetsOrder(flags: Int32, order: [Int64]) case updateStickerSets case updateSavedGifs - case updateBotInlineQuery(flags: Int32, queryId: Int64, userId: Int32, query: String, geo: Api.GeoPoint?, peerType: Api.InlineQueryPeerType?, offset: String) - case updateBotInlineSend(flags: Int32, userId: Int32, query: String, geo: Api.GeoPoint?, id: String, msgId: Api.InputBotInlineMessageID?) + case updateBotInlineQuery(flags: Int32, queryId: Int64, userId: Int64, query: String, geo: Api.GeoPoint?, peerType: Api.InlineQueryPeerType?, offset: String) + case updateBotInlineSend(flags: Int32, userId: Int64, query: String, geo: Api.GeoPoint?, id: String, msgId: Api.InputBotInlineMessageID?) case updateEditChannelMessage(message: Api.Message, pts: Int32, ptsCount: Int32) - case updateBotCallbackQuery(flags: Int32, queryId: Int64, userId: Int32, peer: Api.Peer, msgId: Int32, chatInstance: Int64, data: Buffer?, gameShortName: String?) + case updateBotCallbackQuery(flags: Int32, queryId: Int64, userId: Int64, peer: Api.Peer, msgId: Int32, chatInstance: Int64, data: Buffer?, gameShortName: String?) case updateEditMessage(message: Api.Message, pts: Int32, ptsCount: Int32) - case updateInlineBotCallbackQuery(flags: Int32, queryId: Int64, userId: Int32, msgId: Api.InputBotInlineMessageID, chatInstance: Int64, data: Buffer?, gameShortName: String?) - case updateReadChannelOutbox(channelId: Int32, maxId: Int32) + case updateInlineBotCallbackQuery(flags: Int32, queryId: Int64, userId: Int64, msgId: Api.InputBotInlineMessageID, chatInstance: Int64, data: Buffer?, gameShortName: String?) + case updateReadChannelOutbox(channelId: Int64, maxId: Int32) case updateDraftMessage(peer: Api.Peer, draft: Api.DraftMessage) case updateReadFeaturedStickers case updateRecentStickers case updateConfig case updatePtsChanged - case updateChannelWebPage(channelId: Int32, webpage: Api.WebPage, pts: Int32, ptsCount: Int32) + case updateChannelWebPage(channelId: Int64, webpage: Api.WebPage, pts: Int32, ptsCount: Int32) case updateDialogPinned(flags: Int32, folderId: Int32?, peer: Api.DialogPeer) case updatePinnedDialogs(flags: Int32, folderId: Int32?, order: [Api.DialogPeer]?) case updateBotWebhookJSON(data: Api.DataJSON) case updateBotWebhookJSONQuery(queryId: Int64, data: Api.DataJSON, timeout: Int32) - case updateBotShippingQuery(queryId: Int64, userId: Int32, payload: Buffer, shippingAddress: Api.PostAddress) - case updateBotPrecheckoutQuery(flags: Int32, queryId: Int64, userId: Int32, payload: Buffer, info: Api.PaymentRequestedInfo?, shippingOptionId: String?, currency: String, totalAmount: Int64) + case updateBotShippingQuery(queryId: Int64, userId: Int64, payload: Buffer, shippingAddress: Api.PostAddress) + case updateBotPrecheckoutQuery(flags: Int32, queryId: Int64, userId: Int64, payload: Buffer, info: Api.PaymentRequestedInfo?, shippingOptionId: String?, currency: String, totalAmount: Int64) case updatePhoneCall(phoneCall: Api.PhoneCall) case updateLangPackTooLong(langCode: String) case updateLangPack(difference: Api.LangPackDifference) case updateFavedStickers - case updateChannelReadMessagesContents(channelId: Int32, messages: [Int32]) + case updateChannelReadMessagesContents(channelId: Int64, messages: [Int32]) case updateContactsReset - case updateChannelAvailableMessages(channelId: Int32, availableMinId: Int32) + case updateChannelAvailableMessages(channelId: Int64, availableMinId: Int32) case updateDialogUnreadMark(flags: Int32, peer: Api.DialogPeer) case updateMessagePoll(flags: Int32, pollId: Int64, poll: Api.Poll?, results: Api.PollResults) case updateChatDefaultBannedRights(peer: Api.Peer, defaultBannedRights: Api.ChatBannedRights, version: Int32) @@ -4702,27 +4698,27 @@ public extension Api { case updateTheme(theme: Api.Theme) case updateGeoLiveViewed(peer: Api.Peer, msgId: Int32) case updateLoginToken - case updateMessagePollVote(pollId: Int64, userId: Int32, options: [Buffer], qts: Int32) + case updateMessagePollVote(pollId: Int64, userId: Int64, options: [Buffer], qts: Int32) case updateDialogFilter(flags: Int32, id: Int32, filter: Api.DialogFilter?) case updateDialogFilterOrder(order: [Int32]) case updateDialogFilters case updatePhoneCallSignalingData(phoneCallId: Int64, data: Buffer) - case updateChannelMessageForwards(channelId: Int32, id: Int32, forwards: Int32) - case updateReadChannelDiscussionInbox(flags: Int32, channelId: Int32, topMsgId: Int32, readMaxId: Int32, broadcastId: Int32?, broadcastPost: Int32?) - case updateReadChannelDiscussionOutbox(channelId: Int32, topMsgId: Int32, readMaxId: Int32) + case updateChannelMessageForwards(channelId: Int64, id: Int32, forwards: Int32) + case updateReadChannelDiscussionInbox(flags: Int32, channelId: Int64, topMsgId: Int32, readMaxId: Int32, broadcastId: Int64?, broadcastPost: Int32?) + case updateReadChannelDiscussionOutbox(channelId: Int64, topMsgId: Int32, readMaxId: Int32) case updatePeerBlocked(peerId: Api.Peer, blocked: Api.Bool) - case updateChannelUserTyping(flags: Int32, channelId: Int32, topMsgId: Int32?, fromId: Api.Peer, action: Api.SendMessageAction) + case updateChannelUserTyping(flags: Int32, channelId: Int64, topMsgId: Int32?, fromId: Api.Peer, action: Api.SendMessageAction) case updatePinnedMessages(flags: Int32, peer: Api.Peer, messages: [Int32], pts: Int32, ptsCount: Int32) - case updatePinnedChannelMessages(flags: Int32, channelId: Int32, messages: [Int32], pts: Int32, ptsCount: Int32) - case updateChat(chatId: Int32) + case updatePinnedChannelMessages(flags: Int32, channelId: Int64, messages: [Int32], pts: Int32, ptsCount: Int32) + case updateChat(chatId: Int64) case updateGroupCallParticipants(call: Api.InputGroupCall, participants: [Api.GroupCallParticipant], version: Int32) - case updateGroupCall(chatId: Int32, call: Api.GroupCall) + case updateGroupCall(chatId: Int64, call: Api.GroupCall) case updatePeerHistoryTTL(flags: Int32, peer: Api.Peer, ttlPeriod: Int32?) - case updateChatParticipant(flags: Int32, chatId: Int32, date: Int32, actorId: Int32, userId: Int32, prevParticipant: Api.ChatParticipant?, newParticipant: Api.ChatParticipant?, invite: Api.ExportedChatInvite?, qts: Int32) - case updateChannelParticipant(flags: Int32, channelId: Int32, date: Int32, actorId: Int32, userId: Int32, prevParticipant: Api.ChannelParticipant?, newParticipant: Api.ChannelParticipant?, invite: Api.ExportedChatInvite?, qts: Int32) - case updateBotStopped(userId: Int32, date: Int32, stopped: Api.Bool, qts: Int32) + case updateChatParticipant(flags: Int32, chatId: Int64, date: Int32, actorId: Int64, userId: Int64, prevParticipant: Api.ChatParticipant?, newParticipant: Api.ChatParticipant?, invite: Api.ExportedChatInvite?, qts: Int32) + case updateChannelParticipant(flags: Int32, channelId: Int64, date: Int32, actorId: Int64, userId: Int64, prevParticipant: Api.ChannelParticipant?, newParticipant: Api.ChannelParticipant?, invite: Api.ExportedChatInvite?, qts: Int32) + case updateBotStopped(userId: Int64, date: Int32, stopped: Api.Bool, qts: Int32) case updateGroupCallConnection(flags: Int32, params: Api.DataJSON) - case updateBotCommands(peer: Api.Peer, botId: Int32, commands: [Api.BotCommand]) + case updateBotCommands(peer: Api.Peer, botId: Int64, commands: [Api.BotCommand]) public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) { switch self { @@ -4755,16 +4751,16 @@ public extension Api { break case .updateUserTyping(let userId, let action): if boxed { - buffer.appendInt32(1548249383) + buffer.appendInt32(-1071741569) } - serializeInt32(userId, buffer: buffer, boxed: false) + serializeInt64(userId, buffer: buffer, boxed: false) action.serialize(buffer, true) break case .updateChatUserTyping(let chatId, let fromId, let action): if boxed { - buffer.appendInt32(-2033525908) + buffer.appendInt32(-2092401936) } - serializeInt32(chatId, buffer: buffer, boxed: false) + serializeInt64(chatId, buffer: buffer, boxed: false) fromId.serialize(buffer, true) action.serialize(buffer, true) break @@ -4776,25 +4772,25 @@ public extension Api { break case .updateUserStatus(let userId, let status): if boxed { - buffer.appendInt32(469489699) + buffer.appendInt32(-440534818) } - serializeInt32(userId, buffer: buffer, boxed: false) + serializeInt64(userId, buffer: buffer, boxed: false) status.serialize(buffer, true) break case .updateUserName(let userId, let firstName, let lastName, let username): if boxed { - buffer.appendInt32(-1489818765) + buffer.appendInt32(-1007549728) } - serializeInt32(userId, buffer: buffer, boxed: false) + serializeInt64(userId, buffer: buffer, boxed: false) serializeString(firstName, buffer: buffer, boxed: false) serializeString(lastName, buffer: buffer, boxed: false) serializeString(username, buffer: buffer, boxed: false) break case .updateUserPhoto(let userId, let date, let photo, let previous): if boxed { - buffer.appendInt32(-1791935732) + buffer.appendInt32(-232290676) } - serializeInt32(userId, buffer: buffer, boxed: false) + serializeInt64(userId, buffer: buffer, boxed: false) serializeInt32(date, buffer: buffer, boxed: false) photo.serialize(buffer, true) previous.serialize(buffer, true) @@ -4829,20 +4825,20 @@ public extension Api { break case .updateChatParticipantAdd(let chatId, let userId, let inviterId, let date, let version): if boxed { - buffer.appendInt32(-364179876) + buffer.appendInt32(1037718609) } - serializeInt32(chatId, buffer: buffer, boxed: false) - serializeInt32(userId, buffer: buffer, boxed: false) - serializeInt32(inviterId, buffer: buffer, boxed: false) + serializeInt64(chatId, buffer: buffer, boxed: false) + serializeInt64(userId, buffer: buffer, boxed: false) + serializeInt64(inviterId, buffer: buffer, boxed: false) serializeInt32(date, buffer: buffer, boxed: false) serializeInt32(version, buffer: buffer, boxed: false) break case .updateChatParticipantDelete(let chatId, let userId, let version): if boxed { - buffer.appendInt32(1851755554) + buffer.appendInt32(-483443337) } - serializeInt32(chatId, buffer: buffer, boxed: false) - serializeInt32(userId, buffer: buffer, boxed: false) + serializeInt64(chatId, buffer: buffer, boxed: false) + serializeInt64(userId, buffer: buffer, boxed: false) serializeInt32(version, buffer: buffer, boxed: false) break case .updateDcOptions(let dcOptions): @@ -4890,9 +4886,9 @@ public extension Api { break case .updateUserPhone(let userId, let phone): if boxed { - buffer.appendInt32(314130811) + buffer.appendInt32(88680979) } - serializeInt32(userId, buffer: buffer, boxed: false) + serializeInt64(userId, buffer: buffer, boxed: false) serializeString(phone, buffer: buffer, boxed: false) break case .updateReadHistoryInbox(let flags, let folderId, let peer, let maxId, let stillUnreadCount, let pts, let ptsCount): @@ -4938,17 +4934,17 @@ public extension Api { break case .updateChannelTooLong(let flags, let channelId, let pts): if boxed { - buffer.appendInt32(-352032773) + buffer.appendInt32(277713951) } serializeInt32(flags, buffer: buffer, boxed: false) - serializeInt32(channelId, buffer: buffer, boxed: false) + serializeInt64(channelId, buffer: buffer, boxed: false) if Int(flags) & Int(1 << 0) != 0 {serializeInt32(pts!, buffer: buffer, boxed: false)} break case .updateChannel(let channelId): if boxed { - buffer.appendInt32(-1227598250) + buffer.appendInt32(1666927625) } - serializeInt32(channelId, buffer: buffer, boxed: false) + serializeInt64(channelId, buffer: buffer, boxed: false) break case .updateNewChannelMessage(let message, let pts, let ptsCount): if boxed { @@ -4960,20 +4956,20 @@ public extension Api { break case .updateReadChannelInbox(let flags, let folderId, let channelId, let maxId, let stillUnreadCount, let pts): if boxed { - buffer.appendInt32(856380452) + buffer.appendInt32(-1842450928) } serializeInt32(flags, buffer: buffer, boxed: false) if Int(flags) & Int(1 << 0) != 0 {serializeInt32(folderId!, buffer: buffer, boxed: false)} - serializeInt32(channelId, buffer: buffer, boxed: false) + serializeInt64(channelId, buffer: buffer, boxed: false) serializeInt32(maxId, buffer: buffer, boxed: false) serializeInt32(stillUnreadCount, buffer: buffer, boxed: false) serializeInt32(pts, buffer: buffer, boxed: false) break case .updateDeleteChannelMessages(let channelId, let messages, let pts, let ptsCount): if boxed { - buffer.appendInt32(-1015733815) + buffer.appendInt32(-1020437742) } - serializeInt32(channelId, buffer: buffer, boxed: false) + serializeInt64(channelId, buffer: buffer, boxed: false) buffer.appendInt32(481674261) buffer.appendInt32(Int32(messages.count)) for item in messages { @@ -4984,18 +4980,18 @@ public extension Api { break case .updateChannelMessageViews(let channelId, let id, let views): if boxed { - buffer.appendInt32(-1734268085) + buffer.appendInt32(-232346616) } - serializeInt32(channelId, buffer: buffer, boxed: false) + serializeInt64(channelId, buffer: buffer, boxed: false) serializeInt32(id, buffer: buffer, boxed: false) serializeInt32(views, buffer: buffer, boxed: false) break case .updateChatParticipantAdmin(let chatId, let userId, let isAdmin, let version): if boxed { - buffer.appendInt32(-1232070311) + buffer.appendInt32(-674602590) } - serializeInt32(chatId, buffer: buffer, boxed: false) - serializeInt32(userId, buffer: buffer, boxed: false) + serializeInt64(chatId, buffer: buffer, boxed: false) + serializeInt64(userId, buffer: buffer, boxed: false) isAdmin.serialize(buffer, true) serializeInt32(version, buffer: buffer, boxed: false) break @@ -5030,11 +5026,11 @@ public extension Api { break case .updateBotInlineQuery(let flags, let queryId, let userId, let query, let geo, let peerType, let offset): if boxed { - buffer.appendInt32(1059076315) + buffer.appendInt32(1232025500) } serializeInt32(flags, buffer: buffer, boxed: false) serializeInt64(queryId, buffer: buffer, boxed: false) - serializeInt32(userId, buffer: buffer, boxed: false) + serializeInt64(userId, buffer: buffer, boxed: false) serializeString(query, buffer: buffer, boxed: false) if Int(flags) & Int(1 << 0) != 0 {geo!.serialize(buffer, true)} if Int(flags) & Int(1 << 1) != 0 {peerType!.serialize(buffer, true)} @@ -5042,10 +5038,10 @@ public extension Api { break case .updateBotInlineSend(let flags, let userId, let query, let geo, let id, let msgId): if boxed { - buffer.appendInt32(239663460) + buffer.appendInt32(317794823) } serializeInt32(flags, buffer: buffer, boxed: false) - serializeInt32(userId, buffer: buffer, boxed: false) + serializeInt64(userId, buffer: buffer, boxed: false) serializeString(query, buffer: buffer, boxed: false) if Int(flags) & Int(1 << 0) != 0 {geo!.serialize(buffer, true)} serializeString(id, buffer: buffer, boxed: false) @@ -5061,11 +5057,11 @@ public extension Api { break case .updateBotCallbackQuery(let flags, let queryId, let userId, let peer, let msgId, let chatInstance, let data, let gameShortName): if boxed { - buffer.appendInt32(-415938591) + buffer.appendInt32(-1177566067) } serializeInt32(flags, buffer: buffer, boxed: false) serializeInt64(queryId, buffer: buffer, boxed: false) - serializeInt32(userId, buffer: buffer, boxed: false) + serializeInt64(userId, buffer: buffer, boxed: false) peer.serialize(buffer, true) serializeInt32(msgId, buffer: buffer, boxed: false) serializeInt64(chatInstance, buffer: buffer, boxed: false) @@ -5082,11 +5078,11 @@ public extension Api { break case .updateInlineBotCallbackQuery(let flags, let queryId, let userId, let msgId, let chatInstance, let data, let gameShortName): if boxed { - buffer.appendInt32(-103646630) + buffer.appendInt32(1763610706) } serializeInt32(flags, buffer: buffer, boxed: false) serializeInt64(queryId, buffer: buffer, boxed: false) - serializeInt32(userId, buffer: buffer, boxed: false) + serializeInt64(userId, buffer: buffer, boxed: false) msgId.serialize(buffer, true) serializeInt64(chatInstance, buffer: buffer, boxed: false) if Int(flags) & Int(1 << 0) != 0 {serializeBytes(data!, buffer: buffer, boxed: false)} @@ -5094,9 +5090,9 @@ public extension Api { break case .updateReadChannelOutbox(let channelId, let maxId): if boxed { - buffer.appendInt32(634833351) + buffer.appendInt32(-1218471511) } - serializeInt32(channelId, buffer: buffer, boxed: false) + serializeInt64(channelId, buffer: buffer, boxed: false) serializeInt32(maxId, buffer: buffer, boxed: false) break case .updateDraftMessage(let peer, let draft): @@ -5132,9 +5128,9 @@ public extension Api { break case .updateChannelWebPage(let channelId, let webpage, let pts, let ptsCount): if boxed { - buffer.appendInt32(1081547008) + buffer.appendInt32(791390623) } - serializeInt32(channelId, buffer: buffer, boxed: false) + serializeInt64(channelId, buffer: buffer, boxed: false) webpage.serialize(buffer, true) serializeInt32(pts, buffer: buffer, boxed: false) serializeInt32(ptsCount, buffer: buffer, boxed: false) @@ -5175,20 +5171,20 @@ public extension Api { break case .updateBotShippingQuery(let queryId, let userId, let payload, let shippingAddress): if boxed { - buffer.appendInt32(-523384512) + buffer.appendInt32(-1246823043) } serializeInt64(queryId, buffer: buffer, boxed: false) - serializeInt32(userId, buffer: buffer, boxed: false) + serializeInt64(userId, buffer: buffer, boxed: false) serializeBytes(payload, buffer: buffer, boxed: false) shippingAddress.serialize(buffer, true) break case .updateBotPrecheckoutQuery(let flags, let queryId, let userId, let payload, let info, let shippingOptionId, let currency, let totalAmount): if boxed { - buffer.appendInt32(1563376297) + buffer.appendInt32(-1934976362) } serializeInt32(flags, buffer: buffer, boxed: false) serializeInt64(queryId, buffer: buffer, boxed: false) - serializeInt32(userId, buffer: buffer, boxed: false) + serializeInt64(userId, buffer: buffer, boxed: false) serializeBytes(payload, buffer: buffer, boxed: false) if Int(flags) & Int(1 << 0) != 0 {info!.serialize(buffer, true)} if Int(flags) & Int(1 << 1) != 0 {serializeString(shippingOptionId!, buffer: buffer, boxed: false)} @@ -5221,9 +5217,9 @@ public extension Api { break case .updateChannelReadMessagesContents(let channelId, let messages): if boxed { - buffer.appendInt32(-1987495099) + buffer.appendInt32(1153291573) } - serializeInt32(channelId, buffer: buffer, boxed: false) + serializeInt64(channelId, buffer: buffer, boxed: false) buffer.appendInt32(481674261) buffer.appendInt32(Int32(messages.count)) for item in messages { @@ -5238,9 +5234,9 @@ public extension Api { break case .updateChannelAvailableMessages(let channelId, let availableMinId): if boxed { - buffer.appendInt32(1893427255) + buffer.appendInt32(-1304443240) } - serializeInt32(channelId, buffer: buffer, boxed: false) + serializeInt64(channelId, buffer: buffer, boxed: false) serializeInt32(availableMinId, buffer: buffer, boxed: false) break case .updateDialogUnreadMark(let flags, let peer): @@ -5334,10 +5330,10 @@ public extension Api { break case .updateMessagePollVote(let pollId, let userId, let options, let qts): if boxed { - buffer.appendInt32(938909451) + buffer.appendInt32(274961865) } serializeInt64(pollId, buffer: buffer, boxed: false) - serializeInt32(userId, buffer: buffer, boxed: false) + serializeInt64(userId, buffer: buffer, boxed: false) buffer.appendInt32(481674261) buffer.appendInt32(Int32(options.count)) for item in options { @@ -5378,28 +5374,28 @@ public extension Api { break case .updateChannelMessageForwards(let channelId, let id, let forwards): if boxed { - buffer.appendInt32(1854571743) + buffer.appendInt32(-761649164) } - serializeInt32(channelId, buffer: buffer, boxed: false) + serializeInt64(channelId, buffer: buffer, boxed: false) serializeInt32(id, buffer: buffer, boxed: false) serializeInt32(forwards, buffer: buffer, boxed: false) break case .updateReadChannelDiscussionInbox(let flags, let channelId, let topMsgId, let readMaxId, let broadcastId, let broadcastPost): if boxed { - buffer.appendInt32(482860628) + buffer.appendInt32(-693004986) } serializeInt32(flags, buffer: buffer, boxed: false) - serializeInt32(channelId, buffer: buffer, boxed: false) + serializeInt64(channelId, buffer: buffer, boxed: false) serializeInt32(topMsgId, buffer: buffer, boxed: false) serializeInt32(readMaxId, buffer: buffer, boxed: false) - if Int(flags) & Int(1 << 0) != 0 {serializeInt32(broadcastId!, buffer: buffer, boxed: false)} + if Int(flags) & Int(1 << 0) != 0 {serializeInt64(broadcastId!, buffer: buffer, boxed: false)} if Int(flags) & Int(1 << 0) != 0 {serializeInt32(broadcastPost!, buffer: buffer, boxed: false)} break case .updateReadChannelDiscussionOutbox(let channelId, let topMsgId, let readMaxId): if boxed { - buffer.appendInt32(1178116716) + buffer.appendInt32(1767677564) } - serializeInt32(channelId, buffer: buffer, boxed: false) + serializeInt64(channelId, buffer: buffer, boxed: false) serializeInt32(topMsgId, buffer: buffer, boxed: false) serializeInt32(readMaxId, buffer: buffer, boxed: false) break @@ -5412,10 +5408,10 @@ public extension Api { break case .updateChannelUserTyping(let flags, let channelId, let topMsgId, let fromId, let action): if boxed { - buffer.appendInt32(1796675352) + buffer.appendInt32(-1937192669) } serializeInt32(flags, buffer: buffer, boxed: false) - serializeInt32(channelId, buffer: buffer, boxed: false) + serializeInt64(channelId, buffer: buffer, boxed: false) if Int(flags) & Int(1 << 0) != 0 {serializeInt32(topMsgId!, buffer: buffer, boxed: false)} fromId.serialize(buffer, true) action.serialize(buffer, true) @@ -5436,10 +5432,10 @@ public extension Api { break case .updatePinnedChannelMessages(let flags, let channelId, let messages, let pts, let ptsCount): if boxed { - buffer.appendInt32(-2054649973) + buffer.appendInt32(1538885128) } serializeInt32(flags, buffer: buffer, boxed: false) - serializeInt32(channelId, buffer: buffer, boxed: false) + serializeInt64(channelId, buffer: buffer, boxed: false) buffer.appendInt32(481674261) buffer.appendInt32(Int32(messages.count)) for item in messages { @@ -5450,9 +5446,9 @@ public extension Api { break case .updateChat(let chatId): if boxed { - buffer.appendInt32(321954198) + buffer.appendInt32(-124097970) } - serializeInt32(chatId, buffer: buffer, boxed: false) + serializeInt64(chatId, buffer: buffer, boxed: false) break case .updateGroupCallParticipants(let call, let participants, let version): if boxed { @@ -5468,9 +5464,9 @@ public extension Api { break case .updateGroupCall(let chatId, let call): if boxed { - buffer.appendInt32(-1537295973) + buffer.appendInt32(347227392) } - serializeInt32(chatId, buffer: buffer, boxed: false) + serializeInt64(chatId, buffer: buffer, boxed: false) call.serialize(buffer, true) break case .updatePeerHistoryTTL(let flags, let peer, let ttlPeriod): @@ -5483,13 +5479,13 @@ public extension Api { break case .updateChatParticipant(let flags, let chatId, let date, let actorId, let userId, let prevParticipant, let newParticipant, let invite, let qts): if boxed { - buffer.appendInt32(-206342113) + buffer.appendInt32(-796432838) } serializeInt32(flags, buffer: buffer, boxed: false) - serializeInt32(chatId, buffer: buffer, boxed: false) + serializeInt64(chatId, buffer: buffer, boxed: false) serializeInt32(date, buffer: buffer, boxed: false) - serializeInt32(actorId, buffer: buffer, boxed: false) - serializeInt32(userId, buffer: buffer, boxed: false) + serializeInt64(actorId, buffer: buffer, boxed: false) + serializeInt64(userId, buffer: buffer, boxed: false) if Int(flags) & Int(1 << 0) != 0 {prevParticipant!.serialize(buffer, true)} if Int(flags) & Int(1 << 1) != 0 {newParticipant!.serialize(buffer, true)} if Int(flags) & Int(1 << 2) != 0 {invite!.serialize(buffer, true)} @@ -5497,13 +5493,13 @@ public extension Api { break case .updateChannelParticipant(let flags, let channelId, let date, let actorId, let userId, let prevParticipant, let newParticipant, let invite, let qts): if boxed { - buffer.appendInt32(2146218476) + buffer.appendInt32(-1738720581) } serializeInt32(flags, buffer: buffer, boxed: false) - serializeInt32(channelId, buffer: buffer, boxed: false) + serializeInt64(channelId, buffer: buffer, boxed: false) serializeInt32(date, buffer: buffer, boxed: false) - serializeInt32(actorId, buffer: buffer, boxed: false) - serializeInt32(userId, buffer: buffer, boxed: false) + serializeInt64(actorId, buffer: buffer, boxed: false) + serializeInt64(userId, buffer: buffer, boxed: false) if Int(flags) & Int(1 << 0) != 0 {prevParticipant!.serialize(buffer, true)} if Int(flags) & Int(1 << 1) != 0 {newParticipant!.serialize(buffer, true)} if Int(flags) & Int(1 << 2) != 0 {invite!.serialize(buffer, true)} @@ -5511,9 +5507,9 @@ public extension Api { break case .updateBotStopped(let userId, let date, let stopped, let qts): if boxed { - buffer.appendInt32(133777546) + buffer.appendInt32(-997782967) } - serializeInt32(userId, buffer: buffer, boxed: false) + serializeInt64(userId, buffer: buffer, boxed: false) serializeInt32(date, buffer: buffer, boxed: false) stopped.serialize(buffer, true) serializeInt32(qts, buffer: buffer, boxed: false) @@ -5527,10 +5523,10 @@ public extension Api { break case .updateBotCommands(let peer, let botId, let commands): if boxed { - buffer.appendInt32(-813823885) + buffer.appendInt32(1299263278) } peer.serialize(buffer, true) - serializeInt32(botId, buffer: buffer, boxed: false) + serializeInt64(botId, buffer: buffer, boxed: false) buffer.appendInt32(481674261) buffer.appendInt32(Int32(commands.count)) for item in commands { @@ -5784,8 +5780,8 @@ public extension Api { } } public static func parse_updateUserTyping(_ reader: BufferReader) -> Update? { - var _1: Int32? - _1 = reader.readInt32() + var _1: Int64? + _1 = reader.readInt64() var _2: Api.SendMessageAction? if let signature = reader.readInt32() { _2 = Api.parse(reader, signature: signature) as? Api.SendMessageAction @@ -5800,8 +5796,8 @@ public extension Api { } } public static func parse_updateChatUserTyping(_ reader: BufferReader) -> Update? { - var _1: Int32? - _1 = reader.readInt32() + var _1: Int64? + _1 = reader.readInt64() var _2: Api.Peer? if let signature = reader.readInt32() { _2 = Api.parse(reader, signature: signature) as? Api.Peer @@ -5834,8 +5830,8 @@ public extension Api { } } public static func parse_updateUserStatus(_ reader: BufferReader) -> Update? { - var _1: Int32? - _1 = reader.readInt32() + var _1: Int64? + _1 = reader.readInt64() var _2: Api.UserStatus? if let signature = reader.readInt32() { _2 = Api.parse(reader, signature: signature) as? Api.UserStatus @@ -5850,8 +5846,8 @@ public extension Api { } } public static func parse_updateUserName(_ reader: BufferReader) -> Update? { - var _1: Int32? - _1 = reader.readInt32() + var _1: Int64? + _1 = reader.readInt64() var _2: String? _2 = parseString(reader) var _3: String? @@ -5870,8 +5866,8 @@ public extension Api { } } public static func parse_updateUserPhoto(_ reader: BufferReader) -> Update? { - var _1: Int32? - _1 = reader.readInt32() + var _1: Int64? + _1 = reader.readInt64() var _2: Int32? _2 = reader.readInt32() var _3: Api.UserProfilePhoto? @@ -5954,12 +5950,12 @@ public extension Api { } } public static func parse_updateChatParticipantAdd(_ reader: BufferReader) -> Update? { - var _1: Int32? - _1 = reader.readInt32() - var _2: Int32? - _2 = reader.readInt32() - var _3: Int32? - _3 = reader.readInt32() + var _1: Int64? + _1 = reader.readInt64() + var _2: Int64? + _2 = reader.readInt64() + var _3: Int64? + _3 = reader.readInt64() var _4: Int32? _4 = reader.readInt32() var _5: Int32? @@ -5977,10 +5973,10 @@ public extension Api { } } public static func parse_updateChatParticipantDelete(_ reader: BufferReader) -> Update? { - var _1: Int32? - _1 = reader.readInt32() - var _2: Int32? - _2 = reader.readInt32() + var _1: Int64? + _1 = reader.readInt64() + var _2: Int64? + _2 = reader.readInt64() var _3: Int32? _3 = reader.readInt32() let _c1 = _1 != nil @@ -6073,8 +6069,8 @@ public extension Api { } } public static func parse_updateUserPhone(_ reader: BufferReader) -> Update? { - var _1: Int32? - _1 = reader.readInt32() + var _1: Int64? + _1 = reader.readInt64() var _2: String? _2 = parseString(reader) let _c1 = _1 != nil @@ -6180,8 +6176,8 @@ public extension Api { public static func parse_updateChannelTooLong(_ reader: BufferReader) -> Update? { var _1: Int32? _1 = reader.readInt32() - var _2: Int32? - _2 = reader.readInt32() + var _2: Int64? + _2 = reader.readInt64() var _3: Int32? if Int(_1!) & Int(1 << 0) != 0 {_3 = reader.readInt32() } let _c1 = _1 != nil @@ -6195,8 +6191,8 @@ public extension Api { } } public static func parse_updateChannel(_ reader: BufferReader) -> Update? { - var _1: Int32? - _1 = reader.readInt32() + var _1: Int64? + _1 = reader.readInt64() let _c1 = _1 != nil if _c1 { return Api.Update.updateChannel(channelId: _1!) @@ -6229,8 +6225,8 @@ public extension Api { _1 = reader.readInt32() var _2: Int32? if Int(_1!) & Int(1 << 0) != 0 {_2 = reader.readInt32() } - var _3: Int32? - _3 = reader.readInt32() + var _3: Int64? + _3 = reader.readInt64() var _4: Int32? _4 = reader.readInt32() var _5: Int32? @@ -6251,8 +6247,8 @@ public extension Api { } } public static func parse_updateDeleteChannelMessages(_ reader: BufferReader) -> Update? { - var _1: Int32? - _1 = reader.readInt32() + var _1: Int64? + _1 = reader.readInt64() var _2: [Int32]? if let _ = reader.readInt32() { _2 = Api.parseVector(reader, elementSignature: -1471112230, elementType: Int32.self) @@ -6273,8 +6269,8 @@ public extension Api { } } public static func parse_updateChannelMessageViews(_ reader: BufferReader) -> Update? { - var _1: Int32? - _1 = reader.readInt32() + var _1: Int64? + _1 = reader.readInt64() var _2: Int32? _2 = reader.readInt32() var _3: Int32? @@ -6290,10 +6286,10 @@ public extension Api { } } public static func parse_updateChatParticipantAdmin(_ reader: BufferReader) -> Update? { - var _1: Int32? - _1 = reader.readInt32() - var _2: Int32? - _2 = reader.readInt32() + var _1: Int64? + _1 = reader.readInt64() + var _2: Int64? + _2 = reader.readInt64() var _3: Api.Bool? if let signature = reader.readInt32() { _3 = Api.parse(reader, signature: signature) as? Api.Bool @@ -6351,8 +6347,8 @@ public extension Api { _1 = reader.readInt32() var _2: Int64? _2 = reader.readInt64() - var _3: Int32? - _3 = reader.readInt32() + var _3: Int64? + _3 = reader.readInt64() var _4: String? _4 = parseString(reader) var _5: Api.GeoPoint? @@ -6382,8 +6378,8 @@ public extension Api { public static func parse_updateBotInlineSend(_ reader: BufferReader) -> Update? { var _1: Int32? _1 = reader.readInt32() - var _2: Int32? - _2 = reader.readInt32() + var _2: Int64? + _2 = reader.readInt64() var _3: String? _3 = parseString(reader) var _4: Api.GeoPoint? @@ -6433,8 +6429,8 @@ public extension Api { _1 = reader.readInt32() var _2: Int64? _2 = reader.readInt64() - var _3: Int32? - _3 = reader.readInt32() + var _3: Int64? + _3 = reader.readInt64() var _4: Api.Peer? if let signature = reader.readInt32() { _4 = Api.parse(reader, signature: signature) as? Api.Peer @@ -6486,8 +6482,8 @@ public extension Api { _1 = reader.readInt32() var _2: Int64? _2 = reader.readInt64() - var _3: Int32? - _3 = reader.readInt32() + var _3: Int64? + _3 = reader.readInt64() var _4: Api.InputBotInlineMessageID? if let signature = reader.readInt32() { _4 = Api.parse(reader, signature: signature) as? Api.InputBotInlineMessageID @@ -6513,8 +6509,8 @@ public extension Api { } } public static func parse_updateReadChannelOutbox(_ reader: BufferReader) -> Update? { - var _1: Int32? - _1 = reader.readInt32() + var _1: Int64? + _1 = reader.readInt64() var _2: Int32? _2 = reader.readInt32() let _c1 = _1 != nil @@ -6557,8 +6553,8 @@ public extension Api { return Api.Update.updatePtsChanged } public static func parse_updateChannelWebPage(_ reader: BufferReader) -> Update? { - var _1: Int32? - _1 = reader.readInt32() + var _1: Int64? + _1 = reader.readInt64() var _2: Api.WebPage? if let signature = reader.readInt32() { _2 = Api.parse(reader, signature: signature) as? Api.WebPage @@ -6651,8 +6647,8 @@ public extension Api { public static func parse_updateBotShippingQuery(_ reader: BufferReader) -> Update? { var _1: Int64? _1 = reader.readInt64() - var _2: Int32? - _2 = reader.readInt32() + var _2: Int64? + _2 = reader.readInt64() var _3: Buffer? _3 = parseBytes(reader) var _4: Api.PostAddress? @@ -6675,8 +6671,8 @@ public extension Api { _1 = reader.readInt32() var _2: Int64? _2 = reader.readInt64() - var _3: Int32? - _3 = reader.readInt32() + var _3: Int64? + _3 = reader.readInt64() var _4: Buffer? _4 = parseBytes(reader) var _5: Api.PaymentRequestedInfo? @@ -6745,8 +6741,8 @@ public extension Api { return Api.Update.updateFavedStickers } public static func parse_updateChannelReadMessagesContents(_ reader: BufferReader) -> Update? { - var _1: Int32? - _1 = reader.readInt32() + var _1: Int64? + _1 = reader.readInt64() var _2: [Int32]? if let _ = reader.readInt32() { _2 = Api.parseVector(reader, elementSignature: -1471112230, elementType: Int32.self) @@ -6764,8 +6760,8 @@ public extension Api { return Api.Update.updateContactsReset } public static func parse_updateChannelAvailableMessages(_ reader: BufferReader) -> Update? { - var _1: Int32? - _1 = reader.readInt32() + var _1: Int64? + _1 = reader.readInt64() var _2: Int32? _2 = reader.readInt32() let _c1 = _1 != nil @@ -6954,8 +6950,8 @@ public extension Api { public static func parse_updateMessagePollVote(_ reader: BufferReader) -> Update? { var _1: Int64? _1 = reader.readInt64() - var _2: Int32? - _2 = reader.readInt32() + var _2: Int64? + _2 = reader.readInt64() var _3: [Buffer]? if let _ = reader.readInt32() { _3 = Api.parseVector(reader, elementSignature: -1255641564, elementType: Buffer.self) @@ -7023,8 +7019,8 @@ public extension Api { } } public static func parse_updateChannelMessageForwards(_ reader: BufferReader) -> Update? { - var _1: Int32? - _1 = reader.readInt32() + var _1: Int64? + _1 = reader.readInt64() var _2: Int32? _2 = reader.readInt32() var _3: Int32? @@ -7042,14 +7038,14 @@ public extension Api { public static func parse_updateReadChannelDiscussionInbox(_ reader: BufferReader) -> Update? { var _1: Int32? _1 = reader.readInt32() - var _2: Int32? - _2 = reader.readInt32() + var _2: Int64? + _2 = reader.readInt64() var _3: Int32? _3 = reader.readInt32() var _4: Int32? _4 = reader.readInt32() - var _5: Int32? - if Int(_1!) & Int(1 << 0) != 0 {_5 = reader.readInt32() } + var _5: Int64? + if Int(_1!) & Int(1 << 0) != 0 {_5 = reader.readInt64() } var _6: Int32? if Int(_1!) & Int(1 << 0) != 0 {_6 = reader.readInt32() } let _c1 = _1 != nil @@ -7066,8 +7062,8 @@ public extension Api { } } public static func parse_updateReadChannelDiscussionOutbox(_ reader: BufferReader) -> Update? { - var _1: Int32? - _1 = reader.readInt32() + var _1: Int64? + _1 = reader.readInt64() var _2: Int32? _2 = reader.readInt32() var _3: Int32? @@ -7103,8 +7099,8 @@ public extension Api { public static func parse_updateChannelUserTyping(_ reader: BufferReader) -> Update? { var _1: Int32? _1 = reader.readInt32() - var _2: Int32? - _2 = reader.readInt32() + var _2: Int64? + _2 = reader.readInt64() var _3: Int32? if Int(_1!) & Int(1 << 0) != 0 {_3 = reader.readInt32() } var _4: Api.Peer? @@ -7157,8 +7153,8 @@ public extension Api { public static func parse_updatePinnedChannelMessages(_ reader: BufferReader) -> Update? { var _1: Int32? _1 = reader.readInt32() - var _2: Int32? - _2 = reader.readInt32() + var _2: Int64? + _2 = reader.readInt64() var _3: [Int32]? if let _ = reader.readInt32() { _3 = Api.parseVector(reader, elementSignature: -1471112230, elementType: Int32.self) @@ -7180,8 +7176,8 @@ public extension Api { } } public static func parse_updateChat(_ reader: BufferReader) -> Update? { - var _1: Int32? - _1 = reader.readInt32() + var _1: Int64? + _1 = reader.readInt64() let _c1 = _1 != nil if _c1 { return Api.Update.updateChat(chatId: _1!) @@ -7212,8 +7208,8 @@ public extension Api { } } public static func parse_updateGroupCall(_ reader: BufferReader) -> Update? { - var _1: Int32? - _1 = reader.readInt32() + var _1: Int64? + _1 = reader.readInt64() var _2: Api.GroupCall? if let signature = reader.readInt32() { _2 = Api.parse(reader, signature: signature) as? Api.GroupCall @@ -7249,14 +7245,14 @@ public extension Api { public static func parse_updateChatParticipant(_ reader: BufferReader) -> Update? { var _1: Int32? _1 = reader.readInt32() - var _2: Int32? - _2 = reader.readInt32() + var _2: Int64? + _2 = reader.readInt64() var _3: Int32? _3 = reader.readInt32() - var _4: Int32? - _4 = reader.readInt32() - var _5: Int32? - _5 = reader.readInt32() + var _4: Int64? + _4 = reader.readInt64() + var _5: Int64? + _5 = reader.readInt64() var _6: Api.ChatParticipant? if Int(_1!) & Int(1 << 0) != 0 {if let signature = reader.readInt32() { _6 = Api.parse(reader, signature: signature) as? Api.ChatParticipant @@ -7290,14 +7286,14 @@ public extension Api { public static func parse_updateChannelParticipant(_ reader: BufferReader) -> Update? { var _1: Int32? _1 = reader.readInt32() - var _2: Int32? - _2 = reader.readInt32() + var _2: Int64? + _2 = reader.readInt64() var _3: Int32? _3 = reader.readInt32() - var _4: Int32? - _4 = reader.readInt32() - var _5: Int32? - _5 = reader.readInt32() + var _4: Int64? + _4 = reader.readInt64() + var _5: Int64? + _5 = reader.readInt64() var _6: Api.ChannelParticipant? if Int(_1!) & Int(1 << 0) != 0 {if let signature = reader.readInt32() { _6 = Api.parse(reader, signature: signature) as? Api.ChannelParticipant @@ -7329,8 +7325,8 @@ public extension Api { } } public static func parse_updateBotStopped(_ reader: BufferReader) -> Update? { - var _1: Int32? - _1 = reader.readInt32() + var _1: Int64? + _1 = reader.readInt64() var _2: Int32? _2 = reader.readInt32() var _3: Api.Bool? @@ -7371,8 +7367,8 @@ public extension Api { if let signature = reader.readInt32() { _1 = Api.parse(reader, signature: signature) as? Api.Peer } - var _2: Int32? - _2 = reader.readInt32() + var _2: Int64? + _2 = reader.readInt64() var _3: [Api.BotCommand]? if let _ = reader.readInt32() { _3 = Api.parseVector(reader, elementSignature: 0, elementType: Api.BotCommand.self) @@ -7512,58 +7508,58 @@ public extension Api { } public enum ChannelParticipant: TypeConstructorDescription { - case channelParticipant(userId: Int32, date: Int32) - case channelParticipantSelf(userId: Int32, inviterId: Int32, date: Int32) - case channelParticipantCreator(flags: Int32, userId: Int32, adminRights: Api.ChatAdminRights, rank: String?) - case channelParticipantAdmin(flags: Int32, userId: Int32, inviterId: Int32?, promotedBy: Int32, date: Int32, adminRights: Api.ChatAdminRights, rank: String?) - case channelParticipantBanned(flags: Int32, peer: Api.Peer, kickedBy: Int32, date: Int32, bannedRights: Api.ChatBannedRights) + case channelParticipant(userId: Int64, date: Int32) + case channelParticipantSelf(userId: Int64, inviterId: Int64, date: Int32) + case channelParticipantCreator(flags: Int32, userId: Int64, adminRights: Api.ChatAdminRights, rank: String?) + case channelParticipantAdmin(flags: Int32, userId: Int64, inviterId: Int64?, promotedBy: Int64, date: Int32, adminRights: Api.ChatAdminRights, rank: String?) + case channelParticipantBanned(flags: Int32, peer: Api.Peer, kickedBy: Int64, date: Int32, bannedRights: Api.ChatBannedRights) case channelParticipantLeft(peer: Api.Peer) public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) { switch self { case .channelParticipant(let userId, let date): if boxed { - buffer.appendInt32(367766557) + buffer.appendInt32(-1072953408) } - serializeInt32(userId, buffer: buffer, boxed: false) + serializeInt64(userId, buffer: buffer, boxed: false) serializeInt32(date, buffer: buffer, boxed: false) break case .channelParticipantSelf(let userId, let inviterId, let date): if boxed { - buffer.appendInt32(-1557620115) + buffer.appendInt32(682146919) } - serializeInt32(userId, buffer: buffer, boxed: false) - serializeInt32(inviterId, buffer: buffer, boxed: false) + serializeInt64(userId, buffer: buffer, boxed: false) + serializeInt64(inviterId, buffer: buffer, boxed: false) serializeInt32(date, buffer: buffer, boxed: false) break case .channelParticipantCreator(let flags, let userId, let adminRights, let rank): if boxed { - buffer.appendInt32(1149094475) + buffer.appendInt32(803602899) } serializeInt32(flags, buffer: buffer, boxed: false) - serializeInt32(userId, buffer: buffer, boxed: false) + serializeInt64(userId, buffer: buffer, boxed: false) adminRights.serialize(buffer, true) if Int(flags) & Int(1 << 0) != 0 {serializeString(rank!, buffer: buffer, boxed: false)} break case .channelParticipantAdmin(let flags, let userId, let inviterId, let promotedBy, let date, let adminRights, let rank): if boxed { - buffer.appendInt32(-859915345) + buffer.appendInt32(885242707) } serializeInt32(flags, buffer: buffer, boxed: false) - serializeInt32(userId, buffer: buffer, boxed: false) - if Int(flags) & Int(1 << 1) != 0 {serializeInt32(inviterId!, buffer: buffer, boxed: false)} - serializeInt32(promotedBy, buffer: buffer, boxed: false) + serializeInt64(userId, buffer: buffer, boxed: false) + if Int(flags) & Int(1 << 1) != 0 {serializeInt64(inviterId!, buffer: buffer, boxed: false)} + serializeInt64(promotedBy, buffer: buffer, boxed: false) serializeInt32(date, buffer: buffer, boxed: false) adminRights.serialize(buffer, true) if Int(flags) & Int(1 << 2) != 0 {serializeString(rank!, buffer: buffer, boxed: false)} break case .channelParticipantBanned(let flags, let peer, let kickedBy, let date, let bannedRights): if boxed { - buffer.appendInt32(1352785878) + buffer.appendInt32(1844969806) } serializeInt32(flags, buffer: buffer, boxed: false) peer.serialize(buffer, true) - serializeInt32(kickedBy, buffer: buffer, boxed: false) + serializeInt64(kickedBy, buffer: buffer, boxed: false) serializeInt32(date, buffer: buffer, boxed: false) bannedRights.serialize(buffer, true) break @@ -7594,8 +7590,8 @@ public extension Api { } public static func parse_channelParticipant(_ reader: BufferReader) -> ChannelParticipant? { - var _1: Int32? - _1 = reader.readInt32() + var _1: Int64? + _1 = reader.readInt64() var _2: Int32? _2 = reader.readInt32() let _c1 = _1 != nil @@ -7608,10 +7604,10 @@ public extension Api { } } public static func parse_channelParticipantSelf(_ reader: BufferReader) -> ChannelParticipant? { - var _1: Int32? - _1 = reader.readInt32() - var _2: Int32? - _2 = reader.readInt32() + var _1: Int64? + _1 = reader.readInt64() + var _2: Int64? + _2 = reader.readInt64() var _3: Int32? _3 = reader.readInt32() let _c1 = _1 != nil @@ -7627,8 +7623,8 @@ public extension Api { public static func parse_channelParticipantCreator(_ reader: BufferReader) -> ChannelParticipant? { var _1: Int32? _1 = reader.readInt32() - var _2: Int32? - _2 = reader.readInt32() + var _2: Int64? + _2 = reader.readInt64() var _3: Api.ChatAdminRights? if let signature = reader.readInt32() { _3 = Api.parse(reader, signature: signature) as? Api.ChatAdminRights @@ -7649,12 +7645,12 @@ public extension Api { public static func parse_channelParticipantAdmin(_ reader: BufferReader) -> ChannelParticipant? { var _1: Int32? _1 = reader.readInt32() - var _2: Int32? - _2 = reader.readInt32() - var _3: Int32? - if Int(_1!) & Int(1 << 1) != 0 {_3 = reader.readInt32() } - var _4: Int32? - _4 = reader.readInt32() + var _2: Int64? + _2 = reader.readInt64() + var _3: Int64? + if Int(_1!) & Int(1 << 1) != 0 {_3 = reader.readInt64() } + var _4: Int64? + _4 = reader.readInt64() var _5: Int32? _5 = reader.readInt32() var _6: Api.ChatAdminRights? @@ -7684,8 +7680,8 @@ public extension Api { if let signature = reader.readInt32() { _2 = Api.parse(reader, signature: signature) as? Api.Peer } - var _3: Int32? - _3 = reader.readInt32() + var _3: Int64? + _3 = reader.readInt64() var _4: Int32? _4 = reader.readInt32() var _5: Api.ChatBannedRights? @@ -7720,32 +7716,32 @@ public extension Api { } public enum MessageUserVote: TypeConstructorDescription { - case messageUserVote(userId: Int32, option: Buffer, date: Int32) - case messageUserVoteInputOption(userId: Int32, date: Int32) - case messageUserVoteMultiple(userId: Int32, options: [Buffer], date: Int32) + case messageUserVote(userId: Int64, option: Buffer, date: Int32) + case messageUserVoteInputOption(userId: Int64, date: Int32) + case messageUserVoteMultiple(userId: Int64, options: [Buffer], date: Int32) public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) { switch self { case .messageUserVote(let userId, let option, let date): if boxed { - buffer.appendInt32(-1567730343) + buffer.appendInt32(886196148) } - serializeInt32(userId, buffer: buffer, boxed: false) + serializeInt64(userId, buffer: buffer, boxed: false) serializeBytes(option, buffer: buffer, boxed: false) serializeInt32(date, buffer: buffer, boxed: false) break case .messageUserVoteInputOption(let userId, let date): if boxed { - buffer.appendInt32(909603888) + buffer.appendInt32(1017491692) } - serializeInt32(userId, buffer: buffer, boxed: false) + serializeInt64(userId, buffer: buffer, boxed: false) serializeInt32(date, buffer: buffer, boxed: false) break case .messageUserVoteMultiple(let userId, let options, let date): if boxed { - buffer.appendInt32(244310238) + buffer.appendInt32(-1973033641) } - serializeInt32(userId, buffer: buffer, boxed: false) + serializeInt64(userId, buffer: buffer, boxed: false) buffer.appendInt32(481674261) buffer.appendInt32(Int32(options.count)) for item in options { @@ -7768,8 +7764,8 @@ public extension Api { } public static func parse_messageUserVote(_ reader: BufferReader) -> MessageUserVote? { - var _1: Int32? - _1 = reader.readInt32() + var _1: Int64? + _1 = reader.readInt64() var _2: Buffer? _2 = parseBytes(reader) var _3: Int32? @@ -7785,8 +7781,8 @@ public extension Api { } } public static func parse_messageUserVoteInputOption(_ reader: BufferReader) -> MessageUserVote? { - var _1: Int32? - _1 = reader.readInt32() + var _1: Int64? + _1 = reader.readInt64() var _2: Int32? _2 = reader.readInt32() let _c1 = _1 != nil @@ -7799,8 +7795,8 @@ public extension Api { } } public static func parse_messageUserVoteMultiple(_ reader: BufferReader) -> MessageUserVote? { - var _1: Int32? - _1 = reader.readInt32() + var _1: Int64? + _1 = reader.readInt64() var _2: [Buffer]? if let _ = reader.readInt32() { _2 = Api.parseVector(reader, elementSignature: -1255641564, elementType: Buffer.self) @@ -8174,15 +8170,15 @@ public extension Api { } public enum ContactStatus: TypeConstructorDescription { - case contactStatus(userId: Int32, status: Api.UserStatus) + case contactStatus(userId: Int64, status: Api.UserStatus) public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) { switch self { case .contactStatus(let userId, let status): if boxed { - buffer.appendInt32(-748155807) + buffer.appendInt32(383348795) } - serializeInt32(userId, buffer: buffer, boxed: false) + serializeInt64(userId, buffer: buffer, boxed: false) status.serialize(buffer, true) break } @@ -8196,8 +8192,8 @@ public extension Api { } public static func parse_contactStatus(_ reader: BufferReader) -> ContactStatus? { - var _1: Int32? - _1 = reader.readInt32() + var _1: Int64? + _1 = reader.readInt64() var _2: Api.UserStatus? if let signature = reader.readInt32() { _2 = Api.parse(reader, signature: signature) as? Api.UserStatus @@ -9858,15 +9854,15 @@ public extension Api { } public enum ChatAdminWithInvites: TypeConstructorDescription { - case chatAdminWithInvites(adminId: Int32, invitesCount: Int32, revokedInvitesCount: Int32) + case chatAdminWithInvites(adminId: Int64, invitesCount: Int32, revokedInvitesCount: Int32) public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) { switch self { case .chatAdminWithInvites(let adminId, let invitesCount, let revokedInvitesCount): if boxed { - buffer.appendInt32(-539872497) + buffer.appendInt32(-219353309) } - serializeInt32(adminId, buffer: buffer, boxed: false) + serializeInt64(adminId, buffer: buffer, boxed: false) serializeInt32(invitesCount, buffer: buffer, boxed: false) serializeInt32(revokedInvitesCount, buffer: buffer, boxed: false) break @@ -9881,8 +9877,8 @@ public extension Api { } public static func parse_chatAdminWithInvites(_ reader: BufferReader) -> ChatAdminWithInvites? { - var _1: Int32? - _1 = reader.readInt32() + var _1: Int64? + _1 = reader.readInt64() var _2: Int32? _2 = reader.readInt32() var _3: Int32? @@ -10606,11 +10602,11 @@ public extension Api { indirect public enum InputPeer: TypeConstructorDescription { case inputPeerEmpty case inputPeerSelf - case inputPeerChat(chatId: Int32) - case inputPeerUser(userId: Int32, accessHash: Int64) - case inputPeerChannel(channelId: Int32, accessHash: Int64) - case inputPeerUserFromMessage(peer: Api.InputPeer, msgId: Int32, userId: Int32) - case inputPeerChannelFromMessage(peer: Api.InputPeer, msgId: Int32, channelId: Int32) + case inputPeerChat(chatId: Int64) + case inputPeerUser(userId: Int64, accessHash: Int64) + case inputPeerChannel(channelId: Int64, accessHash: Int64) + case inputPeerUserFromMessage(peer: Api.InputPeer, msgId: Int32, userId: Int64) + case inputPeerChannelFromMessage(peer: Api.InputPeer, msgId: Int32, channelId: Int64) public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) { switch self { @@ -10628,39 +10624,39 @@ public extension Api { break case .inputPeerChat(let chatId): if boxed { - buffer.appendInt32(396093539) + buffer.appendInt32(900291769) } - serializeInt32(chatId, buffer: buffer, boxed: false) + serializeInt64(chatId, buffer: buffer, boxed: false) break case .inputPeerUser(let userId, let accessHash): if boxed { - buffer.appendInt32(2072935910) + buffer.appendInt32(-571955892) } - serializeInt32(userId, buffer: buffer, boxed: false) + serializeInt64(userId, buffer: buffer, boxed: false) serializeInt64(accessHash, buffer: buffer, boxed: false) break case .inputPeerChannel(let channelId, let accessHash): if boxed { - buffer.appendInt32(548253432) + buffer.appendInt32(666680316) } - serializeInt32(channelId, buffer: buffer, boxed: false) + serializeInt64(channelId, buffer: buffer, boxed: false) serializeInt64(accessHash, buffer: buffer, boxed: false) break case .inputPeerUserFromMessage(let peer, let msgId, let userId): if boxed { - buffer.appendInt32(398123750) + buffer.appendInt32(-1468331492) } peer.serialize(buffer, true) serializeInt32(msgId, buffer: buffer, boxed: false) - serializeInt32(userId, buffer: buffer, boxed: false) + serializeInt64(userId, buffer: buffer, boxed: false) break case .inputPeerChannelFromMessage(let peer, let msgId, let channelId): if boxed { - buffer.appendInt32(-1667893317) + buffer.appendInt32(-1121318848) } peer.serialize(buffer, true) serializeInt32(msgId, buffer: buffer, boxed: false) - serializeInt32(channelId, buffer: buffer, boxed: false) + serializeInt64(channelId, buffer: buffer, boxed: false) break } } @@ -10691,8 +10687,8 @@ public extension Api { return Api.InputPeer.inputPeerSelf } public static func parse_inputPeerChat(_ reader: BufferReader) -> InputPeer? { - var _1: Int32? - _1 = reader.readInt32() + var _1: Int64? + _1 = reader.readInt64() let _c1 = _1 != nil if _c1 { return Api.InputPeer.inputPeerChat(chatId: _1!) @@ -10702,8 +10698,8 @@ public extension Api { } } public static func parse_inputPeerUser(_ reader: BufferReader) -> InputPeer? { - var _1: Int32? - _1 = reader.readInt32() + var _1: Int64? + _1 = reader.readInt64() var _2: Int64? _2 = reader.readInt64() let _c1 = _1 != nil @@ -10716,8 +10712,8 @@ public extension Api { } } public static func parse_inputPeerChannel(_ reader: BufferReader) -> InputPeer? { - var _1: Int32? - _1 = reader.readInt32() + var _1: Int64? + _1 = reader.readInt64() var _2: Int64? _2 = reader.readInt64() let _c1 = _1 != nil @@ -10736,8 +10732,8 @@ public extension Api { } var _2: Int32? _2 = reader.readInt32() - var _3: Int32? - _3 = reader.readInt32() + var _3: Int64? + _3 = reader.readInt64() let _c1 = _1 != nil let _c2 = _2 != nil let _c3 = _3 != nil @@ -10755,8 +10751,8 @@ public extension Api { } var _2: Int32? _2 = reader.readInt32() - var _3: Int32? - _3 = reader.readInt32() + var _3: Int64? + _3 = reader.readInt64() let _c1 = _1 != nil let _c2 = _2 != nil let _c3 = _3 != nil @@ -10770,15 +10766,15 @@ public extension Api { } public enum Contact: TypeConstructorDescription { - case contact(userId: Int32, mutual: Api.Bool) + case contact(userId: Int64, mutual: Api.Bool) public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) { switch self { case .contact(let userId, let mutual): if boxed { - buffer.appendInt32(-116274796) + buffer.appendInt32(341499403) } - serializeInt32(userId, buffer: buffer, boxed: false) + serializeInt64(userId, buffer: buffer, boxed: false) mutual.serialize(buffer, true) break } @@ -10792,8 +10788,8 @@ public extension Api { } public static func parse_contact(_ reader: BufferReader) -> Contact? { - var _1: Int32? - _1 = reader.readInt32() + var _1: Int64? + _1 = reader.readInt64() var _2: Api.Bool? if let signature = reader.readInt32() { _2 = Api.parse(reader, signature: signature) as? Api.Bool @@ -11128,8 +11124,8 @@ public extension Api { case inputPrivacyValueDisallowContacts case inputPrivacyValueDisallowAll case inputPrivacyValueDisallowUsers(users: [Api.InputUser]) - case inputPrivacyValueAllowChatParticipants(chats: [Int32]) - case inputPrivacyValueDisallowChatParticipants(chats: [Int32]) + case inputPrivacyValueAllowChatParticipants(chats: [Int64]) + case inputPrivacyValueDisallowChatParticipants(chats: [Int64]) public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) { switch self { @@ -11179,22 +11175,22 @@ public extension Api { break case .inputPrivacyValueAllowChatParticipants(let chats): if boxed { - buffer.appendInt32(1283572154) + buffer.appendInt32(-2079962673) } buffer.appendInt32(481674261) buffer.appendInt32(Int32(chats.count)) for item in chats { - serializeInt32(item, buffer: buffer, boxed: false) + serializeInt64(item, buffer: buffer, boxed: false) } break case .inputPrivacyValueDisallowChatParticipants(let chats): if boxed { - buffer.appendInt32(-668769361) + buffer.appendInt32(-380694650) } buffer.appendInt32(481674261) buffer.appendInt32(Int32(chats.count)) for item in chats { - serializeInt32(item, buffer: buffer, boxed: false) + serializeInt64(item, buffer: buffer, boxed: false) } break } @@ -11260,9 +11256,9 @@ public extension Api { } } public static func parse_inputPrivacyValueAllowChatParticipants(_ reader: BufferReader) -> InputPrivacyRule? { - var _1: [Int32]? + var _1: [Int64]? if let _ = reader.readInt32() { - _1 = Api.parseVector(reader, elementSignature: -1471112230, elementType: Int32.self) + _1 = Api.parseVector(reader, elementSignature: 570911930, elementType: Int64.self) } let _c1 = _1 != nil if _c1 { @@ -11273,9 +11269,9 @@ public extension Api { } } public static func parse_inputPrivacyValueDisallowChatParticipants(_ reader: BufferReader) -> InputPrivacyRule? { - var _1: [Int32]? + var _1: [Int64]? if let _ = reader.readInt32() { - _1 = Api.parseVector(reader, elementSignature: -1471112230, elementType: Int32.self) + _1 = Api.parseVector(reader, elementSignature: 570911930, elementType: Int64.self) } let _c1 = _1 != nil if _c1 { @@ -11306,7 +11302,7 @@ public extension Api { case channelAdminLogEventActionTogglePreHistoryHidden(newValue: Api.Bool) case channelAdminLogEventActionDefaultBannedRights(prevBannedRights: Api.ChatBannedRights, newBannedRights: Api.ChatBannedRights) case channelAdminLogEventActionStopPoll(message: Api.Message) - case channelAdminLogEventActionChangeLinkedChat(prevValue: Int32, newValue: Int32) + case channelAdminLogEventActionChangeLinkedChat(prevValue: Int64, newValue: Int64) case channelAdminLogEventActionChangeLocation(prevValue: Api.ChannelLocation, newValue: Api.ChannelLocation) case channelAdminLogEventActionToggleSlowMode(prevValue: Int32, newValue: Int32) case channelAdminLogEventActionStartGroupCall(call: Api.InputGroupCall) @@ -11443,10 +11439,10 @@ public extension Api { break case .channelAdminLogEventActionChangeLinkedChat(let prevValue, let newValue): if boxed { - buffer.appendInt32(-1569748965) + buffer.appendInt32(84703944) } - serializeInt32(prevValue, buffer: buffer, boxed: false) - serializeInt32(newValue, buffer: buffer, boxed: false) + serializeInt64(prevValue, buffer: buffer, boxed: false) + serializeInt64(newValue, buffer: buffer, boxed: false) break case .channelAdminLogEventActionChangeLocation(let prevValue, let newValue): if boxed { @@ -11859,10 +11855,10 @@ public extension Api { } } public static func parse_channelAdminLogEventActionChangeLinkedChat(_ reader: BufferReader) -> ChannelAdminLogEventAction? { - var _1: Int32? - _1 = reader.readInt32() - var _2: Int32? - _2 = reader.readInt32() + var _1: Int64? + _1 = reader.readInt64() + var _2: Int64? + _2 = reader.readInt64() let _c1 = _1 != nil let _c2 = _2 != nil if _c1 && _c2 { @@ -12728,15 +12724,15 @@ public extension Api { } public enum StatsGroupTopPoster: TypeConstructorDescription { - case statsGroupTopPoster(userId: Int32, messages: Int32, avgChars: Int32) + case statsGroupTopPoster(userId: Int64, messages: Int32, avgChars: Int32) public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) { switch self { case .statsGroupTopPoster(let userId, let messages, let avgChars): if boxed { - buffer.appendInt32(418631927) + buffer.appendInt32(-1660637285) } - serializeInt32(userId, buffer: buffer, boxed: false) + serializeInt64(userId, buffer: buffer, boxed: false) serializeInt32(messages, buffer: buffer, boxed: false) serializeInt32(avgChars, buffer: buffer, boxed: false) break @@ -12751,8 +12747,8 @@ public extension Api { } public static func parse_statsGroupTopPoster(_ reader: BufferReader) -> StatsGroupTopPoster? { - var _1: Int32? - _1 = reader.readInt32() + var _1: Int64? + _1 = reader.readInt64() var _2: Int32? _2 = reader.readInt32() var _3: Int32? @@ -13568,16 +13564,16 @@ public extension Api { } public enum HighScore: TypeConstructorDescription { - case highScore(pos: Int32, userId: Int32, score: Int32) + case highScore(pos: Int32, userId: Int64, score: Int32) public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) { switch self { case .highScore(let pos, let userId, let score): if boxed { - buffer.appendInt32(1493171408) + buffer.appendInt32(1940093419) } serializeInt32(pos, buffer: buffer, boxed: false) - serializeInt32(userId, buffer: buffer, boxed: false) + serializeInt64(userId, buffer: buffer, boxed: false) serializeInt32(score, buffer: buffer, boxed: false) break } @@ -13593,8 +13589,8 @@ public extension Api { public static func parse_highScore(_ reader: BufferReader) -> HighScore? { var _1: Int32? _1 = reader.readInt32() - var _2: Int32? - _2 = reader.readInt32() + var _2: Int64? + _2 = reader.readInt64() var _3: Int32? _3 = reader.readInt32() let _c1 = _1 != nil @@ -13936,8 +13932,8 @@ public extension Api { public enum InputUser: TypeConstructorDescription { case inputUserEmpty case inputUserSelf - case inputUser(userId: Int32, accessHash: Int64) - case inputUserFromMessage(peer: Api.InputPeer, msgId: Int32, userId: Int32) + case inputUser(userId: Int64, accessHash: Int64) + case inputUserFromMessage(peer: Api.InputPeer, msgId: Int32, userId: Int64) public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) { switch self { @@ -13955,18 +13951,18 @@ public extension Api { break case .inputUser(let userId, let accessHash): if boxed { - buffer.appendInt32(-668391402) + buffer.appendInt32(-233744186) } - serializeInt32(userId, buffer: buffer, boxed: false) + serializeInt64(userId, buffer: buffer, boxed: false) serializeInt64(accessHash, buffer: buffer, boxed: false) break case .inputUserFromMessage(let peer, let msgId, let userId): if boxed { - buffer.appendInt32(756118935) + buffer.appendInt32(497305826) } peer.serialize(buffer, true) serializeInt32(msgId, buffer: buffer, boxed: false) - serializeInt32(userId, buffer: buffer, boxed: false) + serializeInt64(userId, buffer: buffer, boxed: false) break } } @@ -13991,8 +13987,8 @@ public extension Api { return Api.InputUser.inputUserSelf } public static func parse_inputUser(_ reader: BufferReader) -> InputUser? { - var _1: Int32? - _1 = reader.readInt32() + var _1: Int64? + _1 = reader.readInt64() var _2: Int64? _2 = reader.readInt64() let _c1 = _1 != nil @@ -14011,8 +14007,8 @@ public extension Api { } var _2: Int32? _2 = reader.readInt32() - var _3: Int32? - _3 = reader.readInt32() + var _3: Int64? + _3 = reader.readInt64() let _c1 = _1 != nil let _c2 = _2 != nil let _c3 = _3 != nil @@ -14740,15 +14736,15 @@ public extension Api { } public enum ChatInviteImporter: TypeConstructorDescription { - case chatInviteImporter(userId: Int32, date: Int32) + case chatInviteImporter(userId: Int64, date: Int32) public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) { switch self { case .chatInviteImporter(let userId, let date): if boxed { - buffer.appendInt32(507405952) + buffer.appendInt32(190633460) } - serializeInt32(userId, buffer: buffer, boxed: false) + serializeInt64(userId, buffer: buffer, boxed: false) serializeInt32(date, buffer: buffer, boxed: false) break } @@ -14762,8 +14758,8 @@ public extension Api { } public static func parse_chatInviteImporter(_ reader: BufferReader) -> ChatInviteImporter? { - var _1: Int32? - _1 = reader.readInt32() + var _1: Int64? + _1 = reader.readInt64() var _2: Int32? _2 = reader.readInt32() let _c1 = _1 != nil @@ -14816,13 +14812,13 @@ public extension Api { } public enum MessageReplies: TypeConstructorDescription { - case messageReplies(flags: Int32, replies: Int32, repliesPts: Int32, recentRepliers: [Api.Peer]?, channelId: Int32?, maxId: Int32?, readMaxId: Int32?) + case messageReplies(flags: Int32, replies: Int32, repliesPts: Int32, recentRepliers: [Api.Peer]?, channelId: Int64?, maxId: Int32?, readMaxId: Int32?) public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) { switch self { case .messageReplies(let flags, let replies, let repliesPts, let recentRepliers, let channelId, let maxId, let readMaxId): if boxed { - buffer.appendInt32(1093204652) + buffer.appendInt32(-2083123262) } serializeInt32(flags, buffer: buffer, boxed: false) serializeInt32(replies, buffer: buffer, boxed: false) @@ -14832,7 +14828,7 @@ public extension Api { for item in recentRepliers! { item.serialize(buffer, true) }} - if Int(flags) & Int(1 << 0) != 0 {serializeInt32(channelId!, buffer: buffer, boxed: false)} + if Int(flags) & Int(1 << 0) != 0 {serializeInt64(channelId!, buffer: buffer, boxed: false)} if Int(flags) & Int(1 << 2) != 0 {serializeInt32(maxId!, buffer: buffer, boxed: false)} if Int(flags) & Int(1 << 3) != 0 {serializeInt32(readMaxId!, buffer: buffer, boxed: false)} break @@ -14857,8 +14853,8 @@ public extension Api { if Int(_1!) & Int(1 << 1) != 0 {if let _ = reader.readInt32() { _4 = Api.parseVector(reader, elementSignature: 0, elementType: Api.Peer.self) } } - var _5: Int32? - if Int(_1!) & Int(1 << 0) != 0 {_5 = reader.readInt32() } + var _5: Int64? + if Int(_1!) & Int(1 << 0) != 0 {_5 = reader.readInt64() } var _6: Int32? if Int(_1!) & Int(1 << 2) != 0 {_6 = reader.readInt32() } var _7: Int32? @@ -15663,8 +15659,8 @@ public extension Api { } public enum Updates: TypeConstructorDescription { case updatesTooLong - case updateShortMessage(flags: Int32, id: Int32, userId: Int32, message: String, pts: Int32, ptsCount: Int32, date: Int32, fwdFrom: Api.MessageFwdHeader?, viaBotId: Int32?, replyTo: Api.MessageReplyHeader?, entities: [Api.MessageEntity]?, ttlPeriod: Int32?) - case updateShortChatMessage(flags: Int32, id: Int32, fromId: Int32, chatId: Int32, message: String, pts: Int32, ptsCount: Int32, date: Int32, fwdFrom: Api.MessageFwdHeader?, viaBotId: Int32?, replyTo: Api.MessageReplyHeader?, entities: [Api.MessageEntity]?, ttlPeriod: Int32?) + case updateShortMessage(flags: Int32, id: Int32, userId: Int64, message: String, pts: Int32, ptsCount: Int32, date: Int32, fwdFrom: Api.MessageFwdHeader?, viaBotId: Int64?, replyTo: Api.MessageReplyHeader?, entities: [Api.MessageEntity]?, ttlPeriod: Int32?) + case updateShortChatMessage(flags: Int32, id: Int32, fromId: Int64, chatId: Int64, message: String, pts: Int32, ptsCount: Int32, date: Int32, fwdFrom: Api.MessageFwdHeader?, viaBotId: Int64?, replyTo: Api.MessageReplyHeader?, entities: [Api.MessageEntity]?, ttlPeriod: Int32?) case updateShort(update: Api.Update, date: Int32) case updatesCombined(updates: [Api.Update], users: [Api.User], chats: [Api.Chat], date: Int32, seqStart: Int32, seq: Int32) case updates(updates: [Api.Update], users: [Api.User], chats: [Api.Chat], date: Int32, seq: Int32) @@ -15680,17 +15676,17 @@ public extension Api { break case .updateShortMessage(let flags, let id, let userId, let message, let pts, let ptsCount, let date, let fwdFrom, let viaBotId, let replyTo, let entities, let ttlPeriod): if boxed { - buffer.appendInt32(-84936653) + buffer.appendInt32(826001400) } serializeInt32(flags, buffer: buffer, boxed: false) serializeInt32(id, buffer: buffer, boxed: false) - serializeInt32(userId, buffer: buffer, boxed: false) + serializeInt64(userId, buffer: buffer, boxed: false) serializeString(message, buffer: buffer, boxed: false) serializeInt32(pts, buffer: buffer, boxed: false) serializeInt32(ptsCount, buffer: buffer, boxed: false) serializeInt32(date, buffer: buffer, boxed: false) if Int(flags) & Int(1 << 2) != 0 {fwdFrom!.serialize(buffer, true)} - if Int(flags) & Int(1 << 11) != 0 {serializeInt32(viaBotId!, buffer: buffer, boxed: false)} + if Int(flags) & Int(1 << 11) != 0 {serializeInt64(viaBotId!, buffer: buffer, boxed: false)} if Int(flags) & Int(1 << 3) != 0 {replyTo!.serialize(buffer, true)} if Int(flags) & Int(1 << 7) != 0 {buffer.appendInt32(481674261) buffer.appendInt32(Int32(entities!.count)) @@ -15701,18 +15697,18 @@ public extension Api { break case .updateShortChatMessage(let flags, let id, let fromId, let chatId, let message, let pts, let ptsCount, let date, let fwdFrom, let viaBotId, let replyTo, let entities, let ttlPeriod): if boxed { - buffer.appendInt32(290961496) + buffer.appendInt32(1299050149) } serializeInt32(flags, buffer: buffer, boxed: false) serializeInt32(id, buffer: buffer, boxed: false) - serializeInt32(fromId, buffer: buffer, boxed: false) - serializeInt32(chatId, buffer: buffer, boxed: false) + serializeInt64(fromId, buffer: buffer, boxed: false) + serializeInt64(chatId, buffer: buffer, boxed: false) serializeString(message, buffer: buffer, boxed: false) serializeInt32(pts, buffer: buffer, boxed: false) serializeInt32(ptsCount, buffer: buffer, boxed: false) serializeInt32(date, buffer: buffer, boxed: false) if Int(flags) & Int(1 << 2) != 0 {fwdFrom!.serialize(buffer, true)} - if Int(flags) & Int(1 << 11) != 0 {serializeInt32(viaBotId!, buffer: buffer, boxed: false)} + if Int(flags) & Int(1 << 11) != 0 {serializeInt64(viaBotId!, buffer: buffer, boxed: false)} if Int(flags) & Int(1 << 3) != 0 {replyTo!.serialize(buffer, true)} if Int(flags) & Int(1 << 7) != 0 {buffer.appendInt32(481674261) buffer.appendInt32(Int32(entities!.count)) @@ -15820,8 +15816,8 @@ public extension Api { _1 = reader.readInt32() var _2: Int32? _2 = reader.readInt32() - var _3: Int32? - _3 = reader.readInt32() + var _3: Int64? + _3 = reader.readInt64() var _4: String? _4 = parseString(reader) var _5: Int32? @@ -15834,8 +15830,8 @@ public extension Api { if Int(_1!) & Int(1 << 2) != 0 {if let signature = reader.readInt32() { _8 = Api.parse(reader, signature: signature) as? Api.MessageFwdHeader } } - var _9: Int32? - if Int(_1!) & Int(1 << 11) != 0 {_9 = reader.readInt32() } + var _9: Int64? + if Int(_1!) & Int(1 << 11) != 0 {_9 = reader.readInt64() } var _10: Api.MessageReplyHeader? if Int(_1!) & Int(1 << 3) != 0 {if let signature = reader.readInt32() { _10 = Api.parse(reader, signature: signature) as? Api.MessageReplyHeader @@ -15870,10 +15866,10 @@ public extension Api { _1 = reader.readInt32() var _2: Int32? _2 = reader.readInt32() - var _3: Int32? - _3 = reader.readInt32() - var _4: Int32? - _4 = reader.readInt32() + var _3: Int64? + _3 = reader.readInt64() + var _4: Int64? + _4 = reader.readInt64() var _5: String? _5 = parseString(reader) var _6: Int32? @@ -15886,8 +15882,8 @@ public extension Api { if Int(_1!) & Int(1 << 2) != 0 {if let signature = reader.readInt32() { _9 = Api.parse(reader, signature: signature) as? Api.MessageFwdHeader } } - var _10: Int32? - if Int(_1!) & Int(1 << 11) != 0 {_10 = reader.readInt32() } + var _10: Int64? + if Int(_1!) & Int(1 << 11) != 0 {_10 = reader.readInt64() } var _11: Api.MessageReplyHeader? if Int(_1!) & Int(1 << 3) != 0 {if let signature = reader.readInt32() { _11 = Api.parse(reader, signature: signature) as? Api.MessageReplyHeader @@ -16075,7 +16071,7 @@ public extension Api { case messageMediaEmpty case messageMediaPhoto(flags: Int32, photo: Api.Photo?, ttlSeconds: Int32?) case messageMediaGeo(geo: Api.GeoPoint) - case messageMediaContact(phoneNumber: String, firstName: String, lastName: String, vcard: String, userId: Int32) + case messageMediaContact(phoneNumber: String, firstName: String, lastName: String, vcard: String, userId: Int64) case messageMediaUnsupported case messageMediaDocument(flags: Int32, document: Api.Document?, ttlSeconds: Int32?) case messageMediaWebPage(webpage: Api.WebPage) @@ -16110,13 +16106,13 @@ public extension Api { break case .messageMediaContact(let phoneNumber, let firstName, let lastName, let vcard, let userId): if boxed { - buffer.appendInt32(-873313984) + buffer.appendInt32(1882335561) } serializeString(phoneNumber, buffer: buffer, boxed: false) serializeString(firstName, buffer: buffer, boxed: false) serializeString(lastName, buffer: buffer, boxed: false) serializeString(vcard, buffer: buffer, boxed: false) - serializeInt32(userId, buffer: buffer, boxed: false) + serializeInt64(userId, buffer: buffer, boxed: false) break case .messageMediaUnsupported: if boxed { @@ -16270,8 +16266,8 @@ public extension Api { _3 = parseString(reader) var _4: String? _4 = parseString(reader) - var _5: Int32? - _5 = reader.readInt32() + var _5: Int64? + _5 = reader.readInt64() let _c1 = _1 != nil let _c2 = _2 != nil let _c3 = _3 != nil @@ -16994,15 +16990,15 @@ public extension Api { } public enum BotInfo: TypeConstructorDescription { - case botInfo(userId: Int32, description: String, commands: [Api.BotCommand]) + case botInfo(userId: Int64, description: String, commands: [Api.BotCommand]) public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) { switch self { case .botInfo(let userId, let description, let commands): if boxed { - buffer.appendInt32(-1729618630) + buffer.appendInt32(460632885) } - serializeInt32(userId, buffer: buffer, boxed: false) + serializeInt64(userId, buffer: buffer, boxed: false) serializeString(description, buffer: buffer, boxed: false) buffer.appendInt32(481674261) buffer.appendInt32(Int32(commands.count)) @@ -17021,8 +17017,8 @@ public extension Api { } public static func parse_botInfo(_ reader: BufferReader) -> BotInfo? { - var _1: Int32? - _1 = reader.readInt32() + var _1: Int64? + _1 = reader.readInt64() var _2: String? _2 = parseString(reader) var _3: [Api.BotCommand]? @@ -17042,23 +17038,23 @@ public extension Api { } public enum User: TypeConstructorDescription { - case userEmpty(id: Int32) - case user(flags: Int32, id: Int32, accessHash: Int64?, firstName: String?, lastName: String?, username: String?, phone: String?, photo: Api.UserProfilePhoto?, status: Api.UserStatus?, botInfoVersion: Int32?, restrictionReason: [Api.RestrictionReason]?, botInlinePlaceholder: String?, langCode: String?) + case userEmpty(id: Int64) + case user(flags: Int32, id: Int64, accessHash: Int64?, firstName: String?, lastName: String?, username: String?, phone: String?, photo: Api.UserProfilePhoto?, status: Api.UserStatus?, botInfoVersion: Int32?, restrictionReason: [Api.RestrictionReason]?, botInlinePlaceholder: String?, langCode: String?) public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) { switch self { case .userEmpty(let id): if boxed { - buffer.appendInt32(537022650) + buffer.appendInt32(-742634630) } - serializeInt32(id, buffer: buffer, boxed: false) + serializeInt64(id, buffer: buffer, boxed: false) break case .user(let flags, let id, let accessHash, let firstName, let lastName, let username, let phone, let photo, let status, let botInfoVersion, let restrictionReason, let botInlinePlaceholder, let langCode): if boxed { - buffer.appendInt32(-1820043071) + buffer.appendInt32(1073147056) } serializeInt32(flags, buffer: buffer, boxed: false) - serializeInt32(id, buffer: buffer, boxed: false) + serializeInt64(id, buffer: buffer, boxed: false) if Int(flags) & Int(1 << 0) != 0 {serializeInt64(accessHash!, buffer: buffer, boxed: false)} if Int(flags) & Int(1 << 1) != 0 {serializeString(firstName!, buffer: buffer, boxed: false)} if Int(flags) & Int(1 << 2) != 0 {serializeString(lastName!, buffer: buffer, boxed: false)} @@ -17088,8 +17084,8 @@ public extension Api { } public static func parse_userEmpty(_ reader: BufferReader) -> User? { - var _1: Int32? - _1 = reader.readInt32() + var _1: Int64? + _1 = reader.readInt64() let _c1 = _1 != nil if _c1 { return Api.User.userEmpty(id: _1!) @@ -17101,8 +17097,8 @@ public extension Api { public static func parse_user(_ reader: BufferReader) -> User? { var _1: Int32? _1 = reader.readInt32() - var _2: Int32? - _2 = reader.readInt32() + var _2: Int64? + _2 = reader.readInt64() var _3: Int64? if Int(_1!) & Int(1 << 0) != 0 {_3 = reader.readInt64() } var _4: String? @@ -17155,7 +17151,7 @@ public extension Api { } public enum Message: TypeConstructorDescription { case messageEmpty(flags: Int32, id: Int32, peerId: Api.Peer?) - case message(flags: Int32, id: Int32, fromId: Api.Peer?, peerId: Api.Peer, fwdFrom: Api.MessageFwdHeader?, viaBotId: Int32?, replyTo: Api.MessageReplyHeader?, date: Int32, message: String, media: Api.MessageMedia?, replyMarkup: Api.ReplyMarkup?, entities: [Api.MessageEntity]?, views: Int32?, forwards: Int32?, replies: Api.MessageReplies?, editDate: Int32?, postAuthor: String?, groupedId: Int64?, restrictionReason: [Api.RestrictionReason]?, ttlPeriod: Int32?) + case message(flags: Int32, id: Int32, fromId: Api.Peer?, peerId: Api.Peer, fwdFrom: Api.MessageFwdHeader?, viaBotId: Int64?, replyTo: Api.MessageReplyHeader?, date: Int32, message: String, media: Api.MessageMedia?, replyMarkup: Api.ReplyMarkup?, entities: [Api.MessageEntity]?, views: Int32?, forwards: Int32?, replies: Api.MessageReplies?, editDate: Int32?, postAuthor: String?, groupedId: Int64?, restrictionReason: [Api.RestrictionReason]?, ttlPeriod: Int32?) case messageService(flags: Int32, id: Int32, fromId: Api.Peer?, peerId: Api.Peer, replyTo: Api.MessageReplyHeader?, date: Int32, action: Api.MessageAction, ttlPeriod: Int32?) public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) { @@ -17170,14 +17166,14 @@ public extension Api { break case .message(let flags, let id, let fromId, let peerId, let fwdFrom, let viaBotId, let replyTo, let date, let message, let media, let replyMarkup, let entities, let views, let forwards, let replies, let editDate, let postAuthor, let groupedId, let restrictionReason, let ttlPeriod): if boxed { - buffer.appendInt32(-1125940270) + buffer.appendInt32(-2049520670) } serializeInt32(flags, buffer: buffer, boxed: false) serializeInt32(id, buffer: buffer, boxed: false) if Int(flags) & Int(1 << 8) != 0 {fromId!.serialize(buffer, true)} peerId.serialize(buffer, true) if Int(flags) & Int(1 << 2) != 0 {fwdFrom!.serialize(buffer, true)} - if Int(flags) & Int(1 << 11) != 0 {serializeInt32(viaBotId!, buffer: buffer, boxed: false)} + if Int(flags) & Int(1 << 11) != 0 {serializeInt64(viaBotId!, buffer: buffer, boxed: false)} if Int(flags) & Int(1 << 3) != 0 {replyTo!.serialize(buffer, true)} serializeInt32(date, buffer: buffer, boxed: false) serializeString(message, buffer: buffer, boxed: false) @@ -17264,8 +17260,8 @@ public extension Api { if Int(_1!) & Int(1 << 2) != 0 {if let signature = reader.readInt32() { _5 = Api.parse(reader, signature: signature) as? Api.MessageFwdHeader } } - var _6: Int32? - if Int(_1!) & Int(1 << 11) != 0 {_6 = reader.readInt32() } + var _6: Int64? + if Int(_1!) & Int(1 << 11) != 0 {_6 = reader.readInt64() } var _7: Api.MessageReplyHeader? if Int(_1!) & Int(1 << 3) != 0 {if let signature = reader.readInt32() { _7 = Api.parse(reader, signature: signature) as? Api.MessageReplyHeader @@ -17376,15 +17372,15 @@ public extension Api { } public enum StatsGroupTopInviter: TypeConstructorDescription { - case statsGroupTopInviter(userId: Int32, invitations: Int32) + case statsGroupTopInviter(userId: Int64, invitations: Int32) public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) { switch self { case .statsGroupTopInviter(let userId, let invitations): if boxed { - buffer.appendInt32(831924812) + buffer.appendInt32(1398765469) } - serializeInt32(userId, buffer: buffer, boxed: false) + serializeInt64(userId, buffer: buffer, boxed: false) serializeInt32(invitations, buffer: buffer, boxed: false) break } @@ -17398,8 +17394,8 @@ public extension Api { } public static func parse_statsGroupTopInviter(_ reader: BufferReader) -> StatsGroupTopInviter? { - var _1: Int32? - _1 = reader.readInt32() + var _1: Int64? + _1 = reader.readInt64() var _2: Int32? _2 = reader.readInt32() let _c1 = _1 != nil @@ -17860,24 +17856,24 @@ public extension Api { } public enum ChatParticipants: TypeConstructorDescription { - case chatParticipantsForbidden(flags: Int32, chatId: Int32, selfParticipant: Api.ChatParticipant?) - case chatParticipants(chatId: Int32, participants: [Api.ChatParticipant], version: Int32) + case chatParticipantsForbidden(flags: Int32, chatId: Int64, selfParticipant: Api.ChatParticipant?) + case chatParticipants(chatId: Int64, participants: [Api.ChatParticipant], version: Int32) public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) { switch self { case .chatParticipantsForbidden(let flags, let chatId, let selfParticipant): if boxed { - buffer.appendInt32(-57668565) + buffer.appendInt32(-2023500831) } serializeInt32(flags, buffer: buffer, boxed: false) - serializeInt32(chatId, buffer: buffer, boxed: false) + serializeInt64(chatId, buffer: buffer, boxed: false) if Int(flags) & Int(1 << 0) != 0 {selfParticipant!.serialize(buffer, true)} break case .chatParticipants(let chatId, let participants, let version): if boxed { - buffer.appendInt32(1061556205) + buffer.appendInt32(1018991608) } - serializeInt32(chatId, buffer: buffer, boxed: false) + serializeInt64(chatId, buffer: buffer, boxed: false) buffer.appendInt32(481674261) buffer.appendInt32(Int32(participants.count)) for item in participants { @@ -17900,8 +17896,8 @@ public extension Api { public static func parse_chatParticipantsForbidden(_ reader: BufferReader) -> ChatParticipants? { var _1: Int32? _1 = reader.readInt32() - var _2: Int32? - _2 = reader.readInt32() + var _2: Int64? + _2 = reader.readInt64() var _3: Api.ChatParticipant? if Int(_1!) & Int(1 << 0) != 0 {if let signature = reader.readInt32() { _3 = Api.parse(reader, signature: signature) as? Api.ChatParticipant @@ -17917,8 +17913,8 @@ public extension Api { } } public static func parse_chatParticipants(_ reader: BufferReader) -> ChatParticipants? { - var _1: Int32? - _1 = reader.readInt32() + var _1: Int64? + _1 = reader.readInt64() var _2: [Api.ChatParticipant]? if let _ = reader.readInt32() { _2 = Api.parseVector(reader, elementSignature: 0, elementType: Api.ChatParticipant.self) @@ -18866,17 +18862,17 @@ public extension Api { } public enum ChannelAdminLogEvent: TypeConstructorDescription { - case channelAdminLogEvent(id: Int64, date: Int32, userId: Int32, action: Api.ChannelAdminLogEventAction) + case channelAdminLogEvent(id: Int64, date: Int32, userId: Int64, action: Api.ChannelAdminLogEventAction) public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) { switch self { case .channelAdminLogEvent(let id, let date, let userId, let action): if boxed { - buffer.appendInt32(995769920) + buffer.appendInt32(531458253) } serializeInt64(id, buffer: buffer, boxed: false) serializeInt32(date, buffer: buffer, boxed: false) - serializeInt32(userId, buffer: buffer, boxed: false) + serializeInt64(userId, buffer: buffer, boxed: false) action.serialize(buffer, true) break } @@ -18894,8 +18890,8 @@ public extension Api { _1 = reader.readInt64() var _2: Int32? _2 = reader.readInt32() - var _3: Int32? - _3 = reader.readInt32() + var _3: Int64? + _3 = reader.readInt64() var _4: Api.ChannelAdminLogEventAction? if let signature = reader.readInt32() { _4 = Api.parse(reader, signature: signature) as? Api.ChannelAdminLogEventAction @@ -20012,17 +20008,17 @@ public extension Api { } public enum ExportedChatInvite: TypeConstructorDescription { - case chatInviteExported(flags: Int32, link: String, adminId: Int32, date: Int32, startDate: Int32?, expireDate: Int32?, usageLimit: Int32?, usage: Int32?) + case chatInviteExported(flags: Int32, link: String, adminId: Int64, date: Int32, startDate: Int32?, expireDate: Int32?, usageLimit: Int32?, usage: Int32?) public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) { switch self { case .chatInviteExported(let flags, let link, let adminId, let date, let startDate, let expireDate, let usageLimit, let usage): if boxed { - buffer.appendInt32(1847917725) + buffer.appendInt32(-1316944408) } serializeInt32(flags, buffer: buffer, boxed: false) serializeString(link, buffer: buffer, boxed: false) - serializeInt32(adminId, buffer: buffer, boxed: false) + serializeInt64(adminId, buffer: buffer, boxed: false) serializeInt32(date, buffer: buffer, boxed: false) if Int(flags) & Int(1 << 4) != 0 {serializeInt32(startDate!, buffer: buffer, boxed: false)} if Int(flags) & Int(1 << 1) != 0 {serializeInt32(expireDate!, buffer: buffer, boxed: false)} @@ -20044,8 +20040,8 @@ public extension Api { _1 = reader.readInt32() var _2: String? _2 = parseString(reader) - var _3: Int32? - _3 = reader.readInt32() + var _3: Int64? + _3 = reader.readInt64() var _4: Int32? _4 = reader.readInt32() var _5: Int32? @@ -20746,12 +20742,12 @@ public extension Api { public enum PrivacyRule: TypeConstructorDescription { case privacyValueAllowContacts case privacyValueAllowAll - case privacyValueAllowUsers(users: [Int32]) + case privacyValueAllowUsers(users: [Int64]) case privacyValueDisallowContacts case privacyValueDisallowAll - case privacyValueDisallowUsers(users: [Int32]) - case privacyValueAllowChatParticipants(chats: [Int32]) - case privacyValueDisallowChatParticipants(chats: [Int32]) + case privacyValueDisallowUsers(users: [Int64]) + case privacyValueAllowChatParticipants(chats: [Int64]) + case privacyValueDisallowChatParticipants(chats: [Int64]) public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) { switch self { @@ -20769,12 +20765,12 @@ public extension Api { break case .privacyValueAllowUsers(let users): if boxed { - buffer.appendInt32(1297858060) + buffer.appendInt32(-1198497870) } buffer.appendInt32(481674261) buffer.appendInt32(Int32(users.count)) for item in users { - serializeInt32(item, buffer: buffer, boxed: false) + serializeInt64(item, buffer: buffer, boxed: false) } break case .privacyValueDisallowContacts: @@ -20791,32 +20787,32 @@ public extension Api { break case .privacyValueDisallowUsers(let users): if boxed { - buffer.appendInt32(209668535) + buffer.appendInt32(-463335103) } buffer.appendInt32(481674261) buffer.appendInt32(Int32(users.count)) for item in users { - serializeInt32(item, buffer: buffer, boxed: false) + serializeInt64(item, buffer: buffer, boxed: false) } break case .privacyValueAllowChatParticipants(let chats): if boxed { - buffer.appendInt32(415136107) + buffer.appendInt32(1796427406) } buffer.appendInt32(481674261) buffer.appendInt32(Int32(chats.count)) for item in chats { - serializeInt32(item, buffer: buffer, boxed: false) + serializeInt64(item, buffer: buffer, boxed: false) } break case .privacyValueDisallowChatParticipants(let chats): if boxed { - buffer.appendInt32(-1397881200) + buffer.appendInt32(1103656293) } buffer.appendInt32(481674261) buffer.appendInt32(Int32(chats.count)) for item in chats { - serializeInt32(item, buffer: buffer, boxed: false) + serializeInt64(item, buffer: buffer, boxed: false) } break } @@ -20850,9 +20846,9 @@ public extension Api { return Api.PrivacyRule.privacyValueAllowAll } public static func parse_privacyValueAllowUsers(_ reader: BufferReader) -> PrivacyRule? { - var _1: [Int32]? + var _1: [Int64]? if let _ = reader.readInt32() { - _1 = Api.parseVector(reader, elementSignature: -1471112230, elementType: Int32.self) + _1 = Api.parseVector(reader, elementSignature: 570911930, elementType: Int64.self) } let _c1 = _1 != nil if _c1 { @@ -20869,9 +20865,9 @@ public extension Api { return Api.PrivacyRule.privacyValueDisallowAll } public static func parse_privacyValueDisallowUsers(_ reader: BufferReader) -> PrivacyRule? { - var _1: [Int32]? + var _1: [Int64]? if let _ = reader.readInt32() { - _1 = Api.parseVector(reader, elementSignature: -1471112230, elementType: Int32.self) + _1 = Api.parseVector(reader, elementSignature: 570911930, elementType: Int64.self) } let _c1 = _1 != nil if _c1 { @@ -20882,9 +20878,9 @@ public extension Api { } } public static func parse_privacyValueAllowChatParticipants(_ reader: BufferReader) -> PrivacyRule? { - var _1: [Int32]? + var _1: [Int64]? if let _ = reader.readInt32() { - _1 = Api.parseVector(reader, elementSignature: -1471112230, elementType: Int32.self) + _1 = Api.parseVector(reader, elementSignature: 570911930, elementType: Int64.self) } let _c1 = _1 != nil if _c1 { @@ -20895,9 +20891,9 @@ public extension Api { } } public static func parse_privacyValueDisallowChatParticipants(_ reader: BufferReader) -> PrivacyRule? { - var _1: [Int32]? + var _1: [Int64]? if let _ = reader.readInt32() { - _1 = Api.parseVector(reader, elementSignature: -1471112230, elementType: Int32.self) + _1 = Api.parseVector(reader, elementSignature: 570911930, elementType: Int64.self) } let _c1 = _1 != nil if _c1 { @@ -20911,16 +20907,16 @@ public extension Api { } public enum MessageAction: TypeConstructorDescription { case messageActionEmpty - case messageActionChatCreate(title: String, users: [Int32]) + case messageActionChatCreate(title: String, users: [Int64]) case messageActionChatEditTitle(title: String) case messageActionChatEditPhoto(photo: Api.Photo) case messageActionChatDeletePhoto - case messageActionChatAddUser(users: [Int32]) - case messageActionChatDeleteUser(userId: Int32) - case messageActionChatJoinedByLink(inviterId: Int32) + case messageActionChatAddUser(users: [Int64]) + case messageActionChatDeleteUser(userId: Int64) + case messageActionChatJoinedByLink(inviterId: Int64) case messageActionChannelCreate(title: String) - case messageActionChatMigrateTo(channelId: Int32) - case messageActionChannelMigrateFrom(title: String, chatId: Int32) + case messageActionChatMigrateTo(channelId: Int64) + case messageActionChannelMigrateFrom(title: String, chatId: Int64) case messageActionPinMessage case messageActionHistoryClear case messageActionGameScore(gameId: Int64, score: Int32) @@ -20935,7 +20931,7 @@ public extension Api { case messageActionContactSignUp case messageActionGeoProximityReached(fromId: Api.Peer, toId: Api.Peer, distance: Int32) case messageActionGroupCall(flags: Int32, call: Api.InputGroupCall, duration: Int32?) - case messageActionInviteToGroupCall(call: Api.InputGroupCall, users: [Int32]) + case messageActionInviteToGroupCall(call: Api.InputGroupCall, users: [Int64]) case messageActionSetMessagesTTL(period: Int32) case messageActionGroupCallScheduled(call: Api.InputGroupCall, scheduleDate: Int32) case messageActionSetChatTheme(emoticon: String) @@ -20950,13 +20946,13 @@ public extension Api { break case .messageActionChatCreate(let title, let users): if boxed { - buffer.appendInt32(-1503425638) + buffer.appendInt32(-1119368275) } serializeString(title, buffer: buffer, boxed: false) buffer.appendInt32(481674261) buffer.appendInt32(Int32(users.count)) for item in users { - serializeInt32(item, buffer: buffer, boxed: false) + serializeInt64(item, buffer: buffer, boxed: false) } break case .messageActionChatEditTitle(let title): @@ -20979,25 +20975,25 @@ public extension Api { break case .messageActionChatAddUser(let users): if boxed { - buffer.appendInt32(1217033015) + buffer.appendInt32(365886720) } buffer.appendInt32(481674261) buffer.appendInt32(Int32(users.count)) for item in users { - serializeInt32(item, buffer: buffer, boxed: false) + serializeInt64(item, buffer: buffer, boxed: false) } break case .messageActionChatDeleteUser(let userId): if boxed { - buffer.appendInt32(-1297179892) + buffer.appendInt32(-1539362612) } - serializeInt32(userId, buffer: buffer, boxed: false) + serializeInt64(userId, buffer: buffer, boxed: false) break case .messageActionChatJoinedByLink(let inviterId): if boxed { - buffer.appendInt32(-123931160) + buffer.appendInt32(51520707) } - serializeInt32(inviterId, buffer: buffer, boxed: false) + serializeInt64(inviterId, buffer: buffer, boxed: false) break case .messageActionChannelCreate(let title): if boxed { @@ -21007,16 +21003,16 @@ public extension Api { break case .messageActionChatMigrateTo(let channelId): if boxed { - buffer.appendInt32(1371385889) + buffer.appendInt32(-519864430) } - serializeInt32(channelId, buffer: buffer, boxed: false) + serializeInt64(channelId, buffer: buffer, boxed: false) break case .messageActionChannelMigrateFrom(let title, let chatId): if boxed { - buffer.appendInt32(-1336546578) + buffer.appendInt32(-365344535) } serializeString(title, buffer: buffer, boxed: false) - serializeInt32(chatId, buffer: buffer, boxed: false) + serializeInt64(chatId, buffer: buffer, boxed: false) break case .messageActionPinMessage: if boxed { @@ -21128,13 +21124,13 @@ public extension Api { break case .messageActionInviteToGroupCall(let call, let users): if boxed { - buffer.appendInt32(1991897370) + buffer.appendInt32(1345295095) } call.serialize(buffer, true) buffer.appendInt32(481674261) buffer.appendInt32(Int32(users.count)) for item in users { - serializeInt32(item, buffer: buffer, boxed: false) + serializeInt64(item, buffer: buffer, boxed: false) } break case .messageActionSetMessagesTTL(let period): @@ -21228,9 +21224,9 @@ public extension Api { public static func parse_messageActionChatCreate(_ reader: BufferReader) -> MessageAction? { var _1: String? _1 = parseString(reader) - var _2: [Int32]? + var _2: [Int64]? if let _ = reader.readInt32() { - _2 = Api.parseVector(reader, elementSignature: -1471112230, elementType: Int32.self) + _2 = Api.parseVector(reader, elementSignature: 570911930, elementType: Int64.self) } let _c1 = _1 != nil let _c2 = _2 != nil @@ -21269,9 +21265,9 @@ public extension Api { return Api.MessageAction.messageActionChatDeletePhoto } public static func parse_messageActionChatAddUser(_ reader: BufferReader) -> MessageAction? { - var _1: [Int32]? + var _1: [Int64]? if let _ = reader.readInt32() { - _1 = Api.parseVector(reader, elementSignature: -1471112230, elementType: Int32.self) + _1 = Api.parseVector(reader, elementSignature: 570911930, elementType: Int64.self) } let _c1 = _1 != nil if _c1 { @@ -21282,8 +21278,8 @@ public extension Api { } } public static func parse_messageActionChatDeleteUser(_ reader: BufferReader) -> MessageAction? { - var _1: Int32? - _1 = reader.readInt32() + var _1: Int64? + _1 = reader.readInt64() let _c1 = _1 != nil if _c1 { return Api.MessageAction.messageActionChatDeleteUser(userId: _1!) @@ -21293,8 +21289,8 @@ public extension Api { } } public static func parse_messageActionChatJoinedByLink(_ reader: BufferReader) -> MessageAction? { - var _1: Int32? - _1 = reader.readInt32() + var _1: Int64? + _1 = reader.readInt64() let _c1 = _1 != nil if _c1 { return Api.MessageAction.messageActionChatJoinedByLink(inviterId: _1!) @@ -21315,8 +21311,8 @@ public extension Api { } } public static func parse_messageActionChatMigrateTo(_ reader: BufferReader) -> MessageAction? { - var _1: Int32? - _1 = reader.readInt32() + var _1: Int64? + _1 = reader.readInt64() let _c1 = _1 != nil if _c1 { return Api.MessageAction.messageActionChatMigrateTo(channelId: _1!) @@ -21328,8 +21324,8 @@ public extension Api { public static func parse_messageActionChannelMigrateFrom(_ reader: BufferReader) -> MessageAction? { var _1: String? _1 = parseString(reader) - var _2: Int32? - _2 = reader.readInt32() + var _2: Int64? + _2 = reader.readInt64() let _c1 = _1 != nil let _c2 = _2 != nil if _c1 && _c2 { @@ -21532,9 +21528,9 @@ public extension Api { if let signature = reader.readInt32() { _1 = Api.parse(reader, signature: signature) as? Api.InputGroupCall } - var _2: [Int32]? + var _2: [Int64]? if let _ = reader.readInt32() { - _2 = Api.parseVector(reader, elementSignature: -1471112230, elementType: Int32.self) + _2 = Api.parseVector(reader, elementSignature: 570911930, elementType: Int64.self) } let _c1 = _1 != nil let _c2 = _2 != nil @@ -21587,10 +21583,10 @@ public extension Api { } public enum PhoneCall: TypeConstructorDescription { case phoneCallEmpty(id: Int64) - case phoneCallWaiting(flags: Int32, id: Int64, accessHash: Int64, date: Int32, adminId: Int32, participantId: Int32, protocol: Api.PhoneCallProtocol, receiveDate: Int32?) - case phoneCallRequested(flags: Int32, id: Int64, accessHash: Int64, date: Int32, adminId: Int32, participantId: Int32, gAHash: Buffer, protocol: Api.PhoneCallProtocol) - case phoneCallAccepted(flags: Int32, id: Int64, accessHash: Int64, date: Int32, adminId: Int32, participantId: Int32, gB: Buffer, protocol: Api.PhoneCallProtocol) - case phoneCall(flags: Int32, id: Int64, accessHash: Int64, date: Int32, adminId: Int32, participantId: Int32, gAOrB: Buffer, keyFingerprint: Int64, protocol: Api.PhoneCallProtocol, connections: [Api.PhoneConnection], startDate: Int32) + case phoneCallWaiting(flags: Int32, id: Int64, accessHash: Int64, date: Int32, adminId: Int64, participantId: Int64, protocol: Api.PhoneCallProtocol, receiveDate: Int32?) + case phoneCallRequested(flags: Int32, id: Int64, accessHash: Int64, date: Int32, adminId: Int64, participantId: Int64, gAHash: Buffer, protocol: Api.PhoneCallProtocol) + case phoneCallAccepted(flags: Int32, id: Int64, accessHash: Int64, date: Int32, adminId: Int64, participantId: Int64, gB: Buffer, protocol: Api.PhoneCallProtocol) + case phoneCall(flags: Int32, id: Int64, accessHash: Int64, date: Int32, adminId: Int64, participantId: Int64, gAOrB: Buffer, keyFingerprint: Int64, protocol: Api.PhoneCallProtocol, connections: [Api.PhoneConnection], startDate: Int32) case phoneCallDiscarded(flags: Int32, id: Int64, reason: Api.PhoneCallDiscardReason?, duration: Int32?) public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) { @@ -21603,53 +21599,53 @@ public extension Api { break case .phoneCallWaiting(let flags, let id, let accessHash, let date, let adminId, let participantId, let `protocol`, let receiveDate): if boxed { - buffer.appendInt32(462375633) + buffer.appendInt32(-987599081) } serializeInt32(flags, buffer: buffer, boxed: false) serializeInt64(id, buffer: buffer, boxed: false) serializeInt64(accessHash, buffer: buffer, boxed: false) serializeInt32(date, buffer: buffer, boxed: false) - serializeInt32(adminId, buffer: buffer, boxed: false) - serializeInt32(participantId, buffer: buffer, boxed: false) + serializeInt64(adminId, buffer: buffer, boxed: false) + serializeInt64(participantId, buffer: buffer, boxed: false) `protocol`.serialize(buffer, true) if Int(flags) & Int(1 << 0) != 0 {serializeInt32(receiveDate!, buffer: buffer, boxed: false)} break case .phoneCallRequested(let flags, let id, let accessHash, let date, let adminId, let participantId, let gAHash, let `protocol`): if boxed { - buffer.appendInt32(-2014659757) + buffer.appendInt32(347139340) } serializeInt32(flags, buffer: buffer, boxed: false) serializeInt64(id, buffer: buffer, boxed: false) serializeInt64(accessHash, buffer: buffer, boxed: false) serializeInt32(date, buffer: buffer, boxed: false) - serializeInt32(adminId, buffer: buffer, boxed: false) - serializeInt32(participantId, buffer: buffer, boxed: false) + serializeInt64(adminId, buffer: buffer, boxed: false) + serializeInt64(participantId, buffer: buffer, boxed: false) serializeBytes(gAHash, buffer: buffer, boxed: false) `protocol`.serialize(buffer, true) break case .phoneCallAccepted(let flags, let id, let accessHash, let date, let adminId, let participantId, let gB, let `protocol`): if boxed { - buffer.appendInt32(-1719909046) + buffer.appendInt32(912311057) } serializeInt32(flags, buffer: buffer, boxed: false) serializeInt64(id, buffer: buffer, boxed: false) serializeInt64(accessHash, buffer: buffer, boxed: false) serializeInt32(date, buffer: buffer, boxed: false) - serializeInt32(adminId, buffer: buffer, boxed: false) - serializeInt32(participantId, buffer: buffer, boxed: false) + serializeInt64(adminId, buffer: buffer, boxed: false) + serializeInt64(participantId, buffer: buffer, boxed: false) serializeBytes(gB, buffer: buffer, boxed: false) `protocol`.serialize(buffer, true) break case .phoneCall(let flags, let id, let accessHash, let date, let adminId, let participantId, let gAOrB, let keyFingerprint, let `protocol`, let connections, let startDate): if boxed { - buffer.appendInt32(-2025673089) + buffer.appendInt32(-1770029977) } serializeInt32(flags, buffer: buffer, boxed: false) serializeInt64(id, buffer: buffer, boxed: false) serializeInt64(accessHash, buffer: buffer, boxed: false) serializeInt32(date, buffer: buffer, boxed: false) - serializeInt32(adminId, buffer: buffer, boxed: false) - serializeInt32(participantId, buffer: buffer, boxed: false) + serializeInt64(adminId, buffer: buffer, boxed: false) + serializeInt64(participantId, buffer: buffer, boxed: false) serializeBytes(gAOrB, buffer: buffer, boxed: false) serializeInt64(keyFingerprint, buffer: buffer, boxed: false) `protocol`.serialize(buffer, true) @@ -21709,10 +21705,10 @@ public extension Api { _3 = reader.readInt64() var _4: Int32? _4 = reader.readInt32() - var _5: Int32? - _5 = reader.readInt32() - var _6: Int32? - _6 = reader.readInt32() + var _5: Int64? + _5 = reader.readInt64() + var _6: Int64? + _6 = reader.readInt64() var _7: Api.PhoneCallProtocol? if let signature = reader.readInt32() { _7 = Api.parse(reader, signature: signature) as? Api.PhoneCallProtocol @@ -21743,10 +21739,10 @@ public extension Api { _3 = reader.readInt64() var _4: Int32? _4 = reader.readInt32() - var _5: Int32? - _5 = reader.readInt32() - var _6: Int32? - _6 = reader.readInt32() + var _5: Int64? + _5 = reader.readInt64() + var _6: Int64? + _6 = reader.readInt64() var _7: Buffer? _7 = parseBytes(reader) var _8: Api.PhoneCallProtocol? @@ -21777,10 +21773,10 @@ public extension Api { _3 = reader.readInt64() var _4: Int32? _4 = reader.readInt32() - var _5: Int32? - _5 = reader.readInt32() - var _6: Int32? - _6 = reader.readInt32() + var _5: Int64? + _5 = reader.readInt64() + var _6: Int64? + _6 = reader.readInt64() var _7: Buffer? _7 = parseBytes(reader) var _8: Api.PhoneCallProtocol? @@ -21811,10 +21807,10 @@ public extension Api { _3 = reader.readInt64() var _4: Int32? _4 = reader.readInt32() - var _5: Int32? - _5 = reader.readInt32() - var _6: Int32? - _6 = reader.readInt32() + var _5: Int64? + _5 = reader.readInt64() + var _6: Int64? + _6 = reader.readInt64() var _7: Buffer? _7 = parseBytes(reader) var _8: Int64? @@ -22237,6 +22233,7 @@ public extension Api { } public enum InputBotInlineMessageID: TypeConstructorDescription { case inputBotInlineMessageID(dcId: Int32, id: Int64, accessHash: Int64) + case inputBotInlineMessageID64(dcId: Int32, ownerId: Int64, id: Int32, accessHash: Int64) public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) { switch self { @@ -22248,6 +22245,15 @@ public extension Api { serializeInt64(id, buffer: buffer, boxed: false) serializeInt64(accessHash, buffer: buffer, boxed: false) break + case .inputBotInlineMessageID64(let dcId, let ownerId, let id, let accessHash): + if boxed { + buffer.appendInt32(-1227287081) + } + serializeInt32(dcId, buffer: buffer, boxed: false) + serializeInt64(ownerId, buffer: buffer, boxed: false) + serializeInt32(id, buffer: buffer, boxed: false) + serializeInt64(accessHash, buffer: buffer, boxed: false) + break } } @@ -22255,6 +22261,8 @@ public extension Api { switch self { case .inputBotInlineMessageID(let dcId, let id, let accessHash): return ("inputBotInlineMessageID", [("dcId", dcId), ("id", id), ("accessHash", accessHash)]) + case .inputBotInlineMessageID64(let dcId, let ownerId, let id, let accessHash): + return ("inputBotInlineMessageID64", [("dcId", dcId), ("ownerId", ownerId), ("id", id), ("accessHash", accessHash)]) } } @@ -22275,6 +22283,26 @@ public extension Api { return nil } } + public static func parse_inputBotInlineMessageID64(_ reader: BufferReader) -> InputBotInlineMessageID? { + var _1: Int32? + _1 = reader.readInt32() + var _2: Int64? + _2 = reader.readInt64() + var _3: Int32? + _3 = reader.readInt32() + var _4: Int64? + _4 = reader.readInt64() + let _c1 = _1 != nil + let _c2 = _2 != nil + let _c3 = _3 != nil + let _c4 = _4 != nil + if _c1 && _c2 && _c3 && _c4 { + return Api.InputBotInlineMessageID.inputBotInlineMessageID64(dcId: _1!, ownerId: _2!, id: _3!, accessHash: _4!) + } + else { + return nil + } + } } public enum PageRelatedArticle: TypeConstructorDescription { @@ -22535,7 +22563,7 @@ public extension Api { case messageEntityCode(offset: Int32, length: Int32) case messageEntityPre(offset: Int32, length: Int32, language: String) case messageEntityTextUrl(offset: Int32, length: Int32, url: String) - case messageEntityMentionName(offset: Int32, length: Int32, userId: Int32) + case messageEntityMentionName(offset: Int32, length: Int32, userId: Int64) case inputMessageEntityMentionName(offset: Int32, length: Int32, userId: Api.InputUser) case messageEntityPhone(offset: Int32, length: Int32) case messageEntityCashtag(offset: Int32, length: Int32) @@ -22627,11 +22655,11 @@ public extension Api { break case .messageEntityMentionName(let offset, let length, let userId): if boxed { - buffer.appendInt32(892193368) + buffer.appendInt32(-595914432) } serializeInt32(offset, buffer: buffer, boxed: false) serializeInt32(length, buffer: buffer, boxed: false) - serializeInt32(userId, buffer: buffer, boxed: false) + serializeInt64(userId, buffer: buffer, boxed: false) break case .inputMessageEntityMentionName(let offset, let length, let userId): if boxed { @@ -22894,8 +22922,8 @@ public extension Api { _1 = reader.readInt32() var _2: Int32? _2 = reader.readInt32() - var _3: Int32? - _3 = reader.readInt32() + var _3: Int64? + _3 = reader.readInt64() let _c1 = _1 != nil let _c2 = _2 != nil let _c3 = _3 != nil @@ -23137,9 +23165,9 @@ public extension Api { } public enum EncryptedChat: TypeConstructorDescription { case encryptedChatEmpty(id: Int32) - case encryptedChatWaiting(id: Int32, accessHash: Int64, date: Int32, adminId: Int32, participantId: Int32) - case encryptedChatRequested(flags: Int32, folderId: Int32?, id: Int32, accessHash: Int64, date: Int32, adminId: Int32, participantId: Int32, gA: Buffer) - case encryptedChat(id: Int32, accessHash: Int64, date: Int32, adminId: Int32, participantId: Int32, gAOrB: Buffer, keyFingerprint: Int64) + case encryptedChatWaiting(id: Int32, accessHash: Int64, date: Int32, adminId: Int64, participantId: Int64) + case encryptedChatRequested(flags: Int32, folderId: Int32?, id: Int32, accessHash: Int64, date: Int32, adminId: Int64, participantId: Int64, gA: Buffer) + case encryptedChat(id: Int32, accessHash: Int64, date: Int32, adminId: Int64, participantId: Int64, gAOrB: Buffer, keyFingerprint: Int64) case encryptedChatDiscarded(flags: Int32, id: Int32) public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) { @@ -23152,36 +23180,36 @@ public extension Api { break case .encryptedChatWaiting(let id, let accessHash, let date, let adminId, let participantId): if boxed { - buffer.appendInt32(1006044124) + buffer.appendInt32(1722964307) } serializeInt32(id, buffer: buffer, boxed: false) serializeInt64(accessHash, buffer: buffer, boxed: false) serializeInt32(date, buffer: buffer, boxed: false) - serializeInt32(adminId, buffer: buffer, boxed: false) - serializeInt32(participantId, buffer: buffer, boxed: false) + serializeInt64(adminId, buffer: buffer, boxed: false) + serializeInt64(participantId, buffer: buffer, boxed: false) break case .encryptedChatRequested(let flags, let folderId, let id, let accessHash, let date, let adminId, let participantId, let gA): if boxed { - buffer.appendInt32(1651608194) + buffer.appendInt32(1223809356) } serializeInt32(flags, buffer: buffer, boxed: false) if Int(flags) & Int(1 << 0) != 0 {serializeInt32(folderId!, buffer: buffer, boxed: false)} serializeInt32(id, buffer: buffer, boxed: false) serializeInt64(accessHash, buffer: buffer, boxed: false) serializeInt32(date, buffer: buffer, boxed: false) - serializeInt32(adminId, buffer: buffer, boxed: false) - serializeInt32(participantId, buffer: buffer, boxed: false) + serializeInt64(adminId, buffer: buffer, boxed: false) + serializeInt64(participantId, buffer: buffer, boxed: false) serializeBytes(gA, buffer: buffer, boxed: false) break case .encryptedChat(let id, let accessHash, let date, let adminId, let participantId, let gAOrB, let keyFingerprint): if boxed { - buffer.appendInt32(-94974410) + buffer.appendInt32(1643173063) } serializeInt32(id, buffer: buffer, boxed: false) serializeInt64(accessHash, buffer: buffer, boxed: false) serializeInt32(date, buffer: buffer, boxed: false) - serializeInt32(adminId, buffer: buffer, boxed: false) - serializeInt32(participantId, buffer: buffer, boxed: false) + serializeInt64(adminId, buffer: buffer, boxed: false) + serializeInt64(participantId, buffer: buffer, boxed: false) serializeBytes(gAOrB, buffer: buffer, boxed: false) serializeInt64(keyFingerprint, buffer: buffer, boxed: false) break @@ -23228,10 +23256,10 @@ public extension Api { _2 = reader.readInt64() var _3: Int32? _3 = reader.readInt32() - var _4: Int32? - _4 = reader.readInt32() - var _5: Int32? - _5 = reader.readInt32() + var _4: Int64? + _4 = reader.readInt64() + var _5: Int64? + _5 = reader.readInt64() let _c1 = _1 != nil let _c2 = _2 != nil let _c3 = _3 != nil @@ -23255,10 +23283,10 @@ public extension Api { _4 = reader.readInt64() var _5: Int32? _5 = reader.readInt32() - var _6: Int32? - _6 = reader.readInt32() - var _7: Int32? - _7 = reader.readInt32() + var _6: Int64? + _6 = reader.readInt64() + var _7: Int64? + _7 = reader.readInt64() var _8: Buffer? _8 = parseBytes(reader) let _c1 = _1 != nil @@ -23283,10 +23311,10 @@ public extension Api { _2 = reader.readInt64() var _3: Int32? _3 = reader.readInt32() - var _4: Int32? - _4 = reader.readInt32() - var _5: Int32? - _5 = reader.readInt32() + var _4: Int64? + _4 = reader.readInt64() + var _5: Int64? + _5 = reader.readInt64() var _6: Buffer? _6 = parseBytes(reader) var _7: Int64? @@ -23498,16 +23526,16 @@ public extension Api { } public enum WebAuthorization: TypeConstructorDescription { - case webAuthorization(hash: Int64, botId: Int32, domain: String, browser: String, platform: String, dateCreated: Int32, dateActive: Int32, ip: String, region: String) + case webAuthorization(hash: Int64, botId: Int64, domain: String, browser: String, platform: String, dateCreated: Int32, dateActive: Int32, ip: String, region: String) public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) { switch self { case .webAuthorization(let hash, let botId, let domain, let browser, let platform, let dateCreated, let dateActive, let ip, let region): if boxed { - buffer.appendInt32(-892779534) + buffer.appendInt32(-1493633966) } serializeInt64(hash, buffer: buffer, boxed: false) - serializeInt32(botId, buffer: buffer, boxed: false) + serializeInt64(botId, buffer: buffer, boxed: false) serializeString(domain, buffer: buffer, boxed: false) serializeString(browser, buffer: buffer, boxed: false) serializeString(platform, buffer: buffer, boxed: false) @@ -23529,8 +23557,8 @@ public extension Api { public static func parse_webAuthorization(_ reader: BufferReader) -> WebAuthorization? { var _1: Int64? _1 = reader.readInt64() - var _2: Int32? - _2 = reader.readInt32() + var _2: Int64? + _2 = reader.readInt64() var _3: String? _3 = parseString(reader) var _4: String? @@ -23564,15 +23592,15 @@ public extension Api { } public enum ImportedContact: TypeConstructorDescription { - case importedContact(userId: Int32, clientId: Int64) + case importedContact(userId: Int64, clientId: Int64) public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) { switch self { case .importedContact(let userId, let clientId): if boxed { - buffer.appendInt32(-805141448) + buffer.appendInt32(-1052885936) } - serializeInt32(userId, buffer: buffer, boxed: false) + serializeInt64(userId, buffer: buffer, boxed: false) serializeInt64(clientId, buffer: buffer, boxed: false) break } @@ -23586,8 +23614,8 @@ public extension Api { } public static func parse_importedContact(_ reader: BufferReader) -> ImportedContact? { - var _1: Int32? - _1 = reader.readInt32() + var _1: Int64? + _1 = reader.readInt64() var _2: Int64? _2 = reader.readInt64() let _c1 = _1 != nil diff --git a/submodules/TelegramApi/Sources/Api3.swift b/submodules/TelegramApi/Sources/Api3.swift index da75f10e38..80854e60f0 100644 --- a/submodules/TelegramApi/Sources/Api3.swift +++ b/submodules/TelegramApi/Sources/Api3.swift @@ -301,19 +301,19 @@ public struct payments { } public enum PaymentForm: TypeConstructorDescription { - case paymentForm(flags: Int32, formId: Int64, botId: Int32, invoice: Api.Invoice, providerId: Int32, url: String, nativeProvider: String?, nativeParams: Api.DataJSON?, savedInfo: Api.PaymentRequestedInfo?, savedCredentials: Api.PaymentSavedCredentials?, users: [Api.User]) + case paymentForm(flags: Int32, formId: Int64, botId: Int64, invoice: Api.Invoice, providerId: Int64, url: String, nativeProvider: String?, nativeParams: Api.DataJSON?, savedInfo: Api.PaymentRequestedInfo?, savedCredentials: Api.PaymentSavedCredentials?, users: [Api.User]) public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) { switch self { case .paymentForm(let flags, let formId, let botId, let invoice, let providerId, let url, let nativeProvider, let nativeParams, let savedInfo, let savedCredentials, let users): if boxed { - buffer.appendInt32(-1928649707) + buffer.appendInt32(378828315) } serializeInt32(flags, buffer: buffer, boxed: false) serializeInt64(formId, buffer: buffer, boxed: false) - serializeInt32(botId, buffer: buffer, boxed: false) + serializeInt64(botId, buffer: buffer, boxed: false) invoice.serialize(buffer, true) - serializeInt32(providerId, buffer: buffer, boxed: false) + serializeInt64(providerId, buffer: buffer, boxed: false) serializeString(url, buffer: buffer, boxed: false) if Int(flags) & Int(1 << 4) != 0 {serializeString(nativeProvider!, buffer: buffer, boxed: false)} if Int(flags) & Int(1 << 4) != 0 {nativeParams!.serialize(buffer, true)} @@ -340,14 +340,14 @@ public struct payments { _1 = reader.readInt32() var _2: Int64? _2 = reader.readInt64() - var _3: Int32? - _3 = reader.readInt32() + var _3: Int64? + _3 = reader.readInt64() var _4: Api.Invoice? if let signature = reader.readInt32() { _4 = Api.parse(reader, signature: signature) as? Api.Invoice } - var _5: Int32? - _5 = reader.readInt32() + var _5: Int64? + _5 = reader.readInt64() var _6: String? _6 = parseString(reader) var _7: String? @@ -389,18 +389,18 @@ public struct payments { } public enum PaymentReceipt: TypeConstructorDescription { - case paymentReceipt(flags: Int32, date: Int32, botId: Int32, providerId: Int32, title: String, description: String, photo: Api.WebDocument?, invoice: Api.Invoice, info: Api.PaymentRequestedInfo?, shipping: Api.ShippingOption?, tipAmount: Int64?, currency: String, totalAmount: Int64, credentialsTitle: String, users: [Api.User]) + case paymentReceipt(flags: Int32, date: Int32, botId: Int64, providerId: Int64, title: String, description: String, photo: Api.WebDocument?, invoice: Api.Invoice, info: Api.PaymentRequestedInfo?, shipping: Api.ShippingOption?, tipAmount: Int64?, currency: String, totalAmount: Int64, credentialsTitle: String, users: [Api.User]) public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) { switch self { case .paymentReceipt(let flags, let date, let botId, let providerId, let title, let description, let photo, let invoice, let info, let shipping, let tipAmount, let currency, let totalAmount, let credentialsTitle, let users): if boxed { - buffer.appendInt32(280319440) + buffer.appendInt32(1891958275) } serializeInt32(flags, buffer: buffer, boxed: false) serializeInt32(date, buffer: buffer, boxed: false) - serializeInt32(botId, buffer: buffer, boxed: false) - serializeInt32(providerId, buffer: buffer, boxed: false) + serializeInt64(botId, buffer: buffer, boxed: false) + serializeInt64(providerId, buffer: buffer, boxed: false) serializeString(title, buffer: buffer, boxed: false) serializeString(description, buffer: buffer, boxed: false) if Int(flags) & Int(1 << 2) != 0 {photo!.serialize(buffer, true)} @@ -432,10 +432,10 @@ public struct payments { _1 = reader.readInt32() var _2: Int32? _2 = reader.readInt32() - var _3: Int32? - _3 = reader.readInt32() - var _4: Int32? - _4 = reader.readInt32() + var _3: Int64? + _3 = reader.readInt64() + var _4: Int64? + _4 = reader.readInt64() var _5: String? _5 = parseString(reader) var _6: String? @@ -1081,15 +1081,15 @@ public struct auth { } public enum ExportedAuthorization: TypeConstructorDescription { - case exportedAuthorization(id: Int32, bytes: Buffer) + case exportedAuthorization(id: Int64, bytes: Buffer) public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) { switch self { case .exportedAuthorization(let id, let bytes): if boxed { - buffer.appendInt32(-543777747) + buffer.appendInt32(-1271602504) } - serializeInt32(id, buffer: buffer, boxed: false) + serializeInt64(id, buffer: buffer, boxed: false) serializeBytes(bytes, buffer: buffer, boxed: false) break } @@ -1103,8 +1103,8 @@ public struct auth { } public static func parse_exportedAuthorization(_ reader: BufferReader) -> ExportedAuthorization? { - var _1: Int32? - _1 = reader.readInt32() + var _1: Int64? + _1 = reader.readInt64() var _2: Buffer? _2 = parseBytes(reader) let _c1 = _1 != nil diff --git a/submodules/TelegramApi/Sources/Api4.swift b/submodules/TelegramApi/Sources/Api4.swift index 8e3c974239..01ee7d95e9 100644 --- a/submodules/TelegramApi/Sources/Api4.swift +++ b/submodules/TelegramApi/Sources/Api4.swift @@ -916,7 +916,7 @@ public struct account { } public enum Themes: TypeConstructorDescription { case themesNotModified - case themes(hash: Int32, themes: [Api.Theme]) + case themes(hash: Int64, themes: [Api.Theme]) public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) { switch self { @@ -928,9 +928,9 @@ public struct account { break case .themes(let hash, let themes): if boxed { - buffer.appendInt32(2137482273) + buffer.appendInt32(-1707242387) } - serializeInt32(hash, buffer: buffer, boxed: false) + serializeInt64(hash, buffer: buffer, boxed: false) buffer.appendInt32(481674261) buffer.appendInt32(Int32(themes.count)) for item in themes { @@ -953,8 +953,8 @@ public struct account { return Api.account.Themes.themesNotModified } public static func parse_themes(_ reader: BufferReader) -> Themes? { - var _1: Int32? - _1 = reader.readInt32() + var _1: Int64? + _1 = reader.readInt64() var _2: [Api.Theme]? if let _ = reader.readInt32() { _2 = Api.parseVector(reader, elementSignature: 0, elementType: Api.Theme.self) @@ -972,7 +972,7 @@ public struct account { } public enum WallPapers: TypeConstructorDescription { case wallPapersNotModified - case wallPapers(hash: Int32, wallpapers: [Api.WallPaper]) + case wallPapers(hash: Int64, wallpapers: [Api.WallPaper]) public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) { switch self { @@ -984,9 +984,9 @@ public struct account { break case .wallPapers(let hash, let wallpapers): if boxed { - buffer.appendInt32(1881892265) + buffer.appendInt32(-842824308) } - serializeInt32(hash, buffer: buffer, boxed: false) + serializeInt64(hash, buffer: buffer, boxed: false) buffer.appendInt32(481674261) buffer.appendInt32(Int32(wallpapers.count)) for item in wallpapers { @@ -1009,8 +1009,8 @@ public struct account { return Api.account.WallPapers.wallPapersNotModified } public static func parse_wallPapers(_ reader: BufferReader) -> WallPapers? { - var _1: Int32? - _1 = reader.readInt32() + var _1: Int64? + _1 = reader.readInt64() var _2: [Api.WallPaper]? if let _ = reader.readInt32() { _2 = Api.parseVector(reader, elementSignature: 0, elementType: Api.WallPaper.self) @@ -2079,16 +2079,16 @@ public extension Api { }) } - public static func getDialogs(flags: Int32, folderId: Int32?, offsetDate: Int32, offsetId: Int32, offsetPeer: Api.InputPeer, limit: Int32, hash: Int32) -> (FunctionDescription, Buffer, DeserializeFunctionResponse) { + public static func getDialogs(flags: Int32, folderId: Int32?, offsetDate: Int32, offsetId: Int32, offsetPeer: Api.InputPeer, limit: Int32, hash: Int64) -> (FunctionDescription, Buffer, DeserializeFunctionResponse) { let buffer = Buffer() - buffer.appendInt32(-1594999949) + buffer.appendInt32(-1594569905) serializeInt32(flags, buffer: buffer, boxed: false) if Int(flags) & Int(1 << 1) != 0 {serializeInt32(folderId!, buffer: buffer, boxed: false)} serializeInt32(offsetDate, buffer: buffer, boxed: false) serializeInt32(offsetId, buffer: buffer, boxed: false) offsetPeer.serialize(buffer, true) serializeInt32(limit, buffer: buffer, boxed: false) - serializeInt32(hash, buffer: buffer, boxed: false) + serializeInt64(hash, buffer: buffer, boxed: false) return (FunctionDescription(name: "messages.getDialogs", parameters: [("flags", flags), ("folderId", folderId), ("offsetDate", offsetDate), ("offsetId", offsetId), ("offsetPeer", offsetPeer), ("limit", limit), ("hash", hash)]), buffer, DeserializeFunctionResponse { (buffer: Buffer) -> Api.messages.Dialogs? in let reader = BufferReader(buffer) var result: Api.messages.Dialogs? @@ -2099,9 +2099,9 @@ public extension Api { }) } - public static func getHistory(peer: Api.InputPeer, offsetId: Int32, offsetDate: Int32, addOffset: Int32, limit: Int32, maxId: Int32, minId: Int32, hash: Int32) -> (FunctionDescription, Buffer, DeserializeFunctionResponse) { + public static func getHistory(peer: Api.InputPeer, offsetId: Int32, offsetDate: Int32, addOffset: Int32, limit: Int32, maxId: Int32, minId: Int32, hash: Int64) -> (FunctionDescription, Buffer, DeserializeFunctionResponse) { let buffer = Buffer() - buffer.appendInt32(-591691168) + buffer.appendInt32(1143203525) peer.serialize(buffer, true) serializeInt32(offsetId, buffer: buffer, boxed: false) serializeInt32(offsetDate, buffer: buffer, boxed: false) @@ -2109,7 +2109,7 @@ public extension Api { serializeInt32(limit, buffer: buffer, boxed: false) serializeInt32(maxId, buffer: buffer, boxed: false) serializeInt32(minId, buffer: buffer, boxed: false) - serializeInt32(hash, buffer: buffer, boxed: false) + serializeInt64(hash, buffer: buffer, boxed: false) return (FunctionDescription(name: "messages.getHistory", parameters: [("peer", peer), ("offsetId", offsetId), ("offsetDate", offsetDate), ("addOffset", addOffset), ("limit", limit), ("maxId", maxId), ("minId", minId), ("hash", hash)]), buffer, DeserializeFunctionResponse { (buffer: Buffer) -> Api.messages.Messages? in let reader = BufferReader(buffer) var result: Api.messages.Messages? @@ -2120,9 +2120,9 @@ public extension Api { }) } - public static func search(flags: Int32, peer: Api.InputPeer, q: String, fromId: Api.InputPeer?, topMsgId: Int32?, filter: Api.MessagesFilter, minDate: Int32, maxDate: Int32, offsetId: Int32, addOffset: Int32, limit: Int32, maxId: Int32, minId: Int32, hash: Int32) -> (FunctionDescription, Buffer, DeserializeFunctionResponse) { + public static func search(flags: Int32, peer: Api.InputPeer, q: String, fromId: Api.InputPeer?, topMsgId: Int32?, filter: Api.MessagesFilter, minDate: Int32, maxDate: Int32, offsetId: Int32, addOffset: Int32, limit: Int32, maxId: Int32, minId: Int32, hash: Int64) -> (FunctionDescription, Buffer, DeserializeFunctionResponse) { let buffer = Buffer() - buffer.appendInt32(204812012) + buffer.appendInt32(-1593989278) serializeInt32(flags, buffer: buffer, boxed: false) peer.serialize(buffer, true) serializeString(q, buffer: buffer, boxed: false) @@ -2136,7 +2136,7 @@ public extension Api { serializeInt32(limit, buffer: buffer, boxed: false) serializeInt32(maxId, buffer: buffer, boxed: false) serializeInt32(minId, buffer: buffer, boxed: false) - serializeInt32(hash, buffer: buffer, boxed: false) + serializeInt64(hash, buffer: buffer, boxed: false) return (FunctionDescription(name: "messages.search", parameters: [("flags", flags), ("peer", peer), ("q", q), ("fromId", fromId), ("topMsgId", topMsgId), ("filter", filter), ("minDate", minDate), ("maxDate", maxDate), ("offsetId", offsetId), ("addOffset", addOffset), ("limit", limit), ("maxId", maxId), ("minId", minId), ("hash", hash)]), buffer, DeserializeFunctionResponse { (buffer: Buffer) -> Api.messages.Messages? in let reader = BufferReader(buffer) var result: Api.messages.Messages? @@ -2355,13 +2355,13 @@ public extension Api { }) } - public static func getChats(id: [Int32]) -> (FunctionDescription, Buffer, DeserializeFunctionResponse) { + public static func getChats(id: [Int64]) -> (FunctionDescription, Buffer, DeserializeFunctionResponse) { let buffer = Buffer() - buffer.appendInt32(1013621127) + buffer.appendInt32(1240027791) buffer.appendInt32(481674261) buffer.appendInt32(Int32(id.count)) for item in id { - serializeInt32(item, buffer: buffer, boxed: false) + serializeInt64(item, buffer: buffer, boxed: false) } return (FunctionDescription(name: "messages.getChats", parameters: [("id", id)]), buffer, DeserializeFunctionResponse { (buffer: Buffer) -> Api.messages.Chats? in let reader = BufferReader(buffer) @@ -2373,10 +2373,10 @@ public extension Api { }) } - public static func getFullChat(chatId: Int32) -> (FunctionDescription, Buffer, DeserializeFunctionResponse) { + public static func getFullChat(chatId: Int64) -> (FunctionDescription, Buffer, DeserializeFunctionResponse) { let buffer = Buffer() - buffer.appendInt32(998448230) - serializeInt32(chatId, buffer: buffer, boxed: false) + buffer.appendInt32(-1364194508) + serializeInt64(chatId, buffer: buffer, boxed: false) return (FunctionDescription(name: "messages.getFullChat", parameters: [("chatId", chatId)]), buffer, DeserializeFunctionResponse { (buffer: Buffer) -> Api.messages.ChatFull? in let reader = BufferReader(buffer) var result: Api.messages.ChatFull? @@ -2387,10 +2387,10 @@ public extension Api { }) } - public static func editChatTitle(chatId: Int32, title: String) -> (FunctionDescription, Buffer, DeserializeFunctionResponse) { + public static func editChatTitle(chatId: Int64, title: String) -> (FunctionDescription, Buffer, DeserializeFunctionResponse) { let buffer = Buffer() - buffer.appendInt32(-599447467) - serializeInt32(chatId, buffer: buffer, boxed: false) + buffer.appendInt32(1937260541) + serializeInt64(chatId, buffer: buffer, boxed: false) serializeString(title, buffer: buffer, boxed: false) return (FunctionDescription(name: "messages.editChatTitle", parameters: [("chatId", chatId), ("title", title)]), buffer, DeserializeFunctionResponse { (buffer: Buffer) -> Api.Updates? in let reader = BufferReader(buffer) @@ -2402,10 +2402,10 @@ public extension Api { }) } - public static func editChatPhoto(chatId: Int32, photo: Api.InputChatPhoto) -> (FunctionDescription, Buffer, DeserializeFunctionResponse) { + public static func editChatPhoto(chatId: Int64, photo: Api.InputChatPhoto) -> (FunctionDescription, Buffer, DeserializeFunctionResponse) { let buffer = Buffer() - buffer.appendInt32(-900957736) - serializeInt32(chatId, buffer: buffer, boxed: false) + buffer.appendInt32(903730804) + serializeInt64(chatId, buffer: buffer, boxed: false) photo.serialize(buffer, true) return (FunctionDescription(name: "messages.editChatPhoto", parameters: [("chatId", chatId), ("photo", photo)]), buffer, DeserializeFunctionResponse { (buffer: Buffer) -> Api.Updates? in let reader = BufferReader(buffer) @@ -2417,10 +2417,10 @@ public extension Api { }) } - public static func addChatUser(chatId: Int32, userId: Api.InputUser, fwdLimit: Int32) -> (FunctionDescription, Buffer, DeserializeFunctionResponse) { + public static func addChatUser(chatId: Int64, userId: Api.InputUser, fwdLimit: Int32) -> (FunctionDescription, Buffer, DeserializeFunctionResponse) { let buffer = Buffer() - buffer.appendInt32(-106911223) - serializeInt32(chatId, buffer: buffer, boxed: false) + buffer.appendInt32(-230206493) + serializeInt64(chatId, buffer: buffer, boxed: false) userId.serialize(buffer, true) serializeInt32(fwdLimit, buffer: buffer, boxed: false) return (FunctionDescription(name: "messages.addChatUser", parameters: [("chatId", chatId), ("userId", userId), ("fwdLimit", fwdLimit)]), buffer, DeserializeFunctionResponse { (buffer: Buffer) -> Api.Updates? in @@ -2433,11 +2433,11 @@ public extension Api { }) } - public static func deleteChatUser(flags: Int32, chatId: Int32, userId: Api.InputUser) -> (FunctionDescription, Buffer, DeserializeFunctionResponse) { + public static func deleteChatUser(flags: Int32, chatId: Int64, userId: Api.InputUser) -> (FunctionDescription, Buffer, DeserializeFunctionResponse) { let buffer = Buffer() - buffer.appendInt32(-986430054) + buffer.appendInt32(-1575461717) serializeInt32(flags, buffer: buffer, boxed: false) - serializeInt32(chatId, buffer: buffer, boxed: false) + serializeInt64(chatId, buffer: buffer, boxed: false) userId.serialize(buffer, true) return (FunctionDescription(name: "messages.deleteChatUser", parameters: [("flags", flags), ("chatId", chatId), ("userId", userId)]), buffer, DeserializeFunctionResponse { (buffer: Buffer) -> Api.Updates? in let reader = BufferReader(buffer) @@ -2657,11 +2657,11 @@ public extension Api { }) } - public static func getStickers(emoticon: String, hash: Int32) -> (FunctionDescription, Buffer, DeserializeFunctionResponse) { + public static func getStickers(emoticon: String, hash: Int64) -> (FunctionDescription, Buffer, DeserializeFunctionResponse) { let buffer = Buffer() - buffer.appendInt32(71126828) + buffer.appendInt32(-710552671) serializeString(emoticon, buffer: buffer, boxed: false) - serializeInt32(hash, buffer: buffer, boxed: false) + serializeInt64(hash, buffer: buffer, boxed: false) return (FunctionDescription(name: "messages.getStickers", parameters: [("emoticon", emoticon), ("hash", hash)]), buffer, DeserializeFunctionResponse { (buffer: Buffer) -> Api.messages.Stickers? in let reader = BufferReader(buffer) var result: Api.messages.Stickers? @@ -2672,10 +2672,10 @@ public extension Api { }) } - public static func getAllStickers(hash: Int32) -> (FunctionDescription, Buffer, DeserializeFunctionResponse) { + public static func getAllStickers(hash: Int64) -> (FunctionDescription, Buffer, DeserializeFunctionResponse) { let buffer = Buffer() - buffer.appendInt32(479598769) - serializeInt32(hash, buffer: buffer, boxed: false) + buffer.appendInt32(-1197432408) + serializeInt64(hash, buffer: buffer, boxed: false) return (FunctionDescription(name: "messages.getAllStickers", parameters: [("hash", hash)]), buffer, DeserializeFunctionResponse { (buffer: Buffer) -> Api.messages.AllStickers? in let reader = BufferReader(buffer) var result: Api.messages.AllStickers? @@ -2831,10 +2831,10 @@ public extension Api { }) } - public static func editChatAdmin(chatId: Int32, userId: Api.InputUser, isAdmin: Api.Bool) -> (FunctionDescription, Buffer, DeserializeFunctionResponse) { + public static func editChatAdmin(chatId: Int64, userId: Api.InputUser, isAdmin: Api.Bool) -> (FunctionDescription, Buffer, DeserializeFunctionResponse) { let buffer = Buffer() - buffer.appendInt32(-1444503762) - serializeInt32(chatId, buffer: buffer, boxed: false) + buffer.appendInt32(-1470377534) + serializeInt64(chatId, buffer: buffer, boxed: false) userId.serialize(buffer, true) isAdmin.serialize(buffer, true) return (FunctionDescription(name: "messages.editChatAdmin", parameters: [("chatId", chatId), ("userId", userId), ("isAdmin", isAdmin)]), buffer, DeserializeFunctionResponse { (buffer: Buffer) -> Api.Bool? in @@ -2847,10 +2847,10 @@ public extension Api { }) } - public static func migrateChat(chatId: Int32) -> (FunctionDescription, Buffer, DeserializeFunctionResponse) { + public static func migrateChat(chatId: Int64) -> (FunctionDescription, Buffer, DeserializeFunctionResponse) { let buffer = Buffer() - buffer.appendInt32(363051235) - serializeInt32(chatId, buffer: buffer, boxed: false) + buffer.appendInt32(-1568189671) + serializeInt64(chatId, buffer: buffer, boxed: false) return (FunctionDescription(name: "messages.migrateChat", parameters: [("chatId", chatId)]), buffer, DeserializeFunctionResponse { (buffer: Buffer) -> Api.Updates? in let reader = BufferReader(buffer) var result: Api.Updates? @@ -2919,10 +2919,10 @@ public extension Api { }) } - public static func getSavedGifs(hash: Int32) -> (FunctionDescription, Buffer, DeserializeFunctionResponse) { + public static func getSavedGifs(hash: Int64) -> (FunctionDescription, Buffer, DeserializeFunctionResponse) { let buffer = Buffer() - buffer.appendInt32(-2084618926) - serializeInt32(hash, buffer: buffer, boxed: false) + buffer.appendInt32(1559270965) + serializeInt64(hash, buffer: buffer, boxed: false) return (FunctionDescription(name: "messages.getSavedGifs", parameters: [("hash", hash)]), buffer, DeserializeFunctionResponse { (buffer: Buffer) -> Api.messages.SavedGifs? in let reader = BufferReader(buffer) var result: Api.messages.SavedGifs? @@ -3163,10 +3163,10 @@ public extension Api { }) } - public static func getFeaturedStickers(hash: Int32) -> (FunctionDescription, Buffer, DeserializeFunctionResponse) { + public static func getFeaturedStickers(hash: Int64) -> (FunctionDescription, Buffer, DeserializeFunctionResponse) { let buffer = Buffer() - buffer.appendInt32(766298703) - serializeInt32(hash, buffer: buffer, boxed: false) + buffer.appendInt32(1685588756) + serializeInt64(hash, buffer: buffer, boxed: false) return (FunctionDescription(name: "messages.getFeaturedStickers", parameters: [("hash", hash)]), buffer, DeserializeFunctionResponse { (buffer: Buffer) -> Api.messages.FeaturedStickers? in let reader = BufferReader(buffer) var result: Api.messages.FeaturedStickers? @@ -3195,11 +3195,11 @@ public extension Api { }) } - public static func getRecentStickers(flags: Int32, hash: Int32) -> (FunctionDescription, Buffer, DeserializeFunctionResponse) { + public static func getRecentStickers(flags: Int32, hash: Int64) -> (FunctionDescription, Buffer, DeserializeFunctionResponse) { let buffer = Buffer() - buffer.appendInt32(1587647177) + buffer.appendInt32(-1649852357) serializeInt32(flags, buffer: buffer, boxed: false) - serializeInt32(hash, buffer: buffer, boxed: false) + serializeInt64(hash, buffer: buffer, boxed: false) return (FunctionDescription(name: "messages.getRecentStickers", parameters: [("flags", flags), ("hash", hash)]), buffer, DeserializeFunctionResponse { (buffer: Buffer) -> Api.messages.RecentStickers? in let reader = BufferReader(buffer) var result: Api.messages.RecentStickers? @@ -3256,10 +3256,10 @@ public extension Api { }) } - public static func getMaskStickers(hash: Int32) -> (FunctionDescription, Buffer, DeserializeFunctionResponse) { + public static func getMaskStickers(hash: Int64) -> (FunctionDescription, Buffer, DeserializeFunctionResponse) { let buffer = Buffer() - buffer.appendInt32(1706608543) - serializeInt32(hash, buffer: buffer, boxed: false) + buffer.appendInt32(1678738104) + serializeInt64(hash, buffer: buffer, boxed: false) return (FunctionDescription(name: "messages.getMaskStickers", parameters: [("hash", hash)]), buffer, DeserializeFunctionResponse { (buffer: Buffer) -> Api.messages.AllStickers? in let reader = BufferReader(buffer) var result: Api.messages.AllStickers? @@ -3350,11 +3350,11 @@ public extension Api { }) } - public static func getCommonChats(userId: Api.InputUser, maxId: Int32, limit: Int32) -> (FunctionDescription, Buffer, DeserializeFunctionResponse) { + public static func getCommonChats(userId: Api.InputUser, maxId: Int64, limit: Int32) -> (FunctionDescription, Buffer, DeserializeFunctionResponse) { let buffer = Buffer() - buffer.appendInt32(218777796) + buffer.appendInt32(-468934396) userId.serialize(buffer, true) - serializeInt32(maxId, buffer: buffer, boxed: false) + serializeInt64(maxId, buffer: buffer, boxed: false) serializeInt32(limit, buffer: buffer, boxed: false) return (FunctionDescription(name: "messages.getCommonChats", parameters: [("userId", userId), ("maxId", maxId), ("limit", limit)]), buffer, DeserializeFunctionResponse { (buffer: Buffer) -> Api.messages.Chats? in let reader = BufferReader(buffer) @@ -3366,13 +3366,13 @@ public extension Api { }) } - public static func getAllChats(exceptIds: [Int32]) -> (FunctionDescription, Buffer, DeserializeFunctionResponse) { + public static func getAllChats(exceptIds: [Int64]) -> (FunctionDescription, Buffer, DeserializeFunctionResponse) { let buffer = Buffer() - buffer.appendInt32(-341307408) + buffer.appendInt32(-2023787330) buffer.appendInt32(481674261) buffer.appendInt32(Int32(exceptIds.count)) for item in exceptIds { - serializeInt32(item, buffer: buffer, boxed: false) + serializeInt64(item, buffer: buffer, boxed: false) } return (FunctionDescription(name: "messages.getAllChats", parameters: [("exceptIds", exceptIds)]), buffer, DeserializeFunctionResponse { (buffer: Buffer) -> Api.messages.Chats? in let reader = BufferReader(buffer) @@ -3516,10 +3516,10 @@ public extension Api { }) } - public static func getFavedStickers(hash: Int32) -> (FunctionDescription, Buffer, DeserializeFunctionResponse) { + public static func getFavedStickers(hash: Int64) -> (FunctionDescription, Buffer, DeserializeFunctionResponse) { let buffer = Buffer() - buffer.appendInt32(567151374) - serializeInt32(hash, buffer: buffer, boxed: false) + buffer.appendInt32(82946729) + serializeInt64(hash, buffer: buffer, boxed: false) return (FunctionDescription(name: "messages.getFavedStickers", parameters: [("hash", hash)]), buffer, DeserializeFunctionResponse { (buffer: Buffer) -> Api.messages.FavedStickers? in let reader = BufferReader(buffer) var result: Api.messages.FavedStickers? @@ -3578,12 +3578,12 @@ public extension Api { }) } - public static func getRecentLocations(peer: Api.InputPeer, limit: Int32, hash: Int32) -> (FunctionDescription, Buffer, DeserializeFunctionResponse) { + public static func getRecentLocations(peer: Api.InputPeer, limit: Int32, hash: Int64) -> (FunctionDescription, Buffer, DeserializeFunctionResponse) { let buffer = Buffer() - buffer.appendInt32(-1144759543) + buffer.appendInt32(1881817312) peer.serialize(buffer, true) serializeInt32(limit, buffer: buffer, boxed: false) - serializeInt32(hash, buffer: buffer, boxed: false) + serializeInt64(hash, buffer: buffer, boxed: false) return (FunctionDescription(name: "messages.getRecentLocations", parameters: [("peer", peer), ("limit", limit), ("hash", hash)]), buffer, DeserializeFunctionResponse { (buffer: Buffer) -> Api.messages.Messages? in let reader = BufferReader(buffer) var result: Api.messages.Messages? @@ -3631,12 +3631,12 @@ public extension Api { }) } - public static func searchStickerSets(flags: Int32, q: String, hash: Int32) -> (FunctionDescription, Buffer, DeserializeFunctionResponse) { + public static func searchStickerSets(flags: Int32, q: String, hash: Int64) -> (FunctionDescription, Buffer, DeserializeFunctionResponse) { let buffer = Buffer() - buffer.appendInt32(-1028140917) + buffer.appendInt32(896555914) serializeInt32(flags, buffer: buffer, boxed: false) serializeString(q, buffer: buffer, boxed: false) - serializeInt32(hash, buffer: buffer, boxed: false) + serializeInt64(hash, buffer: buffer, boxed: false) return (FunctionDescription(name: "messages.searchStickerSets", parameters: [("flags", flags), ("q", q), ("hash", hash)]), buffer, DeserializeFunctionResponse { (buffer: Buffer) -> Api.messages.FoundStickerSets? in let reader = BufferReader(buffer) var result: Api.messages.FoundStickerSets? @@ -3945,11 +3945,11 @@ public extension Api { }) } - public static func getScheduledHistory(peer: Api.InputPeer, hash: Int32) -> (FunctionDescription, Buffer, DeserializeFunctionResponse) { + public static func getScheduledHistory(peer: Api.InputPeer, hash: Int64) -> (FunctionDescription, Buffer, DeserializeFunctionResponse) { let buffer = Buffer() - buffer.appendInt32(-490575781) + buffer.appendInt32(-183077365) peer.serialize(buffer, true) - serializeInt32(hash, buffer: buffer, boxed: false) + serializeInt64(hash, buffer: buffer, boxed: false) return (FunctionDescription(name: "messages.getScheduledHistory", parameters: [("peer", peer), ("hash", hash)]), buffer, DeserializeFunctionResponse { (buffer: Buffer) -> Api.messages.Messages? in let reader = BufferReader(buffer) var result: Api.messages.Messages? @@ -4117,12 +4117,12 @@ public extension Api { }) } - public static func getOldFeaturedStickers(offset: Int32, limit: Int32, hash: Int32) -> (FunctionDescription, Buffer, DeserializeFunctionResponse) { + public static func getOldFeaturedStickers(offset: Int32, limit: Int32, hash: Int64) -> (FunctionDescription, Buffer, DeserializeFunctionResponse) { let buffer = Buffer() - buffer.appendInt32(1608974939) + buffer.appendInt32(2127598753) serializeInt32(offset, buffer: buffer, boxed: false) serializeInt32(limit, buffer: buffer, boxed: false) - serializeInt32(hash, buffer: buffer, boxed: false) + serializeInt64(hash, buffer: buffer, boxed: false) return (FunctionDescription(name: "messages.getOldFeaturedStickers", parameters: [("offset", offset), ("limit", limit), ("hash", hash)]), buffer, DeserializeFunctionResponse { (buffer: Buffer) -> Api.messages.FeaturedStickers? in let reader = BufferReader(buffer) var result: Api.messages.FeaturedStickers? @@ -4133,9 +4133,9 @@ public extension Api { }) } - public static func getReplies(peer: Api.InputPeer, msgId: Int32, offsetId: Int32, offsetDate: Int32, addOffset: Int32, limit: Int32, maxId: Int32, minId: Int32, hash: Int32) -> (FunctionDescription, Buffer, DeserializeFunctionResponse) { + public static func getReplies(peer: Api.InputPeer, msgId: Int32, offsetId: Int32, offsetDate: Int32, addOffset: Int32, limit: Int32, maxId: Int32, minId: Int32, hash: Int64) -> (FunctionDescription, Buffer, DeserializeFunctionResponse) { let buffer = Buffer() - buffer.appendInt32(615875002) + buffer.appendInt32(584962828) peer.serialize(buffer, true) serializeInt32(msgId, buffer: buffer, boxed: false) serializeInt32(offsetId, buffer: buffer, boxed: false) @@ -4144,7 +4144,7 @@ public extension Api { serializeInt32(limit, buffer: buffer, boxed: false) serializeInt32(maxId, buffer: buffer, boxed: false) serializeInt32(minId, buffer: buffer, boxed: false) - serializeInt32(hash, buffer: buffer, boxed: false) + serializeInt64(hash, buffer: buffer, boxed: false) return (FunctionDescription(name: "messages.getReplies", parameters: [("peer", peer), ("msgId", msgId), ("offsetId", offsetId), ("offsetDate", offsetDate), ("addOffset", addOffset), ("limit", limit), ("maxId", maxId), ("minId", minId), ("hash", hash)]), buffer, DeserializeFunctionResponse { (buffer: Buffer) -> Api.messages.Messages? in let reader = BufferReader(buffer) var result: Api.messages.Messages? @@ -4200,10 +4200,10 @@ public extension Api { }) } - public static func deleteChat(chatId: Int32) -> (FunctionDescription, Buffer, DeserializeFunctionResponse) { + public static func deleteChat(chatId: Int64) -> (FunctionDescription, Buffer, DeserializeFunctionResponse) { let buffer = Buffer() - buffer.appendInt32(-2094760687) - serializeInt32(chatId, buffer: buffer, boxed: false) + buffer.appendInt32(1540419152) + serializeInt64(chatId, buffer: buffer, boxed: false) return (FunctionDescription(name: "messages.deleteChat", parameters: [("chatId", chatId)]), buffer, DeserializeFunctionResponse { (buffer: Buffer) -> Api.Bool? in let reader = BufferReader(buffer) var result: Api.Bool? @@ -4447,6 +4447,21 @@ public extension Api { return result }) } + + public static func getMessageReadParticipants(peer: Api.InputPeer, msgId: Int32) -> (FunctionDescription, Buffer, DeserializeFunctionResponse<[Int64]>) { + let buffer = Buffer() + buffer.appendInt32(745510839) + peer.serialize(buffer, true) + serializeInt32(msgId, buffer: buffer, boxed: false) + return (FunctionDescription(name: "messages.getMessageReadParticipants", parameters: [("peer", peer), ("msgId", msgId)]), buffer, DeserializeFunctionResponse { (buffer: Buffer) -> [Int64]? in + let reader = BufferReader(buffer) + var result: [Int64]? + if let _ = reader.readInt32() { + result = Api.parseVector(reader, elementSignature: 570911930, elementType: Int64.self) + } + return result + }) + } } public struct channels { public static func readHistory(channel: Api.InputChannel, maxId: Int32) -> (FunctionDescription, Buffer, DeserializeFunctionResponse) { @@ -4537,14 +4552,14 @@ public extension Api { }) } - public static func getParticipants(channel: Api.InputChannel, filter: Api.ChannelParticipantsFilter, offset: Int32, limit: Int32, hash: Int32) -> (FunctionDescription, Buffer, DeserializeFunctionResponse) { + public static func getParticipants(channel: Api.InputChannel, filter: Api.ChannelParticipantsFilter, offset: Int32, limit: Int32, hash: Int64) -> (FunctionDescription, Buffer, DeserializeFunctionResponse) { let buffer = Buffer() - buffer.appendInt32(306054633) + buffer.appendInt32(2010044880) channel.serialize(buffer, true) filter.serialize(buffer, true) serializeInt32(offset, buffer: buffer, boxed: false) serializeInt32(limit, buffer: buffer, boxed: false) - serializeInt32(hash, buffer: buffer, boxed: false) + serializeInt64(hash, buffer: buffer, boxed: false) return (FunctionDescription(name: "channels.getParticipants", parameters: [("channel", channel), ("filter", filter), ("offset", offset), ("limit", limit), ("hash", hash)]), buffer, DeserializeFunctionResponse { (buffer: Buffer) -> Api.channels.ChannelParticipants? in let reader = BufferReader(buffer) var result: Api.channels.ChannelParticipants? @@ -5343,10 +5358,10 @@ public extension Api { }) } - public static func importAuthorization(id: Int32, bytes: Buffer) -> (FunctionDescription, Buffer, DeserializeFunctionResponse) { + public static func importAuthorization(id: Int64, bytes: Buffer) -> (FunctionDescription, Buffer, DeserializeFunctionResponse) { let buffer = Buffer() - buffer.appendInt32(-470837741) - serializeInt32(id, buffer: buffer, boxed: false) + buffer.appendInt32(-1518699091) + serializeInt64(id, buffer: buffer, boxed: false) serializeBytes(bytes, buffer: buffer, boxed: false) return (FunctionDescription(name: "auth.importAuthorization", parameters: [("id", id), ("bytes", bytes)]), buffer, DeserializeFunctionResponse { (buffer: Buffer) -> Api.auth.Authorization? in let reader = BufferReader(buffer) @@ -5484,15 +5499,15 @@ public extension Api { }) } - public static func exportLoginToken(apiId: Int32, apiHash: String, exceptIds: [Int32]) -> (FunctionDescription, Buffer, DeserializeFunctionResponse) { + public static func exportLoginToken(apiId: Int32, apiHash: String, exceptIds: [Int64]) -> (FunctionDescription, Buffer, DeserializeFunctionResponse) { let buffer = Buffer() - buffer.appendInt32(-1313598185) + buffer.appendInt32(-1210022402) serializeInt32(apiId, buffer: buffer, boxed: false) serializeString(apiHash, buffer: buffer, boxed: false) buffer.appendInt32(481674261) buffer.appendInt32(Int32(exceptIds.count)) for item in exceptIds { - serializeInt32(item, buffer: buffer, boxed: false) + serializeInt64(item, buffer: buffer, boxed: false) } return (FunctionDescription(name: "auth.exportLoginToken", parameters: [("apiId", apiId), ("apiHash", apiHash), ("exceptIds", exceptIds)]), buffer, DeserializeFunctionResponse { (buffer: Buffer) -> Api.auth.LoginToken? in let reader = BufferReader(buffer) @@ -5680,10 +5695,10 @@ public extension Api { } } public struct contacts { - public static func getContactIDs(hash: Int32) -> (FunctionDescription, Buffer, DeserializeFunctionResponse<[Int32]>) { + public static func getContactIDs(hash: Int64) -> (FunctionDescription, Buffer, DeserializeFunctionResponse<[Int32]>) { let buffer = Buffer() - buffer.appendInt32(749357634) - serializeInt32(hash, buffer: buffer, boxed: false) + buffer.appendInt32(2061264541) + serializeInt64(hash, buffer: buffer, boxed: false) return (FunctionDescription(name: "contacts.getContactIDs", parameters: [("hash", hash)]), buffer, DeserializeFunctionResponse { (buffer: Buffer) -> [Int32]? in let reader = BufferReader(buffer) var result: [Int32]? @@ -5708,10 +5723,10 @@ public extension Api { }) } - public static func getContacts(hash: Int32) -> (FunctionDescription, Buffer, DeserializeFunctionResponse) { + public static func getContacts(hash: Int64) -> (FunctionDescription, Buffer, DeserializeFunctionResponse) { let buffer = Buffer() - buffer.appendInt32(-1071414113) - serializeInt32(hash, buffer: buffer, boxed: false) + buffer.appendInt32(1574346258) + serializeInt64(hash, buffer: buffer, boxed: false) return (FunctionDescription(name: "contacts.getContacts", parameters: [("hash", hash)]), buffer, DeserializeFunctionResponse { (buffer: Buffer) -> Api.contacts.Contacts? in let reader = BufferReader(buffer) var result: Api.contacts.Contacts? @@ -5848,13 +5863,13 @@ public extension Api { }) } - public static func getTopPeers(flags: Int32, offset: Int32, limit: Int32, hash: Int32) -> (FunctionDescription, Buffer, DeserializeFunctionResponse) { + public static func getTopPeers(flags: Int32, offset: Int32, limit: Int32, hash: Int64) -> (FunctionDescription, Buffer, DeserializeFunctionResponse) { let buffer = Buffer() - buffer.appendInt32(-728224331) + buffer.appendInt32(-1758168906) serializeInt32(flags, buffer: buffer, boxed: false) serializeInt32(offset, buffer: buffer, boxed: false) serializeInt32(limit, buffer: buffer, boxed: false) - serializeInt32(hash, buffer: buffer, boxed: false) + serializeInt64(hash, buffer: buffer, boxed: false) return (FunctionDescription(name: "contacts.getTopPeers", parameters: [("flags", flags), ("offset", offset), ("limit", limit), ("hash", hash)]), buffer, DeserializeFunctionResponse { (buffer: Buffer) -> Api.contacts.TopPeers? in let reader = BufferReader(buffer) var result: Api.contacts.TopPeers? @@ -6646,9 +6661,9 @@ public extension Api { } } public struct account { - public static func registerDevice(flags: Int32, tokenType: Int32, token: String, appSandbox: Api.Bool, secret: Buffer, otherUids: [Int32]) -> (FunctionDescription, Buffer, DeserializeFunctionResponse) { + public static func registerDevice(flags: Int32, tokenType: Int32, token: String, appSandbox: Api.Bool, secret: Buffer, otherUids: [Int64]) -> (FunctionDescription, Buffer, DeserializeFunctionResponse) { let buffer = Buffer() - buffer.appendInt32(1754754159) + buffer.appendInt32(-326762118) serializeInt32(flags, buffer: buffer, boxed: false) serializeInt32(tokenType, buffer: buffer, boxed: false) serializeString(token, buffer: buffer, boxed: false) @@ -6657,7 +6672,7 @@ public extension Api { buffer.appendInt32(481674261) buffer.appendInt32(Int32(otherUids.count)) for item in otherUids { - serializeInt32(item, buffer: buffer, boxed: false) + serializeInt64(item, buffer: buffer, boxed: false) } return (FunctionDescription(name: "account.registerDevice", parameters: [("flags", flags), ("tokenType", tokenType), ("token", token), ("appSandbox", appSandbox), ("secret", secret), ("otherUids", otherUids)]), buffer, DeserializeFunctionResponse { (buffer: Buffer) -> Api.Bool? in let reader = BufferReader(buffer) @@ -6669,15 +6684,15 @@ public extension Api { }) } - public static func unregisterDevice(tokenType: Int32, token: String, otherUids: [Int32]) -> (FunctionDescription, Buffer, DeserializeFunctionResponse) { + public static func unregisterDevice(tokenType: Int32, token: String, otherUids: [Int64]) -> (FunctionDescription, Buffer, DeserializeFunctionResponse) { let buffer = Buffer() - buffer.appendInt32(813089983) + buffer.appendInt32(1779249670) serializeInt32(tokenType, buffer: buffer, boxed: false) serializeString(token, buffer: buffer, boxed: false) buffer.appendInt32(481674261) buffer.appendInt32(Int32(otherUids.count)) for item in otherUids { - serializeInt32(item, buffer: buffer, boxed: false) + serializeInt64(item, buffer: buffer, boxed: false) } return (FunctionDescription(name: "account.unregisterDevice", parameters: [("tokenType", tokenType), ("token", token), ("otherUids", otherUids)]), buffer, DeserializeFunctionResponse { (buffer: Buffer) -> Api.Bool? in let reader = BufferReader(buffer) @@ -6763,10 +6778,10 @@ public extension Api { }) } - public static func getWallPapers(hash: Int32) -> (FunctionDescription, Buffer, DeserializeFunctionResponse) { + public static func getWallPapers(hash: Int64) -> (FunctionDescription, Buffer, DeserializeFunctionResponse) { let buffer = Buffer() - buffer.appendInt32(-1430579357) - serializeInt32(hash, buffer: buffer, boxed: false) + buffer.appendInt32(127302966) + serializeInt64(hash, buffer: buffer, boxed: false) return (FunctionDescription(name: "account.getWallPapers", parameters: [("hash", hash)]), buffer, DeserializeFunctionResponse { (buffer: Buffer) -> Api.account.WallPapers? in let reader = BufferReader(buffer) var result: Api.account.WallPapers? @@ -7164,10 +7179,10 @@ public extension Api { }) } - public static func getAuthorizationForm(botId: Int32, scope: String, publicKey: String) -> (FunctionDescription, Buffer, DeserializeFunctionResponse) { + public static func getAuthorizationForm(botId: Int64, scope: String, publicKey: String) -> (FunctionDescription, Buffer, DeserializeFunctionResponse) { let buffer = Buffer() - buffer.appendInt32(-1200903967) - serializeInt32(botId, buffer: buffer, boxed: false) + buffer.appendInt32(-1456907910) + serializeInt64(botId, buffer: buffer, boxed: false) serializeString(scope, buffer: buffer, boxed: false) serializeString(publicKey, buffer: buffer, boxed: false) return (FunctionDescription(name: "account.getAuthorizationForm", parameters: [("botId", botId), ("scope", scope), ("publicKey", publicKey)]), buffer, DeserializeFunctionResponse { (buffer: Buffer) -> Api.account.AuthorizationForm? in @@ -7180,10 +7195,10 @@ public extension Api { }) } - public static func acceptAuthorization(botId: Int32, scope: String, publicKey: String, valueHashes: [Api.SecureValueHash], credentials: Api.SecureCredentialsEncrypted) -> (FunctionDescription, Buffer, DeserializeFunctionResponse) { + public static func acceptAuthorization(botId: Int64, scope: String, publicKey: String, valueHashes: [Api.SecureValueHash], credentials: Api.SecureCredentialsEncrypted) -> (FunctionDescription, Buffer, DeserializeFunctionResponse) { let buffer = Buffer() - buffer.appendInt32(-419267436) - serializeInt32(botId, buffer: buffer, boxed: false) + buffer.appendInt32(-202552205) + serializeInt64(botId, buffer: buffer, boxed: false) serializeString(scope, buffer: buffer, boxed: false) serializeString(publicKey, buffer: buffer, boxed: false) buffer.appendInt32(481674261) @@ -7583,11 +7598,11 @@ public extension Api { }) } - public static func getThemes(format: String, hash: Int32) -> (FunctionDescription, Buffer, DeserializeFunctionResponse) { + public static func getThemes(format: String, hash: Int64) -> (FunctionDescription, Buffer, DeserializeFunctionResponse) { let buffer = Buffer() - buffer.appendInt32(676939512) + buffer.appendInt32(1913054296) serializeString(format, buffer: buffer, boxed: false) - serializeInt32(hash, buffer: buffer, boxed: false) + serializeInt64(hash, buffer: buffer, boxed: false) return (FunctionDescription(name: "account.getThemes", parameters: [("format", format), ("hash", hash)]), buffer, DeserializeFunctionResponse { (buffer: Buffer) -> Api.account.Themes? in let reader = BufferReader(buffer) var result: Api.account.Themes? diff --git a/submodules/TelegramCallsUI/Sources/CallKitIntegration.swift b/submodules/TelegramCallsUI/Sources/CallKitIntegration.swift index 86c7fb2049..bca3f90d24 100644 --- a/submodules/TelegramCallsUI/Sources/CallKitIntegration.swift +++ b/submodules/TelegramCallsUI/Sources/CallKitIntegration.swift @@ -169,7 +169,7 @@ class CallKitProviderDelegate: NSObject, CXProviderDelegate { func startCall(context: AccountContext, peerId: PeerId, isVideo: Bool, displayTitle: String) { let uuid = UUID() self.currentStartCallAccount = (uuid, context) - let handle = CXHandle(type: .generic, value: "\(peerId.id._internalGetInt32Value())") + let handle = CXHandle(type: .generic, value: "\(peerId.id._internalGetInt64Value())") let startCallAction = CXStartCallAction(call: uuid, handle: handle) startCallAction.contactIdentifier = displayTitle diff --git a/submodules/TelegramCallsUI/Sources/CallRatingController.swift b/submodules/TelegramCallsUI/Sources/CallRatingController.swift index e79ce92ec5..b2b89b7630 100644 --- a/submodules/TelegramCallsUI/Sources/CallRatingController.swift +++ b/submodules/TelegramCallsUI/Sources/CallRatingController.swift @@ -240,7 +240,7 @@ private final class CallRatingAlertContentNode: AlertContentNode { } func rateCallAndSendLogs(engine: TelegramEngine, callId: CallId, starsCount: Int, comment: String, userInitiated: Bool, includeLogs: Bool) -> Signal { - let peerId = PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt32Value(4244000)) + let peerId = PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt64Value(4244000)) let rate = engine.calls.rateCall(callId: callId, starsCount: Int32(starsCount), comment: comment, userInitiated: userInitiated) if includeLogs { diff --git a/submodules/TelegramCallsUI/Sources/PresentationCallManager.swift b/submodules/TelegramCallsUI/Sources/PresentationCallManager.swift index 0769584735..f1ddbbb019 100644 --- a/submodules/TelegramCallsUI/Sources/PresentationCallManager.swift +++ b/submodules/TelegramCallsUI/Sources/PresentationCallManager.swift @@ -204,8 +204,8 @@ public final class PresentationCallManagerImpl: PresentationCallManager { }) startCallImpl = { [weak self] context, uuid, handle, isVideo in - if let strongSelf = self, let userId = Int32(handle) { - return strongSelf.startCall(context: context, peerId: PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt32Value(userId)), isVideo: isVideo, internalId: uuid) + if let strongSelf = self, let userId = Int64(handle) { + return strongSelf.startCall(context: context, peerId: PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt64Value(userId)), isVideo: isVideo, internalId: uuid) |> take(1) |> map { result -> Bool in return result diff --git a/submodules/TelegramCore/Sources/Account/Account.swift b/submodules/TelegramCore/Sources/Account/Account.swift index d3f7e8f9f7..f514da28e5 100644 --- a/submodules/TelegramCore/Sources/Account/Account.swift +++ b/submodules/TelegramCore/Sources/Account/Account.swift @@ -106,7 +106,9 @@ public class UnauthorizedAccount { network.context.performBatchUpdates({ var datacenterIds: [Int] = [1, 2] - if !testingEnvironment { + if testingEnvironment { + datacenterIds = [3] + } else { datacenterIds.append(contentsOf: [4]) } for id in datacenterIds { diff --git a/submodules/TelegramCore/Sources/Account/AccountIntermediateState.swift b/submodules/TelegramCore/Sources/Account/AccountIntermediateState.swift index 5f394fb703..194cf5a28c 100644 --- a/submodules/TelegramCore/Sources/Account/AccountIntermediateState.swift +++ b/submodules/TelegramCore/Sources/Account/AccountIntermediateState.swift @@ -354,7 +354,7 @@ struct AccountMutableState { for chat in chats { switch chat { - case let .channel(_, _, _, _, _, _, _, _, _, _, _, _, participantsCount): + case let .channel(_, _, _, _, _, _, _, _, _, _, _, participantsCount): if let participantsCount = participantsCount { self.addOperation(.UpdateCachedPeerData(chat.peerId, { current in var previous: CachedChannelData @@ -416,7 +416,7 @@ struct AccountMutableState { switch user { case let .user(_, id, _, _, _, _, _, _, status, _, _, _, _): if let status = status { - presences[PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt32Value(id))] = status + presences[PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt64Value(id))] = status } break case .userEmpty: diff --git a/submodules/TelegramCore/Sources/Account/AccountManager.swift b/submodules/TelegramCore/Sources/Account/AccountManager.swift index e62e7dc6d2..815540377f 100644 --- a/submodules/TelegramCore/Sources/Account/AccountManager.swift +++ b/submodules/TelegramCore/Sources/Account/AccountManager.swift @@ -130,7 +130,7 @@ private var declaredEncodables: Void = { declareEncodable(CloudChatRemoveMessagesOperation.self, f: { CloudChatRemoveMessagesOperation(decoder: $0) }) declareEncodable(AutoremoveTimeoutMessageAttribute.self, f: { AutoremoveTimeoutMessageAttribute(decoder: $0) }) declareEncodable(AutoclearTimeoutMessageAttribute.self, f: { AutoclearTimeoutMessageAttribute(decoder: $0) }) - declareEncodable(GlobalNotificationSettings.self, f: { GlobalNotificationSettings(decoder: $0) }) + //declareEncodable(GlobalNotificationSettings.self, f: { GlobalNotificationSettings(decoder: $0) }) declareEncodable(CloudChatRemoveChatOperation.self, f: { CloudChatRemoveChatOperation(decoder: $0) }) declareEncodable(SynchronizePinnedChatsOperation.self, f: { SynchronizePinnedChatsOperation(decoder: $0) }) declareEncodable(SynchronizeConsumeMessageContentsOperation.self, f: { SynchronizeConsumeMessageContentsOperation(decoder: $0) }) @@ -223,8 +223,8 @@ private var declaredEncodables: Void = { declareEncodable(CachedChatContextResult.self, f: { CachedChatContextResult(decoder: $0) }) declareEncodable(PeerAccessRestrictionInfo.self, f: { PeerAccessRestrictionInfo(decoder: $0) }) declareEncodable(TelegramMediaImage.VideoRepresentation.self, f: { TelegramMediaImage.VideoRepresentation(decoder: $0) }) - declareEncodable(Country.self, f: { Country(decoder: $0) }) - declareEncodable(Country.CountryCode.self, f: { Country.CountryCode(decoder: $0) }) + //declareEncodable(Country.self, f: { Country(decoder: $0) }) + //declareEncodable(Country.CountryCode.self, f: { Country.CountryCode(decoder: $0) }) //declareEncodable(CountriesList.self, f: { CountriesList(decoder: $0) }) declareEncodable(ValidationMessageAttribute.self, f: { ValidationMessageAttribute(decoder: $0) }) declareEncodable(EmojiSearchQueryMessageAttribute.self, f: { EmojiSearchQueryMessageAttribute(decoder: $0) }) @@ -235,7 +235,7 @@ private var declaredEncodables: Void = { //declareEncodable(WallpapersState.self, f: { WallpapersState(decoder: $0) }) declareEncodable(WallpaperDataResource.self, f: { WallpaperDataResource(decoder: $0) }) declareEncodable(ForwardOptionsMessageAttribute.self, f: { ForwardOptionsMessageAttribute(decoder: $0) }) - declareEncodable(ChatTheme.self, f: { ChatTheme(decoder: $0) }) + //declareEncodable(ChatTheme.self, f: { ChatTheme(decoder: $0) }) //declareEncodable(ChatThemes.self, f: { ChatThemes(decoder: $0) }) return diff --git a/submodules/TelegramCore/Sources/ApiUtils/ApiGroupOrChannel.swift b/submodules/TelegramCore/Sources/ApiUtils/ApiGroupOrChannel.swift index 197ba7a61e..d4db336c18 100644 --- a/submodules/TelegramCore/Sources/ApiUtils/ApiGroupOrChannel.swift +++ b/submodules/TelegramCore/Sources/ApiUtils/ApiGroupOrChannel.swift @@ -29,7 +29,7 @@ func parseTelegramGroupOrChannel(chat: Api.Chat) -> Peer? { if let migratedTo = migratedTo { switch migratedTo { case let .inputChannel(channelId, accessHash): - migrationReference = TelegramGroupToChannelMigrationReference(peerId: PeerId(namespace: Namespaces.Peer.CloudChannel, id: PeerId.Id._internalFromInt32Value(channelId)), accessHash: accessHash) + migrationReference = TelegramGroupToChannelMigrationReference(peerId: PeerId(namespace: Namespaces.Peer.CloudChannel, id: PeerId.Id._internalFromInt64Value(channelId)), accessHash: accessHash) case .inputChannelEmpty: break case .inputChannelFromMessage: @@ -52,12 +52,12 @@ func parseTelegramGroupOrChannel(chat: Api.Chat) -> Peer? { if (flags & Int32(1 << 24)) != 0 { groupFlags.insert(.hasActiveVoiceChat) } - return TelegramGroup(id: PeerId(namespace: Namespaces.Peer.CloudGroup, id: PeerId.Id._internalFromInt32Value(id)), title: title, photo: imageRepresentationsForApiChatPhoto(photo), participantCount: Int(participantsCount), role: role, membership: left ? .Left : .Member, flags: groupFlags, defaultBannedRights: defaultBannedRights.flatMap(TelegramChatBannedRights.init(apiBannedRights:)), migrationReference: migrationReference, creationDate: date, version: Int(version)) + return TelegramGroup(id: PeerId(namespace: Namespaces.Peer.CloudGroup, id: PeerId.Id._internalFromInt64Value(id)), title: title, photo: imageRepresentationsForApiChatPhoto(photo), participantCount: Int(participantsCount), role: role, membership: left ? .Left : .Member, flags: groupFlags, defaultBannedRights: defaultBannedRights.flatMap(TelegramChatBannedRights.init(apiBannedRights:)), migrationReference: migrationReference, creationDate: date, version: Int(version)) case let .chatEmpty(id): - return TelegramGroup(id: PeerId(namespace: Namespaces.Peer.CloudGroup, id: PeerId.Id._internalFromInt32Value(id)), title: "", photo: [], participantCount: 0, role: .member, membership: .Removed, flags: [], defaultBannedRights: nil, migrationReference: nil, creationDate: 0, version: 0) + return TelegramGroup(id: PeerId(namespace: Namespaces.Peer.CloudGroup, id: PeerId.Id._internalFromInt64Value(id)), title: "", photo: [], participantCount: 0, role: .member, membership: .Removed, flags: [], defaultBannedRights: nil, migrationReference: nil, creationDate: 0, version: 0) case let .chatForbidden(id, title): - return TelegramGroup(id: PeerId(namespace: Namespaces.Peer.CloudGroup, id: PeerId.Id._internalFromInt32Value(id)), title: title, photo: [], participantCount: 0, role: .member, membership: .Removed, flags: [], defaultBannedRights: nil, migrationReference: nil, creationDate: 0, version: 0) - case let .channel(flags, id, accessHash, title, username, photo, date, version, restrictionReason, adminRights, bannedRights, defaultBannedRights, _): + return TelegramGroup(id: PeerId(namespace: Namespaces.Peer.CloudGroup, id: PeerId.Id._internalFromInt64Value(id)), title: title, photo: [], participantCount: 0, role: .member, membership: .Removed, flags: [], defaultBannedRights: nil, migrationReference: nil, creationDate: 0, version: 0) + case let .channel(flags, id, accessHash, title, username, photo, date, restrictionReason, adminRights, bannedRights, defaultBannedRights, _): let isMin = (flags & (1 << 12)) != 0 let participationStatus: TelegramChannelParticipationStatus @@ -128,7 +128,7 @@ func parseTelegramGroupOrChannel(chat: Api.Chat) -> Peer? { } } - return TelegramChannel(id: PeerId(namespace: Namespaces.Peer.CloudChannel, id: PeerId.Id._internalFromInt32Value(id)), accessHash: accessHashValue, title: title, username: username, photo: imageRepresentationsForApiChatPhoto(photo), creationDate: date, version: version, participationStatus: participationStatus, info: info, flags: channelFlags, restrictionInfo: restrictionInfo, adminRights: adminRights.flatMap(TelegramChatAdminRights.init), bannedRights: bannedRights.flatMap(TelegramChatBannedRights.init), defaultBannedRights: defaultBannedRights.flatMap(TelegramChatBannedRights.init)) + return TelegramChannel(id: PeerId(namespace: Namespaces.Peer.CloudChannel, id: PeerId.Id._internalFromInt64Value(id)), accessHash: accessHashValue, title: title, username: username, photo: imageRepresentationsForApiChatPhoto(photo), creationDate: date, version: 0, participationStatus: participationStatus, info: info, flags: channelFlags, restrictionInfo: restrictionInfo, adminRights: adminRights.flatMap(TelegramChatAdminRights.init), bannedRights: bannedRights.flatMap(TelegramChatBannedRights.init), defaultBannedRights: defaultBannedRights.flatMap(TelegramChatBannedRights.init)) case let .channelForbidden(flags, id, accessHash, title, untilDate): let info: TelegramChannelInfo if (flags & Int32(1 << 8)) != 0 { @@ -137,7 +137,7 @@ func parseTelegramGroupOrChannel(chat: Api.Chat) -> Peer? { info = .broadcast(TelegramChannelBroadcastInfo(flags: [])) } - return TelegramChannel(id: PeerId(namespace: Namespaces.Peer.CloudChannel, id: PeerId.Id._internalFromInt32Value(id)), accessHash: .personal(accessHash), title: title, username: nil, photo: [], creationDate: 0, version: 0, participationStatus: .kicked, info: info, flags: TelegramChannelFlags(), restrictionInfo: nil, adminRights: nil, bannedRights: TelegramChatBannedRights(flags: [.banReadMessages], untilDate: untilDate ?? Int32.max), defaultBannedRights: nil) + return TelegramChannel(id: PeerId(namespace: Namespaces.Peer.CloudChannel, id: PeerId.Id._internalFromInt64Value(id)), accessHash: .personal(accessHash), title: title, username: nil, photo: [], creationDate: 0, version: 0, participationStatus: .kicked, info: info, flags: TelegramChannelFlags(), restrictionInfo: nil, adminRights: nil, bannedRights: TelegramChatBannedRights(flags: [.banReadMessages], untilDate: untilDate ?? Int32.max), defaultBannedRights: nil) } } @@ -145,7 +145,7 @@ func mergeGroupOrChannel(lhs: Peer?, rhs: Api.Chat) -> Peer? { switch rhs { case .chat, .chatEmpty, .chatForbidden, .channelForbidden: return parseTelegramGroupOrChannel(chat: rhs) - case let .channel(flags, _, accessHash, title, username, photo, _, _, _, _, _, defaultBannedRights, _): + case let .channel(flags, _, accessHash, title, username, photo, _, _, _, _, defaultBannedRights, _): let isMin = (flags & (1 << 12)) != 0 if accessHash != nil && !isMin { return parseTelegramGroupOrChannel(chat: rhs) diff --git a/submodules/TelegramCore/Sources/ApiUtils/ApiUtils.swift b/submodules/TelegramCore/Sources/ApiUtils/ApiUtils.swift index 7511586eb5..19bb0ca95e 100644 --- a/submodules/TelegramCore/Sources/ApiUtils/ApiUtils.swift +++ b/submodules/TelegramCore/Sources/ApiUtils/ApiUtils.swift @@ -7,11 +7,11 @@ public extension PeerReference { var id: PeerId { switch self { case let .user(id, _): - return PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt32Value(id)) + return PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt64Value(id)) case let .group(id): - return PeerId(namespace: Namespaces.Peer.CloudGroup, id: PeerId.Id._internalFromInt32Value(id)) + return PeerId(namespace: Namespaces.Peer.CloudGroup, id: PeerId.Id._internalFromInt64Value(id)) case let .channel(id, _): - return PeerId(namespace: Namespaces.Peer.CloudChannel, id: PeerId.Id._internalFromInt32Value(id)) + return PeerId(namespace: Namespaces.Peer.CloudChannel, id: PeerId.Id._internalFromInt64Value(id)) } } } @@ -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._internalGetInt32Value(), accessHash: user.accessHash?.value ?? 0) + return Api.InputPeer.inputPeerUser(userId: user.id.id._internalGetInt64Value(), accessHash: user.accessHash?.value ?? 0) case let group as TelegramGroup: - return Api.InputPeer.inputPeerChat(chatId: group.id.id._internalGetInt32Value()) + return Api.InputPeer.inputPeerChat(chatId: group.id.id._internalGetInt64Value()) case let channel as TelegramChannel: if let accessHash = channel.accessHash { - return Api.InputPeer.inputPeerChannel(channelId: channel.id.id._internalGetInt32Value(), accessHash: accessHash.value) + return Api.InputPeer.inputPeerChannel(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._internalGetInt32Value(), accessHash: user.accessHash!.value) + return Api.InputPeer.inputPeerUser(userId: user.id.id._internalGetInt64Value(), accessHash: user.accessHash!.value) case let group as TelegramGroup: - return Api.InputPeer.inputPeerChat(chatId: group.id.id._internalGetInt32Value()) + return Api.InputPeer.inputPeerChat(chatId: group.id.id._internalGetInt64Value()) case let channel as TelegramChannel: if let accessHash = channel.accessHash { - return Api.InputPeer.inputPeerChannel(channelId: channel.id.id._internalGetInt32Value(), accessHash: accessHash.value) + return Api.InputPeer.inputPeerChannel(channelId: channel.id.id._internalGetInt64Value(), accessHash: accessHash.value) } else { return nil } @@ -81,7 +81,7 @@ func apiInputPeer(_ peer: Peer) -> Api.InputPeer? { func apiInputChannel(_ peer: Peer) -> Api.InputChannel? { if let channel = peer as? TelegramChannel, let accessHash = channel.accessHash { - return Api.InputChannel.inputChannel(channelId: channel.id.id._internalGetInt32Value(), accessHash: accessHash.value) + return Api.InputChannel.inputChannel(channelId: channel.id.id._internalGetInt64Value(), accessHash: accessHash.value) } else { return nil } @@ -89,7 +89,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._internalGetInt32Value(), accessHash: accessHash.value) + return Api.InputUser.inputUser(userId: user.id.id._internalGetInt64Value(), accessHash: accessHash.value) } else { return nil } @@ -97,7 +97,7 @@ func apiInputUser(_ peer: Peer) -> Api.InputUser? { func apiInputSecretChat(_ peer: Peer) -> Api.InputEncryptedChat? { if let chat = peer as? TelegramSecretChat { - return Api.InputEncryptedChat.inputEncryptedChat(chatId: peer.id.id._internalGetInt32Value(), accessHash: chat.accessHash) + return Api.InputEncryptedChat.inputEncryptedChat(chatId: Int32(peer.id.id._internalGetInt64Value()), accessHash: chat.accessHash) } else { return nil } diff --git a/submodules/TelegramCore/Sources/ApiUtils/CachedChannelParticipants.swift b/submodules/TelegramCore/Sources/ApiUtils/CachedChannelParticipants.swift index 9308fcc9ee..d8622dc414 100644 --- a/submodules/TelegramCore/Sources/ApiUtils/CachedChannelParticipants.swift +++ b/submodules/TelegramCore/Sources/ApiUtils/CachedChannelParticipants.swift @@ -198,17 +198,17 @@ extension ChannelParticipant { init(apiParticipant: Api.ChannelParticipant) { switch apiParticipant { case let .channelParticipant(userId, date): - self = .member(id: PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt32Value(userId)), invitedAt: date, adminInfo: nil, banInfo: nil, rank: nil) + self = .member(id: PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt64Value(userId)), invitedAt: date, adminInfo: nil, banInfo: nil, rank: nil) case let .channelParticipantCreator(_, userId, adminRights, rank): - self = .creator(id: PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt32Value(userId)), adminInfo: ChannelParticipantAdminInfo(rights: TelegramChatAdminRights(apiAdminRights: adminRights) ?? TelegramChatAdminRights(rights: []), promotedBy: PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt32Value(userId)), canBeEditedByAccountPeer: true), rank: rank) + self = .creator(id: PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt64Value(userId)), adminInfo: ChannelParticipantAdminInfo(rights: TelegramChatAdminRights(apiAdminRights: adminRights) ?? TelegramChatAdminRights(rights: []), promotedBy: PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt64Value(userId)), canBeEditedByAccountPeer: true), rank: rank) case let .channelParticipantBanned(flags, userId, restrictedBy, date, bannedRights): let hasLeft = (flags & (1 << 0)) != 0 - let banInfo = ChannelParticipantBannedInfo(rights: TelegramChatBannedRights(apiBannedRights: bannedRights), restrictedBy: PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt32Value(restrictedBy)), timestamp: date, isMember: !hasLeft) + let banInfo = ChannelParticipantBannedInfo(rights: TelegramChatBannedRights(apiBannedRights: bannedRights), restrictedBy: PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt64Value(restrictedBy)), timestamp: date, isMember: !hasLeft) self = .member(id: userId.peerId, invitedAt: date, adminInfo: nil, banInfo: banInfo, rank: nil) case let .channelParticipantAdmin(flags, userId, _, promotedBy, date, adminRights, rank: rank): - self = .member(id: PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt32Value(userId)), invitedAt: date, adminInfo: ChannelParticipantAdminInfo(rights: TelegramChatAdminRights(apiAdminRights: adminRights) ?? TelegramChatAdminRights(rights: []), promotedBy: PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt32Value(promotedBy)), canBeEditedByAccountPeer: (flags & (1 << 0)) != 0), banInfo: nil, rank: rank) + self = .member(id: PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt64Value(userId)), invitedAt: date, adminInfo: ChannelParticipantAdminInfo(rights: TelegramChatAdminRights(apiAdminRights: adminRights) ?? TelegramChatAdminRights(rights: []), promotedBy: PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt64Value(promotedBy)), canBeEditedByAccountPeer: (flags & (1 << 0)) != 0), banInfo: nil, rank: rank) case let .channelParticipantSelf(userId, _, date): - self = .member(id: PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt32Value(userId)), invitedAt: date, adminInfo: nil, banInfo: nil, rank: nil) + self = .member(id: PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt64Value(userId)), invitedAt: date, adminInfo: nil, banInfo: nil, rank: nil) case let .channelParticipantLeft(userId): self = .member(id: userId.peerId, invitedAt: 0, adminInfo: nil, banInfo: nil, rank: nil) } diff --git a/submodules/TelegramCore/Sources/ApiUtils/CachedGroupParticipants.swift b/submodules/TelegramCore/Sources/ApiUtils/CachedGroupParticipants.swift index 75705d1f95..3dc2195436 100644 --- a/submodules/TelegramCore/Sources/ApiUtils/CachedGroupParticipants.swift +++ b/submodules/TelegramCore/Sources/ApiUtils/CachedGroupParticipants.swift @@ -7,11 +7,11 @@ extension GroupParticipant { init(apiParticipant: Api.ChatParticipant) { switch apiParticipant { case let .chatParticipantCreator(userId): - self = .creator(id: PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt32Value(userId))) + self = .creator(id: PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt64Value(userId))) case let .chatParticipantAdmin(userId, inviterId, date): - self = .admin(id: PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt32Value(userId)), invitedBy: PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt32Value(inviterId)), invitedAt: 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): - self = .member(id: PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt32Value(userId)), invitedBy: PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt32Value(inviterId)), invitedAt: 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/ExportedInvitation.swift b/submodules/TelegramCore/Sources/ApiUtils/ExportedInvitation.swift index ce25d8aaf3..81e7e3e49f 100644 --- a/submodules/TelegramCore/Sources/ApiUtils/ExportedInvitation.swift +++ b/submodules/TelegramCore/Sources/ApiUtils/ExportedInvitation.swift @@ -7,7 +7,7 @@ extension ExportedInvitation { init(apiExportedInvite: Api.ExportedChatInvite) { switch apiExportedInvite { case let .chatInviteExported(flags, link, adminId, date, startDate, expireDate, usageLimit, usage): - self = ExportedInvitation(link: link, isPermanent: (flags & (1 << 5)) != 0, isRevoked: (flags & (1 << 0)) != 0, adminId: PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt32Value(adminId)), date: date, startDate: startDate, expireDate: expireDate, usageLimit: usageLimit, count: usage) + self = ExportedInvitation(link: link, isPermanent: (flags & (1 << 5)) != 0, isRevoked: (flags & (1 << 0)) != 0, adminId: PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt64Value(adminId)), date: date, startDate: startDate, expireDate: expireDate, usageLimit: usageLimit, count: usage) } } } diff --git a/submodules/TelegramCore/Sources/ApiUtils/RemoteStorageConfiguration.swift b/submodules/TelegramCore/Sources/ApiUtils/RemoteStorageConfiguration.swift index a7bf1c4d06..e584aa0507 100644 --- a/submodules/TelegramCore/Sources/ApiUtils/RemoteStorageConfiguration.swift +++ b/submodules/TelegramCore/Sources/ApiUtils/RemoteStorageConfiguration.swift @@ -5,7 +5,7 @@ import SwiftSignalKit func currentWebDocumentsHostDatacenterId(postbox: Postbox, isTestingEnvironment: Bool) -> Signal { return postbox.transaction { transaction -> Int32 in - if let entry = transaction.getPreferencesEntry(key: PreferencesKeys.remoteStorageConfiguration) as? RemoteStorageConfiguration { + if let entry = transaction.getPreferencesEntry(key: PreferencesKeys.remoteStorageConfiguration)?.get(RemoteStorageConfiguration.self) { return entry.webDocumentsHostDatacenterId } else { if isTestingEnvironment { @@ -18,10 +18,10 @@ func currentWebDocumentsHostDatacenterId(postbox: Postbox, isTestingEnvironment: } func updateRemoteStorageConfiguration(transaction: Transaction, configuration: RemoteStorageConfiguration) { - let current = transaction.getPreferencesEntry(key: PreferencesKeys.remoteStorageConfiguration) as? RemoteStorageConfiguration - if let current = current, current.isEqual(to: configuration) { + let current = transaction.getPreferencesEntry(key: PreferencesKeys.remoteStorageConfiguration)?.get(RemoteStorageConfiguration.self) + if let current = current, current == configuration { return } - transaction.setPreferencesEntry(key: PreferencesKeys.remoteStorageConfiguration, value: configuration) + transaction.setPreferencesEntry(key: PreferencesKeys.remoteStorageConfiguration, value: PreferencesEntry(configuration)) } diff --git a/submodules/TelegramCore/Sources/ApiUtils/StoreMessage_Telegram.swift b/submodules/TelegramCore/Sources/ApiUtils/StoreMessage_Telegram.swift index d725e46ef3..1e15edb319 100644 --- a/submodules/TelegramCore/Sources/ApiUtils/StoreMessage_Telegram.swift +++ b/submodules/TelegramCore/Sources/ApiUtils/StoreMessage_Telegram.swift @@ -156,14 +156,14 @@ func apiMessagePeerIds(_ message: Api.Message) -> [PeerId] { } if let viaBotId = viaBotId { - result.append(PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt32Value(viaBotId))) + result.append(PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt64Value(viaBotId))) } if let media = media { switch media { case let .messageMediaContact(_, _, _, _, userId): if userId != 0 { - result.append(PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt32Value(userId))) + result.append(PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt64Value(userId))) } default: break @@ -174,7 +174,7 @@ func apiMessagePeerIds(_ message: Api.Message) -> [PeerId] { for entity in entities { switch entity { case let .messageEntityMentionName(_, _, userId): - result.append(PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt32Value(userId))) + result.append(PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt64Value(userId))) default: break } @@ -198,27 +198,27 @@ func apiMessagePeerIds(_ message: Api.Message) -> [PeerId] { case .messageActionChannelCreate, .messageActionChatDeletePhoto, .messageActionChatEditPhoto, .messageActionChatEditTitle, .messageActionEmpty, .messageActionPinMessage, .messageActionHistoryClear, .messageActionGameScore, .messageActionPaymentSent, .messageActionPaymentSentMe, .messageActionPhoneCall, .messageActionScreenshotTaken, .messageActionCustomAction, .messageActionBotAllowed, .messageActionSecureValuesSent, .messageActionSecureValuesSentMe, .messageActionContactSignUp, .messageActionGroupCall, .messageActionSetMessagesTTL, .messageActionGroupCallScheduled, .messageActionSetChatTheme: break case let .messageActionChannelMigrateFrom(_, chatId): - result.append(PeerId(namespace: Namespaces.Peer.CloudGroup, id: PeerId.Id._internalFromInt32Value(chatId))) + result.append(PeerId(namespace: Namespaces.Peer.CloudGroup, id: PeerId.Id._internalFromInt64Value(chatId))) case let .messageActionChatAddUser(users): for id in users { - result.append(PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt32Value(id))) + result.append(PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt64Value(id))) } case let .messageActionChatCreate(_, users): for id in users { - result.append(PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt32Value(id))) + result.append(PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt64Value(id))) } case let .messageActionChatDeleteUser(userId): - result.append(PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt32Value(userId))) + result.append(PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt64Value(userId))) case let .messageActionChatJoinedByLink(inviterId): - result.append(PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt32Value(inviterId))) + result.append(PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt64Value(inviterId))) case let .messageActionChatMigrateTo(channelId): - result.append(PeerId(namespace: Namespaces.Peer.CloudChannel, id: PeerId.Id._internalFromInt32Value(channelId))) + result.append(PeerId(namespace: Namespaces.Peer.CloudChannel, id: PeerId.Id._internalFromInt64Value(channelId))) case let .messageActionGeoProximityReached(fromId, toId, _): result.append(fromId.peerId) result.append(toId.peerId) case let .messageActionInviteToGroupCall(_, userIds): for id in userIds { - result.append(PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt32Value(id))) + result.append(PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt64Value(id))) } } @@ -262,7 +262,7 @@ func textMediaAndExpirationTimerFromApiMedia(_ media: Api.MessageMedia?, _ peerI return (TelegramMediaExpiredContent(data: .image), nil) } case let .messageMediaContact(phoneNumber, firstName, lastName, vcard, userId): - let contactPeerId: PeerId? = userId == 0 ? nil : PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt32Value(userId)) + let contactPeerId: PeerId? = userId == 0 ? nil : PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt64Value(userId)) let mediaContact = TelegramMediaContact(firstName: firstName, lastName: lastName, phoneNumber: phoneNumber, peerId: contactPeerId, vCardData: vcard.isEmpty ? nil : vcard) return (mediaContact, nil) case let .messageMediaGeo(geo): @@ -353,7 +353,7 @@ func messageTextEntitiesFromApiEntities(_ entities: [Api.MessageEntity]) -> [Mes case let .messageEntityTextUrl(offset, length, url): result.append(MessageTextEntity(range: Int(offset) ..< Int(offset + length), type: .TextUrl(url: url))) case let .messageEntityMentionName(offset, length, userId): - result.append(MessageTextEntity(range: Int(offset) ..< Int(offset + length), type: .TextMention(peerId: PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt32Value(userId))))) + result.append(MessageTextEntity(range: Int(offset) ..< Int(offset + length), type: .TextMention(peerId: PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt64Value(userId))))) case let .messageEntityPhone(offset, length): result.append(MessageTextEntity(range: Int(offset) ..< Int(offset + length), type: .PhoneNumber)) case let .messageEntityCashtag(offset, length): @@ -384,10 +384,10 @@ extension StoreMessage { peerId = chatPeerId.peerId authorId = resolvedFromId case let .peerChat(chatId): - peerId = PeerId(namespace: Namespaces.Peer.CloudGroup, id: PeerId.Id._internalFromInt32Value(chatId)) + peerId = PeerId(namespace: Namespaces.Peer.CloudGroup, id: PeerId.Id._internalFromInt64Value(chatId)) authorId = resolvedFromId case let .peerChannel(channelId): - peerId = PeerId(namespace: Namespaces.Peer.CloudChannel, id: PeerId.Id._internalFromInt32Value(channelId)) + peerId = PeerId(namespace: Namespaces.Peer.CloudChannel, id: PeerId.Id._internalFromInt64Value(channelId)) authorId = resolvedFromId } @@ -501,7 +501,7 @@ extension StoreMessage { } if let viaBotId = viaBotId { - attributes.append(InlineBotMessageAttribute(peerId: PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt32Value(viaBotId)), title: nil)) + attributes.append(InlineBotMessageAttribute(peerId: PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt64Value(viaBotId)), title: nil)) } if namespace != Namespaces.Message.ScheduledCloud { @@ -560,7 +560,7 @@ extension StoreMessage { recentRepliersPeerIds = nil } - let commentsPeerId = channelId.flatMap { PeerId(namespace: Namespaces.Peer.CloudChannel, id: PeerId.Id._internalFromInt32Value($0)) } + let commentsPeerId = channelId.flatMap { PeerId(namespace: Namespaces.Peer.CloudChannel, id: PeerId.Id._internalFromInt64Value($0)) } attributes.append(ReplyThreadMessageAttribute(count: repliesCount, latestUsers: recentRepliersPeerIds ?? [], commentsPeerId: commentsPeerId, maxMessageId: maxId, maxReadMessageId: readMaxId)) } diff --git a/submodules/TelegramCore/Sources/ApiUtils/TelegramMediaAction.swift b/submodules/TelegramCore/Sources/ApiUtils/TelegramMediaAction.swift index 3cd70e1c3f..df9db3bfb3 100644 --- a/submodules/TelegramCore/Sources/ApiUtils/TelegramMediaAction.swift +++ b/submodules/TelegramCore/Sources/ApiUtils/TelegramMediaAction.swift @@ -8,23 +8,23 @@ func telegramMediaActionFromApiAction(_ action: Api.MessageAction) -> TelegramMe case let .messageActionChannelCreate(title): return TelegramMediaAction(action: .groupCreated(title: title)) case let .messageActionChannelMigrateFrom(title, chatId): - return TelegramMediaAction(action: .channelMigratedFromGroup(title: title, groupId: PeerId(namespace: Namespaces.Peer.CloudGroup, id: PeerId.Id._internalFromInt32Value(chatId)))) + return TelegramMediaAction(action: .channelMigratedFromGroup(title: title, groupId: PeerId(namespace: Namespaces.Peer.CloudGroup, id: PeerId.Id._internalFromInt64Value(chatId)))) case let .messageActionChatAddUser(users): - return TelegramMediaAction(action: .addedMembers(peerIds: users.map({ PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt32Value($0)) }))) + return TelegramMediaAction(action: .addedMembers(peerIds: users.map({ PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt64Value($0)) }))) case let .messageActionChatCreate(title, _): return TelegramMediaAction(action: .groupCreated(title: title)) case .messageActionChatDeletePhoto: return TelegramMediaAction(action: .photoUpdated(image: nil)) case let .messageActionChatDeleteUser(userId): - return TelegramMediaAction(action: .removedMembers(peerIds: [PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt32Value(userId))])) + return TelegramMediaAction(action: .removedMembers(peerIds: [PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt64Value(userId))])) case let .messageActionChatEditPhoto(photo): return TelegramMediaAction(action: .photoUpdated(image: telegramMediaImageFromApiPhoto(photo))) case let .messageActionChatEditTitle(title): return TelegramMediaAction(action: .titleUpdated(title: title)) case let .messageActionChatJoinedByLink(inviterId): - return TelegramMediaAction(action: .joinedByLink(inviter: PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt32Value(inviterId)))) + return TelegramMediaAction(action: .joinedByLink(inviter: PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt64Value(inviterId)))) case let .messageActionChatMigrateTo(channelId): - return TelegramMediaAction(action: .groupMigratedToChannel(channelId: PeerId(namespace: Namespaces.Peer.CloudChannel, id: PeerId.Id._internalFromInt32Value(channelId)))) + return TelegramMediaAction(action: .groupMigratedToChannel(channelId: PeerId(namespace: Namespaces.Peer.CloudChannel, id: PeerId.Id._internalFromInt64Value(channelId)))) case .messageActionHistoryClear: return TelegramMediaAction(action: .historyCleared) case .messageActionPinMessage: @@ -67,7 +67,7 @@ func telegramMediaActionFromApiAction(_ action: Api.MessageAction) -> TelegramMe switch call { case let .inputGroupCall(id, accessHash): return TelegramMediaAction(action: .inviteToGroupPhoneCall(callId: id, accessHash: accessHash, peerIds: userIds.map { userId in - PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt32Value(userId)) + PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt64Value(userId)) })) } case let .messageActionSetMessagesTTL(period): diff --git a/submodules/TelegramCore/Sources/ApiUtils/TelegramMediaPoll.swift b/submodules/TelegramCore/Sources/ApiUtils/TelegramMediaPoll.swift index 0316add8e5..dfa545f2cd 100644 --- a/submodules/TelegramCore/Sources/ApiUtils/TelegramMediaPoll.swift +++ b/submodules/TelegramCore/Sources/ApiUtils/TelegramMediaPoll.swift @@ -35,7 +35,7 @@ extension TelegramMediaPollResults { } self.init(voters: results.flatMap({ $0.map(TelegramMediaPollOptionVoters.init(apiVoters:)) }), totalVoters: totalVoters, recentVoters: recentVoters.flatMap { recentVoters in - return recentVoters.map { PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt32Value($0)) } + return recentVoters.map { PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt64Value($0)) } } ?? [], solution: parsedSolution) } } diff --git a/submodules/TelegramCore/Sources/ApiUtils/TelegramUser.swift b/submodules/TelegramCore/Sources/ApiUtils/TelegramUser.swift index 822edcf0e1..38bc91b459 100644 --- a/submodules/TelegramCore/Sources/ApiUtils/TelegramUser.swift +++ b/submodules/TelegramCore/Sources/ApiUtils/TelegramUser.swift @@ -69,9 +69,9 @@ extension TelegramUser { let restrictionInfo: PeerAccessRestrictionInfo? = restrictionReason.flatMap(PeerAccessRestrictionInfo.init(apiReasons:)) - self.init(id: PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt32Value(id)), accessHash: accessHashValue, firstName: firstName, lastName: lastName, username: username, phone: phone, photo: representations, botInfo: botInfo, restrictionInfo: restrictionInfo, flags: userFlags) + self.init(id: PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt64Value(id)), accessHash: accessHashValue, firstName: firstName, lastName: lastName, username: username, phone: phone, photo: representations, botInfo: botInfo, restrictionInfo: restrictionInfo, flags: userFlags) case let .userEmpty(id): - self.init(id: PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt32Value(id)), accessHash: nil, firstName: nil, lastName: nil, username: nil, phone: nil, photo: [], botInfo: nil, restrictionInfo: nil, flags: []) + self.init(id: PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt64Value(id)), accessHash: nil, firstName: nil, lastName: nil, username: nil, phone: nil, photo: [], botInfo: nil, restrictionInfo: nil, flags: []) } } diff --git a/submodules/TelegramCore/Sources/MacOS/GroupReturnAndLeft.swift b/submodules/TelegramCore/Sources/MacOS/GroupReturnAndLeft.swift index 5073e42342..452366babe 100644 --- a/submodules/TelegramCore/Sources/MacOS/GroupReturnAndLeft.swift +++ b/submodules/TelegramCore/Sources/MacOS/GroupReturnAndLeft.swift @@ -9,7 +9,7 @@ public func returnGroup(account: Account, peerId: PeerId) -> Signal take(1) |> mapToSignal { peer -> Signal in if let inputUser = apiInputUser(peer) { - return account.network.request(Api.functions.messages.addChatUser(chatId: peerId.id._internalGetInt32Value(), userId: inputUser, fwdLimit: 50)) + return account.network.request(Api.functions.messages.addChatUser(chatId: peerId.id._internalGetInt64Value(), userId: inputUser, fwdLimit: 50)) |> retryRequest |> mapToSignal { updates -> Signal in account.stateManager.addUpdates(updates) @@ -26,7 +26,7 @@ public func leftGroup(account: Account, peerId: PeerId) -> Signal |> take(1) |> mapToSignal { peer -> Signal in if let inputUser = apiInputUser(peer) { - return account.network.request(Api.functions.messages.deleteChatUser(flags: 0, chatId: peerId.id._internalGetInt32Value(), userId: inputUser)) + return account.network.request(Api.functions.messages.deleteChatUser(flags: 0, chatId: peerId.id._internalGetInt64Value(), userId: inputUser)) |> retryRequest |> mapToSignal { updates -> Signal in account.stateManager.addUpdates(updates) diff --git a/submodules/TelegramCore/Sources/Network/Network.swift b/submodules/TelegramCore/Sources/Network/Network.swift index d374004222..00d91651f6 100644 --- a/submodules/TelegramCore/Sources/Network/Network.swift +++ b/submodules/TelegramCore/Sources/Network/Network.swift @@ -473,16 +473,7 @@ func initializedNetwork(accountId: AccountRecordId, arguments: NetworkInitializa } } - let useTempAuthKeys: Bool - if let networkSettings = networkSettings { - if let userEnableTempKeys = networkSettings.userEnableTempKeys { - useTempAuthKeys = userEnableTempKeys - } else { - useTempAuthKeys = networkSettings.defaultEnableTempKeys - } - } else { - useTempAuthKeys = true - } + let useTempAuthKeys: Bool = true var contextValue: MTContext? sharedContexts.with { store in @@ -506,7 +497,8 @@ func initializedNetwork(accountId: AccountRecordId, arguments: NetworkInitializa if testingEnvironment { seedAddressList = [ 1: ["149.154.175.10"], - 2: ["149.154.167.40"] + 2: ["149.154.167.40"], + 3: ["149.154.175.117"] ] } else { seedAddressList = [ diff --git a/submodules/TelegramCore/Sources/PeerStatistics.swift b/submodules/TelegramCore/Sources/PeerStatistics.swift index f3282247c4..adb54cbb4a 100644 --- a/submodules/TelegramCore/Sources/PeerStatistics.swift +++ b/submodules/TelegramCore/Sources/PeerStatistics.swift @@ -1064,7 +1064,7 @@ extension GroupStatsTopPoster { init(apiStatsGroupTopPoster: Api.StatsGroupTopPoster) { switch apiStatsGroupTopPoster { case let .statsGroupTopPoster(userId, messages, avgChars): - self = GroupStatsTopPoster(peerId: PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt32Value(userId)), messageCount: messages, averageChars: avgChars) + self = GroupStatsTopPoster(peerId: PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt64Value(userId)), messageCount: messages, averageChars: avgChars) } } } @@ -1073,7 +1073,7 @@ extension GroupStatsTopAdmin { init(apiStatsGroupTopAdmin: Api.StatsGroupTopAdmin) { switch apiStatsGroupTopAdmin { case let .statsGroupTopAdmin(userId, deleted, kicked, banned): - self = GroupStatsTopAdmin(peerId: PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt32Value(userId)), deletedCount: deleted, kickedCount: kicked, bannedCount: banned) + self = GroupStatsTopAdmin(peerId: PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt64Value(userId)), deletedCount: deleted, kickedCount: kicked, bannedCount: banned) } } } @@ -1082,7 +1082,7 @@ extension GroupStatsTopInviter { init(apiStatsGroupTopInviter: Api.StatsGroupTopInviter) { switch apiStatsGroupTopInviter { case let .statsGroupTopInviter(userId, invitations): - self = GroupStatsTopInviter(peerId: PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt32Value(userId)), inviteCount: invitations) + self = GroupStatsTopInviter(peerId: PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt64Value(userId)), inviteCount: invitations) } } } diff --git a/submodules/TelegramCore/Sources/PendingMessages/StandaloneUploadedMedia.swift b/submodules/TelegramCore/Sources/PendingMessages/StandaloneUploadedMedia.swift index 8f2e3a2516..d5c485279c 100644 --- a/submodules/TelegramCore/Sources/PendingMessages/StandaloneUploadedMedia.swift +++ b/submodules/TelegramCore/Sources/PendingMessages/StandaloneUploadedMedia.swift @@ -86,7 +86,7 @@ public func standaloneUploadedImage(account: Account, peerId: PeerId, text: Stri case let .inputSecretFile(file, _, key): return account.postbox.transaction { transaction -> Api.InputEncryptedChat? in if let peer = transaction.getPeer(peerId) as? TelegramSecretChat { - return Api.InputEncryptedChat.inputEncryptedChat(chatId: peer.id.id._internalGetInt32Value(), accessHash: peer.accessHash) + return Api.InputEncryptedChat.inputEncryptedChat(chatId: Int32(peer.id.id._internalGetInt64Value()), accessHash: peer.accessHash) } return nil } @@ -180,7 +180,7 @@ public func standaloneUploadedFile(account: Account, peerId: PeerId, text: Strin case let .inputSecretFile(file, _, key): return account.postbox.transaction { transaction -> Api.InputEncryptedChat? in if let peer = transaction.getPeer(peerId) as? TelegramSecretChat { - return Api.InputEncryptedChat.inputEncryptedChat(chatId: peer.id.id._internalGetInt32Value(), accessHash: peer.accessHash) + return Api.InputEncryptedChat.inputEncryptedChat(chatId: Int32(peer.id.id._internalGetInt64Value()), accessHash: peer.accessHash) } return nil } diff --git a/submodules/TelegramCore/Sources/SecretChats/SecretChatIncomingEncryptedOperation.swift b/submodules/TelegramCore/Sources/SecretChats/SecretChatIncomingEncryptedOperation.swift index ac12d5a720..f1b08a934c 100644 --- a/submodules/TelegramCore/Sources/SecretChats/SecretChatIncomingEncryptedOperation.swift +++ b/submodules/TelegramCore/Sources/SecretChats/SecretChatIncomingEncryptedOperation.swift @@ -16,9 +16,9 @@ extension SecretChatIncomingEncryptedOperation { convenience init(message: Api.EncryptedMessage) { switch message { case let .encryptedMessage(randomId, chatId, date, bytes, file): - self.init(peerId: PeerId(namespace: Namespaces.Peer.SecretChat, id: PeerId.Id._internalFromInt32Value(chatId)), globallyUniqueId: randomId, timestamp: date, type: .message, keyFingerprint: keyFingerprintFromBytes(bytes), contents: MemoryBuffer(bytes), mediaFileReference: SecretChatFileReference(file)) + self.init(peerId: PeerId(namespace: Namespaces.Peer.SecretChat, id: PeerId.Id._internalFromInt64Value(Int64(chatId))), globallyUniqueId: randomId, timestamp: date, type: .message, keyFingerprint: keyFingerprintFromBytes(bytes), contents: MemoryBuffer(bytes), mediaFileReference: SecretChatFileReference(file)) case let .encryptedMessageService(randomId, chatId, date, bytes): - self.init(peerId: PeerId(namespace: Namespaces.Peer.SecretChat, id: PeerId.Id._internalFromInt32Value(chatId)), globallyUniqueId: randomId, timestamp: date, type: .service, keyFingerprint: keyFingerprintFromBytes(bytes), contents: MemoryBuffer(bytes), mediaFileReference: nil) + self.init(peerId: PeerId(namespace: Namespaces.Peer.SecretChat, id: PeerId.Id._internalFromInt64Value(Int64(chatId))), globallyUniqueId: randomId, timestamp: date, type: .service, keyFingerprint: keyFingerprintFromBytes(bytes), contents: MemoryBuffer(bytes), mediaFileReference: nil) } } } diff --git a/submodules/TelegramCore/Sources/SecretChats/UpdateSecretChat.swift b/submodules/TelegramCore/Sources/SecretChats/UpdateSecretChat.swift index 5aa27b54f2..759ee4495d 100644 --- a/submodules/TelegramCore/Sources/SecretChats/UpdateSecretChat.swift +++ b/submodules/TelegramCore/Sources/SecretChats/UpdateSecretChat.swift @@ -18,7 +18,7 @@ func updateSecretChat(encryptionProvider: EncryptionProvider, accountPeerId: Pee assert((currentPeer == nil) == (currentState == nil)) switch chat { case let .encryptedChat(_, _, _, adminId, _, gAOrB, remoteKeyFingerprint): - if let currentPeer = currentPeer, let currentState = currentState, adminId == accountPeerId.id._internalGetInt32Value() { + if let currentPeer = currentPeer, let currentState = currentState, adminId == accountPeerId.id._internalGetInt64Value() { if case let .handshake(handshakeState) = currentState.embeddedState, case let .requested(_, p, a) = handshakeState { let pData = p.makeData() let aData = a.makeData() @@ -87,7 +87,7 @@ func updateSecretChat(encryptionProvider: EncryptionProvider, accountPeerId: Pee case .encryptedChatEmpty(_): break case let .encryptedChatRequested(_, folderId, _, accessHash, date, adminId, participantId, gA): - if currentPeer == nil && participantId == accountPeerId.id._internalGetInt32Value() { + if currentPeer == nil && participantId == accountPeerId.id._internalGetInt64Value() { if settings.acceptOnThisDevice { let state = SecretChatState(role: .participant, embeddedState: .handshake(.accepting), keychain: SecretChatKeychain(keys: []), keyFingerprint: nil, messageAutoremoveTimeout: nil) @@ -98,7 +98,7 @@ func updateSecretChat(encryptionProvider: EncryptionProvider, accountPeerId: Pee let updatedState = addSecretChatOutgoingOperation(transaction: transaction, peerId: chat.peerId, operation: .initialHandshakeAccept(gA: MemoryBuffer(gA), accessHash: accessHash, b: b), state: state) transaction.setPeerChatState(chat.peerId, state: updatedState) - let peer = TelegramSecretChat(id: chat.peerId, creationDate: date, regularPeerId: PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt32Value(adminId)), accessHash: accessHash, role: updatedState.role, embeddedState: updatedState.embeddedState.peerState, messageAutoremoveTimeout: nil) + let peer = TelegramSecretChat(id: chat.peerId, creationDate: date, regularPeerId: PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt64Value(adminId)), accessHash: accessHash, role: updatedState.role, embeddedState: updatedState.embeddedState.peerState, messageAutoremoveTimeout: nil) updatePeers(transaction: transaction, peers: [peer], update: { _, updated in return updated }) if folderId != nil { transaction.updatePeerChatListInclusion(peer.id, inclusion: .ifHasMessagesOrOneOf(groupId: Namespaces.PeerGroup.archive, pinningIndex: nil, minTimestamp: date)) @@ -121,9 +121,9 @@ func updateSecretChat(encryptionProvider: EncryptionProvider, accountPeerId: Pee Logger.shared.log("State", "got encryptedChatRequested, but peer already exists or this account is creator") } case let .encryptedChatWaiting(_, accessHash, date, adminId, participantId): - if let requestData = requestData, currentPeer == nil && adminId == accountPeerId.id._internalGetInt32Value() { + if let requestData = requestData, currentPeer == nil && adminId == accountPeerId.id._internalGetInt64Value() { let state = SecretChatState(role: .creator, embeddedState: .handshake(.requested(g: requestData.g, p: requestData.p, a: requestData.a)), keychain: SecretChatKeychain(keys: []), keyFingerprint: nil, messageAutoremoveTimeout: nil) - let peer = TelegramSecretChat(id: chat.peerId, creationDate: date, regularPeerId: PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt32Value(participantId)), accessHash: accessHash, role: state.role, embeddedState: state.embeddedState.peerState, messageAutoremoveTimeout: nil) + let peer = TelegramSecretChat(id: chat.peerId, creationDate: date, regularPeerId: PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt64Value(participantId)), accessHash: accessHash, role: state.role, embeddedState: state.embeddedState.peerState, messageAutoremoveTimeout: nil) updatePeers(transaction: transaction, peers: [peer], update: { _, updated in return updated }) transaction.setPeerChatState(peer.id, state: state) transaction.resetIncomingReadStates([peer.id: [ diff --git a/submodules/TelegramCore/Sources/Settings/AutodownloadSettings.swift b/submodules/TelegramCore/Sources/Settings/AutodownloadSettings.swift index 9d10248914..e4f0e64c89 100644 --- a/submodules/TelegramCore/Sources/Settings/AutodownloadSettings.swift +++ b/submodules/TelegramCore/Sources/Settings/AutodownloadSettings.swift @@ -8,12 +8,12 @@ public func updateAutodownloadSettingsInteractively(accountManager: AccountManag return accountManager.transaction { transaction -> Void in transaction.updateSharedData(SharedDataKeys.autodownloadSettings, { entry in let currentSettings: AutodownloadSettings - if let entry = entry as? AutodownloadSettings { + if let entry = entry?.get(AutodownloadSettings.self) { currentSettings = entry } else { currentSettings = AutodownloadSettings.defaultSettings } - return f(currentSettings) + return PreferencesEntry(f(currentSettings)) }) } } diff --git a/submodules/TelegramCore/Sources/Settings/CacheStorageSettings.swift b/submodules/TelegramCore/Sources/Settings/CacheStorageSettings.swift index 271caf26f6..0ecd9b9e9e 100644 --- a/submodules/TelegramCore/Sources/Settings/CacheStorageSettings.swift +++ b/submodules/TelegramCore/Sources/Settings/CacheStorageSettings.swift @@ -7,12 +7,12 @@ public func updateCacheStorageSettingsInteractively(accountManager: AccountManag return accountManager.transaction { transaction -> Void in transaction.updateSharedData(SharedDataKeys.cacheStorageSettings, { entry in let currentSettings: CacheStorageSettings - if let entry = entry as? CacheStorageSettings { + if let entry = entry?.get(CacheStorageSettings.self) { currentSettings = entry } else { currentSettings = CacheStorageSettings.defaultSettings } - return f(currentSettings) + return PreferencesEntry(f(currentSettings)) }) } } diff --git a/submodules/TelegramCore/Sources/Settings/ContentPrivacySettings.swift b/submodules/TelegramCore/Sources/Settings/ContentPrivacySettings.swift index d189f84ab9..02487dc5c5 100644 --- a/submodules/TelegramCore/Sources/Settings/ContentPrivacySettings.swift +++ b/submodules/TelegramCore/Sources/Settings/ContentPrivacySettings.swift @@ -8,12 +8,12 @@ public func updateContentPrivacySettings(postbox: Postbox, _ f: @escaping (Conte return postbox.transaction { transaction -> Void in var updated: ContentPrivacySettings? transaction.updatePreferencesEntry(key: PreferencesKeys.contentPrivacySettings, { current in - if let current = current as? ContentPrivacySettings { + if let current = current?.get(ContentPrivacySettings.self) { updated = f(current) - return updated + return PreferencesEntry(updated) } else { updated = f(ContentPrivacySettings.defaultSettings) - return updated + return PreferencesEntry(updated) } }) } diff --git a/submodules/TelegramCore/Sources/Settings/LimitsConfiguration.swift b/submodules/TelegramCore/Sources/Settings/LimitsConfiguration.swift index b4df728d36..1293b20df3 100644 --- a/submodules/TelegramCore/Sources/Settings/LimitsConfiguration.swift +++ b/submodules/TelegramCore/Sources/Settings/LimitsConfiguration.swift @@ -3,7 +3,7 @@ import Postbox public func currentLimitsConfiguration(transaction: Transaction) -> LimitsConfiguration { - if let entry = transaction.getPreferencesEntry(key: PreferencesKeys.limitsConfiguration) as? LimitsConfiguration { + if let entry = transaction.getPreferencesEntry(key: PreferencesKeys.limitsConfiguration)?.get(LimitsConfiguration.self) { return entry } else { return LimitsConfiguration.defaultValue @@ -11,7 +11,7 @@ public func currentLimitsConfiguration(transaction: Transaction) -> LimitsConfig } func updateLimitsConfiguration(transaction: Transaction, configuration: LimitsConfiguration) { - if !currentLimitsConfiguration(transaction: transaction).isEqual(to: configuration) { - transaction.setPreferencesEntry(key: PreferencesKeys.limitsConfiguration, value: configuration) + if currentLimitsConfiguration(transaction: transaction) != configuration { + transaction.setPreferencesEntry(key: PreferencesKeys.limitsConfiguration, value: PreferencesEntry(configuration)) } } diff --git a/submodules/TelegramCore/Sources/Settings/LoggingSettings.swift b/submodules/TelegramCore/Sources/Settings/LoggingSettings.swift index f6e240824e..0d8e30c83a 100644 --- a/submodules/TelegramCore/Sources/Settings/LoggingSettings.swift +++ b/submodules/TelegramCore/Sources/Settings/LoggingSettings.swift @@ -7,12 +7,12 @@ public func updateLoggingSettings(accountManager: AccountManager Void in var updated: LoggingSettings? transaction.updateSharedData(SharedDataKeys.loggingSettings, { current in - if let current = current as? LoggingSettings { + if let current = current?.get(LoggingSettings.self) { updated = f(current) - return updated + return PreferencesEntry(updated) } else { updated = f(LoggingSettings.defaultSettings) - return updated + return PreferencesEntry(updated) } }) diff --git a/submodules/TelegramCore/Sources/Settings/NetworkSettings.swift b/submodules/TelegramCore/Sources/Settings/NetworkSettings.swift index 92f42158a5..5f67d7969d 100644 --- a/submodules/TelegramCore/Sources/Settings/NetworkSettings.swift +++ b/submodules/TelegramCore/Sources/Settings/NetworkSettings.swift @@ -20,7 +20,7 @@ public func updateNetworkSettingsInteractively(transaction: Transaction, network var updateNetwork = false var updatedSettings: NetworkSettings? transaction.updatePreferencesEntry(key: PreferencesKeys.networkSettings, { current in - let previous = (current as? NetworkSettings) ?? NetworkSettings.defaultSettings + let previous = current?.get(NetworkSettings.self) ?? NetworkSettings.defaultSettings let updated = f(previous) updatedSettings = updated if updated.reducedBackupDiscoveryTimeout != previous.reducedBackupDiscoveryTimeout { @@ -29,7 +29,7 @@ public func updateNetworkSettingsInteractively(transaction: Transaction, network if updated.backupHostOverride != previous.backupHostOverride { updateNetwork = true } - return updated + return PreferencesEntry(updated) }) if let network = network, updateNetwork, let updatedSettings = updatedSettings { diff --git a/submodules/TelegramCore/Sources/Settings/PrivacySettings.swift b/submodules/TelegramCore/Sources/Settings/PrivacySettings.swift index 07aed7e121..c4e99bdb74 100644 --- a/submodules/TelegramCore/Sources/Settings/PrivacySettings.swift +++ b/submodules/TelegramCore/Sources/Settings/PrivacySettings.swift @@ -161,7 +161,7 @@ extension SelectivePrivacySettings { current = .enableContacts(enableFor: [:], disableFor: [:]) case let .privacyValueAllowUsers(users): for id in users { - if let peer = peers[PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt32Value(id))] { + if let peer = peers[PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt64Value(id))] { enableFor[peer.peer.id] = peer } } @@ -171,13 +171,13 @@ extension SelectivePrivacySettings { break case let .privacyValueDisallowUsers(users): for id in users { - if let peer = peers[PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt32Value(id))] { + if let peer = peers[PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt64Value(id))] { disableFor[peer.peer.id] = peer } } case let .privacyValueAllowChatParticipants(chats): for id in chats { - for possibleId in [PeerId(namespace: Namespaces.Peer.CloudGroup, id: PeerId.Id._internalFromInt32Value(id)), PeerId(namespace: Namespaces.Peer.CloudChannel, id: PeerId.Id._internalFromInt32Value(id))] { + for possibleId in [PeerId(namespace: Namespaces.Peer.CloudGroup, id: PeerId.Id._internalFromInt64Value(id)), PeerId(namespace: Namespaces.Peer.CloudChannel, id: PeerId.Id._internalFromInt64Value(id))] { if let peer = peers[possibleId] { enableFor[peer.peer.id] = peer } @@ -185,7 +185,7 @@ extension SelectivePrivacySettings { } case let .privacyValueDisallowChatParticipants(chats): for id in chats { - for possibleId in [PeerId(namespace: Namespaces.Peer.CloudGroup, id: PeerId.Id._internalFromInt32Value(id)), PeerId(namespace: Namespaces.Peer.CloudChannel, id: PeerId.Id._internalFromInt32Value(id))] { + for possibleId in [PeerId(namespace: Namespaces.Peer.CloudGroup, id: PeerId.Id._internalFromInt64Value(id)), PeerId(namespace: Namespaces.Peer.CloudChannel, id: PeerId.Id._internalFromInt64Value(id))] { if let peer = peers[possibleId] { disableFor[peer.peer.id] = peer } diff --git a/submodules/TelegramCore/Sources/Settings/ProxySettings.swift b/submodules/TelegramCore/Sources/Settings/ProxySettings.swift index 4316c1206a..bc0f85e20f 100644 --- a/submodules/TelegramCore/Sources/Settings/ProxySettings.swift +++ b/submodules/TelegramCore/Sources/Settings/ProxySettings.swift @@ -23,10 +23,10 @@ extension ProxyServerSettings { public func updateProxySettingsInteractively(transaction: AccountManagerModifier, _ f: @escaping (ProxySettings) -> ProxySettings) -> Bool { var hasChanges = false transaction.updateSharedData(SharedDataKeys.proxySettings, { current in - let previous = (current as? ProxySettings) ?? ProxySettings.defaultSettings + let previous = current?.get(ProxySettings.self) ?? ProxySettings.defaultSettings let updated = f(previous) hasChanges = previous != updated - return updated + return PreferencesEntry(updated) }) return hasChanges } diff --git a/submodules/TelegramCore/Sources/Settings/VoipConfiguration.swift b/submodules/TelegramCore/Sources/Settings/VoipConfiguration.swift index 6c34f4bb1f..ef603dc5ba 100644 --- a/submodules/TelegramCore/Sources/Settings/VoipConfiguration.swift +++ b/submodules/TelegramCore/Sources/Settings/VoipConfiguration.swift @@ -1,7 +1,7 @@ import Postbox public func currentVoipConfiguration(transaction: Transaction) -> VoipConfiguration { - if let entry = transaction.getPreferencesEntry(key: PreferencesKeys.voipConfiguration) as? VoipConfiguration { + if let entry = transaction.getPreferencesEntry(key: PreferencesKeys.voipConfiguration)?.get(VoipConfiguration.self) { return entry } else { return VoipConfiguration.defaultValue @@ -12,6 +12,6 @@ func updateVoipConfiguration(transaction: Transaction, _ f: (VoipConfiguration) let current = currentVoipConfiguration(transaction: transaction) let updated = f(current) if updated != current { - transaction.setPreferencesEntry(key: PreferencesKeys.voipConfiguration, value: updated) + transaction.setPreferencesEntry(key: PreferencesKeys.voipConfiguration, value: PreferencesEntry(updated)) } } diff --git a/submodules/TelegramCore/Sources/State/AccountStateManagementUtils.swift b/submodules/TelegramCore/Sources/State/AccountStateManagementUtils.swift index 788cf10fb5..0cff5f6b0a 100644 --- a/submodules/TelegramCore/Sources/State/AccountStateManagementUtils.swift +++ b/submodules/TelegramCore/Sources/State/AccountStateManagementUtils.swift @@ -22,7 +22,7 @@ private func peerIdsFromUpdateGroups(_ groups: [UpdateGroup]) -> Set { } switch group { case let .updateChannelPts(channelId, _, _): - peerIds.insert(PeerId(namespace: Namespaces.Peer.CloudChannel, id: PeerId.Id._internalFromInt32Value(channelId))) + peerIds.insert(PeerId(namespace: Namespaces.Peer.CloudChannel, id: PeerId.Id._internalFromInt64Value(channelId))) default: break } @@ -76,7 +76,7 @@ private func peerIdsRequiringLocalChatStateFromUpdates(_ updates: [Api.Update]) } switch update { case let .updateChannelTooLong(_, channelId, _): - let peerId = PeerId(namespace: Namespaces.Peer.CloudChannel, id: PeerId.Id._internalFromInt32Value(channelId)) + let peerId = PeerId(namespace: Namespaces.Peer.CloudChannel, id: PeerId.Id._internalFromInt64Value(channelId)) peerIds.insert(peerId) case let .updateFolderPeers(folderPeers, _, _): for peer in folderPeers { @@ -86,7 +86,7 @@ private func peerIdsRequiringLocalChatStateFromUpdates(_ updates: [Api.Update]) } } case let .updateReadChannelInbox(_, _, channelId, _, _, _): - peerIds.insert(PeerId(namespace: Namespaces.Peer.CloudChannel, id: PeerId.Id._internalFromInt32Value(channelId))) + peerIds.insert(PeerId(namespace: Namespaces.Peer.CloudChannel, id: PeerId.Id._internalFromInt64Value(channelId))) case let .updateReadHistoryInbox(_, _, peer, _, _, _, _): peerIds.insert(peer.peerId) case let .updateDraftMessage(peer, draft): @@ -113,7 +113,7 @@ private func peerIdsRequiringLocalChatStateFromUpdateGroups(_ groups: [UpdateGro for update in group.updates { switch update { case let .updateChannel(channelId): - channelUpdates.insert(PeerId(namespace: Namespaces.Peer.CloudChannel, id: PeerId.Id._internalFromInt32Value(channelId))) + channelUpdates.insert(PeerId(namespace: Namespaces.Peer.CloudChannel, id: PeerId.Id._internalFromInt64Value(channelId))) default: break } @@ -146,7 +146,7 @@ private func locallyGeneratedMessageTimestampsFromUpdateGroups(_ groups: [Update switch update { case let .updateServiceNotification(_, date, _, _, _, _): if let date = date { - let peerId = PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt32Value(777000)) + let peerId = PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt64Value(777000)) if messageTimestamps[peerId] == nil { messageTimestamps[peerId] = [(Namespaces.Message.Local, date)] } else { @@ -302,7 +302,7 @@ private func peerIdsRequiringLocalChatStateFromDifference(_ difference: Api.upda } switch update { case let .updateChannelTooLong(_, channelId, _): - let peerId = PeerId(namespace: Namespaces.Peer.CloudChannel, id: PeerId.Id._internalFromInt32Value(channelId)) + let peerId = PeerId(namespace: Namespaces.Peer.CloudChannel, id: PeerId.Id._internalFromInt64Value(channelId)) peerIds.insert(peerId) default: break @@ -324,7 +324,7 @@ private func peerIdsRequiringLocalChatStateFromDifference(_ difference: Api.upda } switch update { case let .updateChannelTooLong(_, channelId, _): - let peerId = PeerId(namespace: Namespaces.Peer.CloudChannel, id: PeerId.Id._internalFromInt32Value(channelId)) + let peerId = PeerId(namespace: Namespaces.Peer.CloudChannel, id: PeerId.Id._internalFromInt64Value(channelId)) peerIds.insert(peerId) default: break @@ -357,7 +357,7 @@ private func locallyGeneratedMessageTimestampsFromDifference(_ difference: Api.u switch update { case let .updateServiceNotification(_, date, _, _, _, _): if let date = date { - let peerId = PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt32Value(777000)) + let peerId = PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt64Value(777000)) if messageTimestamps[peerId] == nil { messageTimestamps[peerId] = [(Namespaces.Message.Local, date)] } else { @@ -683,21 +683,21 @@ private func sortedUpdates(_ updates: [Api.Update]) -> [Api.Update] { for update in updates { switch update { case let .updateChannelTooLong(_, channelId, _): - let peerId = PeerId(namespace: Namespaces.Peer.CloudChannel, id: PeerId.Id._internalFromInt32Value(channelId)) + let peerId = PeerId(namespace: Namespaces.Peer.CloudChannel, id: PeerId.Id._internalFromInt64Value(channelId)) if updatesByChannel[peerId] == nil { updatesByChannel[peerId] = [update] } else { updatesByChannel[peerId]!.append(update) } case let .updateDeleteChannelMessages(channelId, _, _, _): - let peerId = PeerId(namespace: Namespaces.Peer.CloudChannel, id: PeerId.Id._internalFromInt32Value(channelId)) + let peerId = PeerId(namespace: Namespaces.Peer.CloudChannel, id: PeerId.Id._internalFromInt64Value(channelId)) if updatesByChannel[peerId] == nil { updatesByChannel[peerId] = [update] } else { updatesByChannel[peerId]!.append(update) } case let .updatePinnedChannelMessages(_, channelId, _, _, _): - let peerId = PeerId(namespace: Namespaces.Peer.CloudChannel, id: PeerId.Id._internalFromInt32Value(channelId)) + let peerId = PeerId(namespace: Namespaces.Peer.CloudChannel, id: PeerId.Id._internalFromInt64Value(channelId)) if updatesByChannel[peerId] == nil { updatesByChannel[peerId] = [update] } else { @@ -724,14 +724,14 @@ private func sortedUpdates(_ updates: [Api.Update]) -> [Api.Update] { otherUpdates.append(update) } case let .updateChannelWebPage(channelId, _, _, _): - let peerId = PeerId(namespace: Namespaces.Peer.CloudChannel, id: PeerId.Id._internalFromInt32Value(channelId)) + let peerId = PeerId(namespace: Namespaces.Peer.CloudChannel, id: PeerId.Id._internalFromInt64Value(channelId)) if updatesByChannel[peerId] == nil { updatesByChannel[peerId] = [update] } else { updatesByChannel[peerId]!.append(update) } case let .updateChannelAvailableMessages(channelId, _): - let peerId = PeerId(namespace: Namespaces.Peer.CloudChannel, id: PeerId.Id._internalFromInt32Value(channelId)) + let peerId = PeerId(namespace: Namespaces.Peer.CloudChannel, id: PeerId.Id._internalFromInt64Value(channelId)) if updatesByChannel[peerId] == nil { updatesByChannel[peerId] = [update] } else { @@ -816,7 +816,7 @@ private func finalStateWithUpdatesAndServerTime(postbox: Postbox, network: Netwo for update in sortedUpdates(updates) { switch update { case let .updateChannelTooLong(_, channelId, channelPts): - let peerId = PeerId(namespace: Namespaces.Peer.CloudChannel, id: PeerId.Id._internalFromInt32Value(channelId)) + let peerId = PeerId(namespace: Namespaces.Peer.CloudChannel, id: PeerId.Id._internalFromInt64Value(channelId)) if !channelsToPoll.contains(peerId) { if let channelPts = channelPts, let channelState = state.channelStates[peerId], channelState.pts >= channelPts { Logger.shared.log("State", "channel \(peerId) (\((updatedState.peers[peerId] as? TelegramChannel)?.title ?? "nil")) skip updateChannelTooLong by pts") @@ -825,7 +825,7 @@ private func finalStateWithUpdatesAndServerTime(postbox: Postbox, network: Netwo } } case let .updateDeleteChannelMessages(channelId, messages, pts: pts, ptsCount): - let peerId = PeerId(namespace: Namespaces.Peer.CloudChannel, id: PeerId.Id._internalFromInt32Value(channelId)) + let peerId = PeerId(namespace: Namespaces.Peer.CloudChannel, id: PeerId.Id._internalFromInt64Value(channelId)) if let previousState = updatedState.channelStates[peerId] { if previousState.pts >= pts { Logger.shared.log("State", "channel \(peerId) (\((updatedState.peers[peerId] as? TelegramChannel)?.title ?? "nil")) skip old delete update") @@ -876,7 +876,7 @@ private func finalStateWithUpdatesAndServerTime(postbox: Postbox, network: Netwo Logger.shared.log("State", "Invalid updateEditChannelMessage") } case let .updateChannelWebPage(channelId, apiWebpage, pts, ptsCount): - let peerId = PeerId(namespace: Namespaces.Peer.CloudChannel, id: PeerId.Id._internalFromInt32Value(channelId)) + let peerId = PeerId(namespace: Namespaces.Peer.CloudChannel, id: PeerId.Id._internalFromInt64Value(channelId)) if let previousState = updatedState.channelStates[peerId] { if previousState.pts >= pts { } else if previousState.pts + ptsCount == pts { @@ -902,7 +902,7 @@ private func finalStateWithUpdatesAndServerTime(postbox: Postbox, network: Netwo } } case let .updateChannelAvailableMessages(channelId, minId): - let peerId = PeerId(namespace: Namespaces.Peer.CloudChannel, id: PeerId.Id._internalFromInt32Value(channelId)) + let peerId = PeerId(namespace: Namespaces.Peer.CloudChannel, id: PeerId.Id._internalFromInt64Value(channelId)) updatedState.updateMinAvailableMessage(MessageId(peerId: peerId, namespace: Namespaces.Message.Cloud, id: minId)) case let .updateDeleteMessages(messages, _, _): updatedState.deleteMessagesWithGlobalIds(messages) @@ -979,7 +979,7 @@ private func finalStateWithUpdatesAndServerTime(postbox: Postbox, network: Netwo if popup { updatedState.addDisplayAlert(text, isDropAuth: type.hasPrefix("AUTH_KEY_DROP_")) } else if let date = date { - let peerId = PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt32Value(777000)) + let peerId = PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt64Value(777000)) if updatedState.peers[peerId] == nil { updatedState.updatePeer(peerId, { peer in @@ -1028,13 +1028,13 @@ private func finalStateWithUpdatesAndServerTime(postbox: Postbox, network: Netwo } } case let .updateReadChannelInbox(_, folderId, channelId, maxId, stillUnreadCount, pts): - updatedState.resetIncomingReadState(groupId: PeerGroupId(rawValue: folderId ?? 0), peerId: PeerId(namespace: Namespaces.Peer.CloudChannel, id: PeerId.Id._internalFromInt32Value(channelId)), namespace: Namespaces.Message.Cloud, maxIncomingReadId: maxId, count: stillUnreadCount, pts: pts) + updatedState.resetIncomingReadState(groupId: PeerGroupId(rawValue: folderId ?? 0), peerId: PeerId(namespace: Namespaces.Peer.CloudChannel, id: PeerId.Id._internalFromInt64Value(channelId)), namespace: Namespaces.Message.Cloud, maxIncomingReadId: maxId, count: stillUnreadCount, pts: pts) case let .updateReadChannelOutbox(channelId, maxId): - updatedState.readOutbox(MessageId(peerId: PeerId(namespace: Namespaces.Peer.CloudChannel, id: PeerId.Id._internalFromInt32Value(channelId)), namespace: Namespaces.Message.Cloud, id: maxId), timestamp: nil) + updatedState.readOutbox(MessageId(peerId: PeerId(namespace: Namespaces.Peer.CloudChannel, id: PeerId.Id._internalFromInt64Value(channelId)), namespace: Namespaces.Message.Cloud, id: maxId), timestamp: nil) case let .updateChannel(channelId): - updatedState.addExternallyUpdatedPeerId(PeerId(namespace: Namespaces.Peer.CloudChannel, id: PeerId.Id._internalFromInt32Value(channelId))) + updatedState.addExternallyUpdatedPeerId(PeerId(namespace: Namespaces.Peer.CloudChannel, id: PeerId.Id._internalFromInt64Value(channelId))) case let .updateChat(chatId): - updatedState.addExternallyUpdatedPeerId(PeerId(namespace: Namespaces.Peer.CloudGroup, id: PeerId.Id._internalFromInt32Value(chatId))) + updatedState.addExternallyUpdatedPeerId(PeerId(namespace: Namespaces.Peer.CloudGroup, id: PeerId.Id._internalFromInt64Value(chatId))) case let .updateReadHistoryInbox(_, folderId, peer, maxId, stillUnreadCount, pts, _): updatedState.resetIncomingReadState(groupId: PeerGroupId(rawValue: folderId ?? 0), peerId: peer.peerId, namespace: Namespaces.Message.Cloud, maxIncomingReadId: maxId, count: stillUnreadCount, pts: pts) case let .updateReadHistoryOutbox(peer, maxId, _, _): @@ -1042,11 +1042,11 @@ private func finalStateWithUpdatesAndServerTime(postbox: Postbox, network: Netwo case let .updateReadChannelDiscussionInbox(_, channelId, topMsgId, readMaxId, mainChannelId, mainChannelPost): var mainChannelMessage: MessageId? if let mainChannelId = mainChannelId, let mainChannelPost = mainChannelPost { - mainChannelMessage = MessageId(peerId: PeerId(namespace: Namespaces.Peer.CloudChannel, id: PeerId.Id._internalFromInt32Value(mainChannelId)), namespace: Namespaces.Message.Cloud, id: mainChannelPost) + mainChannelMessage = MessageId(peerId: PeerId(namespace: Namespaces.Peer.CloudChannel, id: PeerId.Id._internalFromInt64Value(mainChannelId)), namespace: Namespaces.Message.Cloud, id: mainChannelPost) } - updatedState.readThread(threadMessageId: MessageId(peerId: PeerId(namespace: Namespaces.Peer.CloudChannel, id: PeerId.Id._internalFromInt32Value(channelId)), namespace: Namespaces.Message.Cloud, id: topMsgId), readMaxId: readMaxId, isIncoming: true, mainChannelMessage: mainChannelMessage) + updatedState.readThread(threadMessageId: MessageId(peerId: PeerId(namespace: Namespaces.Peer.CloudChannel, id: PeerId.Id._internalFromInt64Value(channelId)), namespace: Namespaces.Message.Cloud, id: topMsgId), readMaxId: readMaxId, isIncoming: true, mainChannelMessage: mainChannelMessage) case let .updateReadChannelDiscussionOutbox(channelId, topMsgId, readMaxId): - updatedState.readThread(threadMessageId: MessageId(peerId: PeerId(namespace: Namespaces.Peer.CloudChannel, id: PeerId.Id._internalFromInt32Value(channelId)), namespace: Namespaces.Message.Cloud, id: topMsgId), readMaxId: readMaxId, isIncoming: false, mainChannelMessage: nil) + updatedState.readThread(threadMessageId: MessageId(peerId: PeerId(namespace: Namespaces.Peer.CloudChannel, id: PeerId.Id._internalFromInt64Value(channelId)), namespace: Namespaces.Message.Cloud, id: topMsgId), readMaxId: readMaxId, isIncoming: false, mainChannelMessage: nil) case let .updateDialogUnreadMark(flags, peer): switch peer { case let .dialogPeer(peer): @@ -1080,9 +1080,9 @@ private func finalStateWithUpdatesAndServerTime(postbox: Postbox, network: Netwo let groupPeerId: PeerId switch participants { case let .chatParticipants(chatId, _, _): - groupPeerId = PeerId(namespace: Namespaces.Peer.CloudGroup, id: PeerId.Id._internalFromInt32Value(chatId)) + groupPeerId = PeerId(namespace: Namespaces.Peer.CloudGroup, id: PeerId.Id._internalFromInt64Value(chatId)) case let .chatParticipantsForbidden(_, chatId, _): - groupPeerId = PeerId(namespace: Namespaces.Peer.CloudGroup, id: PeerId.Id._internalFromInt32Value(chatId)) + groupPeerId = PeerId(namespace: Namespaces.Peer.CloudGroup, id: PeerId.Id._internalFromInt64Value(chatId)) } updatedState.updateCachedPeerData(groupPeerId, { current in let previous: CachedGroupData @@ -1094,9 +1094,9 @@ private func finalStateWithUpdatesAndServerTime(postbox: Postbox, network: Netwo return previous.withUpdatedParticipants(CachedGroupParticipants(apiParticipants: participants)) }) case let .updateChatParticipantAdd(chatId, userId, inviterId, date, _): - let groupPeerId = PeerId(namespace: Namespaces.Peer.CloudGroup, id: PeerId.Id._internalFromInt32Value(chatId)) - let userPeerId = PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt32Value(userId)) - let inviterPeerId = PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt32Value(inviterId)) + let groupPeerId = PeerId(namespace: Namespaces.Peer.CloudGroup, id: PeerId.Id._internalFromInt64Value(chatId)) + let userPeerId = PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt64Value(userId)) + let inviterPeerId = PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt64Value(inviterId)) updatedState.updateCachedPeerData(groupPeerId, { current in if let current = current as? CachedGroupData, let participants = current.participants { var updatedParticipants = participants.participants @@ -1109,8 +1109,8 @@ private func finalStateWithUpdatesAndServerTime(postbox: Postbox, network: Netwo } }) case let .updateChatParticipantDelete(chatId, userId, _): - let groupPeerId = PeerId(namespace: Namespaces.Peer.CloudGroup, id: PeerId.Id._internalFromInt32Value(chatId)) - let userPeerId = PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt32Value(userId)) + let groupPeerId = PeerId(namespace: Namespaces.Peer.CloudGroup, id: PeerId.Id._internalFromInt64Value(chatId)) + let userPeerId = PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt64Value(userId)) updatedState.updateCachedPeerData(groupPeerId, { current in if let current = current as? CachedGroupData, let participants = current.participants { var updatedParticipants = participants.participants @@ -1123,8 +1123,8 @@ private func finalStateWithUpdatesAndServerTime(postbox: Postbox, network: Netwo } }) case let .updateChatParticipantAdmin(chatId, userId, isAdmin, _): - let groupPeerId = PeerId(namespace: Namespaces.Peer.CloudGroup, id: PeerId.Id._internalFromInt32Value(chatId)) - let userPeerId = PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt32Value(userId)) + let groupPeerId = PeerId(namespace: Namespaces.Peer.CloudGroup, id: PeerId.Id._internalFromInt64Value(chatId)) + let userPeerId = PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt64Value(userId)) updatedState.updateCachedPeerData(groupPeerId, { current in if let current = current as? CachedGroupData, let participants = current.participants { var updatedParticipants = participants.participants @@ -1155,12 +1155,12 @@ private func finalStateWithUpdatesAndServerTime(postbox: Postbox, network: Netwo } }) case let .updatePinnedChannelMessages(flags, channelId, messages, pts, ptsCount): - let peerId = PeerId(namespace: Namespaces.Peer.CloudChannel, id: PeerId.Id._internalFromInt32Value(channelId)) + let peerId = PeerId(namespace: Namespaces.Peer.CloudChannel, id: PeerId.Id._internalFromInt64Value(channelId)) if let previousState = updatedState.channelStates[peerId] { if previousState.pts >= pts { Logger.shared.log("State", "channel \(peerId) (\((updatedState.peers[peerId] as? TelegramChannel)?.title ?? "nil")) skip old pinned messages update") } else if previousState.pts + ptsCount == pts { - let channelPeerId = PeerId(namespace: Namespaces.Peer.CloudChannel, id: PeerId.Id._internalFromInt32Value(channelId)) + let channelPeerId = PeerId(namespace: Namespaces.Peer.CloudChannel, id: PeerId.Id._internalFromInt64Value(channelId)) updatedState.updateMessagesPinned(ids: messages.map { id in MessageId(peerId: channelPeerId, namespace: Namespaces.Message.Cloud, id: id) }, pinned: (flags & (1 << 0)) != 0) @@ -1189,10 +1189,10 @@ private func finalStateWithUpdatesAndServerTime(postbox: Postbox, network: Netwo return previous.withUpdatedIsBlocked(blocked == .boolTrue) }) case let .updateUserStatus(userId, status): - updatedState.mergePeerPresences([PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt32Value(userId)): status], explicit: true) + updatedState.mergePeerPresences([PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt64Value(userId)): status], explicit: true) case let .updateUserName(userId, firstName, lastName, username): //TODO add contact checking for apply first and last name - updatedState.updatePeer(PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt32Value(userId)), { peer in + updatedState.updatePeer(PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt64Value(userId)), { peer in if let user = peer as? TelegramUser { return user.withUpdatedUsername(username) } else { @@ -1200,7 +1200,7 @@ private func finalStateWithUpdatesAndServerTime(postbox: Postbox, network: Netwo } }) case let .updateUserPhoto(userId, _, photo, _): - updatedState.updatePeer(PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt32Value(userId)), { peer in + updatedState.updatePeer(PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt64Value(userId)), { peer in if let user = peer as? TelegramUser { return user.withUpdatedPhoto(parsedTelegramProfilePhoto(photo)) } else { @@ -1208,7 +1208,7 @@ private func finalStateWithUpdatesAndServerTime(postbox: Postbox, network: Netwo } }) case let .updateUserPhone(userId, phone): - updatedState.updatePeer(PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt32Value(userId)), { peer in + updatedState.updatePeer(PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt64Value(userId)), { peer in if let user = peer as? TelegramUser { return user.withUpdatedPhone(phone.isEmpty ? nil : phone) } else { @@ -1251,7 +1251,7 @@ private func finalStateWithUpdatesAndServerTime(postbox: Postbox, network: Netwo case let .updateNewEncryptedMessage(message, _): updatedState.addSecretMessages([message]) case let .updateEncryptedMessagesRead(chatId, maxDate, date): - updatedState.readSecretOutbox(peerId: PeerId(namespace: Namespaces.Peer.SecretChat, id: PeerId.Id._internalFromInt32Value(chatId)), timestamp: maxDate, actionTimestamp: date) + updatedState.readSecretOutbox(peerId: PeerId(namespace: Namespaces.Peer.SecretChat, id: PeerId.Id._internalFromInt64Value(Int64(chatId))), timestamp: maxDate, actionTimestamp: date) case let .updateUserTyping(userId, type): if let date = updatesDate, date + 60 > serverTime { let activity = PeerInputActivity(apiType: type, timestamp: date) @@ -1260,7 +1260,7 @@ private func finalStateWithUpdatesAndServerTime(postbox: Postbox, network: Netwo category = .voiceChat } - updatedState.addPeerInputActivity(chatPeerId: PeerActivitySpace(peerId: PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt32Value(userId)), category: category), peerId: PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt32Value(userId)), activity: activity) + updatedState.addPeerInputActivity(chatPeerId: PeerActivitySpace(peerId: PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt64Value(userId)), category: category), peerId: PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt64Value(userId)), activity: activity) } case let .updateChatUserTyping(chatId, userId, type): if let date = updatesDate, date + 60 > serverTime { @@ -1270,11 +1270,11 @@ private func finalStateWithUpdatesAndServerTime(postbox: Postbox, network: Netwo category = .voiceChat } - updatedState.addPeerInputActivity(chatPeerId: PeerActivitySpace(peerId: PeerId(namespace: Namespaces.Peer.CloudGroup, id: PeerId.Id._internalFromInt32Value(chatId)), category: category), peerId: userId.peerId, activity: activity) + updatedState.addPeerInputActivity(chatPeerId: PeerActivitySpace(peerId: PeerId(namespace: Namespaces.Peer.CloudGroup, id: PeerId.Id._internalFromInt64Value(chatId)), category: category), peerId: userId.peerId, activity: activity) } case let .updateChannelUserTyping(_, channelId, topMsgId, userId, type): if let date = updatesDate, date + 60 > serverTime { - let channelPeerId = PeerId(namespace: Namespaces.Peer.CloudChannel, id: PeerId.Id._internalFromInt32Value(channelId)) + let channelPeerId = PeerId(namespace: Namespaces.Peer.CloudChannel, id: PeerId.Id._internalFromInt64Value(channelId)) let threadId = topMsgId.flatMap { makeMessageThreadId(MessageId(peerId: channelPeerId, namespace: Namespaces.Message.Cloud, id: $0)) } let activity = PeerInputActivity(apiType: type, timestamp: date) @@ -1289,7 +1289,7 @@ private func finalStateWithUpdatesAndServerTime(postbox: Postbox, network: Netwo } case let .updateEncryptedChatTyping(chatId): if let date = updatesDate, date + 60 > serverTime { - updatedState.addPeerInputActivity(chatPeerId: PeerActivitySpace(peerId: PeerId(namespace: Namespaces.Peer.SecretChat, id: PeerId.Id._internalFromInt32Value(chatId)), category: .global), peerId: nil, activity: .typingText) + updatedState.addPeerInputActivity(chatPeerId: PeerActivitySpace(peerId: PeerId(namespace: Namespaces.Peer.SecretChat, id: PeerId.Id._internalFromInt64Value(Int64(chatId))), category: .global), peerId: nil, activity: .typingText) } case let .updateDialogPinned(flags, folderId, peer): let groupId: PeerGroupId = folderId.flatMap(PeerGroupId.init(rawValue:)) ?? .root @@ -1324,9 +1324,9 @@ private func finalStateWithUpdatesAndServerTime(postbox: Postbox, network: Netwo case let .updateReadMessagesContents(messages, _, _): updatedState.addReadMessagesContents((nil, messages)) case let .updateChannelReadMessagesContents(channelId, messages): - updatedState.addReadMessagesContents((PeerId(namespace: Namespaces.Peer.CloudChannel, id: PeerId.Id._internalFromInt32Value(channelId)), messages)) + updatedState.addReadMessagesContents((PeerId(namespace: Namespaces.Peer.CloudChannel, id: PeerId.Id._internalFromInt64Value(channelId)), messages)) case let .updateChannelMessageViews(channelId, id, views): - updatedState.addUpdateMessageImpressionCount(id: MessageId(peerId: PeerId(namespace: Namespaces.Peer.CloudChannel, id: PeerId.Id._internalFromInt32Value(channelId)), namespace: Namespaces.Message.Cloud, id: id), count: views) + updatedState.addUpdateMessageImpressionCount(id: MessageId(peerId: PeerId(namespace: Namespaces.Peer.CloudChannel, id: PeerId.Id._internalFromInt64Value(channelId)), namespace: Namespaces.Message.Cloud, id: id), count: views) /*case let .updateChannelMessageForwards(channelId, id, forwards): updatedState.addUpdateMessageForwardsCount(id: MessageId(peerId: PeerId(namespace: Namespaces.Peer.CloudChannel, id: channelId), namespace: Namespaces.Message.Cloud, id: id), count: forwards)*/ case let .updateNewStickerSet(stickerset): @@ -1366,8 +1366,8 @@ private func finalStateWithUpdatesAndServerTime(postbox: Postbox, network: Netwo updatedState.updateGroupCallParticipants(id: id, accessHash: accessHash, participants: participants, version: version) } case let .updateGroupCall(channelId, call): - updatedState.updateGroupCall(peerId: PeerId(namespace: Namespaces.Peer.CloudChannel, id: PeerId.Id._internalFromInt32Value(channelId)), call: call) - updatedState.updateGroupCall(peerId: PeerId(namespace: Namespaces.Peer.CloudGroup, id: PeerId.Id._internalFromInt32Value(channelId)), call: call) + updatedState.updateGroupCall(peerId: PeerId(namespace: Namespaces.Peer.CloudChannel, id: PeerId.Id._internalFromInt64Value(channelId)), call: call) + updatedState.updateGroupCall(peerId: PeerId(namespace: Namespaces.Peer.CloudGroup, id: PeerId.Id._internalFromInt64Value(channelId)), call: call) case let .updatePeerHistoryTTL(_, peer, ttl): updatedState.updateAutoremoveTimeout(peer: peer, value: CachedPeerAutoremoveTimeout.Value(ttl)) case let .updateLangPackTooLong(langCode): @@ -1422,7 +1422,7 @@ private func finalStateWithUpdatesAndServerTime(postbox: Postbox, network: Netwo case let .updateDialogFilter(_, id, filter): updatedState.addUpdateChatListFilter(id: id, filter: filter) case let .updateBotCommands(peer, botId, apiCommands): - let botPeerId = PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt32Value(botId)) + let botPeerId = PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt64Value(botId)) let commands: [BotCommand] = apiCommands.map { command in switch command { case let .botCommand(command, description): @@ -1988,7 +1988,7 @@ private func pollChannel(network: Network, peer: Peer, state: AccountMutableStat Logger.shared.log("State", "Invalid updateEditChannelMessage") } case let .updatePinnedChannelMessages(flags, channelId, messages, _, _): - let channelPeerId = PeerId(namespace: Namespaces.Peer.CloudChannel, id: PeerId.Id._internalFromInt32Value(channelId)) + let channelPeerId = PeerId(namespace: Namespaces.Peer.CloudChannel, id: PeerId.Id._internalFromInt64Value(channelId)) updatedState.updateMessagesPinned(ids: messages.map { id in MessageId(peerId: channelPeerId, namespace: Namespaces.Message.Cloud, id: id) }, pinned: (flags & (1 << 0)) != 0) @@ -2808,35 +2808,35 @@ func replayFinalState(accountManager: AccountManager AppChangelogState) { transaction.updatePreferencesEntry(key: PreferencesKeys.appChangelogState, { current in - return f((current as? AppChangelogState) ?? AppChangelogState.default) + return PreferencesEntry(f((current as? AppChangelogState) ?? AppChangelogState.default)) }) } diff --git a/submodules/TelegramCore/Sources/State/AppConfiguration.swift b/submodules/TelegramCore/Sources/State/AppConfiguration.swift index 73b8a16032..0eb76d360e 100644 --- a/submodules/TelegramCore/Sources/State/AppConfiguration.swift +++ b/submodules/TelegramCore/Sources/State/AppConfiguration.swift @@ -1,7 +1,7 @@ import Postbox private func currentAppConfiguration(transaction: Transaction) -> AppConfiguration { - if let entry = transaction.getPreferencesEntry(key: PreferencesKeys.appConfiguration) as? AppConfiguration { + if let entry = transaction.getPreferencesEntry(key: PreferencesKeys.appConfiguration)?.get(AppConfiguration.self) { return entry } else { return AppConfiguration.defaultValue @@ -12,6 +12,6 @@ func updateAppConfiguration(transaction: Transaction, _ f: (AppConfiguration) -> let current = currentAppConfiguration(transaction: transaction) let updated = f(current) if updated != current { - transaction.setPreferencesEntry(key: PreferencesKeys.appConfiguration, value: updated) + transaction.setPreferencesEntry(key: PreferencesKeys.appConfiguration, value: PreferencesEntry(updated)) } } diff --git a/submodules/TelegramCore/Sources/State/CallSessionManager.swift b/submodules/TelegramCore/Sources/State/CallSessionManager.swift index 4d884ade9f..82ed3e0ab0 100644 --- a/submodules/TelegramCore/Sources/State/CallSessionManager.swift +++ b/submodules/TelegramCore/Sources/State/CallSessionManager.swift @@ -819,7 +819,7 @@ private final class CallSessionManagerContext { versions = libraryVersions } if self.contextIdByStableId[id] == nil { - let internalId = self.addIncoming(peerId: PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt32Value(adminId)), stableId: id, accessHash: accessHash, timestamp: date, gAHash: gAHash.makeData(), versions: versions, isVideo: isVideo) + let internalId = self.addIncoming(peerId: PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt64Value(adminId)), stableId: id, accessHash: accessHash, timestamp: date, gAHash: gAHash.makeData(), versions: versions, isVideo: isVideo) if let internalId = internalId { var resultRingingStateValue: CallSessionRingingState? for ringingState in self.ringingStatesValue() { diff --git a/submodules/TelegramCore/Sources/State/ChannelState.swift b/submodules/TelegramCore/Sources/State/ChannelState.swift index a8a60781ec..41cf6ec493 100644 --- a/submodules/TelegramCore/Sources/State/ChannelState.swift +++ b/submodules/TelegramCore/Sources/State/ChannelState.swift @@ -17,11 +17,11 @@ func channelUpdatesByPeerId(updates: [ChannelUpdate]) -> [PeerId: [ChannelUpdate case let .updateNewChannelMessage(message, _, _): peerId = apiMessagePeerId(message) case let .updateDeleteChannelMessages(channelId, _, _, _): - peerId = PeerId(namespace: Namespaces.Peer.CloudChannel, id: PeerId.Id._internalFromInt32Value(channelId)) + peerId = PeerId(namespace: Namespaces.Peer.CloudChannel, id: PeerId.Id._internalFromInt64Value(channelId)) case let .updateEditChannelMessage(message, _, _): peerId = apiMessagePeerId(message) case let .updateChannelWebPage(channelId, _, _, _): - peerId = PeerId(namespace: Namespaces.Peer.CloudChannel, id: PeerId.Id._internalFromInt32Value(channelId)) + peerId = PeerId(namespace: Namespaces.Peer.CloudChannel, id: PeerId.Id._internalFromInt64Value(channelId)) default: break } diff --git a/submodules/TelegramCore/Sources/State/ContactSyncManager.swift b/submodules/TelegramCore/Sources/State/ContactSyncManager.swift index dc8fd6edfe..c7ceaded56 100644 --- a/submodules/TelegramCore/Sources/State/ContactSyncManager.swift +++ b/submodules/TelegramCore/Sources/State/ContactSyncManager.swift @@ -344,7 +344,7 @@ private func pushDeviceContactData(postbox: Postbox, network: Network, contacts: for item in imported { switch item { case let .importedContact(userId, _): - addedContactPeerIds.insert(PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt32Value(userId))) + addedContactPeerIds.insert(PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt64Value(userId))) } } for item in retryContacts { @@ -398,7 +398,7 @@ private func updateContactPresences(postbox: Postbox, network: Network, accountP for status in statuses { switch status { case let .contactStatus(userId, status): - peerPresences[PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt32Value(userId))] = TelegramUserPresence(apiStatus: status) + peerPresences[PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt64Value(userId))] = TelegramUserPresence(apiStatus: status) } } updatePeerPresences(transaction: transaction, accountPeerId: accountPeerId, peerPresences: peerPresences) diff --git a/submodules/TelegramCore/Sources/State/FetchChatList.swift b/submodules/TelegramCore/Sources/State/FetchChatList.swift index 933f493ccf..3bf3163eeb 100644 --- a/submodules/TelegramCore/Sources/State/FetchChatList.swift +++ b/submodules/TelegramCore/Sources/State/FetchChatList.swift @@ -112,11 +112,11 @@ private func parseDialogs(apiDialogs: [Api.Dialog], apiMessages: [Api.Message], let peerId: PeerId switch apiPeer { case let .peerUser(userId): - peerId = PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt32Value(userId)) + peerId = PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt64Value(userId)) case let .peerChat(chatId): - peerId = PeerId(namespace: Namespaces.Peer.CloudGroup, id: PeerId.Id._internalFromInt32Value(chatId)) + peerId = PeerId(namespace: Namespaces.Peer.CloudGroup, id: PeerId.Id._internalFromInt64Value(chatId)) case let .peerChannel(channelId): - peerId = PeerId(namespace: Namespaces.Peer.CloudChannel, id: PeerId.Id._internalFromInt32Value(channelId)) + peerId = PeerId(namespace: Namespaces.Peer.CloudChannel, id: PeerId.Id._internalFromInt64Value(channelId)) } if readStates[peerId] == nil { @@ -200,7 +200,7 @@ struct FetchedChatList { let peerGroupIds: [PeerId: PeerGroupId] } -func fetchChatList(postbox: Postbox, network: Network, location: FetchChatListLocation, upperBound: MessageIndex, hash: Int32, limit: Int32) -> Signal { +func fetchChatList(postbox: Postbox, network: Network, location: FetchChatListLocation, upperBound: MessageIndex, hash: Int64, limit: Int32) -> Signal { return postbox.stateView() |> mapToSignal { view -> Signal in if let state = view.state as? AuthorizedAccountState { diff --git a/submodules/TelegramCore/Sources/State/HistoryViewStateValidation.swift b/submodules/TelegramCore/Sources/State/HistoryViewStateValidation.swift index cdfa7ccda3..ea190a7647 100644 --- a/submodules/TelegramCore/Sources/State/HistoryViewStateValidation.swift +++ b/submodules/TelegramCore/Sources/State/HistoryViewStateValidation.swift @@ -382,13 +382,14 @@ final class HistoryViewStateValidationContexts { } } -private func hashForScheduledMessages(_ messages: [Message]) -> Int32 { - var acc: UInt32 = 0 +private func hashForScheduledMessages(_ messages: [Message]) -> Int64 { + var acc: UInt64 = 0 let sorted = messages.sorted(by: { $0.timestamp > $1.timestamp }) for message in sorted { - acc = (acc &* 20261) &+ UInt32(message.id.id) + combineInt64Hash(&acc, with: UInt64(message.id.id)) + var editTimestamp: Int32 = 0 inner: for attribute in message.attributes { if let attribute = attribute as? EditedMessageAttribute { @@ -396,23 +397,40 @@ private func hashForScheduledMessages(_ messages: [Message]) -> Int32 { break inner } } - acc = (acc &* 20261) &+ UInt32(editTimestamp) - acc = (acc &* 20261) &+ UInt32(message.timestamp) + combineInt64Hash(&acc, with: UInt64(editTimestamp)) + combineInt64Hash(&acc, with: UInt64(message.timestamp)) } - return Int32(bitPattern: acc & UInt32(0x7FFFFFFF)) + return finalizeInt64Hash(acc) } -private func hashForMessages(_ messages: [Message], withChannelIds: Bool) -> Int32 { - var acc: UInt32 = 0 +public func combineInt64Hash(_ acc: inout UInt64, with value: UInt64) { + acc ^= (acc >> 21) + acc ^= (acc << 35) + acc ^= (acc >> 4) + acc = acc &+ value +} + +public func combineInt64Hash(_ acc: inout UInt64, with peerId: PeerId) { + let value = UInt64(bitPattern: peerId.id._internalGetInt64Value()) + combineInt64Hash(&acc, with: value) +} + +public func finalizeInt64Hash(_ acc: UInt64) -> Int64 { + return Int64(bitPattern: acc) +} + +private func hashForMessages(_ messages: [Message], withChannelIds: Bool) -> Int64 { + var acc: UInt64 = 0 let sorted = messages.sorted(by: { $0.index > $1.index }) for message in sorted { if withChannelIds { - acc = (acc &* 20261) &+ UInt32(message.id.peerId.id._internalGetInt32Value()) + combineInt64Hash(&acc, with: message.id.peerId) } - - acc = (acc &* 20261) &+ UInt32(message.id.id) + + combineInt64Hash(&acc, with: UInt64(message.id.id)) + var timestamp = message.timestamp inner: for attribute in message.attributes { if let attribute = attribute as? EditedMessageAttribute { @@ -421,22 +439,22 @@ private func hashForMessages(_ messages: [Message], withChannelIds: Bool) -> Int } } if message.tags.contains(.pinned) { - acc = (acc &* 20261) &+ UInt32(1) + combineInt64Hash(&acc, with: UInt64(1)) } - acc = (acc &* 20261) &+ UInt32(timestamp) + combineInt64Hash(&acc, with: UInt64(timestamp)) } - return Int32(bitPattern: acc & UInt32(0x7FFFFFFF)) + return finalizeInt64Hash(acc) } -private func hashForMessages(_ messages: [StoreMessage], withChannelIds: Bool) -> Int32 { - var acc: UInt32 = 0 +private func hashForMessages(_ messages: [StoreMessage], withChannelIds: Bool) -> Int64 { + var acc: UInt64 = 0 for message in messages { if case let .Id(id) = message.id { if withChannelIds { - acc = (acc &* 20261) &+ UInt32(id.peerId.id._internalGetInt32Value()) + combineInt64Hash(&acc, with: id.peerId) } - acc = (acc &* 20261) &+ UInt32(id.id) + combineInt64Hash(&acc, with: UInt64(id.id)) var timestamp = message.timestamp inner: for attribute in message.attributes { if let attribute = attribute as? EditedMessageAttribute { @@ -444,10 +462,10 @@ private func hashForMessages(_ messages: [StoreMessage], withChannelIds: Bool) - break inner } } - acc = (acc &* 20261) &+ UInt32(timestamp) + combineInt64Hash(&acc, with: UInt64(timestamp)) } } - return Int32(bitPattern: acc & UInt32(0x7FFFFFFF)) + return finalizeInt64Hash(acc) } private enum ValidatedMessages { diff --git a/submodules/TelegramCore/Sources/State/Holes.swift b/submodules/TelegramCore/Sources/State/Holes.swift index 492af14958..24a1d0ced5 100644 --- a/submodules/TelegramCore/Sources/State/Holes.swift +++ b/submodules/TelegramCore/Sources/State/Holes.swift @@ -173,7 +173,7 @@ func fetchMessageHistoryHole(accountPeerId: PeerId, source: FetchMessageHistoryH } |> take(1) |> mapToSignal { _ -> Signal in - return postbox.transaction { transaction -> (Api.InputPeer?, Int32) in + return postbox.transaction { transaction -> (Api.InputPeer?, Int64) in switch peerInput { case let .direct(peerId, _): return (transaction.getPeer(peerId).flatMap(forceApiInputPeer), 0) @@ -572,13 +572,13 @@ func fetchMessageHistoryHole(accountPeerId: PeerId, source: FetchMessageHistoryH func groupBoundaryPeer(_ peerId: PeerId, accountPeerId: PeerId) -> Api.Peer { switch peerId.namespace { case Namespaces.Peer.CloudUser: - return Api.Peer.peerUser(userId: peerId.id._internalGetInt32Value()) + return Api.Peer.peerUser(userId: peerId.id._internalGetInt64Value()) case Namespaces.Peer.CloudGroup: - return Api.Peer.peerChat(chatId: peerId.id._internalGetInt32Value()) + return Api.Peer.peerChat(chatId: peerId.id._internalGetInt64Value()) case Namespaces.Peer.CloudChannel: - return Api.Peer.peerChannel(channelId: peerId.id._internalGetInt32Value()) + return Api.Peer.peerChannel(channelId: peerId.id._internalGetInt64Value()) default: - return Api.Peer.peerUser(userId: accountPeerId.id._internalGetInt32Value()) + return Api.Peer.peerUser(userId: accountPeerId.id._internalGetInt64Value()) } } diff --git a/submodules/TelegramCore/Sources/State/ManagedCloudChatRemoveMessagesOperations.swift b/submodules/TelegramCore/Sources/State/ManagedCloudChatRemoveMessagesOperations.swift index 3888eb3484..94012f9a5e 100644 --- a/submodules/TelegramCore/Sources/State/ManagedCloudChatRemoveMessagesOperations.swift +++ b/submodules/TelegramCore/Sources/State/ManagedCloudChatRemoveMessagesOperations.swift @@ -176,7 +176,7 @@ private func removeMessages(postbox: Postbox, network: Network, stateManager: Ac if let result = result { switch result { case let .affectedMessages(pts, ptsCount): - stateManager.addUpdateGroups([.updateChannelPts(channelId: peer.id.id._internalGetInt32Value(), pts: pts, ptsCount: ptsCount)]) + stateManager.addUpdateGroups([.updateChannelPts(channelId: peer.id.id._internalGetInt64Value(), pts: pts, ptsCount: ptsCount)]) } } return .complete() @@ -266,7 +266,7 @@ private func removeChat(transaction: Transaction, postbox: Postbox, network: Net } else if peer.id.namespace == Namespaces.Peer.CloudGroup { let deleteUser: Signal if operation.deleteGloballyIfPossible { - deleteUser = network.request(Api.functions.messages.deleteChat(chatId: peer.id.id._internalGetInt32Value())) + deleteUser = network.request(Api.functions.messages.deleteChat(chatId: peer.id.id._internalGetInt64Value())) |> `catch` { _ in return .single(.boolFalse) } @@ -274,7 +274,7 @@ private func removeChat(transaction: Transaction, postbox: Postbox, network: Net return .complete() } } else { - deleteUser = network.request(Api.functions.messages.deleteChatUser(flags: 0, chatId: peer.id.id._internalGetInt32Value(), userId: Api.InputUser.inputUserSelf)) + deleteUser = network.request(Api.functions.messages.deleteChatUser(flags: 0, chatId: peer.id.id._internalGetInt64Value(), userId: Api.InputUser.inputUserSelf)) |> map { result -> Api.Updates? in return result } diff --git a/submodules/TelegramCore/Sources/State/ManagedConfigurationUpdates.swift b/submodules/TelegramCore/Sources/State/ManagedConfigurationUpdates.swift index 2453192284..657ff3f395 100644 --- a/submodules/TelegramCore/Sources/State/ManagedConfigurationUpdates.swift +++ b/submodules/TelegramCore/Sources/State/ManagedConfigurationUpdates.swift @@ -35,13 +35,10 @@ func managedConfigurationUpdates(accountManager: AccountManager GlobalNotificationSettingsSet) -> Signal { return postbox.transaction { transaction -> Void in transaction.updatePreferencesEntry(key: PreferencesKeys.globalNotifications, { current in - if let current = current as? GlobalNotificationSettings { - return GlobalNotificationSettings(toBeSynchronized: f(current.effective), remote: current.remote) + if let current = current?.get(GlobalNotificationSettings.self) { + return PreferencesEntry(GlobalNotificationSettings(toBeSynchronized: f(current.effective), remote: current.remote)) } else { let settings = f(GlobalNotificationSettingsSet.defaultSettings) - return GlobalNotificationSettings(toBeSynchronized: settings, remote: settings) + return PreferencesEntry(GlobalNotificationSettings(toBeSynchronized: settings, remote: settings)) } }) } @@ -56,7 +56,7 @@ private enum SynchronizeGlobalSettingsData: Equatable { func managedGlobalNotificationSettings(postbox: Postbox, network: Network) -> Signal { let data = postbox.preferencesView(keys: [PreferencesKeys.globalNotifications]) |> map { view -> SynchronizeGlobalSettingsData in - if let preferences = view.values[PreferencesKeys.globalNotifications] as? GlobalNotificationSettings { + if let preferences = view.values[PreferencesKeys.globalNotifications]?.get(GlobalNotificationSettings.self) { if let settings = preferences.toBeSynchronized { return .push(settings) } else { @@ -77,10 +77,10 @@ func managedGlobalNotificationSettings(postbox: Postbox, network: Network) -> Si |> mapToSignal { settings -> Signal in return postbox.transaction { transaction -> Void in transaction.updatePreferencesEntry(key: PreferencesKeys.globalNotifications, { current in - if let current = current as? GlobalNotificationSettings { - return GlobalNotificationSettings(toBeSynchronized: current.toBeSynchronized, remote: settings) + if let current = current?.get(GlobalNotificationSettings.self) { + return PreferencesEntry(GlobalNotificationSettings(toBeSynchronized: current.toBeSynchronized, remote: settings)) } else { - return GlobalNotificationSettings(toBeSynchronized: nil, remote: settings) + return PreferencesEntry(GlobalNotificationSettings(toBeSynchronized: nil, remote: settings)) } }) } @@ -89,8 +89,8 @@ func managedGlobalNotificationSettings(postbox: Postbox, network: Network) -> Si return pushedNotificationSettings(network: network, settings: settings) |> then(postbox.transaction { transaction -> Void in transaction.updatePreferencesEntry(key: PreferencesKeys.globalNotifications, { current in - if let current = current as? GlobalNotificationSettings, current.toBeSynchronized == settings { - return GlobalNotificationSettings(toBeSynchronized: nil, remote: settings) + if let current = current?.get(GlobalNotificationSettings.self), current.toBeSynchronized == settings { + return PreferencesEntry(GlobalNotificationSettings(toBeSynchronized: nil, remote: settings)) } else { return current } diff --git a/submodules/TelegramCore/Sources/State/ManagedLocalInputActivities.swift b/submodules/TelegramCore/Sources/State/ManagedLocalInputActivities.swift index b0c73b6652..f06531a28b 100644 --- a/submodules/TelegramCore/Sources/State/ManagedLocalInputActivities.swift +++ b/submodules/TelegramCore/Sources/State/ManagedLocalInputActivities.swift @@ -186,7 +186,7 @@ private func requestActivity(postbox: Postbox, network: Network, accountPeerId: } } else if let peer = peer as? TelegramSecretChat, activity == .typingText { let _ = PeerId(peer.id.toInt64()) - return network.request(Api.functions.messages.setEncryptedTyping(peer: .inputEncryptedChat(chatId: peer.id.id._internalGetInt32Value(), accessHash: peer.accessHash), typing: .boolTrue)) + return network.request(Api.functions.messages.setEncryptedTyping(peer: .inputEncryptedChat(chatId: Int32(peer.id.id._internalGetInt64Value()), accessHash: peer.accessHash), typing: .boolTrue)) |> `catch` { _ -> Signal in return .single(.boolFalse) } diff --git a/submodules/TelegramCore/Sources/State/ManagedLocalizationUpdatesOperations.swift b/submodules/TelegramCore/Sources/State/ManagedLocalizationUpdatesOperations.swift index 182f8787a3..99977c2d8c 100644 --- a/submodules/TelegramCore/Sources/State/ManagedLocalizationUpdatesOperations.swift +++ b/submodules/TelegramCore/Sources/State/ManagedLocalizationUpdatesOperations.swift @@ -118,7 +118,7 @@ private enum SynchronizeLocalizationUpdatesError { func getLocalization(_ transaction: AccountManagerModifier) -> (primary: (code: String, version: Int32, entries: [LocalizationEntry]), secondary: (code: String, version: Int32, entries: [LocalizationEntry])?) { let localizationSettings: LocalizationSettings? - if let current = transaction.getSharedData(SharedDataKeys.localizationSettings) as? LocalizationSettings { + if let current = transaction.getSharedData(SharedDataKeys.localizationSettings)?.get(LocalizationSettings.self) { localizationSettings = current } else { localizationSettings = nil @@ -170,7 +170,7 @@ private func synchronizeLocalizationUpdates(accountManager: AccountManager Signal in let (primary, secondary) = getLocalization(transaction) - var currentSettings = transaction.getSharedData(SharedDataKeys.localizationSettings) as? LocalizationSettings ?? LocalizationSettings(primaryComponent: LocalizationComponent(languageCode: "en", localizedName: "English", localization: Localization(version: 0, entries: []), customPluralizationCode: nil), secondaryComponent: nil) + var currentSettings = transaction.getSharedData(SharedDataKeys.localizationSettings)?.get(LocalizationSettings.self) ?? LocalizationSettings(primaryComponent: LocalizationComponent(languageCode: "en", localizedName: "English", localization: Localization(version: 0, entries: []), customPluralizationCode: nil), secondaryComponent: nil) for difference in parsedDifferences { let current: (isPrimary: Bool, entries: [LocalizationEntry]) @@ -208,12 +208,11 @@ private func synchronizeLocalizationUpdates(accountManager: AccountManager mapError { _ -> SynchronizeLocalizationUpdatesError in - return .reset } |> switchToLatest } @@ -282,7 +281,7 @@ func tryApplyingLanguageDifference(transaction: AccountManagerModifier Int32 { - var acc: UInt32 = 0 +private func hashForIds(_ ids: [Int64]) -> Int64 { + var acc: UInt64 = 0 for id in ids { - let low = UInt32(UInt64(bitPattern: id) & (0xffffffff as UInt64)) - let high = UInt32((UInt64(bitPattern: id) >> 32) & (0xffffffff as UInt64)) - - acc = (acc &* 20261) &+ high - acc = (acc &* 20261) &+ low + combineInt64Hash(&acc, with: UInt64(bitPattern: id)) } - return Int32(bitPattern: acc & UInt32(0x7FFFFFFF)) + return finalizeInt64Hash(acc) } -private func managedRecentMedia(postbox: Postbox, network: Network, collectionId: Int32, reverseHashOrder: Bool, forceFetch: Bool, fetch: @escaping (Int32) -> Signal<[OrderedItemListEntry]?, NoError>) -> Signal { +private func managedRecentMedia(postbox: Postbox, network: Network, collectionId: Int32, reverseHashOrder: Bool, forceFetch: Bool, fetch: @escaping (Int64) -> Signal<[OrderedItemListEntry]?, NoError>) -> Signal { return postbox.transaction { transaction -> Signal in var itemIds = transaction.getOrderedListItemIds(collectionId: collectionId).map { RecentMediaItemId($0).mediaId.id diff --git a/submodules/TelegramCore/Sources/State/ManagedSecretChatOutgoingOperations.swift b/submodules/TelegramCore/Sources/State/ManagedSecretChatOutgoingOperations.swift index 540b4d33f0..146d0ac618 100644 --- a/submodules/TelegramCore/Sources/State/ManagedSecretChatOutgoingOperations.swift +++ b/submodules/TelegramCore/Sources/State/ManagedSecretChatOutgoingOperations.swift @@ -226,7 +226,7 @@ private func initialHandshakeAccept(postbox: Postbox, network: Network, peerId: memcpy(&keyFingerprint, bytes.advanced(by: keyHash.count - 8), 8) } - let result = network.request(Api.functions.messages.acceptEncryption(peer: .inputEncryptedChat(chatId: peerId.id._internalGetInt32Value(), accessHash: accessHash), gB: Buffer(data: gb), keyFingerprint: keyFingerprint)) + let result = network.request(Api.functions.messages.acceptEncryption(peer: .inputEncryptedChat(chatId: Int32(peerId.id._internalGetInt64Value()), accessHash: accessHash), gB: Buffer(data: gb), keyFingerprint: keyFingerprint)) let response = result |> map { result -> Api.EncryptedChat? in @@ -1635,7 +1635,7 @@ private func sendBoxedDecryptedMessage(postbox: Postbox, network: Network, peer: decryptedMessage.serialize(payload, role: state.role, sequenceInfo: sequenceInfo) let encryptedPayload = encryptedMessageContents(parameters: parameters, data: MemoryBuffer(payload)) let sendMessage: Signal - let inputPeer = Api.InputEncryptedChat.inputEncryptedChat(chatId: peer.id.id._internalGetInt32Value(), accessHash: peer.accessHash) + let inputPeer = Api.InputEncryptedChat.inputEncryptedChat(chatId: Int32(peer.id.id._internalGetInt64Value()), accessHash: peer.accessHash) var flags: Int32 = 0 if silent { @@ -1675,7 +1675,7 @@ private func requestTerminateSecretChat(postbox: Postbox, network: Network, peer if requestRemoteHistoryRemoval { flags |= 1 << 0 } - return network.request(Api.functions.messages.discardEncryption(flags: flags, chatId: peerId.id._internalGetInt32Value())) + return network.request(Api.functions.messages.discardEncryption(flags: flags, chatId: Int32(peerId.id._internalGetInt64Value()))) |> map(Optional.init) |> `catch` { _ in return .single(nil) @@ -1691,7 +1691,7 @@ private func requestTerminateSecretChat(postbox: Postbox, network: Network, peer } |> mapToSignal { peer -> Signal in if let peer = peer { - return network.request(Api.functions.messages.reportEncryptedSpam(peer: Api.InputEncryptedChat.inputEncryptedChat(chatId: peer.id.id._internalGetInt32Value(), accessHash: peer.accessHash))) + return network.request(Api.functions.messages.reportEncryptedSpam(peer: Api.InputEncryptedChat.inputEncryptedChat(chatId: Int32(peer.id.id._internalGetInt64Value()), accessHash: peer.accessHash))) |> map(Optional.init) |> `catch` { _ -> Signal in return .single(nil) diff --git a/submodules/TelegramCore/Sources/State/ManagedSynchronizeInstalledStickerPacksOperations.swift b/submodules/TelegramCore/Sources/State/ManagedSynchronizeInstalledStickerPacksOperations.swift index dea3b12676..b482aa427f 100644 --- a/submodules/TelegramCore/Sources/State/ManagedSynchronizeInstalledStickerPacksOperations.swift +++ b/submodules/TelegramCore/Sources/State/ManagedSynchronizeInstalledStickerPacksOperations.swift @@ -123,14 +123,14 @@ func managedSynchronizeInstalledStickerPacksOperations(postbox: Postbox, network } } -private func hashForStickerPackInfos(_ infos: [StickerPackCollectionInfo]) -> Int32 { - var acc: UInt32 = 0 +private func hashForStickerPackInfos(_ infos: [StickerPackCollectionInfo]) -> Int64 { + var acc: UInt64 = 0 for info in infos { - acc = UInt32(bitPattern: Int32(bitPattern: acc &* UInt32(20261)) &+ info.hash) + combineInt64Hash(&acc, with: UInt64(UInt32(bitPattern: info.hash))) } - return Int32(bitPattern: acc & 0x7FFFFFFF) + return finalizeInt64Hash(acc) } private enum SynchronizeInstalledStickerPacksError { diff --git a/submodules/TelegramCore/Sources/State/ManagedSynchronizePinnedChatsOperations.swift b/submodules/TelegramCore/Sources/State/ManagedSynchronizePinnedChatsOperations.swift index 479b4b9019..bac5ff138d 100644 --- a/submodules/TelegramCore/Sources/State/ManagedSynchronizePinnedChatsOperations.swift +++ b/submodules/TelegramCore/Sources/State/ManagedSynchronizePinnedChatsOperations.swift @@ -82,7 +82,7 @@ func managedSynchronizePinnedChatsOperations(postbox: Postbox, network: Network, let signal = withTakenOperation(postbox: postbox, peerId: entry.peerId, tagLocalIndex: entry.tagLocalIndex, { transaction, entry -> Signal in if let entry = entry { if let operation = entry.contents as? SynchronizePinnedChatsOperation { - return synchronizePinnedChats(transaction: transaction, postbox: postbox, network: network, accountPeerId: accountPeerId, stateManager: stateManager, groupId: PeerGroupId(rawValue: entry.peerId.id._internalGetInt32Value()), operation: operation) + return synchronizePinnedChats(transaction: transaction, postbox: postbox, network: network, accountPeerId: accountPeerId, stateManager: stateManager, groupId: PeerGroupId(rawValue: Int32(entry.peerId.id._internalGetInt64Value())), operation: operation) } else { assertionFailure() } diff --git a/submodules/TelegramCore/Sources/State/ProcessSecretChatIncomingDecryptedOperations.swift b/submodules/TelegramCore/Sources/State/ProcessSecretChatIncomingDecryptedOperations.swift index 54a0e8843c..80816b4681 100644 --- a/submodules/TelegramCore/Sources/State/ProcessSecretChatIncomingDecryptedOperations.swift +++ b/submodules/TelegramCore/Sources/State/ProcessSecretChatIncomingDecryptedOperations.swift @@ -795,7 +795,7 @@ private func parseMessage(peerId: PeerId, authorId: PeerId, tagLocalIndex: Int32 case let .decryptedMessageMediaGeoPoint(lat, long): parsedMedia.append(TelegramMediaMap(latitude: lat, longitude: long, heading: nil, accuracyRadius: nil, geoPlace: nil, venue: nil, liveBroadcastingTimeout: nil, liveProximityNotificationRadius: nil)) case let .decryptedMessageMediaContact(phoneNumber, firstName, lastName, userId): - parsedMedia.append(TelegramMediaContact(firstName: firstName, lastName: lastName, phoneNumber: phoneNumber, peerId: userId == 0 ? nil : PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt32Value(userId)), vCardData: nil)) + parsedMedia.append(TelegramMediaContact(firstName: firstName, lastName: lastName, phoneNumber: phoneNumber, peerId: userId == 0 ? nil : PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt64Value(Int64(userId))), vCardData: nil)) case let .decryptedMessageMediaVenue(lat, long, title, address, provider, venueId): parsedMedia.append(TelegramMediaMap(latitude: lat, longitude: long, heading: nil, accuracyRadius: nil, geoPlace: nil, venue: MapVenue(title: title, address: address, provider: provider, id: venueId, type: nil), liveBroadcastingTimeout: nil, liveProximityNotificationRadius: nil)) case .decryptedMessageMediaEmpty: @@ -1014,7 +1014,7 @@ private func parseMessage(peerId: PeerId, authorId: PeerId, tagLocalIndex: Int32 case let .decryptedMessageMediaGeoPoint(lat, long): parsedMedia.append(TelegramMediaMap(latitude: lat, longitude: long, heading: nil, accuracyRadius: nil, geoPlace: nil, venue: nil, liveBroadcastingTimeout: nil, liveProximityNotificationRadius: nil)) case let .decryptedMessageMediaContact(phoneNumber, firstName, lastName, userId): - parsedMedia.append(TelegramMediaContact(firstName: firstName, lastName: lastName, phoneNumber: phoneNumber, peerId: userId == 0 ? nil : PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt32Value(userId)), vCardData: nil)) + parsedMedia.append(TelegramMediaContact(firstName: firstName, lastName: lastName, phoneNumber: phoneNumber, peerId: userId == 0 ? nil : PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt64Value(Int64(userId))), vCardData: nil)) case let .decryptedMessageMediaVenue(lat, long, title, address, provider, venueId): parsedMedia.append(TelegramMediaMap(latitude: lat, longitude: long, heading: nil, accuracyRadius: nil, geoPlace: nil, venue: MapVenue(title: title, address: address, provider: provider, id: venueId, type: nil), liveBroadcastingTimeout: nil, liveProximityNotificationRadius: nil)) case .decryptedMessageMediaEmpty: @@ -1252,7 +1252,7 @@ private func parseMessage(peerId: PeerId, authorId: PeerId, tagLocalIndex: Int32 case let .decryptedMessageMediaGeoPoint(lat, long): parsedMedia.append(TelegramMediaMap(latitude: lat, longitude: long, heading: nil, accuracyRadius: nil, geoPlace: nil, venue: nil, liveBroadcastingTimeout: nil, liveProximityNotificationRadius: nil)) case let .decryptedMessageMediaContact(phoneNumber, firstName, lastName, userId): - parsedMedia.append(TelegramMediaContact(firstName: firstName, lastName: lastName, phoneNumber: phoneNumber, peerId: userId == 0 ? nil : PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt32Value(userId)), vCardData: nil)) + parsedMedia.append(TelegramMediaContact(firstName: firstName, lastName: lastName, phoneNumber: phoneNumber, peerId: userId == 0 ? nil : PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt64Value(Int64(userId))), vCardData: nil)) case let .decryptedMessageMediaVenue(lat, long, title, address, provider, venueId): parsedMedia.append(TelegramMediaMap(latitude: lat, longitude: long, heading: nil, accuracyRadius: nil, geoPlace: nil, venue: MapVenue(title: title, address: address, provider: provider, id: venueId, type: nil), liveBroadcastingTimeout: nil, liveProximityNotificationRadius: nil)) case .decryptedMessageMediaEmpty: diff --git a/submodules/TelegramCore/Sources/State/Serialization.swift b/submodules/TelegramCore/Sources/State/Serialization.swift index 5975b76068..6186d380d5 100644 --- a/submodules/TelegramCore/Sources/State/Serialization.swift +++ b/submodules/TelegramCore/Sources/State/Serialization.swift @@ -210,7 +210,7 @@ public class BoxedMessage: NSObject { public class Serialization: NSObject, MTSerialization { public func currentLayer() -> UInt { - return 132 + return 133 } public func parseMessage(_ data: Data!) -> Any! { @@ -236,7 +236,7 @@ public class Serialization: NSObject, MTSerialization { } } - public func importAuthorization(_ authId: Int32, bytes: Data!) -> Data! { + public func importAuthorization(_ authId: Int64, bytes: Data!) -> Data! { return Api.functions.auth.importAuthorization(id: authId, bytes: Buffer(data: bytes)).1.makeData() } diff --git a/submodules/TelegramCore/Sources/State/StickerManagement.swift b/submodules/TelegramCore/Sources/State/StickerManagement.swift index 9a745f00c8..f6109865d7 100644 --- a/submodules/TelegramCore/Sources/State/StickerManagement.swift +++ b/submodules/TelegramCore/Sources/State/StickerManagement.swift @@ -5,16 +5,12 @@ import SwiftSignalKit private func hashForIdsReverse(_ ids: [Int64]) -> Int32 { - var acc: UInt32 = 0 + var acc: UInt64 = 0 for id in ids { - let low = UInt32(UInt64(bitPattern: id) & (0xffffffff as UInt64)) - let high = UInt32((UInt64(bitPattern: id) >> 32) & (0xffffffff as UInt64)) - - acc = (acc &* 20261) &+ high - acc = (acc &* 20261) &+ low + combineInt64Hash(&acc, with: UInt64(bitPattern: id)) } - return Int32(bitPattern: acc & UInt32(0x7FFFFFFF)) + return Int32(bitPattern: UInt32(clamping: acc & UInt64(0x7FFFFFFF))) } func manageStickerPacks(network: Network, postbox: Postbox) -> Signal { diff --git a/submodules/TelegramCore/Sources/State/SynchronizeEmojiKeywordsOperation.swift b/submodules/TelegramCore/Sources/State/SynchronizeEmojiKeywordsOperation.swift index f4d43adf56..be67c65a80 100644 --- a/submodules/TelegramCore/Sources/State/SynchronizeEmojiKeywordsOperation.swift +++ b/submodules/TelegramCore/Sources/State/SynchronizeEmojiKeywordsOperation.swift @@ -5,7 +5,7 @@ import MurMurHash32 func addSynchronizeEmojiKeywordsOperation(transaction: Transaction, inputLanguageCode: String, languageCode: String?, fromVersion: Int32?) { let tag = OperationLogTags.SynchronizeEmojiKeywords - let peerId = PeerId(namespace: PeerId.Namespace._internalFromInt32Value(0), id: PeerId.Id._internalFromInt32Value(murMurHashString32(inputLanguageCode))) + let peerId = PeerId(namespace: PeerId.Namespace._internalFromInt32Value(0), id: PeerId.Id._internalFromInt64Value(Int64(murMurHashString32(inputLanguageCode)))) var hasExistingOperation = false transaction.operationLogEnumerateEntries(peerId: peerId, tag: tag) { entry -> Bool in diff --git a/submodules/TelegramCore/Sources/State/UpdateGroup.swift b/submodules/TelegramCore/Sources/State/UpdateGroup.swift index 8ae8b4c168..85ac1f8424 100644 --- a/submodules/TelegramCore/Sources/State/UpdateGroup.swift +++ b/submodules/TelegramCore/Sources/State/UpdateGroup.swift @@ -9,7 +9,7 @@ enum UpdateGroup { case withDate(updates: [Api.Update], date: Int32, users: [Api.User], chats: [Api.Chat]) case reset case updatePts(pts: Int32, ptsCount: Int32) - case updateChannelPts(channelId: Int32, pts: Int32, ptsCount: Int32) + case updateChannelPts(channelId: Int64, pts: Int32, ptsCount: Int32) case ensurePeerHasLocalState(id: PeerId) var updates: [Api.Update] { diff --git a/submodules/TelegramCore/Sources/State/UpdateMessageService.swift b/submodules/TelegramCore/Sources/State/UpdateMessageService.swift index fc375938cc..bbfbd80aec 100644 --- a/submodules/TelegramCore/Sources/State/UpdateMessageService.swift +++ b/submodules/TelegramCore/Sources/State/UpdateMessageService.swift @@ -67,7 +67,7 @@ class UpdateMessageService: NSObject, MTMessageService { case let .updateShortMessage(flags, id, userId, message, pts, ptsCount, date, fwdFrom, viaBotId, replyHeader, entities, ttlPeriod): let generatedFromId: Api.Peer if (Int(flags) & 1 << 1) != 0 { - generatedFromId = Api.Peer.peerUser(userId: self.peerId.id._internalGetInt32Value()) + generatedFromId = Api.Peer.peerUser(userId: self.peerId.id._internalGetInt64Value()) } else { generatedFromId = Api.Peer.peerUser(userId: userId) } diff --git a/submodules/TelegramCore/Sources/State/UpdatesApiUtils.swift b/submodules/TelegramCore/Sources/State/UpdatesApiUtils.swift index bf8183fa99..91dcb3b5ef 100644 --- a/submodules/TelegramCore/Sources/State/UpdatesApiUtils.swift +++ b/submodules/TelegramCore/Sources/State/UpdatesApiUtils.swift @@ -145,15 +145,15 @@ extension Api.Chat { var peerId: PeerId { switch self { case let .chat(chat): - return PeerId(namespace: Namespaces.Peer.CloudGroup, id: PeerId.Id._internalFromInt32Value(chat.id)) + return PeerId(namespace: Namespaces.Peer.CloudGroup, id: PeerId.Id._internalFromInt64Value(chat.id)) case let .chatEmpty(id): - return PeerId(namespace: Namespaces.Peer.CloudGroup, id: PeerId.Id._internalFromInt32Value(id)) + return PeerId(namespace: Namespaces.Peer.CloudGroup, id: PeerId.Id._internalFromInt64Value(id)) case let .chatForbidden(id, _): - return PeerId(namespace: Namespaces.Peer.CloudGroup, id: PeerId.Id._internalFromInt32Value(id)) + return PeerId(namespace: Namespaces.Peer.CloudGroup, id: PeerId.Id._internalFromInt64Value(id)) case let .channel(channel): - return PeerId(namespace: Namespaces.Peer.CloudChannel, id: PeerId.Id._internalFromInt32Value(channel.id)) + return PeerId(namespace: Namespaces.Peer.CloudChannel, id: PeerId.Id._internalFromInt64Value(channel.id)) case let .channelForbidden(_, id, _, _, _): - return PeerId(namespace: Namespaces.Peer.CloudChannel, id: PeerId.Id._internalFromInt32Value(id)) + return PeerId(namespace: Namespaces.Peer.CloudChannel, id: PeerId.Id._internalFromInt64Value(id)) } } } @@ -162,9 +162,9 @@ extension Api.User { var peerId: PeerId { switch self { case .user(_, let id, _, _, _, _, _, _, _, _, _, _, _): - return PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt32Value(id)) + return PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt64Value(id)) case let .userEmpty(id): - return PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt32Value(id)) + return PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt64Value(id)) } } } @@ -173,11 +173,11 @@ extension Api.Peer { var peerId: PeerId { switch self { case let .peerChannel(channelId): - return PeerId(namespace: Namespaces.Peer.CloudChannel, id: PeerId.Id._internalFromInt32Value(channelId)) + return PeerId(namespace: Namespaces.Peer.CloudChannel, id: PeerId.Id._internalFromInt64Value(channelId)) case let .peerChat(chatId): - return PeerId(namespace: Namespaces.Peer.CloudGroup, id: PeerId.Id._internalFromInt32Value(chatId)) + return PeerId(namespace: Namespaces.Peer.CloudGroup, id: PeerId.Id._internalFromInt64Value(chatId)) case let .peerUser(userId): - return PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt32Value(userId)) + return PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt64Value(userId)) } } } @@ -247,40 +247,40 @@ extension Api.Update { var peerIds: [PeerId] { switch self { case let .updateChannel(channelId): - return [PeerId(namespace: Namespaces.Peer.CloudChannel, id: PeerId.Id._internalFromInt32Value(channelId))] + return [PeerId(namespace: Namespaces.Peer.CloudChannel, id: PeerId.Id._internalFromInt64Value(channelId))] case let .updateChat(chatId): - return [PeerId(namespace: Namespaces.Peer.CloudGroup, id: PeerId.Id._internalFromInt32Value(chatId))] + return [PeerId(namespace: Namespaces.Peer.CloudGroup, id: PeerId.Id._internalFromInt64Value(chatId))] case let .updateChannelTooLong(_, channelId, _): - return [PeerId(namespace: Namespaces.Peer.CloudChannel, id: PeerId.Id._internalFromInt32Value(channelId))] + return [PeerId(namespace: Namespaces.Peer.CloudChannel, id: PeerId.Id._internalFromInt64Value(channelId))] case let .updateChatParticipantAdd(chatId, userId, inviterId, _, _): - return [PeerId(namespace: Namespaces.Peer.CloudGroup, id: PeerId.Id._internalFromInt32Value(chatId)), PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt32Value(userId)), PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt32Value(inviterId))] + return [PeerId(namespace: Namespaces.Peer.CloudGroup, id: PeerId.Id._internalFromInt64Value(chatId)), PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt64Value(userId)), PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt64Value(inviterId))] case let .updateChatParticipantAdmin(chatId, userId, _, _): - return [PeerId(namespace: Namespaces.Peer.CloudGroup, id: PeerId.Id._internalFromInt32Value(chatId)), PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt32Value(userId))] + return [PeerId(namespace: Namespaces.Peer.CloudGroup, id: PeerId.Id._internalFromInt64Value(chatId)), PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt64Value(userId))] case let .updateChatParticipantDelete(chatId, userId, _): - return [PeerId(namespace: Namespaces.Peer.CloudGroup, id: PeerId.Id._internalFromInt32Value(chatId)), PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt32Value(userId))] + return [PeerId(namespace: Namespaces.Peer.CloudGroup, id: PeerId.Id._internalFromInt64Value(chatId)), PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt64Value(userId))] case let .updateChatParticipants(participants): switch participants { case let .chatParticipants(chatId, _, _): - return [PeerId(namespace: Namespaces.Peer.CloudGroup, id: PeerId.Id._internalFromInt32Value(chatId))] + return [PeerId(namespace: Namespaces.Peer.CloudGroup, id: PeerId.Id._internalFromInt64Value(chatId))] case let .chatParticipantsForbidden(_, chatId, _): - return [PeerId(namespace: Namespaces.Peer.CloudGroup, id: PeerId.Id._internalFromInt32Value(chatId))] + return [PeerId(namespace: Namespaces.Peer.CloudGroup, id: PeerId.Id._internalFromInt64Value(chatId))] } case let .updateDeleteChannelMessages(channelId, _, _, _): - return [PeerId(namespace: Namespaces.Peer.CloudChannel, id: PeerId.Id._internalFromInt32Value(channelId))] + return [PeerId(namespace: Namespaces.Peer.CloudChannel, id: PeerId.Id._internalFromInt64Value(channelId))] case let .updatePinnedChannelMessages(_, channelId, _, _, _): - return [PeerId(namespace: Namespaces.Peer.CloudChannel, id: PeerId.Id._internalFromInt32Value(channelId))] + return [PeerId(namespace: Namespaces.Peer.CloudChannel, id: PeerId.Id._internalFromInt64Value(channelId))] case let .updateNewChannelMessage(message, _, _): return apiMessagePeerIds(message) case let .updateEditChannelMessage(message, _, _): return apiMessagePeerIds(message) case let .updateChannelWebPage(channelId, _, _, _): - return [PeerId(namespace: Namespaces.Peer.CloudChannel, id: PeerId.Id._internalFromInt32Value(channelId))] + return [PeerId(namespace: Namespaces.Peer.CloudChannel, id: PeerId.Id._internalFromInt64Value(channelId))] case let .updateNewMessage(message, _, _): return apiMessagePeerIds(message) case let .updateEditMessage(message, _, _): return apiMessagePeerIds(message) case let .updateReadChannelInbox(_, _, channelId, _, _, _): - return [PeerId(namespace: Namespaces.Peer.CloudChannel, id: PeerId.Id._internalFromInt32Value(channelId))] + return [PeerId(namespace: Namespaces.Peer.CloudChannel, id: PeerId.Id._internalFromInt64Value(channelId))] case let .updateNotifySettings(peer, _): switch peer { case let .notifyPeer(peer): @@ -289,14 +289,14 @@ extension Api.Update { return [] } case let .updateUserName(userId, _, _, _): - return [PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt32Value(userId))] + return [PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt64Value(userId))] case let .updateUserPhone(userId, _): - return [PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt32Value(userId))] + return [PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt64Value(userId))] case let .updateUserPhoto(userId, _, _, _): - return [PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt32Value(userId))] + return [PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt64Value(userId))] case let .updateServiceNotification(_, inboxDate, _, _, _, _): if let _ = inboxDate { - return [PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt32Value(777000))] + return [PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt64Value(777000))] } else { return [] } @@ -417,9 +417,9 @@ extension Api.Updates { case .updatesTooLong: return [] case let .updateShortMessage(_, id, userId, _, _, _, _, _, _, _, _, _): - return [MessageId(peerId: PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt32Value(userId)), namespace: Namespaces.Message.Cloud, id: id)] + return [MessageId(peerId: PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt64Value(userId)), namespace: Namespaces.Message.Cloud, id: id)] case let .updateShortChatMessage(_, id, _, chatId, _, _, _, _, _, _, _, _, _): - return [MessageId(peerId: PeerId(namespace: Namespaces.Peer.CloudGroup, id: PeerId.Id._internalFromInt32Value(chatId)), namespace: Namespaces.Message.Cloud, id: id)] + return [MessageId(peerId: PeerId(namespace: Namespaces.Peer.CloudGroup, id: PeerId.Id._internalFromInt64Value(chatId)), namespace: Namespaces.Message.Cloud, id: id)] } } @@ -451,9 +451,9 @@ extension Api.Updates { return [:] case .updatesTooLong: return [:] - case let .updateShortMessage(_, id, userId, _, _, _, _, _, _, _, _, _): + case .updateShortMessage: return [:] - case let .updateShortChatMessage(_, id, _, chatId, _, _, _, _, _, _, _, _, _): + case .updateShortChatMessage: return [:] } } @@ -548,15 +548,15 @@ extension Api.EncryptedChat { var peerId: PeerId { switch self { case let .encryptedChat(id, _, _, _, _, _, _): - return PeerId(namespace: Namespaces.Peer.SecretChat, id: PeerId.Id._internalFromInt32Value(id)) + return PeerId(namespace: Namespaces.Peer.SecretChat, id: PeerId.Id._internalFromInt64Value(Int64(id))) case let .encryptedChatDiscarded(_, id): - return PeerId(namespace: Namespaces.Peer.SecretChat, id: PeerId.Id._internalFromInt32Value(id)) + return PeerId(namespace: Namespaces.Peer.SecretChat, id: PeerId.Id._internalFromInt64Value(Int64(id))) case let .encryptedChatEmpty(id): - return PeerId(namespace: Namespaces.Peer.SecretChat, id: PeerId.Id._internalFromInt32Value(id)) + return PeerId(namespace: Namespaces.Peer.SecretChat, id: PeerId.Id._internalFromInt64Value(Int64(id))) case let .encryptedChatRequested(_, _, id, _, _, _, _, _): - return PeerId(namespace: Namespaces.Peer.SecretChat, id: PeerId.Id._internalFromInt32Value(id)) + return PeerId(namespace: Namespaces.Peer.SecretChat, id: PeerId.Id._internalFromInt64Value(Int64(id))) case let .encryptedChatWaiting(id, _, _, _, _): - return PeerId(namespace: Namespaces.Peer.SecretChat, id: PeerId.Id._internalFromInt32Value(id)) + return PeerId(namespace: Namespaces.Peer.SecretChat, id: PeerId.Id._internalFromInt64Value(Int64(id))) } } } @@ -565,9 +565,9 @@ extension Api.EncryptedMessage { var peerId: PeerId { switch self { case let .encryptedMessage(_, chatId, _, _, _): - return PeerId(namespace: Namespaces.Peer.SecretChat, id: PeerId.Id._internalFromInt32Value(chatId)) + return PeerId(namespace: Namespaces.Peer.SecretChat, id: PeerId.Id._internalFromInt64Value(Int64(chatId))) case let .encryptedMessageService(_, chatId, _, _): - return PeerId(namespace: Namespaces.Peer.SecretChat, id: PeerId.Id._internalFromInt32Value(chatId)) + return PeerId(namespace: Namespaces.Peer.SecretChat, id: PeerId.Id._internalFromInt64Value(Int64(chatId))) } } } diff --git a/submodules/TelegramCore/Sources/SyncCore/SyncCore_AppConfiguration.swift b/submodules/TelegramCore/Sources/SyncCore/SyncCore_AppConfiguration.swift index e7e54e5fa7..99595e9d22 100644 --- a/submodules/TelegramCore/Sources/SyncCore/SyncCore_AppConfiguration.swift +++ b/submodules/TelegramCore/Sources/SyncCore/SyncCore_AppConfiguration.swift @@ -1,7 +1,7 @@ import Foundation import Postbox -public struct AppConfiguration: Codable { +public struct AppConfiguration: Codable, Equatable { public var data: JSON? public static var defaultValue: AppConfiguration { diff --git a/submodules/TelegramCore/Sources/SyncCore/SyncCore_CachedStickerQueryResult.swift b/submodules/TelegramCore/Sources/SyncCore/SyncCore_CachedStickerQueryResult.swift index c9c908af1b..7a0d7769ec 100644 --- a/submodules/TelegramCore/Sources/SyncCore/SyncCore_CachedStickerQueryResult.swift +++ b/submodules/TelegramCore/Sources/SyncCore/SyncCore_CachedStickerQueryResult.swift @@ -2,10 +2,10 @@ import Postbox public final class CachedStickerQueryResult: PostboxCoding { public let items: [TelegramMediaFile] - public let hash: Int32 + public let hash: Int64 public let timestamp: Int32 - public init(items: [TelegramMediaFile], hash: Int32, timestamp: Int32) { + public init(items: [TelegramMediaFile], hash: Int64, timestamp: Int32) { self.items = items self.hash = hash self.timestamp = timestamp @@ -13,13 +13,13 @@ public final class CachedStickerQueryResult: PostboxCoding { public init(decoder: PostboxDecoder) { self.items = decoder.decodeObjectArrayForKey("it").map { $0 as! TelegramMediaFile } - self.hash = decoder.decodeInt32ForKey("h", orElse: 0) + self.hash = decoder.decodeInt64ForKey("h6", orElse: 0) self.timestamp = decoder.decodeInt32ForKey("t", orElse: 0) } public func encode(_ encoder: PostboxEncoder) { encoder.encodeObjectArray(self.items, forKey: "it") - encoder.encodeInt32(self.hash, forKey: "h") + encoder.encodeInt64(self.hash, forKey: "h6") encoder.encodeInt32(self.timestamp, forKey: "t") } diff --git a/submodules/TelegramCore/Sources/SyncCore/SyncCore_CachedThemesConfiguration.swift b/submodules/TelegramCore/Sources/SyncCore/SyncCore_CachedThemesConfiguration.swift index f8e473bbfd..2b9f2127d7 100644 --- a/submodules/TelegramCore/Sources/SyncCore/SyncCore_CachedThemesConfiguration.swift +++ b/submodules/TelegramCore/Sources/SyncCore/SyncCore_CachedThemesConfiguration.swift @@ -1,17 +1,17 @@ import Postbox public final class CachedThemesConfiguration: PostboxCoding { - public let hash: Int32 + public let hash: Int64 - public init(hash: Int32) { + public init(hash: Int64) { self.hash = hash } public init(decoder: PostboxDecoder) { - self.hash = decoder.decodeInt32ForKey("hash", orElse: 0) + self.hash = decoder.decodeInt64ForKey("hash6", orElse: 0) } public func encode(_ encoder: PostboxEncoder) { - encoder.encodeInt32(self.hash, forKey: "hash") + encoder.encodeInt64(self.hash, forKey: "hash6") } } diff --git a/submodules/TelegramCore/Sources/SyncCore/SyncCore_CachedWallpapersConfiguration.swift b/submodules/TelegramCore/Sources/SyncCore/SyncCore_CachedWallpapersConfiguration.swift index fa22f16806..0d6d2ac9da 100644 --- a/submodules/TelegramCore/Sources/SyncCore/SyncCore_CachedWallpapersConfiguration.swift +++ b/submodules/TelegramCore/Sources/SyncCore/SyncCore_CachedWallpapersConfiguration.swift @@ -1,17 +1,17 @@ import Postbox public final class CachedWallpapersConfiguration: PostboxCoding { - public let hash: Int32 + public let hash: Int64 - public init(hash: Int32) { + public init(hash: Int64) { self.hash = hash } public init(decoder: PostboxDecoder) { - self.hash = decoder.decodeInt32ForKey("hash", orElse: 0) + self.hash = decoder.decodeInt64ForKey("hash6", orElse: 0) } public func encode(_ encoder: PostboxEncoder) { - encoder.encodeInt32(self.hash, forKey: "hash") + encoder.encodeInt64(self.hash, forKey: "hash6") } } diff --git a/submodules/TelegramCore/Sources/SyncCore/SyncCore_GlobalNotificationSettings.swift b/submodules/TelegramCore/Sources/SyncCore/SyncCore_GlobalNotificationSettings.swift index b578c5cfc4..71b1b3138d 100644 --- a/submodules/TelegramCore/Sources/SyncCore/SyncCore_GlobalNotificationSettings.swift +++ b/submodules/TelegramCore/Sources/SyncCore/SyncCore_GlobalNotificationSettings.swift @@ -24,14 +24,15 @@ public struct MessageNotificationSettings: Codable { self.sound = PeerMessageSound.decodeInline(container) } - public func encode(_ encoder: PostboxEncoder) { + public func encode(to encoder: Encoder) throws { + encoder.encodeInt32(self.enabled ? 1 : 0, forKey: "e") encoder.encodeInt32(self.displayPreviews ? 1 : 0, forKey: "p") self.sound.encodeInline(encoder) } } -public struct GlobalNotificationSettingsSet: Codable { +public struct GlobalNotificationSettingsSet: Codable, Equatable { public var privateChats: MessageNotificationSettings public var groupChats: MessageNotificationSettings public var channels: MessageNotificationSettings @@ -57,7 +58,8 @@ public struct GlobalNotificationSettingsSet: Codable { self.contactsJoined = decoder.decodeInt32ForKey("contactsJoined", orElse: 1) != 0 } - public func encode(_ encoder: PostboxEncoder) { + public func encode(to encoder: Encoder) throws { + encoder.encodeObject(self.privateChats, forKey: "p") encoder.encodeObject(self.groupChats, forKey: "g") encoder.encodeObject(self.channels, forKey: "c") diff --git a/submodules/TelegramCore/Sources/SyncCore/SyncCore_LimitsConfiguration.swift b/submodules/TelegramCore/Sources/SyncCore/SyncCore_LimitsConfiguration.swift index b087e508ca..82b78a4fbd 100644 --- a/submodules/TelegramCore/Sources/SyncCore/SyncCore_LimitsConfiguration.swift +++ b/submodules/TelegramCore/Sources/SyncCore/SyncCore_LimitsConfiguration.swift @@ -1,6 +1,6 @@ import Postbox -public struct LimitsConfiguration: Equatable, PreferencesEntry { +public struct LimitsConfiguration: Codable, Equatable { public static let timeIntervalForever: Int32 = 0x7fffffff public var maxPinnedChatCount: Int32 @@ -35,40 +35,37 @@ public struct LimitsConfiguration: Equatable, PreferencesEntry { self.maxMessageRevokeIntervalInPrivateChats = maxMessageRevokeIntervalInPrivateChats } - public init(decoder: PostboxDecoder) { - self.maxPinnedChatCount = decoder.decodeInt32ForKey("maxPinnedChatCount", orElse: 5) - self.maxArchivedPinnedChatCount = decoder.decodeInt32ForKey("maxArchivedPinnedChatCount", orElse: 20) - self.maxGroupMemberCount = decoder.decodeInt32ForKey("maxGroupMemberCount", orElse: 200) - self.maxSupergroupMemberCount = decoder.decodeInt32ForKey("maxSupergroupMemberCount", orElse: 5000) - self.maxMessageForwardBatchSize = decoder.decodeInt32ForKey("maxMessageForwardBatchSize", orElse: 50) - self.maxSavedGifCount = decoder.decodeInt32ForKey("maxSavedGifCount", orElse: 200) - self.maxRecentStickerCount = decoder.decodeInt32ForKey("maxRecentStickerCount", orElse: 20) - self.maxMessageEditingInterval = decoder.decodeInt32ForKey("maxMessageEditingInterval", orElse: 2 * 24 * 60 * 60) - self.maxMediaCaptionLength = decoder.decodeInt32ForKey("maxMediaCaptionLength", orElse: 1000) - self.canRemoveIncomingMessagesInPrivateChats = decoder.decodeInt32ForKey("canRemoveIncomingMessagesInPrivateChats", orElse: 0) != 0 - self.maxMessageRevokeInterval = decoder.decodeInt32ForKey("maxMessageRevokeInterval", orElse: 2 * 24 * 60 * 60) - self.maxMessageRevokeIntervalInPrivateChats = decoder.decodeInt32ForKey("maxMessageRevokeIntervalInPrivateChats", orElse: 2 * 24 * 60 * 60) + public init(from decoder: Decoder) throws { + let container = try decoder.container(keyedBy: StringCodingKey.self) + + self.maxPinnedChatCount = (try? container.decodeIfPresent(Int32.self, forKey: "maxPinnedChatCount")) ?? 5 + self.maxArchivedPinnedChatCount = (try? container.decodeIfPresent(Int32.self, forKey: "maxArchivedPinnedChatCount")) ?? 20 + self.maxGroupMemberCount = (try? container.decodeIfPresent(Int32.self, forKey: "maxGroupMemberCount")) ?? 200 + self.maxSupergroupMemberCount = (try? container.decodeIfPresent(Int32.self, forKey: "maxSupergroupMemberCount")) ?? 5000 + self.maxMessageForwardBatchSize = (try? container.decodeIfPresent(Int32.self, forKey: "maxMessageForwardBatchSize")) ?? 50 + self.maxSavedGifCount = (try? container.decodeIfPresent(Int32.self, forKey: "maxSavedGifCount")) ?? 200 + self.maxRecentStickerCount = (try? container.decodeIfPresent(Int32.self, forKey: "maxRecentStickerCount")) ?? 20 + self.maxMessageEditingInterval = (try? container.decodeIfPresent(Int32.self, forKey: "maxMessageEditingInterval")) ?? (2 * 24 * 60 * 60) + self.maxMediaCaptionLength = (try? container.decodeIfPresent(Int32.self, forKey: "maxMediaCaptionLength")) ?? 1000 + self.canRemoveIncomingMessagesInPrivateChats = (try? container.decodeIfPresent(Int32.self, forKey: "canRemoveIncomingMessagesInPrivateChats") ?? 0) != 0 + self.maxMessageRevokeInterval = (try? container.decodeIfPresent(Int32.self, forKey: "maxMessageRevokeInterval")) ?? (2 * 24 * 60 * 60) + self.maxMessageRevokeIntervalInPrivateChats = (try? container.decodeIfPresent(Int32.self, forKey: "maxMessageRevokeIntervalInPrivateChats")) ?? (2 * 24 * 60 * 60) } - public func encode(_ encoder: PostboxEncoder) { - encoder.encodeInt32(self.maxPinnedChatCount, forKey: "maxPinnedChatCount") - encoder.encodeInt32(self.maxArchivedPinnedChatCount, forKey: "maxArchivedPinnedChatCount") - encoder.encodeInt32(self.maxGroupMemberCount, forKey: "maxGroupMemberCount") - encoder.encodeInt32(self.maxSupergroupMemberCount, forKey: "maxSupergroupMemberCount") - encoder.encodeInt32(self.maxMessageForwardBatchSize, forKey: "maxMessageForwardBatchSize") - encoder.encodeInt32(self.maxSavedGifCount, forKey: "maxSavedGifCount") - encoder.encodeInt32(self.maxRecentStickerCount, forKey: "maxRecentStickerCount") - encoder.encodeInt32(self.maxMessageEditingInterval, forKey: "maxMessageEditingInterval") - encoder.encodeInt32(self.maxMediaCaptionLength, forKey: "maxMediaCaptionLength") - encoder.encodeInt32(self.canRemoveIncomingMessagesInPrivateChats ? 1 : 0, forKey: "canRemoveIncomingMessagesInPrivateChats") - encoder.encodeInt32(self.maxMessageRevokeInterval, forKey: "maxMessageRevokeInterval") - encoder.encodeInt32(self.maxMessageRevokeIntervalInPrivateChats, forKey: "maxMessageRevokeIntervalInPrivateChats") - } - - public func isEqual(to: PreferencesEntry) -> Bool { - guard let to = to as? LimitsConfiguration else { - return false - } - return self == to + public func encode(to encoder: Encoder) throws { + var container = encoder.container(keyedBy: StringCodingKey.self) + + try container.encode(self.maxPinnedChatCount, forKey: "maxPinnedChatCount") + try container.encode(self.maxArchivedPinnedChatCount, forKey: "maxArchivedPinnedChatCount") + try container.encode(self.maxGroupMemberCount, forKey: "maxGroupMemberCount") + try container.encode(self.maxSupergroupMemberCount, forKey: "maxSupergroupMemberCount") + try container.encode(self.maxMessageForwardBatchSize, forKey: "maxMessageForwardBatchSize") + try container.encode(self.maxSavedGifCount, forKey: "maxSavedGifCount") + try container.encode(self.maxRecentStickerCount, forKey: "maxRecentStickerCount") + try container.encode(self.maxMessageEditingInterval, forKey: "maxMessageEditingInterval") + try container.encode(self.maxMediaCaptionLength, forKey: "maxMediaCaptionLength") + try container.encode(self.canRemoveIncomingMessagesInPrivateChats ? 1 : 0, forKey: "canRemoveIncomingMessagesInPrivateChats") + try container.encode(self.maxMessageRevokeInterval, forKey: "maxMessageRevokeInterval") + try container.encode(self.maxMessageRevokeIntervalInPrivateChats, forKey: "maxMessageRevokeIntervalInPrivateChats") } } diff --git a/submodules/TelegramCore/Sources/SyncCore/SyncCore_Localization.swift b/submodules/TelegramCore/Sources/SyncCore/SyncCore_Localization.swift index 21805c0c6c..f625ac64d5 100644 --- a/submodules/TelegramCore/Sources/SyncCore/SyncCore_Localization.swift +++ b/submodules/TelegramCore/Sources/SyncCore/SyncCore_Localization.swift @@ -45,7 +45,7 @@ private func writeString(_ buffer: WriteBuffer, _ string: String) { } } -public final class Localization: PostboxCoding, Equatable { +public final class Localization: Codable, Equatable { public let version: Int32 public let entries: [LocalizationEntry] @@ -54,11 +54,16 @@ public final class Localization: PostboxCoding, Equatable { self.entries = entries } - public init(decoder: PostboxDecoder) { - self.version = decoder.decodeInt32ForKey("v", orElse: 0) - let count = decoder.decodeInt32ForKey("c", orElse: 0) + public init(from decoder: Decoder) throws { + let container = try decoder.container(keyedBy: StringCodingKey.self) + + self.version = (try? container.decode(Int32.self, forKey: "v")) ?? 0 + + let count = (try? container.decode(Int32.self, forKey: "c")) ?? 0 var entries: [LocalizationEntry] = [] - if let data = decoder.decodeBytesForKey("d") { + if let rawData = try? container.decodeIfPresent(Data.self, forKey: "d") { + let data = ReadBuffer(data: rawData) + for _ in 0 ..< count { var flagsValue: Int8 = 0 data.read(&flagsValue, offset: 0, length: 1) @@ -150,9 +155,11 @@ public final class Localization: PostboxCoding, Equatable { self.entries = entries } - public func encode(_ encoder: PostboxEncoder) { - encoder.encodeInt32(self.version, forKey: "v") - encoder.encodeInt32(Int32(self.entries.count), forKey: "c") + public func encode(to encoder: Encoder) throws { + var container = encoder.container(keyedBy: StringCodingKey.self) + + try container.encode(self.version, forKey: "v") + try container.encode(Int32(self.entries.count), forKey: "c") let buffer = WriteBuffer() for entry in self.entries { @@ -205,7 +212,7 @@ public final class Localization: PostboxCoding, Equatable { writeString(buffer, other) } } - encoder.encodeBytes(buffer, forKey: "d") + try container.encode(buffer.makeData(), forKey: "d") } public static func ==(lhs: Localization, rhs: Localization) -> Bool { diff --git a/submodules/TelegramCore/Sources/SyncCore/SyncCore_LocalizationInfo.swift b/submodules/TelegramCore/Sources/SyncCore/SyncCore_LocalizationInfo.swift index add477b445..64a0f5bf98 100644 --- a/submodules/TelegramCore/Sources/SyncCore/SyncCore_LocalizationInfo.swift +++ b/submodules/TelegramCore/Sources/SyncCore/SyncCore_LocalizationInfo.swift @@ -1,6 +1,6 @@ import Postbox -public struct LocalizationInfo: PostboxCoding, Equatable { +public struct LocalizationInfo: PostboxCoding, Codable, Equatable { public let languageCode: String public let baseLanguageCode: String? public let customPluralizationCode: String? @@ -34,6 +34,20 @@ public struct LocalizationInfo: PostboxCoding, Equatable { self.translatedStringCount = decoder.decodeInt32ForKey("lsc", orElse: 0) self.platformUrl = decoder.decodeStringForKey("platformUrl", orElse: "") } + + public init(from decoder: Decoder) throws { + let container = try decoder.container(keyedBy: StringCodingKey.self) + + self.languageCode = (try? container.decode(String.self, forKey: "lc")) ?? "" + self.baseLanguageCode = try? container.decodeIfPresent(String.self, forKey: "nlc") + self.customPluralizationCode = try? container.decodeIfPresent(String.self, forKey: "cpc") + self.title = (try? container.decode(String.self, forKey: "t")) ?? "" + self.localizedTitle = (try? container.decode(String.self, forKey: "lt")) ?? "" + self.isOfficial = ((try? container.decode(Int32.self, forKey: "of")) ?? 0) != 0 + self.totalStringCount = (try? container.decode(Int32.self, forKey: "tsc")) ?? 0 + self.translatedStringCount = (try? container.decode(Int32.self, forKey: "lsc")) ?? 0 + self.platformUrl = (try? container.decode(String.self, forKey: "platformUrl")) ?? "" + } public func encode(_ encoder: PostboxEncoder) { encoder.encodeString(self.languageCode, forKey: "lc") @@ -54,4 +68,18 @@ public struct LocalizationInfo: PostboxCoding, Equatable { encoder.encodeInt32(self.translatedStringCount, forKey: "lsc") encoder.encodeString(self.platformUrl, forKey: "platformUrl") } + + public func encode(to encoder: Encoder) throws { + var container = encoder.container(keyedBy: StringCodingKey.self) + + try container.encode(self.languageCode, forKey: "lc") + try container.encodeIfPresent(self.baseLanguageCode, forKey: "nlc") + try container.encodeIfPresent(self.customPluralizationCode, forKey: "cpc") + try container.encode(self.title, forKey: "t") + try container.encode(self.localizedTitle, forKey: "lt") + try container.encode((self.isOfficial ? 1 : 0) as Int32, forKey: "of") + try container.encode(self.totalStringCount, forKey: "tsc") + try container.encode(self.translatedStringCount, forKey: "lsc") + try container.encode(self.platformUrl, forKey: "platformUrl") + } } diff --git a/submodules/TelegramCore/Sources/SyncCore/SyncCore_LocalizationListState.swift b/submodules/TelegramCore/Sources/SyncCore/SyncCore_LocalizationListState.swift index e9d2195422..51e470c916 100644 --- a/submodules/TelegramCore/Sources/SyncCore/SyncCore_LocalizationListState.swift +++ b/submodules/TelegramCore/Sources/SyncCore/SyncCore_LocalizationListState.swift @@ -1,6 +1,6 @@ import Postbox -public struct LocalizationListState: PreferencesEntry, Equatable { +public struct LocalizationListState: Codable { public var availableOfficialLocalizations: [LocalizationInfo] public var availableSavedLocalizations: [LocalizationInfo] @@ -13,21 +13,17 @@ public struct LocalizationListState: PreferencesEntry, Equatable { self.availableSavedLocalizations = availableSavedLocalizations } - public init(decoder: PostboxDecoder) { - self.availableOfficialLocalizations = decoder.decodeObjectArrayWithDecoderForKey("availableOfficialLocalizations") - self.availableSavedLocalizations = decoder.decodeObjectArrayWithDecoderForKey("availableSavedLocalizations") + public init(from decoder: Decoder) throws { + let container = try decoder.container(keyedBy: StringCodingKey.self) + + self.availableOfficialLocalizations = (try? container.decode([LocalizationInfo].self, forKey: "availableOfficialLocalizations")) ?? [] + self.availableSavedLocalizations = (try? container.decode([LocalizationInfo].self, forKey: "availableSavedLocalizations")) ?? [] } - public func encode(_ encoder: PostboxEncoder) { - encoder.encodeObjectArray(self.availableOfficialLocalizations, forKey: "availableOfficialLocalizations") - encoder.encodeObjectArray(self.availableSavedLocalizations, forKey: "availableSavedLocalizations") - } - - public func isEqual(to: PreferencesEntry) -> Bool { - guard let to = to as? LocalizationListState else { - return false - } - - return self == to + public func encode(to encoder: Encoder) throws { + var container = encoder.container(keyedBy: StringCodingKey.self) + + try container.encode(self.availableOfficialLocalizations, forKey: "availableOfficialLocalizations") + try container.encode(self.availableSavedLocalizations, forKey: "availableSavedLocalizations") } } diff --git a/submodules/TelegramCore/Sources/SyncCore/SyncCore_LocalizationSettings.swift b/submodules/TelegramCore/Sources/SyncCore/SyncCore_LocalizationSettings.swift index 43dd26d943..96b1787377 100644 --- a/submodules/TelegramCore/Sources/SyncCore/SyncCore_LocalizationSettings.swift +++ b/submodules/TelegramCore/Sources/SyncCore/SyncCore_LocalizationSettings.swift @@ -1,8 +1,7 @@ import Foundation import Postbox - -public final class LocalizationComponent: Equatable, PostboxCoding { +public final class LocalizationComponent: Equatable, Codable { public let languageCode: String public let localizedName: String public let localization: Localization @@ -15,22 +14,22 @@ public final class LocalizationComponent: Equatable, PostboxCoding { self.customPluralizationCode = customPluralizationCode } - public init(decoder: PostboxDecoder) { - self.languageCode = decoder.decodeStringForKey("lc", orElse: "") - self.localizedName = decoder.decodeStringForKey("localizedName", orElse: "") - self.localization = decoder.decodeObjectForKey("loc", decoder: { Localization(decoder: $0) }) as! Localization - self.customPluralizationCode = decoder.decodeOptionalStringForKey("cpl") + public init(from decoder: Decoder) throws { + let container = try decoder.container(keyedBy: StringCodingKey.self) + + self.languageCode = (try? container.decode(String.self, forKey: "lc")) ?? "" + self.localizedName = (try? container.decode(String.self, forKey: "localizedName")) ?? "" + self.localization = try container.decode(Localization.self, forKey: "loc") + self.customPluralizationCode = try container.decodeIfPresent(String.self, forKey: "cpl") } - public func encode(_ encoder: PostboxEncoder) { - encoder.encodeString(self.languageCode, forKey: "lc") - encoder.encodeString(self.localizedName, forKey: "localizedName") - encoder.encodeObject(self.localization, forKey: "loc") - if let customPluralizationCode = self.customPluralizationCode { - encoder.encodeString(customPluralizationCode, forKey: "cpl") - } else { - encoder.encodeNil(forKey: "cpl") - } + public func encode(to encoder: Encoder) throws { + var container = encoder.container(keyedBy: StringCodingKey.self) + + try container.encode(self.languageCode, forKey: "lc") + try container.encode(self.localizedName, forKey: "localizedName") + try container.encode(self.localization, forKey: "loc") + try container.encodeIfPresent(self.customPluralizationCode, forKey: "cpl") } public static func ==(lhs: LocalizationComponent, rhs: LocalizationComponent) -> Bool { @@ -50,7 +49,7 @@ public final class LocalizationComponent: Equatable, PostboxCoding { } } -public final class LocalizationSettings: PreferencesEntry, Equatable { +public final class LocalizationSettings: Codable, Equatable { public let primaryComponent: LocalizationComponent public let secondaryComponent: LocalizationComponent? @@ -59,31 +58,28 @@ public final class LocalizationSettings: PreferencesEntry, Equatable { self.secondaryComponent = secondaryComponent } - public init(decoder: PostboxDecoder) { - if let languageCode = decoder.decodeOptionalStringForKey("lc") { - self.primaryComponent = LocalizationComponent(languageCode: languageCode, localizedName: "", localization: decoder.decodeObjectForKey("loc", decoder: { Localization(decoder: $0) }) as! Localization, customPluralizationCode: nil) + public init(from decoder: Decoder) throws { + let container = try decoder.container(keyedBy: StringCodingKey.self) + + if let languageCode = try container.decodeIfPresent(String.self, forKey: "lc") { + self.primaryComponent = LocalizationComponent( + languageCode: languageCode, + localizedName: "", + localization: try container.decode(Localization.self, forKey: "loc"), + customPluralizationCode: nil + ) self.secondaryComponent = nil } else { - self.primaryComponent = decoder.decodeObjectForKey("primaryComponent", decoder: { LocalizationComponent(decoder: $0) }) as! LocalizationComponent - self.secondaryComponent = decoder.decodeObjectForKey("secondaryComponent", decoder: { LocalizationComponent(decoder: $0) }) as? LocalizationComponent + self.primaryComponent = try container.decode(LocalizationComponent.self, forKey: "primaryComponent") + self.secondaryComponent = try container.decodeIfPresent(LocalizationComponent.self, forKey: "secondaryComponent") } } - public func encode(_ encoder: PostboxEncoder) { - encoder.encodeObject(self.primaryComponent, forKey: "primaryComponent") - if let secondaryComponent = self.secondaryComponent { - encoder.encodeObject(secondaryComponent, forKey: "secondaryComponent") - } else { - encoder.encodeNil(forKey: "secondaryComponent") - } - } - - public func isEqual(to: PreferencesEntry) -> Bool { - if let to = to as? LocalizationSettings { - return self == to - } else { - return false - } + public func encode(to encoder: Encoder) throws { + var container = encoder.container(keyedBy: StringCodingKey.self) + + try container.encode(self.primaryComponent, forKey: "primaryComponent") + try container.encodeIfPresent(self.secondaryComponent, forKey: "secondaryComponent") } public static func ==(lhs: LocalizationSettings, rhs: LocalizationSettings) -> Bool { diff --git a/submodules/TelegramCore/Sources/SyncCore/SyncCore_LoggingSettings.swift b/submodules/TelegramCore/Sources/SyncCore/SyncCore_LoggingSettings.swift index e4925d41e7..94d0711800 100644 --- a/submodules/TelegramCore/Sources/SyncCore/SyncCore_LoggingSettings.swift +++ b/submodules/TelegramCore/Sources/SyncCore/SyncCore_LoggingSettings.swift @@ -1,6 +1,6 @@ import Postbox -public final class LoggingSettings: PreferencesEntry, Equatable { +public final class LoggingSettings: Codable { public let logToFile: Bool public let logToConsole: Bool public let redactSensitiveData: Bool @@ -17,16 +17,20 @@ public final class LoggingSettings: PreferencesEntry, Equatable { self.redactSensitiveData = redactSensitiveData } - public init(decoder: PostboxDecoder) { - self.logToFile = decoder.decodeInt32ForKey("logToFile", orElse: 0) != 0 - self.logToConsole = decoder.decodeInt32ForKey("logToConsole", orElse: 0) != 0 - self.redactSensitiveData = decoder.decodeInt32ForKey("redactSensitiveData", orElse: 1) != 0 + public init(from decoder: Decoder) throws { + let container = try decoder.container(keyedBy: StringCodingKey.self) + + self.logToFile = ((try? container.decode(Int32.self, forKey: "logToFile")) ?? 0) != 0 + self.logToConsole = ((try? container.decode(Int32.self, forKey: "logToConsole")) ?? 0) != 0 + self.redactSensitiveData = ((try? container.decode(Int32.self, forKey: "redactSensitiveData")) ?? 1) != 0 } - public func encode(_ encoder: PostboxEncoder) { - encoder.encodeInt32(self.logToFile ? 1 : 0, forKey: "logToFile") - encoder.encodeInt32(self.logToConsole ? 1 : 0, forKey: "logToConsole") - encoder.encodeInt32(self.redactSensitiveData ? 1 : 0, forKey: "redactSensitiveData") + public func encode(to encoder: Encoder) throws { + var container = encoder.container(keyedBy: StringCodingKey.self) + + try container.encode(self.logToFile ? 1 : 0, forKey: "logToFile") + try container.encode(self.logToConsole ? 1 : 0, forKey: "logToConsole") + try container.encode(self.redactSensitiveData ? 1 : 0, forKey: "redactSensitiveData") } public func withUpdatedLogToFile(_ logToFile: Bool) -> LoggingSettings { @@ -53,12 +57,4 @@ public final class LoggingSettings: PreferencesEntry, Equatable { } return true } - - public func isEqual(to: PreferencesEntry) -> Bool { - guard let to = to as? LoggingSettings else { - return false - } - - return self == to - } } diff --git a/submodules/TelegramCore/Sources/SyncCore/SyncCore_NetworkSettings.swift b/submodules/TelegramCore/Sources/SyncCore/SyncCore_NetworkSettings.swift index 94d17222eb..0936f36666 100644 --- a/submodules/TelegramCore/Sources/SyncCore/SyncCore_NetworkSettings.swift +++ b/submodules/TelegramCore/Sources/SyncCore/SyncCore_NetworkSettings.swift @@ -1,57 +1,33 @@ import Postbox -public struct NetworkSettings: PreferencesEntry, Equatable { +public struct NetworkSettings: Codable { public var reducedBackupDiscoveryTimeout: Bool public var applicationUpdateUrlPrefix: String? public var backupHostOverride: String? - public var defaultEnableTempKeys: Bool - public var userEnableTempKeys: Bool? public static var defaultSettings: NetworkSettings { - return NetworkSettings(reducedBackupDiscoveryTimeout: false, applicationUpdateUrlPrefix: nil, backupHostOverride: nil, defaultEnableTempKeys: false, userEnableTempKeys: nil) + return NetworkSettings(reducedBackupDiscoveryTimeout: false, applicationUpdateUrlPrefix: nil, backupHostOverride: nil) } - public init(reducedBackupDiscoveryTimeout: Bool, applicationUpdateUrlPrefix: String?, backupHostOverride: String?, defaultEnableTempKeys: Bool, userEnableTempKeys: Bool?) { + public init(reducedBackupDiscoveryTimeout: Bool, applicationUpdateUrlPrefix: String?, backupHostOverride: String?) { self.reducedBackupDiscoveryTimeout = reducedBackupDiscoveryTimeout self.applicationUpdateUrlPrefix = applicationUpdateUrlPrefix self.backupHostOverride = backupHostOverride - self.defaultEnableTempKeys = defaultEnableTempKeys - self.userEnableTempKeys = userEnableTempKeys } - public init(decoder: PostboxDecoder) { - self.reducedBackupDiscoveryTimeout = decoder.decodeInt32ForKey("reducedBackupDiscoveryTimeout", orElse: 0) != 0 - self.applicationUpdateUrlPrefix = decoder.decodeOptionalStringForKey("applicationUpdateUrlPrefix") - self.backupHostOverride = decoder.decodeOptionalStringForKey("backupHostOverride") - self.defaultEnableTempKeys = decoder.decodeBoolForKey("defaultEnableTempKeys", orElse: false) - self.userEnableTempKeys = decoder.decodeOptionalBoolForKey("userEnableTempKeys") + public init(from decoder: Decoder) throws { + let container = try decoder.container(keyedBy: StringCodingKey.self) + + self.reducedBackupDiscoveryTimeout = ((try? container.decode(Int32.self, forKey: "reducedBackupDiscoveryTimeout")) ?? 0) != 0 + self.applicationUpdateUrlPrefix = try? container.decodeIfPresent(String.self, forKey: "applicationUpdateUrlPrefix") + self.backupHostOverride = try? container.decodeIfPresent(String.self, forKey: "backupHostOverride") } - public func encode(_ encoder: PostboxEncoder) { - encoder.encodeInt32(self.reducedBackupDiscoveryTimeout ? 1 : 0, forKey: "reducedBackupDiscoveryTimeout") - if let applicationUpdateUrlPrefix = self.applicationUpdateUrlPrefix { - encoder.encodeString(applicationUpdateUrlPrefix, forKey: "applicationUpdateUrlPrefix") - } else { - encoder.encodeNil(forKey: "applicationUpdateUrlPrefix") - } - if let backupHostOverride = self.backupHostOverride { - encoder.encodeString(backupHostOverride, forKey: "backupHostOverride") - } else { - encoder.encodeNil(forKey: "backupHostOverride") - } - encoder.encodeBool(self.defaultEnableTempKeys, forKey: "defaultEnableTempKeys") - if let userEnableTempKeys = self.userEnableTempKeys { - encoder.encodeBool(userEnableTempKeys, forKey: "userEnableTempKeys") - } else { - encoder.encodeNil(forKey: "userEnableTempKeys") - } - } - - public func isEqual(to: PreferencesEntry) -> Bool { - guard let to = to as? NetworkSettings else { - return false - } - - return self == to + public func encode(to encoder: Encoder) throws { + var container = encoder.container(keyedBy: StringCodingKey.self) + + try container.encode((self.reducedBackupDiscoveryTimeout ? 1 : 0) as Int32, forKey: "reducedBackupDiscoveryTimeout") + try container.encodeIfPresent(self.applicationUpdateUrlPrefix, forKey: "applicationUpdateUrlPrefix") + try container.encodeIfPresent(self.backupHostOverride, forKey: "backupHostOverride") } } diff --git a/submodules/TelegramCore/Sources/SyncCore/SyncCore_PeerReference.swift b/submodules/TelegramCore/Sources/SyncCore/SyncCore_PeerReference.swift index 9b93b4f6e6..6830c2b3f7 100644 --- a/submodules/TelegramCore/Sources/SyncCore/SyncCore_PeerReference.swift +++ b/submodules/TelegramCore/Sources/SyncCore/SyncCore_PeerReference.swift @@ -1,18 +1,36 @@ import Postbox public enum PeerReference: PostboxCoding, Hashable, Equatable { - case user(id: Int32, accessHash: Int64) - case group(id: Int32) - case channel(id: Int32, accessHash: Int64) + case user(id: Int64, accessHash: Int64) + case group(id: Int64) + case channel(id: Int64, accessHash: Int64) public init(decoder: PostboxDecoder) { switch decoder.decodeInt32ForKey("_r", orElse: 0) { case 0: - self = .user(id: decoder.decodeInt32ForKey("i", orElse: 0), accessHash: decoder.decodeInt64ForKey("h", orElse: 0)) + let id: Int64 + if let idValue = decoder.decodeOptionalInt64ForKey("i") { + id = idValue + } else { + id = Int64(decoder.decodeInt32ForKey("i", orElse: 0)) + } + self = .user(id: id, accessHash: decoder.decodeInt64ForKey("h", orElse: 0)) case 1: - self = .group(id: decoder.decodeInt32ForKey("i", orElse: 0)) + let id: Int64 + if let idValue = decoder.decodeOptionalInt64ForKey("i") { + id = idValue + } else { + id = Int64(decoder.decodeInt32ForKey("i", orElse: 0)) + } + self = .group(id: id) case 2: - self = .channel(id: decoder.decodeInt32ForKey("i", orElse: 0), accessHash: decoder.decodeInt64ForKey("h", orElse: 0)) + let id: Int64 + if let idValue = decoder.decodeOptionalInt64ForKey("i") { + id = idValue + } else { + id = Int64(decoder.decodeInt32ForKey("i", orElse: 0)) + } + self = .channel(id: id, accessHash: decoder.decodeInt64ForKey("h", orElse: 0)) default: assertionFailure() self = .user(id: 0, accessHash: 0) @@ -23,14 +41,14 @@ public enum PeerReference: PostboxCoding, Hashable, Equatable { switch self { case let .user(id, accessHash): encoder.encodeInt32(0, forKey: "_r") - encoder.encodeInt32(id, forKey: "i") + encoder.encodeInt64(id, forKey: "i") encoder.encodeInt64(accessHash, forKey: "h") case let .group(id): encoder.encodeInt32(1, forKey: "_r") - encoder.encodeInt32(id, forKey: "i") + encoder.encodeInt64(id, forKey: "i") case let .channel(id, accessHash): encoder.encodeInt32(2, forKey: "_r") - encoder.encodeInt32(id, forKey: "i") + encoder.encodeInt64(id, forKey: "i") encoder.encodeInt64(accessHash, forKey: "h") } } @@ -39,15 +57,15 @@ public enum PeerReference: PostboxCoding, Hashable, Equatable { switch peer { case let user as TelegramUser: if let accessHash = user.accessHash { - self = .user(id: user.id.id._internalGetInt32Value(), accessHash: accessHash.value) + self = .user(id: user.id.id._internalGetInt64Value(), accessHash: accessHash.value) } else { return nil } case let group as TelegramGroup: - self = .group(id: group.id.id._internalGetInt32Value()) + self = .group(id: group.id.id._internalGetInt64Value()) case let channel as TelegramChannel: if let accessHash = channel.accessHash { - self = .channel(id: channel.id.id._internalGetInt32Value(), accessHash: accessHash.value) + self = .channel(id: channel.id.id._internalGetInt64Value(), accessHash: accessHash.value) } else { return nil } diff --git a/submodules/TelegramCore/Sources/SyncCore/SyncCore_ProxySettings.swift b/submodules/TelegramCore/Sources/SyncCore/SyncCore_ProxySettings.swift index 468875d45d..dc386d20d8 100644 --- a/submodules/TelegramCore/Sources/SyncCore/SyncCore_ProxySettings.swift +++ b/submodules/TelegramCore/Sources/SyncCore/SyncCore_ProxySettings.swift @@ -1,43 +1,39 @@ import Foundation import Postbox -public enum ProxyServerConnection: Equatable, Hashable, PostboxCoding { +public enum ProxyServerConnection: Equatable, Hashable, Codable { case socks5(username: String?, password: String?) case mtp(secret: Data) - public init(decoder: PostboxDecoder) { - switch decoder.decodeInt32ForKey("_t", orElse: 0) { + public init(from decoder: Decoder) throws { + let container = try decoder.container(keyedBy: StringCodingKey.self) + + switch try container.decode(Int32.self, forKey: "_t") { case 0: - self = .socks5(username: decoder.decodeOptionalStringForKey("username"), password: decoder.decodeOptionalStringForKey("password")) + self = .socks5(username: try container.decodeIfPresent(String.self, forKey: "username"), password: try container.decodeIfPresent(String.self, forKey: "password")) case 1: - self = .mtp(secret: decoder.decodeBytesForKey("secret")?.makeData() ?? Data()) + self = .mtp(secret: try container.decode(Data.self, forKey: "secret")) default: self = .socks5(username: nil, password: nil) } } - public func encode(_ encoder: PostboxEncoder) { + public func encode(to encoder: Encoder) throws { + var container = encoder.container(keyedBy: StringCodingKey.self) + switch self { case let .socks5(username, password): - encoder.encodeInt32(0, forKey: "_t") - if let username = username { - encoder.encodeString(username, forKey: "username") - } else { - encoder.encodeNil(forKey: "username") - } - if let password = password { - encoder.encodeString(password, forKey: "password") - } else { - encoder.encodeNil(forKey: "password") - } + try container.encode(0 as Int32, forKey: "_t") + try container.encodeIfPresent(username, forKey: "username") + try container.encodeIfPresent(password, forKey: "password") case let .mtp(secret): - encoder.encodeInt32(1, forKey: "_t") - encoder.encodeBytes(MemoryBuffer(data: secret), forKey: "secret") + try container.encode(1 as Int32, forKey: "_t") + try container.encode(secret, forKey: "secret") } } } -public struct ProxyServerSettings: PostboxCoding, Equatable, Hashable { +public struct ProxyServerSettings: Codable, Equatable, Hashable { public let host: String public let port: Int32 public let connection: ProxyServerConnection @@ -48,31 +44,33 @@ public struct ProxyServerSettings: PostboxCoding, Equatable, Hashable { self.connection = connection } - public init(decoder: PostboxDecoder) { - self.host = decoder.decodeStringForKey("host", orElse: "") - self.port = decoder.decodeInt32ForKey("port", orElse: 0) - if let username = decoder.decodeOptionalStringForKey("username") { - self.connection = .socks5(username: username, password: decoder.decodeOptionalStringForKey("password")) + public init(from decoder: Decoder) throws { + let container = try decoder.container(keyedBy: StringCodingKey.self) + + self.host = (try? container.decode(String.self, forKey: "host")) ?? "" + self.port = (try? container.decode(Int32.self, forKey: "port")) ?? 0 + if let username = try container.decodeIfPresent(String.self, forKey: "username") { + self.connection = .socks5(username: username, password: try container.decodeIfPresent(String.self, forKey: "password")) } else { - self.connection = decoder.decodeObjectForKey("connection", decoder: ProxyServerConnection.init(decoder:)) as? ProxyServerConnection ?? ProxyServerConnection.socks5(username: nil, password: nil) + self.connection = (try? container.decodeIfPresent(ProxyServerConnection.self, forKey: "connection")) ?? ProxyServerConnection.socks5(username: nil, password: nil) } } - public func encode(_ encoder: PostboxEncoder) { - encoder.encodeString(self.host, forKey: "host") - encoder.encodeInt32(self.port, forKey: "port") - encoder.encodeObject(self.connection, forKey: "connection") + public func encode(to encoder: Encoder) throws { + var container = encoder.container(keyedBy: StringCodingKey.self) + + try container.encode(self.host, forKey: "host") + try container.encode(self.port, forKey: "port") + try container.encode(self.connection, forKey: "connection") } - - public var hashValue: Int { - var hash = self.host.hashValue - hash = hash &* 31 &+ self.port.hashValue - hash = hash &* 31 &+ self.connection.hashValue - return hash + + public func hash(into hasher: inout Hasher) { + hasher.combine(self.host) + hasher.combine(self.connection) } } -public struct ProxySettings: PreferencesEntry, Equatable { +public struct ProxySettings: Codable, Equatable { public var enabled: Bool public var servers: [ProxyServerSettings] public var activeServer: ProxyServerSettings? @@ -89,41 +87,22 @@ public struct ProxySettings: PreferencesEntry, Equatable { self.useForCalls = useForCalls } - public init(decoder: PostboxDecoder) { - if let _ = decoder.decodeOptionalStringForKey("host") { - let legacyServer = ProxyServerSettings(decoder: decoder) - if !legacyServer.host.isEmpty && legacyServer.port != 0 { - self.enabled = true - self.servers = [legacyServer] - } else { - self.enabled = false - self.servers = [] - } - } else { - self.enabled = decoder.decodeInt32ForKey("enabled", orElse: 0) != 0 - self.servers = decoder.decodeObjectArrayWithDecoderForKey("servers") - } - self.activeServer = decoder.decodeObjectForKey("activeServer", decoder: ProxyServerSettings.init(decoder:)) as? ProxyServerSettings - self.useForCalls = decoder.decodeInt32ForKey("useForCalls", orElse: 0) != 0 + public init(from decoder: Decoder) throws { + let container = try decoder.container(keyedBy: StringCodingKey.self) + + self.enabled = ((try? container.decode(Int32.self, forKey: "enabled")) ?? 0) != 0 + self.servers = try container.decode([ProxyServerSettings].self, forKey: "servers") + self.activeServer = try container.decodeIfPresent(ProxyServerSettings.self, forKey: "activeServer") + self.useForCalls = ((try? container.decode(Int32.self, forKey: "useForCalls")) ?? 0) != 0 } - public func encode(_ encoder: PostboxEncoder) { - encoder.encodeInt32(self.enabled ? 1 : 0, forKey: "enabled") - encoder.encodeObjectArray(self.servers, forKey: "servers") - if let activeServer = self.activeServer { - encoder.encodeObject(activeServer, forKey: "activeServer") - } else { - encoder.encodeNil(forKey: "activeServer") - } - encoder.encodeInt32(self.useForCalls ? 1 : 0, forKey: "useForCalls") - } - - public func isEqual(to: PreferencesEntry) -> Bool { - guard let to = to as? ProxySettings else { - return false - } - - return self == to + public func encode(to encoder: Encoder) throws { + var container = encoder.container(keyedBy: StringCodingKey.self) + + try container.encode((self.enabled ? 1 : 0) as Int32, forKey: "enabled") + try container.encode(self.servers, forKey: "servers") + try container.encodeIfPresent(self.activeServer, forKey: "activeServer") + try container.encode((self.useForCalls ? 1 : 0) as Int32, forKey: "useForCalls") } public var effectiveActiveServer: ProxyServerSettings? { diff --git a/submodules/TelegramCore/Sources/SyncCore/SyncCore_RemoteStorageConfiguration.swift b/submodules/TelegramCore/Sources/SyncCore/SyncCore_RemoteStorageConfiguration.swift index d8a5efd263..3b6e620157 100644 --- a/submodules/TelegramCore/Sources/SyncCore/SyncCore_RemoteStorageConfiguration.swift +++ b/submodules/TelegramCore/Sources/SyncCore/SyncCore_RemoteStorageConfiguration.swift @@ -1,25 +1,26 @@ import Postbox -public final class RemoteStorageConfiguration: PreferencesEntry { +public final class RemoteStorageConfiguration: Codable, Equatable { public let webDocumentsHostDatacenterId: Int32 public init(webDocumentsHostDatacenterId: Int32) { self.webDocumentsHostDatacenterId = webDocumentsHostDatacenterId } - public init(decoder: PostboxDecoder) { - self.webDocumentsHostDatacenterId = decoder.decodeInt32ForKey("webDocumentsHostDatacenterId", orElse: 4) + public init(from decoder: Decoder) throws { + let container = try decoder.container(keyedBy: StringCodingKey.self) + + self.webDocumentsHostDatacenterId = try container.decode(Int32.self, forKey: "webDocumentsHostDatacenterId") } - public func encode(_ encoder: PostboxEncoder) { - encoder.encodeInt32(self.webDocumentsHostDatacenterId, forKey: "webDocumentsHostDatacenterId") + public func encode(to encoder: Encoder) throws { + var container = encoder.container(keyedBy: StringCodingKey.self) + + try container.encode(self.webDocumentsHostDatacenterId, forKey: "webDocumentsHostDatacenterId") } - - public func isEqual(to: PreferencesEntry) -> Bool { - guard let to = to as? RemoteStorageConfiguration else { - return false - } - if self.webDocumentsHostDatacenterId != to.webDocumentsHostDatacenterId { + + public static func ==(lhs: RemoteStorageConfiguration, rhs: RemoteStorageConfiguration) -> Bool { + if lhs.webDocumentsHostDatacenterId != rhs.webDocumentsHostDatacenterId { return false } return true diff --git a/submodules/TelegramCore/Sources/SyncCore/SyncCore_SearchBotsConfiguration.swift b/submodules/TelegramCore/Sources/SyncCore/SyncCore_SearchBotsConfiguration.swift index f2d8972db8..3e188d4e57 100644 --- a/submodules/TelegramCore/Sources/SyncCore/SyncCore_SearchBotsConfiguration.swift +++ b/submodules/TelegramCore/Sources/SyncCore/SyncCore_SearchBotsConfiguration.swift @@ -1,7 +1,7 @@ import Foundation import Postbox -public struct SearchBotsConfiguration: Equatable, PreferencesEntry { +public struct SearchBotsConfiguration: Equatable, Codable { public let imageBotUsername: String? public let gifBotUsername: String? public let venueBotUsername: String? @@ -16,40 +16,25 @@ public struct SearchBotsConfiguration: Equatable, PreferencesEntry { self.venueBotUsername = venueBotUsername } - public init(decoder: PostboxDecoder) { - self.imageBotUsername = decoder.decodeOptionalStringForKey("img") - self.gifBotUsername = decoder.decodeOptionalStringForKey("gif") - self.venueBotUsername = decoder.decodeOptionalStringForKey("venue") + public init(from decoder: Decoder) throws { + let container = try decoder.container(keyedBy: StringCodingKey.self) + + self.imageBotUsername = try container.decodeIfPresent(String.self, forKey: "img") + self.gifBotUsername = try container.decodeIfPresent(String.self, forKey: "gif") + self.venueBotUsername = try container.decodeIfPresent(String.self, forKey: "venue") } - public func encode(_ encoder: PostboxEncoder) { - if let imageBotUsername = self.imageBotUsername { - encoder.encodeString(imageBotUsername, forKey: "img") - } else { - encoder.encodeNil(forKey: "img") - } - if let gifBotUsername = self.gifBotUsername { - encoder.encodeString(gifBotUsername, forKey: "gif") - } else { - encoder.encodeNil(forKey: "gif") - } - if let venueBotUsername = self.venueBotUsername { - encoder.encodeString(venueBotUsername, forKey: "venue") - } else { - encoder.encodeNil(forKey: "venue") - } - } - - public func isEqual(to: PreferencesEntry) -> Bool { - guard let to = to as? SearchBotsConfiguration else { - return false - } - return self == to + public func encode(to encoder: Encoder) throws { + var container = encoder.container(keyedBy: StringCodingKey.self) + + try container.encodeIfPresent(self.imageBotUsername, forKey: "img") + try container.encodeIfPresent(self.gifBotUsername, forKey: "gif") + try container.encodeIfPresent(self.venueBotUsername, forKey: "venue") } } public func currentSearchBotsConfiguration(transaction: Transaction) -> SearchBotsConfiguration { - if let entry = transaction.getPreferencesEntry(key: PreferencesKeys.searchBotsConfiguration) as? SearchBotsConfiguration { + if let entry = transaction.getPreferencesEntry(key: PreferencesKeys.searchBotsConfiguration)?.get(SearchBotsConfiguration.self) { return entry } else { return SearchBotsConfiguration.defaultValue @@ -57,7 +42,7 @@ public func currentSearchBotsConfiguration(transaction: Transaction) -> SearchBo } public func updateSearchBotsConfiguration(transaction: Transaction, configuration: SearchBotsConfiguration) { - if !currentSearchBotsConfiguration(transaction: transaction).isEqual(to: configuration) { - transaction.setPreferencesEntry(key: PreferencesKeys.searchBotsConfiguration, value: configuration) + if currentSearchBotsConfiguration(transaction: transaction) != configuration { + transaction.setPreferencesEntry(key: PreferencesKeys.searchBotsConfiguration, value: PreferencesEntry(configuration)) } } diff --git a/submodules/TelegramCore/Sources/SyncCore/SyncCore_SecretChatSettings.swift b/submodules/TelegramCore/Sources/SyncCore/SyncCore_SecretChatSettings.swift index 88050f1e89..e25f56c8a7 100644 --- a/submodules/TelegramCore/Sources/SyncCore/SyncCore_SecretChatSettings.swift +++ b/submodules/TelegramCore/Sources/SyncCore/SyncCore_SecretChatSettings.swift @@ -2,7 +2,7 @@ import Foundation import Postbox -public struct SecretChatSettings: Equatable, PreferencesEntry { +public struct SecretChatSettings: Equatable, Codable { public private(set) var acceptOnThisDevice: Bool public static var defaultSettings: SecretChatSettings { @@ -13,19 +13,15 @@ public struct SecretChatSettings: Equatable, PreferencesEntry { self.acceptOnThisDevice = acceptOnThisDevice } - public init(decoder: PostboxDecoder) { - self.acceptOnThisDevice = decoder.decodeInt32ForKey("acceptOnThisDevice", orElse: 1) != 0 + public init(from decoder: Decoder) throws { + let container = try decoder.container(keyedBy: StringCodingKey.self) + + self.acceptOnThisDevice = ((try? container.decode(Int32.self, forKey: "acceptOnThisDevice")) ?? 1) != 0 } - public func encode(_ encoder: PostboxEncoder) { - encoder.encodeInt32(self.acceptOnThisDevice ? 1 : 0, forKey: "acceptOnThisDevice") - } - - public func isEqual(to: PreferencesEntry) -> Bool { - if let to = to as? SecretChatSettings { - return self == to - } else { - return false - } + public func encode(to encoder: Encoder) throws { + var container = encoder.container(keyedBy: StringCodingKey.self) + + try container.encode((self.acceptOnThisDevice ? 1 : 0) as Int32, forKey: "acceptOnThisDevice") } } diff --git a/submodules/TelegramCore/Sources/SyncCore/SyncCore_StandaloneAccountTransaction.swift b/submodules/TelegramCore/Sources/SyncCore/SyncCore_StandaloneAccountTransaction.swift index c847557787..2d16cfdff6 100644 --- a/submodules/TelegramCore/Sources/SyncCore/SyncCore_StandaloneAccountTransaction.swift +++ b/submodules/TelegramCore/Sources/SyncCore/SyncCore_StandaloneAccountTransaction.swift @@ -34,7 +34,7 @@ public let telegramPostboxSeedConfiguration: SeedConfiguration = { globalMessageIdsPeerIdNamespaces.insert(GlobalMessageIdsNamespace(peerIdNamespace: peerIdNamespace, messageIdNamespace: Namespaces.Message.Cloud)) } - return SeedConfiguration(globalMessageIdsPeerIdNamespaces: globalMessageIdsPeerIdNamespaces, initializeChatListWithHole: (topLevel: ChatListHole(index: MessageIndex(id: MessageId(peerId: PeerId(namespace: Namespaces.Peer.Empty, id: PeerId.Id._internalFromInt32Value(0)), namespace: Namespaces.Message.Cloud, id: 1), timestamp: Int32.max - 1)), groups: ChatListHole(index: MessageIndex(id: MessageId(peerId: PeerId(namespace: Namespaces.Peer.Empty, id: PeerId.Id._internalFromInt32Value(0)), namespace: Namespaces.Message.Cloud, id: 1), timestamp: Int32.max - 1))), messageHoles: messageHoles, upgradedMessageHoles: upgradedMessageHoles, messageThreadHoles: messageThreadHoles, existingMessageTags: MessageTags.all, messageTagsWithSummary: [.unseenPersonalMessage, .pinned], existingGlobalMessageTags: GlobalMessageTags.all, peerNamespacesRequiringMessageTextIndex: [Namespaces.Peer.SecretChat], peerSummaryCounterTags: { peer, isContact in + return SeedConfiguration(globalMessageIdsPeerIdNamespaces: globalMessageIdsPeerIdNamespaces, initializeChatListWithHole: (topLevel: ChatListHole(index: MessageIndex(id: MessageId(peerId: PeerId(namespace: Namespaces.Peer.Empty, id: PeerId.Id._internalFromInt64Value(0)), namespace: Namespaces.Message.Cloud, id: 1), timestamp: Int32.max - 1)), groups: ChatListHole(index: MessageIndex(id: MessageId(peerId: PeerId(namespace: Namespaces.Peer.Empty, id: PeerId.Id._internalFromInt64Value(0)), namespace: Namespaces.Message.Cloud, id: 1), timestamp: Int32.max - 1))), messageHoles: messageHoles, upgradedMessageHoles: upgradedMessageHoles, messageThreadHoles: messageThreadHoles, existingMessageTags: MessageTags.all, messageTagsWithSummary: [.unseenPersonalMessage, .pinned], existingGlobalMessageTags: GlobalMessageTags.all, peerNamespacesRequiringMessageTextIndex: [Namespaces.Peer.SecretChat], peerSummaryCounterTags: { peer, isContact in if let peer = peer as? TelegramUser { if peer.botInfo != nil { return .bot diff --git a/submodules/TelegramCore/Sources/SyncCore/SyncCore_SuggestedLocalizationEntry.swift b/submodules/TelegramCore/Sources/SyncCore/SyncCore_SuggestedLocalizationEntry.swift index 93b18cf4e2..df304b4ab5 100644 --- a/submodules/TelegramCore/Sources/SyncCore/SyncCore_SuggestedLocalizationEntry.swift +++ b/submodules/TelegramCore/Sources/SyncCore/SyncCore_SuggestedLocalizationEntry.swift @@ -1,6 +1,6 @@ import Postbox -public final class SuggestedLocalizationEntry: PreferencesEntry { +public final class SuggestedLocalizationEntry: Codable { public let languageCode: String public let isSeen: Bool @@ -9,22 +9,18 @@ public final class SuggestedLocalizationEntry: PreferencesEntry { self.isSeen = isSeen } - public init(decoder: PostboxDecoder) { - self.languageCode = decoder.decodeStringForKey("lc", orElse: "en") - self.isSeen = decoder.decodeInt32ForKey("s", orElse: 0) != 0 + public init(from decoder: Decoder) throws { + let container = try decoder.container(keyedBy: StringCodingKey.self) + + self.languageCode = try container.decode(String.self, forKey: "lc") + self.isSeen = (try container.decode(Int32.self, forKey: "s")) != 0 } - public func encode(_ encoder: PostboxEncoder) { - encoder.encodeString(self.languageCode, forKey: "lc") - encoder.encodeInt32(self.isSeen ? 1 : 0, forKey: "s") - } - - public func isEqual(to: PreferencesEntry) -> Bool { - if let to = to as? SuggestedLocalizationEntry { - return self == to - } else { - return false - } + public func encode(to encoder: Encoder) throws { + var container = encoder.container(keyedBy: StringCodingKey.self) + + try container.encode(self.languageCode, forKey: "lc") + try container.encode((self.isSeen ? 1 : 0) as Int32, forKey: "s") } public static func ==(lhs: SuggestedLocalizationEntry, rhs: SuggestedLocalizationEntry) -> Bool { diff --git a/submodules/TelegramCore/Sources/SyncCore/SyncCore_SynchronizePinnedChatsOperation.swift b/submodules/TelegramCore/Sources/SyncCore/SyncCore_SynchronizePinnedChatsOperation.swift index 02b21573c2..24dd5195fe 100644 --- a/submodules/TelegramCore/Sources/SyncCore/SyncCore_SynchronizePinnedChatsOperation.swift +++ b/submodules/TelegramCore/Sources/SyncCore/SyncCore_SynchronizePinnedChatsOperation.swift @@ -48,7 +48,7 @@ public func addSynchronizePinnedChatsOperation(transaction: Transaction, groupId var previousItemIds = transaction.getPinnedItemIds(groupId: groupId) var updateLocalIndex: Int32? - transaction.operationLogEnumerateEntries(peerId: PeerId(namespace: PeerId.Namespace._internalFromInt32Value(0), id: PeerId.Id._internalFromInt32Value(rawId)), tag: OperationLogTags.SynchronizePinnedChats, { entry in + transaction.operationLogEnumerateEntries(peerId: PeerId(namespace: PeerId.Namespace._internalFromInt32Value(0), id: PeerId.Id._internalFromInt64Value(Int64(rawId))), tag: OperationLogTags.SynchronizePinnedChats, { entry in updateLocalIndex = entry.tagLocalIndex if let contents = entry.contents as? SynchronizePinnedChatsOperation { previousItemIds = contents.previousItemIds @@ -57,7 +57,7 @@ public func addSynchronizePinnedChatsOperation(transaction: Transaction, groupId }) let operationContents = SynchronizePinnedChatsOperation(previousItemIds: previousItemIds) if let updateLocalIndex = updateLocalIndex { - let _ = transaction.operationLogRemoveEntry(peerId: PeerId(namespace: PeerId.Namespace._internalFromInt32Value(0), id: PeerId.Id._internalFromInt32Value(rawId)), tag: OperationLogTags.SynchronizePinnedChats, tagLocalIndex: updateLocalIndex) + let _ = transaction.operationLogRemoveEntry(peerId: PeerId(namespace: PeerId.Namespace._internalFromInt32Value(0), id: PeerId.Id._internalFromInt64Value(Int64(rawId))), tag: OperationLogTags.SynchronizePinnedChats, tagLocalIndex: updateLocalIndex) } - transaction.operationLogAddEntry(peerId: PeerId(namespace: PeerId.Namespace._internalFromInt32Value(0), id: PeerId.Id._internalFromInt32Value(rawId)), tag: OperationLogTags.SynchronizePinnedChats, tagLocalIndex: .automatic, tagMergedIndex: .automatic, contents: operationContents) + transaction.operationLogAddEntry(peerId: PeerId(namespace: PeerId.Namespace._internalFromInt32Value(0), id: PeerId.Id._internalFromInt64Value(Int64(rawId))), tag: OperationLogTags.SynchronizePinnedChats, tagLocalIndex: .automatic, tagMergedIndex: .automatic, contents: operationContents) } diff --git a/submodules/TelegramCore/Sources/SyncCore/SyncCore_TelegramPeerNotificationSettings.swift b/submodules/TelegramCore/Sources/SyncCore/SyncCore_TelegramPeerNotificationSettings.swift index 3909c52596..529efd76d7 100644 --- a/submodules/TelegramCore/Sources/SyncCore/SyncCore_TelegramPeerNotificationSettings.swift +++ b/submodules/TelegramCore/Sources/SyncCore/SyncCore_TelegramPeerNotificationSettings.swift @@ -170,7 +170,7 @@ public final class TelegramPeerNotificationSettings: PeerNotificationSettings, E self.displayPreviews = displayPreviews } - public init() { + public init(decoder: PostboxDecoder) { self.muteState = PeerMuteState.decodeInline(decoder) self.messageSound = PeerMessageSound.decodeInline(decoder) self.displayPreviews = PeerNotificationDisplayPreviews.decodeInline(decoder) diff --git a/submodules/TelegramCore/Sources/SyncCore/SyncCore_TelegramTheme.swift b/submodules/TelegramCore/Sources/SyncCore/SyncCore_TelegramTheme.swift index 2cdd71be2d..3a7c4d34f4 100644 --- a/submodules/TelegramCore/Sources/SyncCore/SyncCore_TelegramTheme.swift +++ b/submodules/TelegramCore/Sources/SyncCore/SyncCore_TelegramTheme.swift @@ -1,3 +1,4 @@ +import Foundation import Postbox public enum TelegramBaseTheme: Int32 { @@ -13,7 +14,7 @@ public extension UInt32 { } } -public final class TelegramThemeSettings: PostboxCoding, Equatable { +public final class TelegramThemeSettings: PostboxCoding, Codable, Equatable { public static func == (lhs: TelegramThemeSettings, rhs: TelegramThemeSettings) -> Bool { if lhs.baseTheme != rhs.baseTheme { return false @@ -63,6 +64,21 @@ public final class TelegramThemeSettings: PostboxCoding, Equatable { self.animateMessageColors = decoder.decodeInt32ForKey("animateMessageColors", orElse: 0) != 0 self.wallpaper = decoder.decodeObjectForKey("wallpaper", decoder: { TelegramWallpaper(decoder: $0) }) as? TelegramWallpaper } + + public init(from decoder: Decoder) throws { + let container = try decoder.container(keyedBy: StringCodingKey.self) + + self.baseTheme = TelegramBaseTheme(rawValue: try container.decode(Int32.self, forKey: "baseTheme")) ?? .classic + self.accentColor = UInt32(bitPattern: try container.decode(Int32.self, forKey: "accent")) + self.messageColors = (try container.decode([Int32].self, forKey: "messageColors")).map(UInt32.init(bitPattern:)) + self.animateMessageColors = (try container.decode(Int32.self, forKey: "animateMessageColors")) != 0 + + if let wallpaperData = try container.decodeIfPresent(Data.self, forKey: "wallpaper") { + self.wallpaper = TelegramWallpaper(decoder: PostboxDecoder(buffer: MemoryBuffer(data: wallpaperData))) + } else { + self.wallpaper = nil + } + } public func encode(_ encoder: PostboxEncoder) { encoder.encodeInt32(self.baseTheme.rawValue, forKey: "baseTheme") @@ -75,9 +91,26 @@ public final class TelegramThemeSettings: PostboxCoding, Equatable { encoder.encodeNil(forKey: "wallpaper") } } + + public func encode(to encoder: Encoder) throws { + var container = encoder.container(keyedBy: StringCodingKey.self) + + try container.encode(self.baseTheme.rawValue, forKey: "baseTheme") + try container.encode(Int32(bitPattern: self.accentColor), forKey: "accent") + try container.encode(self.messageColors.map(Int32.init(bitPattern:)), forKey: "messageColors") + try container.encode((self.animateMessageColors ? 1 : 0) as Int32, forKey: "animateMessageColors") + + if let wallpaper = self.wallpaper { + let innerEncoder = PostboxEncoder() + wallpaper.encode(innerEncoder) + try container.encode(innerEncoder.makeData(), forKey: "wallpaper") + } else { + try container.encodeNil(forKey: "wallpaper") + } + } } -public final class TelegramTheme: OrderedItemListEntryContents, Equatable { +public final class TelegramTheme: Codable, OrderedItemListEntryContents, Equatable { public let id: Int64 public let accessHash: Int64 public let slug: String @@ -111,6 +144,27 @@ public final class TelegramTheme: OrderedItemListEntryContents, Equatable { self.isDefault = decoder.decodeInt32ForKey("isDefault", orElse: 0) != 0 self.installCount = decoder.decodeOptionalInt32ForKey("installCount") } + + public init(from decoder: Decoder) throws { + let container = try decoder.container(keyedBy: StringCodingKey.self) + + self.id = try container.decode(Int64.self, forKey: "id") + self.accessHash = try container.decode(Int64.self, forKey: "accessHash") + self.slug = try container.decode(String.self, forKey: "slug") + self.title = try container.decode(String.self, forKey: "title") + + if let fileData = try container.decodeIfPresent(Data.self, forKey: "file") { + self.file = TelegramMediaFile(decoder: PostboxDecoder(buffer: MemoryBuffer(data: fileData))) + } else { + self.file = nil + } + + self.settings = try container.decodeIfPresent(TelegramThemeSettings.self, forKey: "settings") + + self.isCreator = (try container.decode(Int32.self, forKey: "isCreator")) != 0 + self.isDefault = (try container.decode(Int32.self, forKey: "isDefault")) != 0 + self.installCount = try container.decodeIfPresent(Int32.self, forKey: "installCount") + } public func encode(_ encoder: PostboxEncoder) { encoder.encodeInt64(self.id, forKey: "id") @@ -135,6 +189,26 @@ public final class TelegramTheme: OrderedItemListEntryContents, Equatable { encoder.encodeNil(forKey: "installCount") } } + + public func encode(to encoder: Encoder) throws { + var container = encoder.container(keyedBy: StringCodingKey.self) + + try container.encode(self.id, forKey: "id") + try container.encode(self.accessHash, forKey: "accessHash") + try container.encode(self.slug, forKey: "slug") + try container.encode(self.title, forKey: "title") + if let file = self.file { + let innerEncoder = PostboxEncoder() + file.encode(innerEncoder) + try container.encode(innerEncoder.makeData(), forKey: "file") + } else { + try container.encodeNil(forKey: "file") + } + try container.encodeIfPresent(self.settings, forKey: "settings") + try container.encode((self.isCreator ? 1 : 0) as Int32, forKey: "isCreator") + try container.encode((self.isDefault ? 1 : 0) as Int32, forKey: "isDefault") + try container.encodeIfPresent(self.installCount, forKey: "installCount") + } public static func ==(lhs: TelegramTheme, rhs: TelegramTheme) -> Bool { if lhs.id != rhs.id { diff --git a/submodules/TelegramCore/Sources/SyncCore/SyncCore_ThemeSettings.swift b/submodules/TelegramCore/Sources/SyncCore/SyncCore_ThemeSettings.swift index 4f4cfc163e..64191262a0 100644 --- a/submodules/TelegramCore/Sources/SyncCore/SyncCore_ThemeSettings.swift +++ b/submodules/TelegramCore/Sources/SyncCore/SyncCore_ThemeSettings.swift @@ -1,30 +1,22 @@ import Postbox -public final class ThemeSettings: PreferencesEntry, Equatable { +public final class ThemeSettings: Codable, Equatable { public let currentTheme: TelegramTheme? public init(currentTheme: TelegramTheme?) { self.currentTheme = currentTheme } - public init(decoder: PostboxDecoder) { - self.currentTheme = decoder.decodeObjectForKey("t", decoder: { TelegramTheme(decoder: $0) }) as? TelegramTheme + public init(from decoder: Decoder) throws { + let container = try decoder.container(keyedBy: StringCodingKey.self) + + self.currentTheme = try container.decodeIfPresent(TelegramTheme.self, forKey: "t") } - public func encode(_ encoder: PostboxEncoder) { - if let currentTheme = currentTheme { - encoder.encodeObject(currentTheme, forKey: "t") - } else { - encoder.encodeNil(forKey: "t") - } - } - - public func isEqual(to: PreferencesEntry) -> Bool { - if let to = to as? ThemeSettings { - return self == to - } else { - return false - } + public func encode(to encoder: Encoder) throws { + var container = encoder.container(keyedBy: StringCodingKey.self) + + try container.encodeIfPresent(self.currentTheme, forKey: "t") } public static func ==(lhs: ThemeSettings, rhs: ThemeSettings) -> Bool { diff --git a/submodules/TelegramCore/Sources/SyncCore/SyncCore_VoipConfiguration.swift b/submodules/TelegramCore/Sources/SyncCore/SyncCore_VoipConfiguration.swift index ddc94d0152..c91b598a8b 100644 --- a/submodules/TelegramCore/Sources/SyncCore/SyncCore_VoipConfiguration.swift +++ b/submodules/TelegramCore/Sources/SyncCore/SyncCore_VoipConfiguration.swift @@ -7,7 +7,7 @@ public enum VoiceCallP2PMode: Int32 { case always = 2 } -public struct VoipConfiguration: PreferencesEntry, Equatable { +public struct VoipConfiguration: Codable, Equatable { public var serializedData: String? public static var defaultValue: VoipConfiguration { @@ -18,22 +18,15 @@ public struct VoipConfiguration: PreferencesEntry, Equatable { self.serializedData = serializedData } - public init(decoder: PostboxDecoder) { - self.serializedData = decoder.decodeOptionalStringForKey("serializedData") + public init(from decoder: Decoder) throws { + let container = try decoder.container(keyedBy: StringCodingKey.self) + + self.serializedData = try container.decodeIfPresent(String.self, forKey: "serializedData") } - public func encode(_ encoder: PostboxEncoder) { - if let serializedData = self.serializedData { - encoder.encodeString(serializedData, forKey: "serializedData") - } else { - encoder.encodeNil(forKey: "serializedData") - } - } - - public func isEqual(to: PreferencesEntry) -> Bool { - guard let to = to as? VoipConfiguration else { - return false - } - return self == to + public func encode(to encoder: Encoder) throws { + var container = encoder.container(keyedBy: StringCodingKey.self) + + try container.encodeIfPresent(self.serializedData, forKey: "serializedData") } } diff --git a/submodules/TelegramCore/Sources/SyncCore/SyncCore_WalletCollection.swift b/submodules/TelegramCore/Sources/SyncCore/SyncCore_WalletCollection.swift deleted file mode 100644 index acfe00e3c2..0000000000 --- a/submodules/TelegramCore/Sources/SyncCore/SyncCore_WalletCollection.swift +++ /dev/null @@ -1,56 +0,0 @@ -import Foundation -import Postbox - -public struct WalletCollectionItem: Equatable, PostboxCoding { - public let info: Data - public var exportCompleted: Bool - public var state: Data? - - public init(info: Data, exportCompleted: Bool, state: Data?) { - self.info = info - self.exportCompleted = exportCompleted - self.state = state - } - - public init(decoder: PostboxDecoder) { - self.info = decoder.decodeDataForKey("info") ?? Data() - self.exportCompleted = decoder.decodeInt32ForKey("exportCompleted", orElse: 0) != 0 - self.state = decoder.decodeDataForKey("state") - } - - public func encode(_ encoder: PostboxEncoder) { - encoder.encodeData(self.info, forKey: "info") - encoder.encodeInt32(self.exportCompleted ? 1 : 0, forKey: "exportCompleted") - if let state = self.state { - encoder.encodeData(state, forKey: "state") - } else { - encoder.encodeNil(forKey: "state") - } - } -} - -public struct WalletCollection: PreferencesEntry { - public var wallets: [WalletCollectionItem] - - public init(wallets: [WalletCollectionItem]) { - self.wallets = wallets - } - - public init(decoder: PostboxDecoder) { - self.wallets = decoder.decodeObjectArrayWithDecoderForKey("wallets") - } - - public func encode(_ encoder: PostboxEncoder) { - encoder.encodeObjectArray(self.wallets, forKey: "wallets") - } - - public func isEqual(to: PreferencesEntry) -> Bool { - guard let other = to as? WalletCollection else { - return false - } - if self.wallets != other.wallets { - return false - } - return true - } -} diff --git a/submodules/TelegramCore/Sources/SyncCore/SyncCore_wallapersState.swift b/submodules/TelegramCore/Sources/SyncCore/SyncCore_wallapersState.swift index 7d7a6af064..8e44e097ca 100644 --- a/submodules/TelegramCore/Sources/SyncCore/SyncCore_wallapersState.swift +++ b/submodules/TelegramCore/Sources/SyncCore/SyncCore_wallapersState.swift @@ -1,7 +1,8 @@ +import Foundation import Postbox import SwiftSignalKit -public struct WallpapersState: PreferencesEntry, Equatable { +public struct WallpapersState: Codable, Equatable { public var wallpapers: [TelegramWallpaper] public static var `default`: WallpapersState { @@ -12,24 +13,33 @@ public struct WallpapersState: PreferencesEntry, Equatable { self.wallpapers = wallpapers } - public init(decoder: PostboxDecoder) { - self.wallpapers = decoder.decodeObjectArrayWithDecoderForKey("wallpapers") + public init(from decoder: Decoder) throws { + let container = try decoder.container(keyedBy: StringCodingKey.self) + + let wallpapersData = try container.decode([Data].self, forKey: "wallpapers") + self.wallpapers = wallpapersData.map { data in + return TelegramWallpaper(decoder: PostboxDecoder(buffer: MemoryBuffer(data: data))) + } } - public func encode(_ encoder: PostboxEncoder) { - encoder.encodeObjectArray(self.wallpapers, forKey: "wallpapers") - } + public func encode(to encoder: Encoder) throws { + var container = encoder.container(keyedBy: StringCodingKey.self) - public func isEqual(to: PreferencesEntry) -> Bool { - return self == (to as? WallpapersState) + let wallpapersData: [Data] = self.wallpapers.map { wallpaper in + let innerEncoder = PostboxEncoder() + wallpaper.encode(innerEncoder) + return innerEncoder.makeData() + } + + try container.encode(wallpapersData, forKey: "wallpapers") } } public extension WallpapersState { static func update(transaction: AccountManagerModifier, _ f: (WallpapersState) -> WallpapersState) { transaction.updateSharedData(SharedDataKeys.wallapersState, { current in - let item = (transaction.getSharedData(SharedDataKeys.wallapersState) as? WallpapersState) ?? WallpapersState(wallpapers: []) - return f(item) + let item = (transaction.getSharedData(SharedDataKeys.wallapersState)?.get(WallpapersState.self)) ?? WallpapersState(wallpapers: []) + return PreferencesEntry(f(item)) }) } } diff --git a/submodules/TelegramCore/Sources/TelegramEngine/AccountData/RegisterNotificationToken.swift b/submodules/TelegramCore/Sources/TelegramEngine/AccountData/RegisterNotificationToken.swift index 4eaf3a7c92..25a5d71201 100644 --- a/submodules/TelegramCore/Sources/TelegramEngine/AccountData/RegisterNotificationToken.swift +++ b/submodules/TelegramCore/Sources/TelegramEngine/AccountData/RegisterNotificationToken.swift @@ -17,7 +17,7 @@ func _internal_unregisterNotificationToken(account: Account, token: Data, type: case .voip: mappedType = 9 } - return account.network.request(Api.functions.account.unregisterDevice(tokenType: mappedType, token: hexString(token), otherUids: otherAccountUserIds.map({ $0._internalGetInt32Value() }))) + return account.network.request(Api.functions.account.unregisterDevice(tokenType: mappedType, token: hexString(token), otherUids: otherAccountUserIds.map({ $0._internalGetInt64Value() }))) |> retryRequest |> ignoreValues } @@ -41,7 +41,7 @@ func _internal_registerNotificationToken(account: Account, token: Data, type: No if excludeMutedChats { flags |= 1 << 0 } - return account.network.request(Api.functions.account.registerDevice(flags: flags, tokenType: mappedType, token: hexString(token), appSandbox: sandbox ? .boolTrue : .boolFalse, secret: Buffer(data: keyData), otherUids: otherAccountUserIds.map({ $0._internalGetInt32Value() }))) + return account.network.request(Api.functions.account.registerDevice(flags: flags, tokenType: mappedType, token: hexString(token), appSandbox: sandbox ? .boolTrue : .boolFalse, secret: Buffer(data: keyData), otherUids: otherAccountUserIds.map({ $0._internalGetInt64Value() }))) |> retryRequest |> ignoreValues } diff --git a/submodules/TelegramCore/Sources/TelegramEngine/Auth/AuthTransfer.swift b/submodules/TelegramCore/Sources/TelegramEngine/Auth/AuthTransfer.swift index 0f0a569a89..21ceaf85e8 100644 --- a/submodules/TelegramCore/Sources/TelegramEngine/Auth/AuthTransfer.swift +++ b/submodules/TelegramCore/Sources/TelegramEngine/Auth/AuthTransfer.swift @@ -21,7 +21,7 @@ public enum ExportAuthTransferTokenResult { } func _internal_exportAuthTransferToken(accountManager: AccountManager, account: UnauthorizedAccount, otherAccountUserIds: [PeerId.Id], syncContacts: Bool) -> Signal { - return account.network.request(Api.functions.auth.exportLoginToken(apiId: account.networkArguments.apiId, apiHash: account.networkArguments.apiHash, exceptIds: otherAccountUserIds.map({ $0._internalGetInt32Value() }))) + return account.network.request(Api.functions.auth.exportLoginToken(apiId: account.networkArguments.apiId, apiHash: account.networkArguments.apiHash, exceptIds: otherAccountUserIds.map({ $0._internalGetInt64Value() }))) |> map(Optional.init) |> `catch` { error -> Signal in if error.errorDescription == "SESSION_PASSWORD_NEEDED" { diff --git a/submodules/TelegramCore/Sources/TelegramEngine/Calls/GroupCalls.swift b/submodules/TelegramCore/Sources/TelegramEngine/Calls/GroupCalls.swift index 884c143858..e4255094a1 100644 --- a/submodules/TelegramCore/Sources/TelegramEngine/Calls/GroupCalls.swift +++ b/submodules/TelegramCore/Sources/TelegramEngine/Calls/GroupCalls.swift @@ -2239,7 +2239,7 @@ func _internal_groupCallDisplayAsAvailablePeers(network: Network, postbox: Postb for chat in chats { if let groupOrChannel = parseTelegramGroupOrChannel(chat: chat) { switch chat { - case let .channel(_, _, _, _, _, _, _, _, _, _, _, _, participantsCount): + case let .channel(_, _, _, _, _, _, _, _, _, _, _, participantsCount): if let participantsCount = participantsCount { subscribers[groupOrChannel.id] = participantsCount } diff --git a/submodules/TelegramCore/Sources/TelegramEngine/Contacts/ContactManagement.swift b/submodules/TelegramCore/Sources/TelegramEngine/Contacts/ContactManagement.swift index a39575d6f3..74ab3af05c 100644 --- a/submodules/TelegramCore/Sources/TelegramEngine/Contacts/ContactManagement.swift +++ b/submodules/TelegramCore/Sources/TelegramEngine/Contacts/ContactManagement.swift @@ -10,7 +10,7 @@ private func md5(_ data: Data) -> Data { } } -private func updatedRemoteContactPeers(network: Network, hash: Int32) -> Signal<([Peer], [PeerId: PeerPresence], Int32)?, NoError> { +private func updatedRemoteContactPeers(network: Network, hash: Int64) -> Signal<([Peer], [PeerId: PeerPresence], Int32)?, NoError> { return network.request(Api.functions.contacts.getContacts(hash: hash), automaticFloodWait: false) |> map(Optional.init) |> `catch` { _ -> Signal in @@ -38,24 +38,23 @@ private func updatedRemoteContactPeers(network: Network, hash: Int32) -> Signal< } } -private func hashForCountAndIds(count: Int32, ids: [Int32]) -> Int32 { - var acc: Int64 = 0 +private func hashForCountAndIds(count: Int32, ids: [Int64]) -> Int64 { + var acc: UInt64 = 0 - acc = (acc &* 20261) &+ Int64(count) + combineInt64Hash(&acc, with: UInt64(count)) for id in ids { - acc = (acc &* 20261) &+ Int64(id) - acc = acc & Int64(0x7FFFFFFF) + combineInt64Hash(&acc, with: UInt64(bitPattern: id)) } - return Int32(acc & Int64(0x7FFFFFFF)) + return finalizeInt64Hash(acc) } func syncContactsOnce(network: Network, postbox: Postbox, accountPeerId: PeerId) -> Signal { - let initialContactPeerIdsHash = postbox.transaction { transaction -> Int32 in + let initialContactPeerIdsHash = postbox.transaction { transaction -> Int64 in let contactPeerIds = transaction.getContactPeerIds() let totalCount = transaction.getRemoteContactCount() let peerIds = Set(contactPeerIds.filter({ $0.namespace == Namespaces.Peer.CloudUser })) - return hashForCountAndIds(count: totalCount, ids: peerIds.map({ $0.id._internalGetInt32Value() }).sorted()) + return hashForCountAndIds(count: totalCount, ids: peerIds.map({ $0.id._internalGetInt64Value() }).sorted()) } let updatedPeers = initialContactPeerIdsHash diff --git a/submodules/TelegramCore/Sources/TelegramEngine/Localization/Countries.swift b/submodules/TelegramCore/Sources/TelegramEngine/Localization/Countries.swift index 143467c29c..037bfaba7c 100644 --- a/submodules/TelegramCore/Sources/TelegramEngine/Localization/Countries.swift +++ b/submodules/TelegramCore/Sources/TelegramEngine/Localization/Countries.swift @@ -3,12 +3,12 @@ import Postbox import SwiftSignalKit import TelegramApi -public struct Country: PostboxCoding, Equatable { +public struct Country: Codable, Equatable { public static func == (lhs: Country, rhs: Country) -> Bool { return lhs.id == rhs.id && lhs.name == rhs.name && lhs.localizedName == rhs.localizedName && lhs.countryCodes == rhs.countryCodes && lhs.hidden == rhs.hidden } - public struct CountryCode: PostboxCoding, Equatable { + public struct CountryCode: Codable, Equatable { public let code: String public let prefixes: [String] public let patterns: [String] @@ -19,16 +19,20 @@ public struct Country: PostboxCoding, Equatable { self.patterns = patterns } - public init(decoder: PostboxDecoder) { - self.code = decoder.decodeStringForKey("c", orElse: "") - self.prefixes = decoder.decodeStringArrayForKey("pfx") - self.patterns = decoder.decodeStringArrayForKey("ptrn") + public init(from decoder: Decoder) throws { + let container = try decoder.container(keyedBy: StringCodingKey.self) + + self.code = try container.decode(String.self, forKey: "c") + self.prefixes = try container.decode([String].self, forKey: "pfx") + self.patterns = try container.decode([String].self, forKey: "ptrn") } - public func encode(_ encoder: PostboxEncoder) { - encoder.encodeString(self.code, forKey: "c") - encoder.encodeStringArray(self.prefixes, forKey: "pfx") - encoder.encodeStringArray(self.patterns, forKey: "ptrn") + public func encode(to encoder: Encoder) throws { + var container = encoder.container(keyedBy: StringCodingKey.self) + + try container.encode(self.code, forKey: "c") + try container.encode(self.prefixes, forKey: "pfx") + try container.encode(self.patterns, forKey: "ptrn") } } @@ -46,28 +50,28 @@ public struct Country: PostboxCoding, Equatable { self.hidden = hidden } - public init(decoder: PostboxDecoder) { - self.id = decoder.decodeStringForKey("c", orElse: "") - self.name = decoder.decodeStringForKey("n", orElse: "") - self.localizedName = decoder.decodeOptionalStringForKey("ln") - self.countryCodes = decoder.decodeObjectArrayForKey("cc").map { $0 as! CountryCode } - self.hidden = decoder.decodeBoolForKey("h", orElse: false) + public init(from decoder: Decoder) throws { + let container = try decoder.container(keyedBy: StringCodingKey.self) + + self.id = try container.decode(String.self, forKey: "c") + self.name = try container.decode(String.self, forKey: "n") + self.localizedName = try container.decodeIfPresent(String.self, forKey: "ln") + self.countryCodes = try container.decode([CountryCode].self, forKey: "cc") + self.hidden = try container.decode(Bool.self, forKey: "h") } - public func encode(_ encoder: PostboxEncoder) { - encoder.encodeString(self.id, forKey: "c") - encoder.encodeString(self.name, forKey: "n") - if let localizedName = self.localizedName { - encoder.encodeString(localizedName, forKey: "ln") - } else { - encoder.encodeNil(forKey: "ln") - } - encoder.encodeObjectArray(self.countryCodes, forKey: "cc") - encoder.encodeBool(self.hidden, forKey: "h") + public func encode(to encoder: Encoder) throws { + var container = encoder.container(keyedBy: StringCodingKey.self) + + try container.encode(self.id, forKey: "c") + try container.encode(self.name, forKey: "n") + try container.encodeIfPresent(self.localizedName, forKey: "ln") + try container.encode(self.countryCodes, forKey: "cc") + try container.encode(self.hidden, forKey: "h") } } -public final class CountriesList: PreferencesEntry, Equatable { +public final class CountriesList: Codable, Equatable { public let countries: [Country] public let hash: Int32 @@ -76,22 +80,18 @@ public final class CountriesList: PreferencesEntry, Equatable { self.hash = hash } - public init(decoder: PostboxDecoder) { - self.countries = decoder.decodeObjectArrayForKey("c").map { $0 as! Country } - self.hash = decoder.decodeInt32ForKey("h", orElse: 0) + public init(from decoder: Decoder) throws { + let container = try decoder.container(keyedBy: StringCodingKey.self) + + self.countries = try container.decode([Country].self, forKey: "c") + self.hash = try container.decode(Int32.self, forKey: "h") } - public func encode(_ encoder: PostboxEncoder) { - encoder.encodeObjectArray(self.countries, forKey: "c") - encoder.encodeInt32(self.hash, forKey: "h") - } - - public func isEqual(to: PreferencesEntry) -> Bool { - if let to = to as? CountriesList { - return self == to - } else { - return false - } + public func encode(to encoder: Encoder) throws { + var container = encoder.container(keyedBy: StringCodingKey.self) + + try container.encode(self.countries, forKey: "c") + try container.encode(self.hash, forKey: "h") } public static func ==(lhs: CountriesList, rhs: CountriesList) -> Bool { @@ -113,7 +113,7 @@ func _internal_getCountriesList(accountManager: AccountManager take(1) |> map { sharedData -> ([Country], Int32) in - if let countriesList = sharedData.entries[SharedDataKeys.countriesList] as? CountriesList { + if let countriesList = sharedData.entries[SharedDataKeys.countriesList]?.get(CountriesList.self) { return (countriesList.countries, countriesList.hash) } else { return ([], 0) diff --git a/submodules/TelegramCore/Sources/TelegramEngine/Localization/LocalizationListState.swift b/submodules/TelegramCore/Sources/TelegramEngine/Localization/LocalizationListState.swift index 56e224b0c7..49c29a186b 100644 --- a/submodules/TelegramCore/Sources/TelegramEngine/Localization/LocalizationListState.swift +++ b/submodules/TelegramCore/Sources/TelegramEngine/Localization/LocalizationListState.swift @@ -20,7 +20,7 @@ func updateLocalizationListStateInteractively(postbox: Postbox, _ f: @escaping ( func updateLocalizationListStateInteractively(transaction: Transaction, _ f: @escaping (LocalizationListState) -> LocalizationListState) { transaction.updatePreferencesEntry(key: PreferencesKeys.localizationListState, { current in - let previous = (current as? LocalizationListState) ?? LocalizationListState.defaultSettings + let previous = current?.get(LocalizationListState.self) ?? LocalizationListState.defaultSettings var updated = f(previous) var removeOfficialIndices: [Int] = [] var officialSet = Set() @@ -46,7 +46,7 @@ func updateLocalizationListStateInteractively(transaction: Transaction, _ f: @es for i in removeSavedIndices.reversed() { updated.availableSavedLocalizations.remove(at: i) } - return updated + return PreferencesEntry(updated) }) } diff --git a/submodules/TelegramCore/Sources/TelegramEngine/Localization/Localizations.swift b/submodules/TelegramCore/Sources/TelegramEngine/Localization/Localizations.swift index 845530e01d..172f3e09f0 100644 --- a/submodules/TelegramCore/Sources/TelegramEngine/Localization/Localizations.swift +++ b/submodules/TelegramCore/Sources/TelegramEngine/Localization/Localizations.swift @@ -124,7 +124,7 @@ func _internal_downloadAndApplyLocalization(accountManager: AccountManager Signal in transaction.updateSharedData(SharedDataKeys.localizationSettings, { _ in - return LocalizationSettings(primaryComponent: LocalizationComponent(languageCode: preview.languageCode, localizedName: preview.localizedTitle, localization: primaryLocalization, customPluralizationCode: preview.customPluralizationCode), secondaryComponent: secondaryComponent) + return PreferencesEntry(LocalizationSettings(primaryComponent: LocalizationComponent(languageCode: preview.languageCode, localizedName: preview.localizedTitle, localization: primaryLocalization, customPluralizationCode: preview.customPluralizationCode), secondaryComponent: secondaryComponent)) }) return postbox.transaction { transaction -> Signal in diff --git a/submodules/TelegramCore/Sources/TelegramEngine/Localization/SuggestedLocalizationEntry.swift b/submodules/TelegramCore/Sources/TelegramEngine/Localization/SuggestedLocalizationEntry.swift index df6d536cd4..4d95f6f16c 100644 --- a/submodules/TelegramCore/Sources/TelegramEngine/Localization/SuggestedLocalizationEntry.swift +++ b/submodules/TelegramCore/Sources/TelegramEngine/Localization/SuggestedLocalizationEntry.swift @@ -6,12 +6,12 @@ import SwiftSignalKit func _internal_markSuggestedLocalizationAsSeenInteractively(postbox: Postbox, languageCode: String) -> Signal { return postbox.transaction { transaction -> Void in transaction.updatePreferencesEntry(key: PreferencesKeys.suggestedLocalization, { current in - if let current = current as? SuggestedLocalizationEntry { + if let current = current?.get(SuggestedLocalizationEntry.self) { if current.languageCode == languageCode, !current.isSeen { - return SuggestedLocalizationEntry(languageCode: languageCode, isSeen: true) + return PreferencesEntry(SuggestedLocalizationEntry(languageCode: languageCode, isSeen: true)) } } else { - return SuggestedLocalizationEntry(languageCode: languageCode, isSeen: true) + return PreferencesEntry(SuggestedLocalizationEntry(languageCode: languageCode, isSeen: true)) } return current }) diff --git a/submodules/TelegramCore/Sources/TelegramEngine/Messages/Polls.swift b/submodules/TelegramCore/Sources/TelegramEngine/Messages/Polls.swift index d73686707a..e8edd1a520 100644 --- a/submodules/TelegramCore/Sources/TelegramEngine/Messages/Polls.swift +++ b/submodules/TelegramCore/Sources/TelegramEngine/Messages/Polls.swift @@ -285,11 +285,11 @@ private final class PollResultsOptionContext { let peerId: PeerId switch vote { case let .messageUserVote(userId, _, _): - peerId = PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt32Value(userId)) + peerId = PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt64Value(userId)) case let .messageUserVoteInputOption(userId, _): - peerId = PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt32Value(userId)) + peerId = PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt64Value(userId)) case let .messageUserVoteMultiple(userId, _, _): - peerId = PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt32Value(userId)) + peerId = PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt64Value(userId)) } if let peer = transaction.getPeer(peerId) { resultPeers.append(RenderedPeer(peer: peer)) diff --git a/submodules/TelegramCore/Sources/TelegramEngine/Payments/BotPaymentForm.swift b/submodules/TelegramCore/Sources/TelegramEngine/Payments/BotPaymentForm.swift index 8b297fa09a..8c50af3d59 100644 --- a/submodules/TelegramCore/Sources/TelegramEngine/Payments/BotPaymentForm.swift +++ b/submodules/TelegramCore/Sources/TelegramEngine/Payments/BotPaymentForm.swift @@ -224,7 +224,7 @@ func _internal_fetchBotPaymentForm(postbox: Postbox, network: Network, messageId parsedSavedCredentials = .card(id: id, title: title) } } - return BotPaymentForm(id: id, canSaveCredentials: (flags & (1 << 2)) != 0, passwordMissing: (flags & (1 << 3)) != 0, invoice: parsedInvoice, paymentBotId: PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt32Value(botId)), providerId: PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt32Value(providerId)), url: url, nativeProvider: parsedNativeProvider, savedInfo: parsedSavedInfo, savedCredentials: parsedSavedCredentials) + return BotPaymentForm(id: id, canSaveCredentials: (flags & (1 << 2)) != 0, passwordMissing: (flags & (1 << 3)) != 0, invoice: parsedInvoice, paymentBotId: PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt64Value(botId)), providerId: PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt64Value(providerId)), url: url, nativeProvider: parsedNativeProvider, savedInfo: parsedSavedInfo, savedCredentials: parsedSavedCredentials) } } |> mapError { _ -> BotPaymentFormRequestError in } @@ -488,26 +488,6 @@ func _internal_requestBotPaymentReceipt(account: Account, messageId: MessageId) let parsedInfo = info.flatMap(BotPaymentRequestedInfo.init) let shippingOption = shipping.flatMap(BotPaymentShippingOption.init) - /*let fields = BotPaymentInvoiceFields() - - let form = BotPaymentForm( - id: 0, - canSaveCredentials: false, - passwordMissing: false, - invoice: BotPaymentInvoice( - isTest: false, - requestedFields: fields, - currency: currency, - prices: [], - tip: nil - ), - providerId: PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt32Value(providerId)), - url: "", - nativeProvider: nil, - savedInfo: nil, - savedCredentials: nil - )*/ - let invoiceMedia = TelegramMediaInvoice( title: title, description: description, @@ -519,7 +499,7 @@ func _internal_requestBotPaymentReceipt(account: Account, messageId: MessageId) flags: [] ) - let botPaymentId = PeerId.init(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt32Value(botId)) + let botPaymentId = PeerId.init(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt64Value(botId)) return BotPaymentReceipt(invoice: parsedInvoice, info: parsedInfo, shippingOption: shippingOption, credentialsTitle: credentialsTitle, invoiceMedia: invoiceMedia, tipAmount: tipAmount, botPaymentId: botPaymentId) } diff --git a/submodules/TelegramCore/Sources/TelegramEngine/Peers/AddPeerMember.swift b/submodules/TelegramCore/Sources/TelegramEngine/Peers/AddPeerMember.swift index 826f15047d..ab4f0daf18 100644 --- a/submodules/TelegramCore/Sources/TelegramEngine/Peers/AddPeerMember.swift +++ b/submodules/TelegramCore/Sources/TelegramEngine/Peers/AddPeerMember.swift @@ -17,7 +17,7 @@ func _internal_addGroupMember(account: Account, peerId: PeerId, memberId: PeerId return account.postbox.transaction { transaction -> Signal in if let peer = transaction.getPeer(peerId), let memberPeer = transaction.getPeer(memberId), let inputUser = apiInputUser(memberPeer) { if let group = peer as? TelegramGroup { - return account.network.request(Api.functions.messages.addChatUser(chatId: group.id.id._internalGetInt32Value(), userId: inputUser, fwdLimit: 100)) + return account.network.request(Api.functions.messages.addChatUser(chatId: group.id.id._internalGetInt64Value(), userId: inputUser, fwdLimit: 100)) |> mapError { error -> AddGroupMemberError in switch error.errorDescription { case "USERS_TOO_MUCH": diff --git a/submodules/TelegramCore/Sources/TelegramEngine/Peers/ChannelAdminEventLogs.swift b/submodules/TelegramCore/Sources/TelegramEngine/Peers/ChannelAdminEventLogs.swift index f6a6a051f5..6c2b20eb56 100644 --- a/submodules/TelegramCore/Sources/TelegramEngine/Peers/ChannelAdminEventLogs.swift +++ b/submodules/TelegramCore/Sources/TelegramEngine/Peers/ChannelAdminEventLogs.swift @@ -220,7 +220,7 @@ func channelAdminLogEvents(postbox: Postbox, network: Network, peerId: PeerId, m action = .pollStopped(rendered) } case let .channelAdminLogEventActionChangeLinkedChat(prevValue, newValue): - action = .linkedPeerUpdated(previous: prevValue == 0 ? nil : peers[PeerId(namespace: Namespaces.Peer.CloudChannel, id: PeerId.Id._internalFromInt32Value(prevValue))], updated: newValue == 0 ? nil : peers[PeerId(namespace: Namespaces.Peer.CloudChannel, id: PeerId.Id._internalFromInt32Value(newValue))]) + action = .linkedPeerUpdated(previous: prevValue == 0 ? nil : peers[PeerId(namespace: Namespaces.Peer.CloudChannel, id: PeerId.Id._internalFromInt64Value(prevValue))], updated: newValue == 0 ? nil : peers[PeerId(namespace: Namespaces.Peer.CloudChannel, id: PeerId.Id._internalFromInt64Value(newValue))]) case let .channelAdminLogEventActionChangeLocation(prevValue, newValue): action = .changeGeoLocation(previous: PeerGeoLocation(apiLocation: prevValue), updated: PeerGeoLocation(apiLocation: newValue)) case let .channelAdminLogEventActionToggleSlowMode(prevValue, newValue): @@ -253,7 +253,7 @@ func channelAdminLogEvents(postbox: Postbox, network: Network, peerId: PeerId, m case let .channelAdminLogEventActionChangeTheme(prevValue, newValue): action = .changeTheme(previous: prevValue, updated: newValue) } - let peerId = PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt32Value(userId)) + let peerId = PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt64Value(userId)) if let action = action { events.append(AdminLogEvent(id: id, peerId: peerId, date: date, action: action)) } diff --git a/submodules/TelegramCore/Sources/TelegramEngine/Peers/ChannelMembers.swift b/submodules/TelegramCore/Sources/TelegramEngine/Peers/ChannelMembers.swift index 6e9b01691c..c90226eb26 100644 --- a/submodules/TelegramCore/Sources/TelegramEngine/Peers/ChannelMembers.swift +++ b/submodules/TelegramCore/Sources/TelegramEngine/Peers/ChannelMembers.swift @@ -20,7 +20,7 @@ public enum ChannelMembersCategory { case mentions(threadId: MessageId?, filter: ChannelMembersCategoryFilter) } -func _internal_channelMembers(postbox: Postbox, network: Network, accountPeerId: PeerId, peerId: PeerId, category: ChannelMembersCategory = .recent(.all), offset: Int32 = 0, limit: Int32 = 64, hash: Int32 = 0) -> Signal<[RenderedChannelParticipant]?, NoError> { +func _internal_channelMembers(postbox: Postbox, network: Network, accountPeerId: PeerId, peerId: PeerId, category: ChannelMembersCategory = .recent(.all), offset: Int32 = 0, limit: Int32 = 64, hash: Int64 = 0) -> Signal<[RenderedChannelParticipant]?, NoError> { return postbox.transaction { transaction -> Signal<[RenderedChannelParticipant]?, NoError> in if let peer = transaction.getPeer(peerId), let inputChannel = apiInputChannel(peer) { let apiFilter: Api.ChannelParticipantsFilter diff --git a/submodules/TelegramCore/Sources/TelegramEngine/Peers/ChatListFiltering.swift b/submodules/TelegramCore/Sources/TelegramEngine/Peers/ChatListFiltering.swift index 81f323abc2..ad610f577f 100644 --- a/submodules/TelegramCore/Sources/TelegramEngine/Peers/ChatListFiltering.swift +++ b/submodules/TelegramCore/Sources/TelegramEngine/Peers/ChatListFiltering.swift @@ -231,7 +231,7 @@ public struct ChatListFilterData: Equatable, Hashable { } } -public struct ChatListFilter: PostboxCoding, Equatable { +public struct ChatListFilter: Codable, Equatable { public var id: Int32 public var title: String public var emoticon: String? @@ -249,35 +249,40 @@ public struct ChatListFilter: PostboxCoding, Equatable { self.data = data } - public init(decoder: PostboxDecoder) { - self.id = decoder.decodeInt32ForKey("id", orElse: 0) - self.title = decoder.decodeStringForKey("title", orElse: "") - self.emoticon = decoder.decodeOptionalStringForKey("emoticon") + public init(from decoder: Decoder) throws { + let container = try decoder.container(keyedBy: StringCodingKey.self) + + self.id = try container.decode(Int32.self, forKey: "id") + self.title = try container.decode(String.self, forKey: "title") + self.emoticon = try container.decodeIfPresent(String.self, forKey: "emoticon") + self.data = ChatListFilterData( - categories: ChatListFilterPeerCategories(rawValue: decoder.decodeInt32ForKey("categories", orElse: 0)), - excludeMuted: decoder.decodeInt32ForKey("excludeMuted", orElse: 0) != 0, - excludeRead: decoder.decodeInt32ForKey("excludeRead", orElse: 0) != 0, - excludeArchived: decoder.decodeInt32ForKey("excludeArchived", orElse: 0) != 0, - includePeers: ChatListFilterIncludePeers(peers: decoder.decodeInt64ArrayForKey("includePeers").map(PeerId.init), pinnedPeers: decoder.decodeInt64ArrayForKey("pinnedPeers").map(PeerId.init)), - excludePeers: decoder.decodeInt64ArrayForKey("excludePeers").map(PeerId.init) + categories: ChatListFilterPeerCategories(rawValue: try container.decode(Int32.self, forKey: "categories")), + excludeMuted: (try container.decode(Int32.self, forKey: "excludeMuted")) != 0, + excludeRead: (try container.decode(Int32.self, forKey: "excludeRead")) != 0, + excludeArchived: (try container.decode(Int32.self, forKey: "excludeArchived")) != 0, + includePeers: ChatListFilterIncludePeers( + peers: (try container.decode([Int64].self, forKey: "includePeers")).map(PeerId.init), + pinnedPeers: (try container.decode([Int64].self, forKey: "pinnedPeers")).map(PeerId.init) + ), + excludePeers: (try container.decode([Int64].self, forKey: "excludePeers")).map(PeerId.init) ) } - public func encode(_ encoder: PostboxEncoder) { - encoder.encodeInt32(self.id, forKey: "id") - encoder.encodeString(self.title, forKey: "title") - if let emoticon = self.emoticon { - encoder.encodeString(emoticon, forKey: "emoticon") - } else { - encoder.encodeNil(forKey: "emoticon") - } - encoder.encodeInt32(self.data.categories.rawValue, forKey: "categories") - encoder.encodeInt32(self.data.excludeMuted ? 1 : 0, forKey: "excludeMuted") - encoder.encodeInt32(self.data.excludeRead ? 1 : 0, forKey: "excludeRead") - encoder.encodeInt32(self.data.excludeArchived ? 1 : 0, forKey: "excludeArchived") - encoder.encodeInt64Array(self.data.includePeers.peers.map { $0.toInt64() }, forKey: "includePeers") - encoder.encodeInt64Array(self.data.includePeers.pinnedPeers.map { $0.toInt64() }, forKey: "pinnedPeers") - encoder.encodeInt64Array(self.data.excludePeers.map { $0.toInt64() }, forKey: "excludePeers") + public func encode(to encoder: Encoder) throws { + var container = encoder.container(keyedBy: StringCodingKey.self) + + try container.encode(self.id, forKey: "id") + try container.encode(self.title, forKey: "title") + try container.encodeIfPresent(self.emoticon, forKey: "emoticon") + + try container.encode(self.data.categories.rawValue, forKey: "categories") + try container.encode(self.data.excludeMuted ? 1 : 0, forKey: "excludeMuted") + try container.encode(self.data.excludeRead ? 1 : 0, forKey: "excludeRead") + try container.encode(self.data.excludeArchived ? 1 : 0, forKey: "excludeArchived") + try container.encode(self.data.includePeers.peers.map { $0.toInt64() }, forKey: "includePeers") + try container.encode(self.data.includePeers.pinnedPeers.map { $0.toInt64() }, forKey: "pinnedPeers") + try container.encode(self.data.excludePeers.map { $0.toInt64() }, forKey: "excludePeers") } } @@ -297,22 +302,22 @@ extension ChatListFilter { includePeers: ChatListFilterIncludePeers(rawPeers: includePeers.compactMap { peer -> PeerId? in switch peer { case let .inputPeerUser(userId, _): - return PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt32Value(userId)) + return PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt64Value(userId)) case let .inputPeerChat(chatId): - return PeerId(namespace: Namespaces.Peer.CloudGroup, id: PeerId.Id._internalFromInt32Value(chatId)) + return PeerId(namespace: Namespaces.Peer.CloudGroup, id: PeerId.Id._internalFromInt64Value(chatId)) case let .inputPeerChannel(channelId, _): - return PeerId(namespace: Namespaces.Peer.CloudChannel, id: PeerId.Id._internalFromInt32Value(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, _): - return PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt32Value(userId)) + return PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt64Value(userId)) case let .inputPeerChat(chatId): - return PeerId(namespace: Namespaces.Peer.CloudGroup, id: PeerId.Id._internalFromInt32Value(chatId)) + return PeerId(namespace: Namespaces.Peer.CloudGroup, id: PeerId.Id._internalFromInt64Value(chatId)) case let .inputPeerChannel(channelId, _): - return PeerId(namespace: Namespaces.Peer.CloudChannel, id: PeerId.Id._internalFromInt32Value(channelId)) + return PeerId(namespace: Namespaces.Peer.CloudChannel, id: PeerId.Id._internalFromInt64Value(channelId)) default: return nil } @@ -320,11 +325,11 @@ extension ChatListFilter { excludePeers: excludePeers.compactMap { peer -> PeerId? in switch peer { case let .inputPeerUser(userId, _): - return PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt32Value(userId)) + return PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt64Value(userId)) case let .inputPeerChat(chatId): - return PeerId(namespace: Namespaces.Peer.CloudGroup, id: PeerId.Id._internalFromInt32Value(chatId)) + return PeerId(namespace: Namespaces.Peer.CloudGroup, id: PeerId.Id._internalFromInt64Value(chatId)) case let .inputPeerChannel(channelId, _): - return PeerId(namespace: Namespaces.Peer.CloudChannel, id: PeerId.Id._internalFromInt32Value(channelId)) + return PeerId(namespace: Namespaces.Peer.CloudChannel, id: PeerId.Id._internalFromInt64Value(channelId)) default: return nil } @@ -425,11 +430,11 @@ private func requestChatListFilters(accountPeerId: PeerId, postbox: Postbox, net var peerId: PeerId? switch peer { case let .inputPeerUser(userId, _): - peerId = PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt32Value(userId)) + peerId = PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt64Value(userId)) case let .inputPeerChat(chatId): - peerId = PeerId(namespace: Namespaces.Peer.CloudGroup, id: PeerId.Id._internalFromInt32Value(chatId)) + peerId = PeerId(namespace: Namespaces.Peer.CloudGroup, id: PeerId.Id._internalFromInt64Value(chatId)) case let .inputPeerChannel(channelId, _): - peerId = PeerId(namespace: Namespaces.Peer.CloudChannel, id: PeerId.Id._internalFromInt32Value(channelId)) + peerId = PeerId(namespace: Namespaces.Peer.CloudChannel, id: PeerId.Id._internalFromInt64Value(channelId)) default: break } @@ -445,11 +450,11 @@ private func requestChatListFilters(accountPeerId: PeerId, postbox: Postbox, net var peerId: PeerId? switch peer { case let .inputPeerUser(userId, _): - peerId = PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt32Value(userId)) + peerId = PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt64Value(userId)) case let .inputPeerChat(chatId): - peerId = PeerId(namespace: Namespaces.Peer.CloudGroup, id: PeerId.Id._internalFromInt32Value(chatId)) + peerId = PeerId(namespace: Namespaces.Peer.CloudGroup, id: PeerId.Id._internalFromInt64Value(chatId)) case let .inputPeerChannel(channelId, _): - peerId = PeerId(namespace: Namespaces.Peer.CloudChannel, id: PeerId.Id._internalFromInt32Value(channelId)) + peerId = PeerId(namespace: Namespaces.Peer.CloudChannel, id: PeerId.Id._internalFromInt64Value(channelId)) default: break } @@ -470,7 +475,7 @@ private func requestChatListFilters(accountPeerId: PeerId, postbox: Postbox, net var missingUsers: [Api.InputUser] = [] var missingChannels: [Api.InputChannel] = [] - var missingGroups: [Int32] = [] + var missingGroups: [Int64] = [] for peer in missingPeers { switch peer { case let .inputPeerUser(userId, accessHash): @@ -746,7 +751,7 @@ private func loadAndStorePeerChatInfos(accountPeerId: PeerId, postbox: Postbox, } } -struct ChatListFiltersState: PreferencesEntry, Equatable { +struct ChatListFiltersState: Codable, Equatable { var filters: [ChatListFilter] var remoteFilters: [ChatListFilter]? @@ -757,26 +762,18 @@ struct ChatListFiltersState: PreferencesEntry, Equatable { self.remoteFilters = remoteFilters } - init(decoder: PostboxDecoder) { - self.filters = decoder.decodeObjectArrayWithDecoderForKey("filters") - self.remoteFilters = decoder.decodeOptionalObjectArrayWithDecoderForKey("remoteFilters") + public init(from decoder: Decoder) throws { + let container = try decoder.container(keyedBy: StringCodingKey.self) + + self.filters = try container.decode([ChatListFilter].self, forKey: "filters") + self.remoteFilters = try container.decodeIfPresent([ChatListFilter].self, forKey: "remoteFilters") } - func encode(_ encoder: PostboxEncoder) { - encoder.encodeObjectArray(self.filters, forKey: "filters") - if let remoteFilters = self.remoteFilters { - encoder.encodeObjectArray(remoteFilters, forKey: "remoteFilters") - } else { - encoder.encodeNil(forKey: "remoteFilters") - } - } - - func isEqual(to: PreferencesEntry) -> Bool { - if let to = to as? ChatListFiltersState, self == to { - return true - } else { - return false - } + func encode(to encoder: Encoder) throws { + var container = encoder.container(keyedBy: StringCodingKey.self) + + try container.encode(self.filters, forKey: "filters") + try container.encodeIfPresent(self.remoteFilters, forKey: "remoteFilters") } } @@ -794,14 +791,14 @@ func _internal_updateChatListFiltersInteractively(postbox: Postbox, _ f: @escapi var updated: [ChatListFilter] = [] var hasUpdates = false transaction.updatePreferencesEntry(key: PreferencesKeys.chatListFilters, { entry in - var state = entry as? ChatListFiltersState ?? ChatListFiltersState.default + var state = entry?.get(ChatListFiltersState.self) ?? ChatListFiltersState.default let updatedFilters = f(state.filters) if updatedFilters != state.filters { state.filters = updatedFilters hasUpdates = true } updated = updatedFilters - return state + return PreferencesEntry(state) }) if hasUpdates { requestChatListFiltersSync(transaction: transaction) @@ -813,13 +810,13 @@ func _internal_updateChatListFiltersInteractively(postbox: Postbox, _ f: @escapi func _internal_updateChatListFiltersInteractively(transaction: Transaction, _ f: ([ChatListFilter]) -> [ChatListFilter]) { var hasUpdates = false transaction.updatePreferencesEntry(key: PreferencesKeys.chatListFilters, { entry in - var state = entry as? ChatListFiltersState ?? ChatListFiltersState.default + var state = entry?.get(ChatListFiltersState.self) ?? ChatListFiltersState.default let updatedFilters = f(state.filters) if updatedFilters != state.filters { state.filters = updatedFilters hasUpdates = true } - return state + return PreferencesEntry(state) }) if hasUpdates { requestChatListFiltersSync(transaction: transaction) @@ -830,7 +827,7 @@ func _internal_updateChatListFiltersInteractively(transaction: Transaction, _ f: func _internal_updatedChatListFilters(postbox: Postbox) -> Signal<[ChatListFilter], NoError> { return postbox.preferencesView(keys: [PreferencesKeys.chatListFilters]) |> map { preferences -> [ChatListFilter] in - let filtersState = preferences.values[PreferencesKeys.chatListFilters] as? ChatListFiltersState ?? ChatListFiltersState.default + let filtersState = preferences.values[PreferencesKeys.chatListFilters]?.get(ChatListFiltersState.self) ?? ChatListFiltersState.default return filtersState.filters } |> distinctUntilChanged @@ -839,7 +836,7 @@ func _internal_updatedChatListFilters(postbox: Postbox) -> Signal<[ChatListFilte func _internal_updatedChatListFiltersInfo(postbox: Postbox) -> Signal<(filters: [ChatListFilter], synchronized: Bool), NoError> { return postbox.preferencesView(keys: [PreferencesKeys.chatListFilters]) |> map { preferences -> (filters: [ChatListFilter], synchronized: Bool) in - let filtersState = preferences.values[PreferencesKeys.chatListFilters] as? ChatListFiltersState ?? ChatListFiltersState.default + let filtersState = preferences.values[PreferencesKeys.chatListFilters]?.get(ChatListFiltersState.self) ?? ChatListFiltersState.default return (filtersState.filters, filtersState.remoteFilters != nil) } |> distinctUntilChanged(isEqual: { lhs, rhs -> Bool in @@ -855,28 +852,28 @@ func _internal_updatedChatListFiltersInfo(postbox: Postbox) -> Signal<(filters: func _internal_currentChatListFilters(postbox: Postbox) -> Signal<[ChatListFilter], NoError> { return postbox.transaction { transaction -> [ChatListFilter] in - let settings = transaction.getPreferencesEntry(key: PreferencesKeys.chatListFilters) as? ChatListFiltersState ?? ChatListFiltersState.default + let settings = transaction.getPreferencesEntry(key: PreferencesKeys.chatListFilters)?.get(ChatListFiltersState.self) ?? ChatListFiltersState.default return settings.filters } } func _internal_currentChatListFilters(transaction: Transaction) -> [ChatListFilter] { - let settings = transaction.getPreferencesEntry(key: PreferencesKeys.chatListFilters) as? ChatListFiltersState ?? ChatListFiltersState.default + let settings = transaction.getPreferencesEntry(key: PreferencesKeys.chatListFilters)?.get(ChatListFiltersState.self) ?? ChatListFiltersState.default return settings.filters } func updateChatListFiltersState(transaction: Transaction, _ f: (ChatListFiltersState) -> ChatListFiltersState) -> ChatListFiltersState { var result: ChatListFiltersState? transaction.updatePreferencesEntry(key: PreferencesKeys.chatListFilters, { entry in - let settings = entry as? ChatListFiltersState ?? ChatListFiltersState.default + let settings = entry?.get(ChatListFiltersState.self) ?? ChatListFiltersState.default let updated = f(settings) result = updated - return updated + return PreferencesEntry(updated) }) return result ?? .default } -public struct ChatListFeaturedFilter: PostboxCoding, Equatable { +public struct ChatListFeaturedFilter: Codable, Equatable { public var title: String public var description: String public var data: ChatListFilterData @@ -891,33 +888,40 @@ public struct ChatListFeaturedFilter: PostboxCoding, Equatable { self.data = data } - public init(decoder: PostboxDecoder) { - self.title = decoder.decodeStringForKey("title", orElse: "") - self.description = decoder.decodeStringForKey("description", orElse: "") + public init(from decoder: Decoder) throws { + let container = try decoder.container(keyedBy: StringCodingKey.self) + + self.title = try container.decode(String.self, forKey: "title") + self.description = try container.decode(String.self, forKey: "description") self.data = ChatListFilterData( - categories: ChatListFilterPeerCategories(rawValue: decoder.decodeInt32ForKey("categories", orElse: 0)), - excludeMuted: decoder.decodeInt32ForKey("excludeMuted", orElse: 0) != 0, - excludeRead: decoder.decodeInt32ForKey("excludeRead", orElse: 0) != 0, - excludeArchived: decoder.decodeInt32ForKey("excludeArchived", orElse: 0) != 0, - includePeers: ChatListFilterIncludePeers(peers: decoder.decodeInt64ArrayForKey("includePeers").map(PeerId.init), pinnedPeers: decoder.decodeInt64ArrayForKey("pinnedPeers").map(PeerId.init)), - excludePeers: decoder.decodeInt64ArrayForKey("excludePeers").map(PeerId.init) + categories: ChatListFilterPeerCategories(rawValue: try container.decode(Int32.self, forKey: "categories")), + excludeMuted: (try container.decode(Int32.self, forKey: "excludeMuted")) != 0, + excludeRead: (try container.decode(Int32.self, forKey: "excludeRead")) != 0, + excludeArchived: (try container.decode(Int32.self, forKey: "excludeArchived")) != 0, + includePeers: ChatListFilterIncludePeers( + peers: (try container.decode([Int64].self, forKey: ("includePeers"))).map(PeerId.init), + pinnedPeers: (try container.decode([Int64].self, forKey: ("pinnedPeers"))).map(PeerId.init) + ), + excludePeers: (try container.decode([Int64].self, forKey: ("excludePeers"))).map(PeerId.init) ) } - public func encode(_ encoder: PostboxEncoder) { - encoder.encodeString(self.title, forKey: "title") - encoder.encodeString(self.description, forKey: "description") - encoder.encodeInt32(self.data.categories.rawValue, forKey: "categories") - encoder.encodeInt32(self.data.excludeMuted ? 1 : 0, forKey: "excludeMuted") - encoder.encodeInt32(self.data.excludeRead ? 1 : 0, forKey: "excludeRead") - encoder.encodeInt32(self.data.excludeArchived ? 1 : 0, forKey: "excludeArchived") - encoder.encodeInt64Array(self.data.includePeers.peers.map { $0.toInt64() }, forKey: "includePeers") - encoder.encodeInt64Array(self.data.includePeers.pinnedPeers.map { $0.toInt64() }, forKey: "pinnedPeers") - encoder.encodeInt64Array(self.data.excludePeers.map { $0.toInt64() }, forKey: "excludePeers") + public func encode(to encoder: Encoder) throws { + var container = encoder.container(keyedBy: StringCodingKey.self) + + try container.encode(self.title, forKey: "title") + try container.encode(self.description, forKey: "description") + try container.encode(self.data.categories.rawValue, forKey: "categories") + try container.encode((self.data.excludeMuted ? 1 : 0) as Int32, forKey: "excludeMuted") + try container.encode((self.data.excludeRead ? 1 : 0) as Int32, forKey: "excludeRead") + try container.encode((self.data.excludeArchived ? 1 : 0) as Int32, forKey: "excludeArchived") + try container.encode(self.data.includePeers.peers.map { $0.toInt64() }, forKey: "includePeers") + try container.encode(self.data.includePeers.pinnedPeers.map { $0.toInt64() }, forKey: "pinnedPeers") + try container.encode(self.data.excludePeers.map { $0.toInt64() }, forKey: "excludePeers") } } -public struct ChatListFiltersFeaturedState: PreferencesEntry, Equatable { +public struct ChatListFiltersFeaturedState: Codable, Equatable { public var filters: [ChatListFeaturedFilter] public var isSeen: Bool @@ -926,33 +930,29 @@ public struct ChatListFiltersFeaturedState: PreferencesEntry, Equatable { self.isSeen = isSeen } - public init(decoder: PostboxDecoder) { - self.filters = decoder.decodeObjectArrayWithDecoderForKey("filters") - self.isSeen = decoder.decodeInt32ForKey("isSeen", orElse: 0) != 0 + public init(from decoder: Decoder) throws { + let container = try decoder.container(keyedBy: StringCodingKey.self) + + self.filters = try container.decode([ChatListFeaturedFilter].self, forKey: "filters") + self.isSeen = (try container.decode(Int32.self, forKey: "isSeen")) != 0 } - public func encode(_ encoder: PostboxEncoder) { - encoder.encodeObjectArray(self.filters, forKey: "filters") - encoder.encodeInt32(self.isSeen ? 1 : 0, forKey: "isSeen") - } - - public func isEqual(to: PreferencesEntry) -> Bool { - if let to = to as? ChatListFiltersFeaturedState, self == to { - return true - } else { - return false - } + public func encode(to encoder: Encoder) throws { + var container = encoder.container(keyedBy: StringCodingKey.self) + + try container.encode(self.filters, forKey: "filters") + try container.encode((self.isSeen ? 1 : 0) as Int32, forKey: "isSeen") } } func _internal_markChatListFeaturedFiltersAsSeen(postbox: Postbox) -> Signal { return postbox.transaction { transaction -> Void in transaction.updatePreferencesEntry(key: PreferencesKeys.chatListFiltersFeaturedState, { entry in - guard var state = entry as? ChatListFiltersFeaturedState else { + guard var state = entry?.get(ChatListFiltersFeaturedState.self) else { return entry } state.isSeen = true - return state + return PreferencesEntry(state) }) } |> ignoreValues @@ -960,11 +960,11 @@ func _internal_markChatListFeaturedFiltersAsSeen(postbox: Postbox) -> Signal mapToSignal { result -> Signal in return postbox.transaction { transaction -> Void in transaction.updatePreferencesEntry(key: PreferencesKeys.chatListFiltersFeaturedState, { entry in - var state = entry as? ChatListFiltersFeaturedState ?? ChatListFiltersFeaturedState(filters: [], isSeen: false) + var state = entry?.get(ChatListFiltersFeaturedState.self) ?? ChatListFiltersFeaturedState(filters: [], isSeen: false) state.filters = result.map { item -> ChatListFeaturedFilter in switch item { case let .dialogFilterSuggested(filter, description): @@ -984,7 +984,7 @@ func _internal_updateChatListFeaturedFilters(postbox: Postbox, network: Network) return ChatListFeaturedFilter(title: parsedFilter.title, description: description, data: parsedFilter.data) } } - return state + return PreferencesEntry(state) }) } |> ignoreValues @@ -1172,7 +1172,7 @@ func managedChatListFilters(postbox: Postbox, network: Network, accountPeerId: P private func synchronizeChatListFilters(transaction: Transaction, accountPeerId: PeerId, postbox: Postbox, network: Network, operation: SynchronizeChatListFiltersOperation) -> Signal { switch operation.content { case .sync: - let settings = transaction.getPreferencesEntry(key: PreferencesKeys.chatListFilters) as? ChatListFiltersState ?? ChatListFiltersState.default + let settings = transaction.getPreferencesEntry(key: PreferencesKeys.chatListFilters)?.get(ChatListFiltersState.self) ?? ChatListFiltersState.default let localFilters = settings.filters let locallyKnownRemoteFilters = settings.remoteFilters ?? [] diff --git a/submodules/TelegramCore/Sources/TelegramEngine/Peers/ConvertGroupToSupergroup.swift b/submodules/TelegramCore/Sources/TelegramEngine/Peers/ConvertGroupToSupergroup.swift index 2edaf4434c..26f89f9310 100644 --- a/submodules/TelegramCore/Sources/TelegramEngine/Peers/ConvertGroupToSupergroup.swift +++ b/submodules/TelegramCore/Sources/TelegramEngine/Peers/ConvertGroupToSupergroup.swift @@ -10,7 +10,7 @@ public enum ConvertGroupToSupergroupError { } func _internal_convertGroupToSupergroup(account: Account, peerId: PeerId) -> Signal { - return account.network.request(Api.functions.messages.migrateChat(chatId: peerId.id._internalGetInt32Value())) + return account.network.request(Api.functions.messages.migrateChat(chatId: peerId.id._internalGetInt64Value())) |> mapError { error -> ConvertGroupToSupergroupError in if error.errorDescription == "CHANNELS_TOO_MUCH" { return .tooManyChannels diff --git a/submodules/TelegramCore/Sources/TelegramEngine/Peers/FindChannelById.swift b/submodules/TelegramCore/Sources/TelegramEngine/Peers/FindChannelById.swift index 9d288f6278..7393db32fa 100644 --- a/submodules/TelegramCore/Sources/TelegramEngine/Peers/FindChannelById.swift +++ b/submodules/TelegramCore/Sources/TelegramEngine/Peers/FindChannelById.swift @@ -3,7 +3,7 @@ import SwiftSignalKit import Postbox import TelegramApi -func _internal_findChannelById(postbox: Postbox, network: Network, channelId: Int32) -> Signal { +func _internal_findChannelById(postbox: Postbox, network: Network, channelId: Int64) -> Signal { return network.request(Api.functions.channels.getChannels(id: [.inputChannel(channelId: channelId, accessHash: 0)])) |> map(Optional.init) |> `catch` { _ -> Signal in diff --git a/submodules/TelegramCore/Sources/TelegramEngine/Peers/GroupsInCommon.swift b/submodules/TelegramCore/Sources/TelegramEngine/Peers/GroupsInCommon.swift index 9fad743857..e7734d21d2 100644 --- a/submodules/TelegramCore/Sources/TelegramEngine/Peers/GroupsInCommon.swift +++ b/submodules/TelegramCore/Sources/TelegramEngine/Peers/GroupsInCommon.swift @@ -58,7 +58,7 @@ private final class GroupsInCommonContextImpl { guard let inputUser = inputUser else { return .single(([], 0)) } - return network.request(Api.functions.messages.getCommonChats(userId: inputUser, maxId: maxId?._internalGetInt32Value() ?? 0, limit: limit)) + return network.request(Api.functions.messages.getCommonChats(userId: inputUser, maxId: maxId?._internalGetInt64Value() ?? 0, limit: limit)) |> map(Optional.init) |> `catch` { _ -> Signal in return .single(nil) diff --git a/submodules/TelegramCore/Sources/TelegramEngine/Peers/InvitationLinks.swift b/submodules/TelegramCore/Sources/TelegramEngine/Peers/InvitationLinks.swift index 8c0b1d6403..e7ce8e3463 100644 --- a/submodules/TelegramCore/Sources/TelegramEngine/Peers/InvitationLinks.swift +++ b/submodules/TelegramCore/Sources/TelegramEngine/Peers/InvitationLinks.swift @@ -651,12 +651,12 @@ final class CachedPeerInvitationImporters: PostboxCoding { self.peerIds = decoder.decodeInt64ArrayForKey("peerIds").map(PeerId.init) var dates: [PeerId: Int32] = [:] - let datesArray = decoder.decodeInt32ArrayForKey("dates") + let datesArray = decoder.decodeInt64ArrayForKey("dates") for index in stride(from: 0, to: datesArray.endIndex, by: 2) { let userId = datesArray[index] let date = datesArray[index + 1] - let peerId = PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt32Value(userId)) - dates[peerId] = date + let peerId = PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt64Value(userId)) + dates[peerId] = Int32(clamping: date) } self.dates = dates @@ -666,12 +666,12 @@ final class CachedPeerInvitationImporters: PostboxCoding { func encode(_ encoder: PostboxEncoder) { encoder.encodeInt64Array(self.peerIds.map { $0.toInt64() }, forKey: "peerIds") - var dates: [Int32] = [] + var dates: [Int64] = [] for (peerId, date) in self.dates { - dates.append(peerId.id._internalGetInt32Value()) - dates.append(date) + dates.append(peerId.id._internalGetInt64Value()) + dates.append(Int64(date)) } - encoder.encodeInt32Array(dates, forKey: "dates") + encoder.encodeInt64Array(dates, forKey: "dates") encoder.encodeInt32(self.count, forKey: "count") } @@ -788,7 +788,7 @@ private final class PeerInvitationImportersContextImpl { let date: Int32 switch importer { case let .chatInviteImporter(userId, dateValue): - peerId = PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt32Value(userId)) + peerId = PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt64Value(userId)) date = dateValue } if let peer = transaction.getPeer(peerId) { @@ -908,7 +908,7 @@ func _internal_peerExportedInvitationsCreators(account: Account, peerId: PeerId) for admin in admins { switch admin { case let .chatAdminWithInvites(adminId, invitesCount, revokedInvitesCount): - let peerId = PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt32Value(adminId)) + let peerId = PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt64Value(adminId)) if let peer = peersMap[peerId], peerId != account.peerId { creators.append(ExportedInvitationCreator(peer: RenderedPeer(peer: peer), count: invitesCount, revokedCount: revokedInvitesCount)) } diff --git a/submodules/TelegramCore/Sources/TelegramEngine/Peers/NotificationExceptionsList.swift b/submodules/TelegramCore/Sources/TelegramEngine/Peers/NotificationExceptionsList.swift index 7d261fe6a6..b2c6c17892 100644 --- a/submodules/TelegramCore/Sources/TelegramEngine/Peers/NotificationExceptionsList.swift +++ b/submodules/TelegramCore/Sources/TelegramEngine/Peers/NotificationExceptionsList.swift @@ -48,11 +48,11 @@ func _internal_notificationExceptionsList(postbox: Postbox, network: Network) -> let peerId: PeerId switch notifyPeer { case let .peerUser(userId): - peerId = PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt32Value(userId)) + peerId = PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt64Value(userId)) case let .peerChat(chatId): - peerId = PeerId(namespace: Namespaces.Peer.CloudGroup, id: PeerId.Id._internalFromInt32Value(chatId)) + peerId = PeerId(namespace: Namespaces.Peer.CloudGroup, id: PeerId.Id._internalFromInt64Value(chatId)) case let .peerChannel(channelId): - peerId = PeerId(namespace: Namespaces.Peer.CloudChannel, id: PeerId.Id._internalFromInt32Value(channelId)) + peerId = PeerId(namespace: Namespaces.Peer.CloudChannel, id: PeerId.Id._internalFromInt64Value(channelId)) } settings[peerId] = TelegramPeerNotificationSettings(apiSettings: notifySettings) default: diff --git a/submodules/TelegramCore/Sources/TelegramEngine/Peers/Peer.swift b/submodules/TelegramCore/Sources/TelegramEngine/Peers/Peer.swift index 501c75e0f1..092be92c31 100644 --- a/submodules/TelegramCore/Sources/TelegramEngine/Peers/Peer.swift +++ b/submodules/TelegramCore/Sources/TelegramEngine/Peers/Peer.swift @@ -138,7 +138,7 @@ public extension EnginePeer { if peer.id.isReplies { return true } - return (peer.id.namespace == Namespaces.Peer.CloudUser && (peer.id.id._internalGetInt32Value() == 777000 || peer.id.id._internalGetInt32Value() == 333000)) + return (peer.id.namespace == Namespaces.Peer.CloudUser && (peer.id.id._internalGetInt64Value() == 777000 || peer.id.id._internalGetInt64Value() == 333000)) } return false } diff --git a/submodules/TelegramCore/Sources/TelegramEngine/Peers/PeerAdmins.swift b/submodules/TelegramCore/Sources/TelegramEngine/Peers/PeerAdmins.swift index 6896019984..8d6e5b9777 100644 --- a/submodules/TelegramCore/Sources/TelegramEngine/Peers/PeerAdmins.swift +++ b/submodules/TelegramCore/Sources/TelegramEngine/Peers/PeerAdmins.swift @@ -13,7 +13,7 @@ func _internal_removeGroupAdmin(account: Account, peerId: PeerId, adminId: PeerI return account.postbox.transaction { transaction -> Signal in if let peer = transaction.getPeer(peerId), let adminPeer = transaction.getPeer(adminId), let inputUser = apiInputUser(adminPeer) { if let group = peer as? TelegramGroup { - return account.network.request(Api.functions.messages.editChatAdmin(chatId: group.id.id._internalGetInt32Value(), userId: inputUser, isAdmin: .boolFalse)) + return account.network.request(Api.functions.messages.editChatAdmin(chatId: group.id.id._internalGetInt64Value(), userId: inputUser, isAdmin: .boolFalse)) |> mapError { _ -> RemoveGroupAdminError in return .generic } |> mapToSignal { result -> Signal in return account.postbox.transaction { transaction -> Void in @@ -61,7 +61,7 @@ func _internal_addGroupAdmin(account: Account, peerId: PeerId, adminId: PeerId) return account.postbox.transaction { transaction -> Signal in if let peer = transaction.getPeer(peerId), let adminPeer = transaction.getPeer(adminId), let inputUser = apiInputUser(adminPeer) { if let group = peer as? TelegramGroup { - return account.network.request(Api.functions.messages.editChatAdmin(chatId: group.id.id._internalGetInt32Value(), userId: inputUser, isAdmin: .boolTrue)) + return account.network.request(Api.functions.messages.editChatAdmin(chatId: group.id.id._internalGetInt64Value(), userId: inputUser, isAdmin: .boolTrue)) |> `catch` { error -> Signal in if error.errorDescription == "USER_NOT_PARTICIPANT" { return _internal_addGroupMember(account: account, peerId: peerId, memberId: adminId) @@ -72,7 +72,7 @@ func _internal_addGroupAdmin(account: Account, peerId: PeerId, adminId: PeerId) return .complete() } |> then( - account.network.request(Api.functions.messages.editChatAdmin(chatId: group.id.id._internalGetInt32Value(), userId: inputUser, isAdmin: .boolTrue)) + account.network.request(Api.functions.messages.editChatAdmin(chatId: group.id.id._internalGetInt64Value(), userId: inputUser, isAdmin: .boolTrue)) |> mapError { error -> AddGroupAdminError in return .generic } diff --git a/submodules/TelegramCore/Sources/TelegramEngine/Peers/PeerPhotoUpdater.swift b/submodules/TelegramCore/Sources/TelegramEngine/Peers/PeerPhotoUpdater.swift index f4abfe1612..f5888f1e09 100644 --- a/submodules/TelegramCore/Sources/TelegramEngine/Peers/PeerPhotoUpdater.swift +++ b/submodules/TelegramCore/Sources/TelegramEngine/Peers/PeerPhotoUpdater.swift @@ -213,7 +213,7 @@ func _internal_updatePeerPhotoInternal(postbox: Postbox, network: Network, state let request: Signal if let peer = peer as? TelegramGroup { - request = network.request(Api.functions.messages.editChatPhoto(chatId: peer.id.id._internalGetInt32Value(), photo: .inputChatUploadedPhoto(flags: flags, file: file, video: videoFile, videoStartTs: videoStartTimestamp))) + request = network.request(Api.functions.messages.editChatPhoto(chatId: peer.id.id._internalGetInt64Value(), photo: .inputChatUploadedPhoto(flags: flags, file: file, video: videoFile, videoStartTs: videoStartTimestamp))) } else if let peer = peer as? TelegramChannel, let inputChannel = apiInputChannel(peer) { request = network.request(Api.functions.channels.editPhoto(channel: inputChannel, photo: .inputChatUploadedPhoto(flags: flags, file: file, video: videoFile, videoStartTs: videoStartTimestamp))) } else { @@ -301,7 +301,7 @@ func _internal_updatePeerPhotoInternal(postbox: Postbox, network: Network, state } else { let request: Signal if let peer = peer as? TelegramGroup { - request = network.request(Api.functions.messages.editChatPhoto(chatId: peer.id.id._internalGetInt32Value(), photo: .inputChatPhotoEmpty)) + request = network.request(Api.functions.messages.editChatPhoto(chatId: peer.id.id._internalGetInt64Value(), photo: .inputChatPhotoEmpty)) } else if let peer = peer as? TelegramChannel, let inputChannel = apiInputChannel(peer) { request = network.request(Api.functions.channels.editPhoto(channel: inputChannel, photo: .inputChatPhotoEmpty)) } else { diff --git a/submodules/TelegramCore/Sources/TelegramEngine/Peers/RemovePeerMember.swift b/submodules/TelegramCore/Sources/TelegramEngine/Peers/RemovePeerMember.swift index d6aaf0c030..a317b51706 100644 --- a/submodules/TelegramCore/Sources/TelegramEngine/Peers/RemovePeerMember.swift +++ b/submodules/TelegramCore/Sources/TelegramEngine/Peers/RemovePeerMember.swift @@ -16,7 +16,7 @@ func _internal_removePeerMember(account: Account, peerId: PeerId, memberId: Peer return account.postbox.transaction { transaction -> Signal in if let peer = transaction.getPeer(peerId), let memberPeer = transaction.getPeer(memberId), let inputUser = apiInputUser(memberPeer) { if let group = peer as? TelegramGroup { - return account.network.request(Api.functions.messages.deleteChatUser(flags: 0, chatId: group.id.id._internalGetInt32Value(), userId: inputUser)) + return account.network.request(Api.functions.messages.deleteChatUser(flags: 0, chatId: group.id.id._internalGetInt64Value(), userId: inputUser)) |> mapError { error -> Void in return Void() } diff --git a/submodules/TelegramCore/Sources/TelegramEngine/Peers/ReportPeer.swift b/submodules/TelegramCore/Sources/TelegramEngine/Peers/ReportPeer.swift index 98ca1a7867..73b3242312 100644 --- a/submodules/TelegramCore/Sources/TelegramEngine/Peers/ReportPeer.swift +++ b/submodules/TelegramCore/Sources/TelegramEngine/Peers/ReportPeer.swift @@ -9,7 +9,7 @@ func _internal_reportPeer(account: Account, peerId: PeerId) -> Signal Signal in if let peer = transaction.getPeer(peerId) { if let peer = peer as? TelegramSecretChat { - return account.network.request(Api.functions.messages.reportEncryptedSpam(peer: Api.InputEncryptedChat.inputEncryptedChat(chatId: peer.id.id._internalGetInt32Value(), accessHash: peer.accessHash))) + return account.network.request(Api.functions.messages.reportEncryptedSpam(peer: Api.InputEncryptedChat.inputEncryptedChat(chatId: Int32(peer.id.id._internalGetInt64Value()), accessHash: peer.accessHash))) |> map(Optional.init) |> `catch` { _ -> Signal in return .single(nil) diff --git a/submodules/TelegramCore/Sources/TelegramEngine/Peers/TelegramEnginePeers.swift b/submodules/TelegramCore/Sources/TelegramEngine/Peers/TelegramEnginePeers.swift index 17e018ff02..8a889a86b7 100644 --- a/submodules/TelegramCore/Sources/TelegramEngine/Peers/TelegramEnginePeers.swift +++ b/submodules/TelegramCore/Sources/TelegramEngine/Peers/TelegramEnginePeers.swift @@ -74,7 +74,7 @@ public extension TelegramEngine { } } - public func findChannelById(channelId: Int32) -> Signal { + public func findChannelById(channelId: Int64) -> Signal { return _internal_findChannelById(postbox: self.account.postbox, network: self.account.network, channelId: channelId) } @@ -215,7 +215,7 @@ public extension TelegramEngine { return _internal_updateChannelHistoryAvailabilitySettingsInteractively(postbox: self.account.postbox, network: self.account.network, accountStateManager: self.account.stateManager, peerId: peerId, historyAvailableForNewMembers: historyAvailableForNewMembers) } - public func channelMembers(peerId: PeerId, category: ChannelMembersCategory = .recent(.all), offset: Int32 = 0, limit: Int32 = 64, hash: Int32 = 0) -> Signal<[RenderedChannelParticipant]?, NoError> { + public func channelMembers(peerId: PeerId, category: ChannelMembersCategory = .recent(.all), offset: Int32 = 0, limit: Int32 = 64, hash: Int64 = 0) -> Signal<[RenderedChannelParticipant]?, NoError> { return _internal_channelMembers(postbox: self.account.postbox, network: self.account.network, accountPeerId: self.account.peerId, peerId: peerId, category: category, offset: offset, limit: limit, hash: hash) } diff --git a/submodules/TelegramCore/Sources/TelegramEngine/Peers/UpdateCachedPeerData.swift b/submodules/TelegramCore/Sources/TelegramEngine/Peers/UpdateCachedPeerData.swift index c53536bbd5..a2bfc8fc3c 100644 --- a/submodules/TelegramCore/Sources/TelegramEngine/Peers/UpdateCachedPeerData.swift +++ b/submodules/TelegramCore/Sources/TelegramEngine/Peers/UpdateCachedPeerData.swift @@ -217,7 +217,7 @@ func _internal_fetchAndUpdateCachedPeerData(accountPeerId: PeerId, peerId rawPee } } } else if peerId.namespace == Namespaces.Peer.CloudGroup { - return network.request(Api.functions.messages.getFullChat(chatId: peerId.id._internalGetInt32Value())) + return network.request(Api.functions.messages.getFullChat(chatId: peerId.id._internalGetInt64Value())) |> retryRequest |> mapToSignal { result -> Signal in return postbox.transaction { transaction -> Bool in @@ -236,7 +236,7 @@ func _internal_fetchAndUpdateCachedPeerData(accountPeerId: PeerId, peerId rawPee for botInfo in chatFull.botInfo ?? [] { switch botInfo { case let .botInfo(userId, _, _): - let peerId = PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt32Value(userId)) + let peerId = PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt64Value(userId)) let parsedBotInfo = BotInfo(apiBotInfo: botInfo) botInfos.append(CachedPeerBotInfo(peerId: peerId, botInfo: parsedBotInfo)) } @@ -382,7 +382,7 @@ func _internal_fetchAndUpdateCachedPeerData(accountPeerId: PeerId, peerId rawPee let linkedDiscussionPeerId: PeerId? if let linkedChatId = linkedChatId, linkedChatId != 0 { - linkedDiscussionPeerId = PeerId(namespace: Namespaces.Peer.CloudChannel, id: PeerId.Id._internalFromInt32Value(linkedChatId)) + linkedDiscussionPeerId = PeerId(namespace: Namespaces.Peer.CloudChannel, id: PeerId.Id._internalFromInt64Value(Int64(linkedChatId))) } else { linkedDiscussionPeerId = nil } @@ -400,7 +400,7 @@ func _internal_fetchAndUpdateCachedPeerData(accountPeerId: PeerId, peerId rawPee for botInfo in apiBotInfos { switch botInfo { case let .botInfo(userId, _, _): - let peerId = PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt32Value(userId)) + let peerId = PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt64Value(userId)) let parsedBotInfo = BotInfo(apiBotInfo: botInfo) botInfos.append(CachedPeerBotInfo(peerId: peerId, botInfo: parsedBotInfo)) } @@ -422,7 +422,7 @@ func _internal_fetchAndUpdateCachedPeerData(accountPeerId: PeerId, peerId rawPee var migrationReference: ChannelMigrationReference? if let migratedFromChatId = migratedFromChatId, let migratedFromMaxId = migratedFromMaxId { - migrationReference = ChannelMigrationReference(maxMessageId: MessageId(peerId: PeerId(namespace: Namespaces.Peer.CloudGroup, id: PeerId.Id._internalFromInt32Value(migratedFromChatId)), namespace: Namespaces.Message.Cloud, id: migratedFromMaxId)) + migrationReference = ChannelMigrationReference(maxMessageId: MessageId(peerId: PeerId(namespace: Namespaces.Peer.CloudGroup, id: PeerId.Id._internalFromInt64Value(migratedFromChatId)), namespace: Namespaces.Message.Cloud, id: migratedFromMaxId)) } var peers: [Peer] = [] @@ -491,7 +491,7 @@ func _internal_fetchAndUpdateCachedPeerData(accountPeerId: PeerId, peerId rawPee case let.channelParticipant(participant, _, _): switch participant { case let .channelParticipantSelf(_, inviterId, _): - invitedBy = PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt32Value(inviterId)) + invitedBy = PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt64Value(inviterId)) default: break } diff --git a/submodules/TelegramCore/Sources/TelegramEngine/Peers/UpdatePeerInfo.swift b/submodules/TelegramCore/Sources/TelegramEngine/Peers/UpdatePeerInfo.swift index 305660764e..27bacc080f 100644 --- a/submodules/TelegramCore/Sources/TelegramEngine/Peers/UpdatePeerInfo.swift +++ b/submodules/TelegramCore/Sources/TelegramEngine/Peers/UpdatePeerInfo.swift @@ -29,7 +29,7 @@ func _internal_updatePeerTitle(account: Account, peerId: PeerId, title: String) } |> mapError { _ -> UpdatePeerTitleError in } } } else if let peer = peer as? TelegramGroup { - return account.network.request(Api.functions.messages.editChatTitle(chatId: peer.id.id._internalGetInt32Value(), title: title)) + return account.network.request(Api.functions.messages.editChatTitle(chatId: peer.id.id._internalGetInt64Value(), title: title)) |> mapError { _ -> UpdatePeerTitleError in return .generic } diff --git a/submodules/TelegramCore/Sources/TelegramEngine/PeersNearby/PeersNearby.swift b/submodules/TelegramCore/Sources/TelegramEngine/PeersNearby/PeersNearby.swift index 66468e0e3d..ac04a7b430 100644 --- a/submodules/TelegramCore/Sources/TelegramEngine/PeersNearby/PeersNearby.swift +++ b/submodules/TelegramCore/Sources/TelegramEngine/PeersNearby/PeersNearby.swift @@ -44,13 +44,13 @@ func _internal_updatePeersNearbyVisibility(account: Account, update: PeerNearbyV let _ = (account.postbox.transaction { transaction in transaction.updatePreferencesEntry(key: PreferencesKeys.peersNearby, { entry in - var settings = entry as? PeersNearbyState ?? PeersNearbyState.default + var settings = entry?.get(PeersNearbyState.self) ?? PeersNearbyState.default if case .invisible = update { settings.visibilityExpires = nil } else if let expires = selfExpires { settings.visibilityExpires = expires } - return settings + return PreferencesEntry(settings) }) }).start() @@ -65,9 +65,9 @@ func _internal_updatePeersNearbyVisibility(account: Account, update: PeerNearbyV if error.errorDescription == "USERPIC_PRIVACY_REQUIRED" { let _ = (account.postbox.transaction { transaction in transaction.updatePreferencesEntry(key: PreferencesKeys.peersNearby, { entry in - var settings = entry as? PeersNearbyState ?? PeersNearbyState.default + var settings = entry?.get(PeersNearbyState.self) ?? PeersNearbyState.default settings.visibilityExpires = nil - return settings + return PreferencesEntry(settings) }) }).start() } @@ -282,7 +282,7 @@ public func updateChannelGeoLocation(postbox: Postbox, network: Network, channel } } -public struct PeersNearbyState: PreferencesEntry, Equatable { +public struct PeersNearbyState: Codable, Equatable { public var visibilityExpires: Int32? public static var `default` = PeersNearbyState(visibilityExpires: nil) @@ -291,23 +291,15 @@ public struct PeersNearbyState: PreferencesEntry, Equatable { self.visibilityExpires = visibilityExpires } - public init(decoder: PostboxDecoder) { - self.visibilityExpires = decoder.decodeOptionalInt32ForKey("expires") + public init(from decoder: Decoder) throws { + let container = try decoder.container(keyedBy: StringCodingKey.self) + + self.visibilityExpires = try container.decodeIfPresent(Int32.self, forKey: "expires") } - public func encode(_ encoder: PostboxEncoder) { - if let expires = self.visibilityExpires { - encoder.encodeInt32(expires, forKey: "expires") - } else { - encoder.encodeNil(forKey: "expires") - } - } - - public func isEqual(to: PreferencesEntry) -> Bool { - if let to = to as? PeersNearbyState, self == to { - return true - } else { - return false - } + public func encode(to encoder: Encoder) throws { + var container = encoder.container(keyedBy: StringCodingKey.self) + + try container.encodeIfPresent(self.visibilityExpires, forKey: "expires") } } diff --git a/submodules/TelegramCore/Sources/TelegramEngine/Privacy/RecentWebSessions.swift b/submodules/TelegramCore/Sources/TelegramEngine/Privacy/RecentWebSessions.swift index 09056fb00c..c1dc5a6d3e 100644 --- a/submodules/TelegramCore/Sources/TelegramEngine/Privacy/RecentWebSessions.swift +++ b/submodules/TelegramCore/Sources/TelegramEngine/Privacy/RecentWebSessions.swift @@ -31,7 +31,7 @@ func webSessions(network: Network) -> Signal<([WebAuthorization], [PeerId: Peer] for authorization in authorizations { switch authorization { case let .webAuthorization(hash, botId, domain, browser, platform, dateCreated, dateActive, ip, region): - sessions.append(WebAuthorization(hash: hash, botId: PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt32Value(botId)), domain: domain, browser: browser, platform: platform, dateCreated: dateCreated, dateActive: dateActive, ip: ip, region: region)) + sessions.append(WebAuthorization(hash: hash, botId: PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt64Value(botId)), domain: domain, browser: browser, platform: platform, dateCreated: dateCreated, dateActive: dateActive, ip: ip, region: region)) } } diff --git a/submodules/TelegramCore/Sources/TelegramEngine/Privacy/UpdatedAccountPrivacySettings.swift b/submodules/TelegramCore/Sources/TelegramEngine/Privacy/UpdatedAccountPrivacySettings.swift index 847cccced8..b9ec6fbb66 100644 --- a/submodules/TelegramCore/Sources/TelegramEngine/Privacy/UpdatedAccountPrivacySettings.swift +++ b/submodules/TelegramCore/Sources/TelegramEngine/Privacy/UpdatedAccountPrivacySettings.swift @@ -232,7 +232,7 @@ func _internal_updateSelectiveAccountPrivacySettings(account: Account, type: Upd rules.append(Api.InputPrivacyRule.inputPrivacyValueAllowUsers(users: apiInputUsers(transaction: transaction, peerIds: enablePeers.users))) } if !enablePeers.groups.isEmpty { - rules.append(Api.InputPrivacyRule.inputPrivacyValueAllowChatParticipants(chats: enablePeers.groups.map({ $0.id._internalGetInt32Value() }))) + rules.append(Api.InputPrivacyRule.inputPrivacyValueAllowChatParticipants(chats: enablePeers.groups.map({ $0.id._internalGetInt64Value() }))) } rules.append(Api.InputPrivacyRule.inputPrivacyValueDisallowAll) @@ -244,14 +244,14 @@ func _internal_updateSelectiveAccountPrivacySettings(account: Account, type: Upd rules.append(Api.InputPrivacyRule.inputPrivacyValueAllowUsers(users: apiInputUsers(transaction: transaction, peerIds: enablePeers.users))) } if !enablePeers.groups.isEmpty { - rules.append(Api.InputPrivacyRule.inputPrivacyValueAllowChatParticipants(chats: enablePeers.groups.map({ $0.id._internalGetInt32Value() }))) + rules.append(Api.InputPrivacyRule.inputPrivacyValueAllowChatParticipants(chats: enablePeers.groups.map({ $0.id._internalGetInt64Value() }))) } if !disablePeers.users.isEmpty { rules.append(Api.InputPrivacyRule.inputPrivacyValueDisallowUsers(users: apiInputUsers(transaction: transaction, peerIds: disablePeers.users))) } if !disablePeers.groups.isEmpty { - rules.append(Api.InputPrivacyRule.inputPrivacyValueDisallowChatParticipants(chats: disablePeers.groups.map({ $0.id._internalGetInt32Value() }))) + rules.append(Api.InputPrivacyRule.inputPrivacyValueDisallowChatParticipants(chats: disablePeers.groups.map({ $0.id._internalGetInt64Value() }))) } rules.append(Api.InputPrivacyRule.inputPrivacyValueAllowContacts) @@ -262,7 +262,7 @@ func _internal_updateSelectiveAccountPrivacySettings(account: Account, type: Upd rules.append(Api.InputPrivacyRule.inputPrivacyValueDisallowUsers(users: apiInputUsers(transaction: transaction, peerIds: disablePeers.users))) } if !disablePeers.groups.isEmpty { - rules.append(Api.InputPrivacyRule.inputPrivacyValueDisallowChatParticipants(chats: disablePeers.groups.map({ $0.id._internalGetInt32Value() }))) + rules.append(Api.InputPrivacyRule.inputPrivacyValueDisallowChatParticipants(chats: disablePeers.groups.map({ $0.id._internalGetInt64Value() }))) } rules.append(Api.InputPrivacyRule.inputPrivacyValueAllowAll) diff --git a/submodules/TelegramCore/Sources/TelegramEngine/SecureId/GrantSecureIdAccess.swift b/submodules/TelegramCore/Sources/TelegramEngine/SecureId/GrantSecureIdAccess.swift index 77b586b24d..a046d3524c 100644 --- a/submodules/TelegramCore/Sources/TelegramEngine/SecureId/GrantSecureIdAccess.swift +++ b/submodules/TelegramCore/Sources/TelegramEngine/SecureId/GrantSecureIdAccess.swift @@ -332,7 +332,7 @@ public func grantSecureIdAccess(network: Network, peerId: PeerId, publicKey: Str valueHashes.append(.secureValueHash(type: apiSecureValueType(value: value.value), hash: Buffer(data: value.opaqueHash))) } - return network.request(Api.functions.account.acceptAuthorization(botId: peerId.id._internalGetInt32Value(), scope: scope, publicKey: publicKey, valueHashes: valueHashes, credentials: .secureCredentialsEncrypted(data: Buffer(data: encryptedCredentialsData), hash: Buffer(data: decryptedCredentialsHash), secret: Buffer(data: encryptedSecretData)))) + return network.request(Api.functions.account.acceptAuthorization(botId: peerId.id._internalGetInt64Value(), scope: scope, publicKey: publicKey, valueHashes: valueHashes, credentials: .secureCredentialsEncrypted(data: Buffer(data: encryptedCredentialsData), hash: Buffer(data: decryptedCredentialsHash), secret: Buffer(data: encryptedSecretData)))) |> mapError { error -> GrantSecureIdAccessError in return .generic } diff --git a/submodules/TelegramCore/Sources/TelegramEngine/SecureId/RequestSecureIdForm.swift b/submodules/TelegramCore/Sources/TelegramEngine/SecureId/RequestSecureIdForm.swift index 03d4e2a505..9bea496571 100644 --- a/submodules/TelegramCore/Sources/TelegramEngine/SecureId/RequestSecureIdForm.swift +++ b/submodules/TelegramCore/Sources/TelegramEngine/SecureId/RequestSecureIdForm.swift @@ -250,7 +250,7 @@ public func requestSecureIdForm(postbox: Postbox, network: Network, peerId: Peer if publicKey.isEmpty { return .fail(.serverError("PUBLIC_KEY_REQUIRED")) } - return network.request(Api.functions.account.getAuthorizationForm(botId: peerId.id._internalGetInt32Value(), scope: scope, publicKey: publicKey)) + return network.request(Api.functions.account.getAuthorizationForm(botId: peerId.id._internalGetInt64Value(), scope: scope, publicKey: publicKey)) |> mapError { error -> RequestSecureIdFormError in switch error.errorDescription { case "APP_VERSION_OUTDATED": diff --git a/submodules/TelegramCore/Sources/TelegramEngine/Themes/ChatThemes.swift b/submodules/TelegramCore/Sources/TelegramEngine/Themes/ChatThemes.swift index 4974ab02c6..518dba5b1d 100644 --- a/submodules/TelegramCore/Sources/TelegramEngine/Themes/ChatThemes.swift +++ b/submodules/TelegramCore/Sources/TelegramEngine/Themes/ChatThemes.swift @@ -3,7 +3,7 @@ import Postbox import SwiftSignalKit import TelegramApi -public struct ChatTheme: PostboxCoding, Equatable { +public struct ChatTheme: Codable, Equatable { public static func == (lhs: ChatTheme, rhs: ChatTheme) -> Bool { return lhs.emoji == rhs.emoji && lhs.theme == rhs.theme && lhs.darkTheme == rhs.darkTheme } @@ -18,21 +18,24 @@ public struct ChatTheme: PostboxCoding, Equatable { self.darkTheme = darkTheme } - public init(decoder: PostboxDecoder) { - self.emoji = decoder.decodeStringForKey("e", orElse: "") - self.theme = decoder.decodeObjectForKey("t") as! TelegramTheme - self.darkTheme = decoder.decodeObjectForKey("dt") as! TelegramTheme + public init(from decoder: Decoder) throws { + let container = try decoder.container(keyedBy: StringCodingKey.self) + + self.emoji = try container.decode(String.self, forKey: "e") + self.theme = try container.decode(TelegramTheme.self, forKey: "t") + self.darkTheme = try container.decode(TelegramTheme.self, forKey: "dt") } - public func encode(_ encoder: PostboxEncoder) { - encoder.encodeString(self.emoji, forKey: "e") - encoder.encodeObject(self.theme, forKey: "t") - encoder.encodeObject(self.darkTheme, forKey: "dt") + public func encode(to encoder: Encoder) throws { + var container = encoder.container(keyedBy: StringCodingKey.self) + + try container.encode(self.emoji, forKey: "e") + try container.encode(self.theme, forKey: "t") + try container.encode(self.darkTheme, forKey: "dt") } } - -public final class ChatThemes: PreferencesEntry, Equatable { +public final class ChatThemes: Codable, Equatable { public let chatThemes: [ChatTheme] public let hash: Int32 @@ -41,22 +44,18 @@ public final class ChatThemes: PreferencesEntry, Equatable { self.hash = hash } - public init(decoder: PostboxDecoder) { - self.chatThemes = decoder.decodeObjectArrayForKey("c").map { $0 as! ChatTheme } - self.hash = decoder.decodeInt32ForKey("h", orElse: 0) + public init(from decoder: Decoder) throws { + let container = try decoder.container(keyedBy: StringCodingKey.self) + + self.chatThemes = try container.decode([ChatTheme].self, forKey: "c") + self.hash = try container.decode(Int32.self, forKey: "h") } - public func encode(_ encoder: PostboxEncoder) { - encoder.encodeObjectArray(self.chatThemes, forKey: "c") - encoder.encodeInt32(self.hash, forKey: "h") - } - - public func isEqual(to: PreferencesEntry) -> Bool { - if let to = to as? ChatThemes { - return self == to - } else { - return false - } + public func encode(to encoder: Encoder) throws { + var container = encoder.container(keyedBy: StringCodingKey.self) + + try container.encode(self.chatThemes, forKey: "c") + try container.encode(self.hash, forKey: "h") } public static func ==(lhs: ChatThemes, rhs: ChatThemes) -> Bool { @@ -77,7 +76,7 @@ func _internal_getChatThemes(accountManager: AccountManager take(1) |> map { sharedData -> ([ChatTheme], Int32) in - if let chatThemes = sharedData.entries[SharedDataKeys.chatThemes] as? ChatThemes { + if let chatThemes = sharedData.entries[SharedDataKeys.chatThemes]?.get(ChatThemes.self) { return (chatThemes.chatThemes, chatThemes.hash) } else { return ([], 0) diff --git a/submodules/TelegramCore/Sources/Themes.swift b/submodules/TelegramCore/Sources/Themes.swift index 6a6a879f6d..b1fa0f1e36 100644 --- a/submodules/TelegramCore/Sources/Themes.swift +++ b/submodules/TelegramCore/Sources/Themes.swift @@ -12,10 +12,10 @@ let telegramThemeFileExtension = "tgios-theme" #endif public func telegramThemes(postbox: Postbox, network: Network, accountManager: AccountManager?, forceUpdate: Bool = false) -> Signal<[TelegramTheme], NoError> { - let fetch: ([TelegramTheme]?, Int32?) -> Signal<[TelegramTheme], NoError> = { current, hash in + let fetch: ([TelegramTheme]?, Int64?) -> Signal<[TelegramTheme], NoError> = { current, hash in network.request(Api.functions.account.getThemes(format: telegramThemeFormat, hash: hash ?? 0)) |> retryRequest - |> mapToSignal { result -> Signal<([TelegramTheme], Int32), NoError> in + |> mapToSignal { result -> Signal<([TelegramTheme], Int64), NoError> in switch result { case let .themes(hash, themes): let result = themes.compactMap { TelegramTheme(apiTheme: $0) } @@ -32,14 +32,14 @@ public func telegramThemes(postbox: Postbox, network: Network, accountManager: A if let accountManager = accountManager { let _ = accountManager.transaction { transaction in transaction.updateSharedData(SharedDataKeys.themeSettings, { current in - var updated = current as? ThemeSettings ?? ThemeSettings(currentTheme: nil) + var updated = current?.get(ThemeSettings.self) ?? ThemeSettings(currentTheme: nil) for theme in items { if theme.id == updated.currentTheme?.id { updated = ThemeSettings(currentTheme: theme) break } } - return updated + return PreferencesEntry(updated) }) }.start() } @@ -70,7 +70,7 @@ public func telegramThemes(postbox: Postbox, network: Network, accountManager: A if forceUpdate { return fetch(nil, nil) } else { - return postbox.transaction { transaction -> ([TelegramTheme], Int32?) in + return postbox.transaction { transaction -> ([TelegramTheme], Int64?) in let configuration = transaction.retrieveItemCacheEntry(id: ItemCacheEntryId(collectionId: Namespaces.CachedItemCollection.cachedThemesConfiguration, key: ValueBoxKey(length: 0))) as? CachedThemesConfiguration let items = transaction.getOrderedListItems(collectionId: Namespaces.OrderedItemList.CloudThemes) return (items.map { $0.contents as! TelegramTheme }, configuration?.hash) @@ -219,7 +219,7 @@ private func uploadTheme(account: Account, resource: MediaResource, thumbnailDat let uploadedThumbnail: Signal if let thumbnailData = thumbnailData { uploadedThumbnail = uploadedThemeThumbnail(postbox: account.postbox, network: account.network, data: thumbnailData) - |> mapError { _ -> UploadThemeError in return .generic } + |> mapError { _ -> UploadThemeError in } |> map(Optional.init) } else { uploadedThumbnail = .single(nil) @@ -228,7 +228,7 @@ private func uploadTheme(account: Account, resource: MediaResource, thumbnailDat return uploadedThumbnail |> mapToSignal { thumbnailResult -> Signal in return uploadedTheme(postbox: account.postbox, network: account.network, resource: resource) - |> mapError { _ -> UploadThemeError in return .generic } + |> mapError { _ -> UploadThemeError in } |> mapToSignal { result -> Signal in switch result.content { case .error: @@ -419,11 +419,11 @@ public func updateTheme(account: Account, accountManager: AccountManager CreateThemeResult in @@ -461,7 +461,7 @@ public func deleteThemeInteractively(account: Account, accountManager: AccountMa public func applyTheme(accountManager: AccountManager, account: Account, theme: TelegramTheme?, autoNight: Bool = false) -> Signal { return accountManager.transaction { transaction -> Signal in transaction.updateSharedData(SharedDataKeys.themeSettings, { _ in - return ThemeSettings(currentTheme: theme) + return PreferencesEntry(ThemeSettings(currentTheme: theme)) }) if let theme = theme { @@ -477,7 +477,7 @@ func managedThemesUpdates(accountManager: AccountManager(value: nil) return accountManager.sharedData(keys: [SharedDataKeys.themeSettings]) |> map { sharedData -> TelegramTheme? in - let themeSettings = (sharedData.entries[SharedDataKeys.themeSettings] as? ThemeSettings) ?? ThemeSettings(currentTheme: nil) + let themeSettings = sharedData.entries[SharedDataKeys.themeSettings]?.get(ThemeSettings.self) ?? ThemeSettings(currentTheme: nil) return themeSettings.currentTheme } |> filter { theme in @@ -493,7 +493,7 @@ func managedThemesUpdates(accountManager: AccountManager mapToSignal { sharedData -> Signal in - let themeSettings = (sharedData.entries[SharedDataKeys.themeSettings] as? ThemeSettings) ?? ThemeSettings(currentTheme: nil) + let themeSettings = sharedData.entries[SharedDataKeys.themeSettings]?.get(ThemeSettings.self) ?? ThemeSettings(currentTheme: nil) if let updatedTheme = themeSettings.currentTheme, updatedTheme.id == theme.id { if !areThemesEqual(updatedTheme, currentTheme) { currentTheme = updatedTheme diff --git a/submodules/TelegramCore/Sources/Utils/PeerUtils.swift b/submodules/TelegramCore/Sources/Utils/PeerUtils.swift index 99f70eea33..70f32297a1 100644 --- a/submodules/TelegramCore/Sources/Utils/PeerUtils.swift +++ b/submodules/TelegramCore/Sources/Utils/PeerUtils.swift @@ -240,7 +240,7 @@ public func isServicePeer(_ peer: Peer) -> Bool { if peer.id.isReplies { return true } - return (peer.id.namespace == Namespaces.Peer.CloudUser && (peer.id.id._internalGetInt32Value() == 777000 || peer.id.id._internalGetInt32Value() == 333000)) + return (peer.id.namespace == Namespaces.Peer.CloudUser && (peer.id.id._internalGetInt64Value() == 777000 || peer.id.id._internalGetInt64Value() == 333000)) } return false } @@ -248,7 +248,7 @@ public func isServicePeer(_ peer: Peer) -> Bool { public extension PeerId { var isReplies: Bool { if self.namespace == Namespaces.Peer.CloudUser { - if self.id._internalGetInt32Value() == 708513 || self.id._internalGetInt32Value() == 1271266957 { + if self.id._internalGetInt64Value() == 708513 || self.id._internalGetInt64Value() == 1271266957 { return true } } @@ -267,7 +267,7 @@ public extension PeerId { var isImport: Bool { if self.namespace == Namespaces.Peer.CloudUser { - if self.id._internalGetInt32Value() == 225079 { + if self.id._internalGetInt64Value() == 225079 { return true } } diff --git a/submodules/TelegramCore/Sources/Wallpapers.swift b/submodules/TelegramCore/Sources/Wallpapers.swift index 56c724eadc..fa323e0ff0 100644 --- a/submodules/TelegramCore/Sources/Wallpapers.swift +++ b/submodules/TelegramCore/Sources/Wallpapers.swift @@ -5,10 +5,10 @@ import TelegramApi public func telegramWallpapers(postbox: Postbox, network: Network, forceUpdate: Bool = false) -> Signal<[TelegramWallpaper], NoError> { - let fetch: ([TelegramWallpaper]?, Int32?) -> Signal<[TelegramWallpaper], NoError> = { current, hash in + let fetch: ([TelegramWallpaper]?, Int64?) -> Signal<[TelegramWallpaper], NoError> = { current, hash in network.request(Api.functions.account.getWallPapers(hash: 0)) |> retryRequest - |> mapToSignal { result -> Signal<([TelegramWallpaper], Int32), NoError> in + |> mapToSignal { result -> Signal<([TelegramWallpaper], Int64), NoError> in switch result { case let .wallPapers(hash, wallpapers): var items: [TelegramWallpaper] = [] @@ -55,7 +55,7 @@ public func telegramWallpapers(postbox: Postbox, network: Network, forceUpdate: if forceUpdate { return fetch(nil, nil) } else { - return postbox.transaction { transaction -> ([TelegramWallpaper], Int32?) in + return postbox.transaction { transaction -> ([TelegramWallpaper], Int64?) in let configuration = transaction.retrieveItemCacheEntry(id: ItemCacheEntryId(collectionId: Namespaces.CachedItemCollection.cachedWallpapersConfiguration, key: ValueBoxKey(length: 0))) as? CachedWallpapersConfiguration let items = transaction.getOrderedListItems(collectionId: Namespaces.OrderedItemList.CloudWallpapers) if items.count == 0 { diff --git a/submodules/TelegramUI/Sources/AppDelegate.swift b/submodules/TelegramUI/Sources/AppDelegate.swift index e8b0702b72..5483fabe3b 100644 --- a/submodules/TelegramUI/Sources/AppDelegate.swift +++ b/submodules/TelegramUI/Sources/AppDelegate.swift @@ -290,13 +290,13 @@ final class SharedApplicationContext { var peerId: PeerId? if let fromId = payload["from_id"] { let fromIdValue = fromId as! NSString - peerId = PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt32Value(Int32(fromIdValue.intValue))) + peerId = PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt64Value(Int64(fromIdValue as String) ?? 0)) } else if let fromId = payload["chat_id"] { let fromIdValue = fromId as! NSString - peerId = PeerId(namespace: Namespaces.Peer.CloudGroup, id: PeerId.Id._internalFromInt32Value(Int32(fromIdValue.intValue))) + peerId = PeerId(namespace: Namespaces.Peer.CloudGroup, id: PeerId.Id._internalFromInt64Value(Int64(fromIdValue as String) ?? 0)) } else if let fromId = payload["channel_id"] { let fromIdValue = fromId as! NSString - peerId = PeerId(namespace: Namespaces.Peer.CloudChannel, id: PeerId.Id._internalFromInt32Value(Int32(fromIdValue.intValue))) + peerId = PeerId(namespace: Namespaces.Peer.CloudChannel, id: PeerId.Id._internalFromInt64Value(Int64(fromIdValue as String) ?? 0)) } if let msgId = payload["msg_id"] { @@ -1705,8 +1705,8 @@ final class SharedApplicationContext { } if let startCallContacts = startCallContacts { - let startCall: (Int32) -> Void = { userId in - self.startCallWhenReady(accountId: nil, peerId: PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt32Value(userId)), isVideo: startCallIsVideo) + let startCall: (Int64) -> Void = { userId in + self.startCallWhenReady(accountId: nil, peerId: PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt64Value(userId)), isVideo: startCallIsVideo) } func cleanPhoneNumber(_ text: String) -> String { @@ -1737,7 +1737,7 @@ final class SharedApplicationContext { var processed = false if let handle = contact.customIdentifier, handle.hasPrefix("tg") { let string = handle.suffix(from: handle.index(handle.startIndex, offsetBy: 2)) - if let userId = Int32(string) { + if let userId = Int64(string) { startCall(userId) processed = true } @@ -1745,7 +1745,7 @@ final class SharedApplicationContext { if !processed, let handle = contact.personHandle, let value = handle.value { switch handle.type { case .unknown: - if let userId = Int32(value) { + if let userId = Int64(value) { startCall(userId) processed = true } @@ -1768,7 +1768,7 @@ final class SharedApplicationContext { return result } |> deliverOnMainQueue).start(next: { peerId in if let peerId = peerId { - startCall(peerId.id._internalGetInt32Value()) + startCall(peerId.id._internalGetInt64Value()) } }) processed = true @@ -1782,8 +1782,8 @@ final class SharedApplicationContext { } else if let sendMessageIntent = userActivity.interaction?.intent as? INSendMessageIntent { if let contact = sendMessageIntent.recipients?.first, let handle = contact.customIdentifier, handle.hasPrefix("tg") { let string = handle.suffix(from: handle.index(handle.startIndex, offsetBy: 2)) - if let userId = Int32(string) { - self.openChatWhenReady(accountId: nil, peerId: PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt32Value(userId)), activateInput: true) + if let userId = Int64(string) { + self.openChatWhenReady(accountId: nil, peerId: PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt64Value(userId)), activateInput: true) } } } @@ -2325,7 +2325,7 @@ private func accountIdFromNotification(_ notification: UNNotification, sharedCon |> take(1) |> map { _, contexts, _ -> AccountRecordId? in for (_, context, _) in contexts { - if Int(context.account.peerId.id._internalGetInt32Value()) == userId { + if Int(context.account.peerId.id._internalGetInt64Value()) == userId { return context.account.id } } @@ -2347,16 +2347,16 @@ private func peerIdFromNotification(_ notification: UNNotification) -> PeerId? { var peerId: PeerId? if let fromId = payload["from_id"] { let fromIdValue = fromId as! NSString - peerId = PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt32Value(Int32(fromIdValue.intValue))) + peerId = PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt64Value(Int64(fromIdValue as String) ?? 0)) } else if let fromId = payload["chat_id"] { let fromIdValue = fromId as! NSString - peerId = PeerId(namespace: Namespaces.Peer.CloudGroup, id: PeerId.Id._internalFromInt32Value(Int32(fromIdValue.intValue))) + peerId = PeerId(namespace: Namespaces.Peer.CloudGroup, id: PeerId.Id._internalFromInt64Value(Int64(fromIdValue as String) ?? 0)) } else if let fromId = payload["channel_id"] { let fromIdValue = fromId as! NSString - peerId = PeerId(namespace: Namespaces.Peer.CloudChannel, id: PeerId.Id._internalFromInt32Value(Int32(fromIdValue.intValue))) + peerId = PeerId(namespace: Namespaces.Peer.CloudChannel, id: PeerId.Id._internalFromInt64Value(Int64(fromIdValue as String) ?? 0)) } else if let fromId = payload["encryption_id"] { let fromIdValue = fromId as! NSString - peerId = PeerId(namespace: Namespaces.Peer.SecretChat, id: PeerId.Id._internalFromInt32Value(Int32(fromIdValue.intValue))) + peerId = PeerId(namespace: Namespaces.Peer.SecretChat, id: PeerId.Id._internalFromInt64Value(Int64(fromIdValue as String) ?? 0)) } return peerId } diff --git a/submodules/TelegramUI/Sources/ChatController.swift b/submodules/TelegramUI/Sources/ChatController.swift index 07c318b576..bba2c26553 100644 --- a/submodules/TelegramUI/Sources/ChatController.swift +++ b/submodules/TelegramUI/Sources/ChatController.swift @@ -745,7 +745,7 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G } } - return context.sharedContext.openChatMessage(OpenChatMessageParams(context: context, chatLocation: openChatLocation, chatLocationContextHolder: strongSelf.chatLocationContextHolder, message: message, standalone: false, reverseMessageGalleryOrder: false, mode: mode, navigationController: strongSelf.effectiveNavigationController, dismissInput: { + return context.sharedContext.openChatMessage(OpenChatMessageParams(context: context, updatedPresentationData: strongSelf.updatedPresentationData, chatLocation: openChatLocation, chatLocationContextHolder: strongSelf.chatLocationContextHolder, message: message, standalone: false, reverseMessageGalleryOrder: false, mode: mode, navigationController: strongSelf.effectiveNavigationController, dismissInput: { self?.chatDisplayNode.dismissInput() }, present: { c, a in self?.present(c, in: .window(.root), with: a, blockInteraction: true) @@ -1660,7 +1660,7 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G }) }, openMessageShareMenu: { [weak self] id in if let strongSelf = self, let messages = strongSelf.chatDisplayNode.historyNode.messageGroupInCurrentHistoryView(id), let _ = messages.first { - let shareController = ShareController(context: strongSelf.context, subject: .messages(messages)) + let shareController = ShareController(context: strongSelf.context, subject: .messages(messages), updatedPresentationData: strongSelf.updatedPresentationData) shareController.dismissed = { [weak self] shared in if shared { self?.commitPurposefulAction() @@ -2568,7 +2568,7 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G guard let strongSelf = self else { return } - let shareController = ShareController(context: strongSelf.context, subject: .text(text.string), externalShare: true, immediateExternalShare: false) + let shareController = ShareController(context: strongSelf.context, subject: .text(text.string), externalShare: true, immediateExternalShare: false, updatedPresentationData: strongSelf.updatedPresentationData) strongSelf.chatDisplayNode.dismissInput() strongSelf.present(shareController, in: .window(.root)) } @@ -3886,7 +3886,19 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G } |> distinctUntilChanged - self.presentationDataDisposable = combineLatest(queue: Queue.mainQueue(), context.sharedContext.presentationData, context.engine.themes.getChatThemes(accountManager: context.sharedContext.accountManager, onlyCached: false), themeEmoticon, self.themeEmoticonPreviewPromise.get(), self.themeDarkAppearancePreviewPromise.get()).start(next: { [weak self] presentationData, chatThemes, themeEmoticon, themeEmoticonPreview, darkAppearancePreview in + let themeSettings = context.sharedContext.accountManager.sharedData(keys: [ApplicationSpecificSharedDataKeys.presentationThemeSettings]) + |> map { sharedData -> PresentationThemeSettings in + let themeSettings: PresentationThemeSettings + if let current = sharedData.entries[ApplicationSpecificSharedDataKeys.presentationThemeSettings] as? PresentationThemeSettings { + themeSettings = current + } else { + themeSettings = PresentationThemeSettings.defaultSettings + } + return themeSettings + } + + let accountManager = context.sharedContext.accountManager + self.presentationDataDisposable = combineLatest(queue: Queue.mainQueue(), context.sharedContext.presentationData, themeSettings, context.engine.themes.getChatThemes(accountManager: accountManager, onlyCached: false), themeEmoticon, self.themeEmoticonPreviewPromise.get(), self.themeDarkAppearancePreviewPromise.get()).start(next: { [weak self] presentationData, themeSettings, chatThemes, themeEmoticon, themeEmoticonPreview, darkAppearancePreview in if let strongSelf = self { let previousTheme = strongSelf.presentationData.theme let previousStrings = strongSelf.presentationData.strings @@ -3914,12 +3926,64 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G } } else if let darkAppearancePreview = darkAppearancePreview { let lightTheme: PresentationTheme - let darkTheme: PresentationTheme + let lightWallpaper: TelegramWallpaper - if presentationData.theme.overallDarkAppearance { + let darkTheme: PresentationTheme + let darkWallpaper: TelegramWallpaper + + if presentationData.autoNightModeTriggered { darkTheme = presentationData.theme + darkWallpaper = presentationData.chatWallpaper + + var currentColors = themeSettings.themeSpecificAccentColors[themeSettings.theme.index] + if let colors = currentColors, colors.baseColor == .theme { + currentColors = nil + } + + let themeSpecificWallpaper = (themeSettings.themeSpecificChatWallpapers[coloredThemeIndex(reference: themeSettings.theme, accentColor: currentColors)] ?? themeSettings.themeSpecificChatWallpapers[themeSettings.theme.index]) + + if let themeSpecificWallpaper = themeSpecificWallpaper { + lightWallpaper = themeSpecificWallpaper + } else { + let theme = makePresentationTheme(mediaBox: accountManager.mediaBox, themeReference: themeSettings.theme, accentColor: currentColors?.color, bubbleColors: currentColors?.customBubbleColors ?? [], wallpaper: currentColors?.wallpaper, baseColor: currentColors?.baseColor) ?? defaultPresentationTheme + lightWallpaper = theme.chat.defaultWallpaper + } + + lightTheme = makePresentationTheme(mediaBox: accountManager.mediaBox, themeReference: themeSettings.theme, accentColor: currentColors?.color, bubbleColors: currentColors?.customBubbleColors ?? [], wallpaper: currentColors?.wallpaper, baseColor: currentColors?.baseColor, serviceBackgroundColor: defaultServiceBackgroundColor) ?? defaultPresentationTheme } else { lightTheme = presentationData.theme + lightWallpaper = presentationData.chatWallpaper + + let automaticTheme = themeSettings.automaticThemeSwitchSetting.theme + let effectiveColors = themeSettings.themeSpecificAccentColors[automaticTheme.index] + let themeSpecificWallpaper = (themeSettings.themeSpecificChatWallpapers[coloredThemeIndex(reference: automaticTheme, accentColor: effectiveColors)] ?? themeSettings.themeSpecificChatWallpapers[automaticTheme.index]) + + darkTheme = makePresentationTheme(mediaBox: accountManager.mediaBox, themeReference: automaticTheme, accentColor: effectiveColors?.color, bubbleColors: effectiveColors?.customBubbleColors ?? [], wallpaper: effectiveColors?.wallpaper, baseColor: effectiveColors?.baseColor, serviceBackgroundColor: defaultServiceBackgroundColor) ?? defaultPresentationTheme + + if let themeSpecificWallpaper = themeSpecificWallpaper { + darkWallpaper = themeSpecificWallpaper + } else { + switch lightWallpaper { + case .builtin, .color, .gradient: + darkWallpaper = darkTheme.chat.defaultWallpaper + case .file: + if lightWallpaper.isPattern { + darkWallpaper = darkTheme.chat.defaultWallpaper + } else { + darkWallpaper = lightWallpaper + } + default: + darkWallpaper = lightWallpaper + } + } + } + + if darkAppearancePreview { + presentationData = presentationData.withUpdated(theme: darkTheme) + presentationData = presentationData.withUpdated(chatWallpaper: darkWallpaper) + } else { + presentationData = presentationData.withUpdated(theme: lightTheme) + presentationData = presentationData.withUpdated(chatWallpaper: lightWallpaper) } } let isFirstTime = !strongSelf.didSetPresentationData @@ -3928,8 +3992,9 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G if isFirstTime || previousTheme !== presentationData.theme || previousStrings !== presentationData.strings || presentationData.chatWallpaper != previousChatWallpaper { strongSelf.themeAndStringsUpdated() + + strongSelf.presentationDataPromise.set(.single(strongSelf.presentationData)) } - strongSelf.presentationDataPromise.set(.single(strongSelf.presentationData)) strongSelf.presentationReady.set(.single(true)) } }) @@ -5514,8 +5579,22 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G let chatController = strongSelf.context.sharedContext.makeChatController(context: strongSelf.context, chatLocation: .peer(peerId), subject: .forwardedMessages(ids: strongSelf.presentationInterfaceState.interfaceState.forwardMessageIds ?? [], options: forwardOptions), botStart: nil, mode: .standard(previewing: true)) chatController.canReadHistory.set(false) - let items = combineLatest(forwardOptions, strongSelf.context.account.postbox.messagesAtIds(strongSelf.presentationInterfaceState.interfaceState.forwardMessageIds ?? [])) - |> map { forwardOptions, messages -> [ContextMenuItem] in + let messageIds = strongSelf.presentationInterfaceState.interfaceState.forwardMessageIds ?? [] + let messagesCount: Signal + if let chatController = chatController as? ChatControllerImpl, messageIds.count > 1 { + messagesCount = .single(messageIds.count) + |> then( + chatController.presentationInterfaceStatePromise.get() + |> map { state -> Int in + return state.interfaceState.selectionState?.selectedIds.count ?? 1 + } + ) + } else { + messagesCount = .single(1) + } + + let items = combineLatest(forwardOptions, strongSelf.context.account.postbox.messagesAtIds(messageIds), messagesCount) + |> map { forwardOptions, messages, messagesCount -> [ContextMenuItem] in var items: [ContextMenuItem] = [] var hasCaptions = false @@ -5637,7 +5716,7 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G f(.default) }))) - items.append(.action(ContextMenuActionItem(text: presentationData.strings.Conversation_ForwardOptions_SendMessages, icon: { theme in return generateTintedImage(image: UIImage(bundleImageName: "Chat/Context Menu/Resend"), color: theme.contextMenu.primaryColor) }, action: { [weak self, weak chatController] c, f in + items.append(.action(ContextMenuActionItem(text: messagesCount == 1 ? presentationData.strings.Conversation_ForwardOptions_SendMessage : presentationData.strings.Conversation_ForwardOptions_SendMessages, icon: { theme in return generateTintedImage(image: UIImage(bundleImageName: "Chat/Context Menu/Resend"), color: theme.contextMenu.primaryColor) }, action: { [weak self, weak chatController] c, f in guard let strongSelf = self else { return } @@ -5683,7 +5762,7 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G let shareController = ShareController(context: strongSelf.context, subject: .messages(messages.sorted(by: { lhs, rhs in return lhs.index < rhs.index - })), externalShare: true, immediateExternalShare: true) + })), externalShare: true, immediateExternalShare: true, updatedPresentationData: strongSelf.updatedPresentationData) strongSelf.chatDisplayNode.dismissInput() strongSelf.present(shareController, in: .window(.root)) } @@ -7044,7 +7123,7 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G let _ = ApplicationSpecificNotice.incrementChatMessageOptionsTip(accountManager: strongSelf.context.sharedContext.accountManager, count: 4).start() - let controller = ChatSendMessageActionSheetController(context: strongSelf.context, interfaceState: strongSelf.presentationInterfaceState, gesture: gesture, sourceSendButton: node, textInputNode: textInputNode, completion: { [weak self] in + let controller = ChatSendMessageActionSheetController(context: strongSelf.context, updatedPresentationData: strongSelf.updatedPresentationData, interfaceState: strongSelf.presentationInterfaceState, gesture: gesture, sourceSendButton: node, textInputNode: textInputNode, completion: { [weak self] in if let strongSelf = self { strongSelf.supportedOrientations = previousSupportedOrientations } @@ -9660,7 +9739,7 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G return } let hasLiveLocation = peer.id.namespace != Namespaces.Peer.SecretChat && peer.id != strongSelf.context.account.peerId && strongSelf.presentationInterfaceState.subject != .scheduledMessages - let controller = LocationPickerController(context: strongSelf.context, mode: .share(peer: peer, selfPeer: selfPeer, hasLiveLocation: hasLiveLocation), completion: { [weak self] location, _ in + let controller = LocationPickerController(context: strongSelf.context, updatedPresentationData: strongSelf.updatedPresentationData, mode: .share(peer: peer, selfPeer: selfPeer, hasLiveLocation: hasLiveLocation), completion: { [weak self] location, _ in guard let strongSelf = self else { return } @@ -13162,7 +13241,7 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G } else { mode = .scheduledMessages(sendWhenOnlineAvailable: sendWhenOnlineAvailable) } - let controller = ChatScheduleTimeController(context: strongSelf.context, peerId: peerId, mode: mode, style: style, currentTime: selectedTime, minimalTime: strongSelf.presentationInterfaceState.slowmodeState?.timeout, dismissByTapOutside: dismissByTapOutside, completion: { time in + let controller = ChatScheduleTimeController(context: strongSelf.context, updatedPresentationData: strongSelf.updatedPresentationData, peerId: peerId, mode: mode, style: style, currentTime: selectedTime, minimalTime: strongSelf.presentationInterfaceState.slowmodeState?.timeout, dismissByTapOutside: dismissByTapOutside, completion: { time in completion(time) }) strongSelf.chatDisplayNode.dismissInput() @@ -13174,7 +13253,7 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G guard case let .peer(peerId) = self.chatLocation else { return } - let controller = ChatTimerScreen(context: self.context, peerId: peerId, style: style, currentTime: selectedTime, dismissByTapOutside: dismissByTapOutside, completion: { time in + let controller = ChatTimerScreen(context: self.context, updatedPresentationData: self.updatedPresentationData, peerId: peerId, style: style, currentTime: selectedTime, dismissByTapOutside: dismissByTapOutside, completion: { time in completion(time) }) self.chatDisplayNode.dismissInput() diff --git a/submodules/TelegramUI/Sources/ChatMediaInputNode.swift b/submodules/TelegramUI/Sources/ChatMediaInputNode.swift index cf55926677..819b35c16f 100644 --- a/submodules/TelegramUI/Sources/ChatMediaInputNode.swift +++ b/submodules/TelegramUI/Sources/ChatMediaInputNode.swift @@ -162,7 +162,7 @@ func preparedChatMediaInputGridEntryTransition(account: Account, view: ItemColle return ChatMediaInputGridTransition(deletions: deletions, insertions: insertions, updates: updates, updateFirstIndexInSectionOffset: firstIndexInSectionOffset, stationaryItems: stationaryItems, scrollToItem: scrollToItem, updateOpaqueState: opaqueState, animated: animated) } -func chatMediaInputPanelEntries(view: ItemCollectionsView, savedStickers: OrderedItemListView?, recentStickers: OrderedItemListView?, temporaryPackOrder: [ItemCollectionId]? = nil, trendingIsDismissed: Bool = false, peerSpecificPack: PeerSpecificPackData?, canInstallPeerSpecificPack: CanInstallPeerSpecificPack, theme: PresentationTheme, strings: PresentationStrings, hasGifs: Bool = true, hasSettings: Bool = true, expanded: Bool = false) -> [ChatMediaInputPanelEntry] { +func chatMediaInputPanelEntries(view: ItemCollectionsView, savedStickers: OrderedItemListView?, recentStickers: OrderedItemListView?, temporaryPackOrder: [ItemCollectionId]? = nil, trendingIsDismissed: Bool = false, peerSpecificPack: PeerSpecificPackData?, canInstallPeerSpecificPack: CanInstallPeerSpecificPack, theme: PresentationTheme, strings: PresentationStrings, hasGifs: Bool = true, hasSettings: Bool = true, expanded: Bool = false, reorderable: Bool = false) -> [ChatMediaInputPanelEntry] { var entries: [ChatMediaInputPanelEntry] = [] if hasGifs { entries.append(.recentGifs(theme, strings, expanded)) @@ -227,7 +227,7 @@ func chatMediaInputPanelEntries(view: ItemCollectionsView, savedStickers: Ordere } for (_, info, topItem) in sortedPacks { - entries.append(.stickerPack(index: index, info: info, topItem: topItem, theme: theme, expanded: expanded)) + entries.append(.stickerPack(index: index, info: info, topItem: topItem, theme: theme, expanded: expanded, reorderable: reorderable)) index += 1 } @@ -624,7 +624,7 @@ final class ChatMediaInputNode: ChatInputNode { self?.lastReorderItemIndex = toIndex let fromEntry = entries[fromIndex] - guard case let .stickerPack(_, fromPackInfo, _, _, _) = fromEntry else { + guard case let .stickerPack(_, fromPackInfo, _, _, _, _) = fromEntry else { return .single(false) } var referenceId: ItemCollectionId? @@ -632,7 +632,7 @@ final class ChatMediaInputNode: ChatInputNode { var afterAll = false if toIndex < entries.count { switch entries[toIndex] { - case let .stickerPack(_, toPackInfo, _, _, _): + case let .stickerPack(_, toPackInfo, _, _, _, _): referenceId = toPackInfo.id default: if entries[toIndex] < fromEntry { @@ -648,7 +648,7 @@ final class ChatMediaInputNode: ChatInputNode { var currentIds: [ItemCollectionId] = [] for entry in entries { switch entry { - case let .stickerPack(_, info, _, _, _): + case let .stickerPack(_, info, _, _, _, _): currentIds.append(info.id) default: break @@ -705,7 +705,7 @@ final class ChatMediaInputNode: ChatInputNode { var currentIds: [ItemCollectionId] = [] for entry in entries { switch entry { - case let .stickerPack(_, info, _, _, _): + case let .stickerPack(_, info, _, _, _, _): currentIds.append(info.id) default: break @@ -1139,7 +1139,7 @@ final class ChatMediaInputNode: ChatInputNode { trendingIsDismissed = true } - let panelEntries = chatMediaInputPanelEntries(view: view, savedStickers: savedStickers, recentStickers: recentStickers, temporaryPackOrder: temporaryPackOrder, trendingIsDismissed: trendingIsDismissed, peerSpecificPack: peerSpecificPack.0, canInstallPeerSpecificPack: peerSpecificPack.1, theme: theme, strings: strings, expanded: panelExpanded) + let panelEntries = chatMediaInputPanelEntries(view: view, savedStickers: savedStickers, recentStickers: recentStickers, temporaryPackOrder: temporaryPackOrder, trendingIsDismissed: trendingIsDismissed, peerSpecificPack: peerSpecificPack.0, canInstallPeerSpecificPack: peerSpecificPack.1, theme: theme, strings: strings, expanded: panelExpanded, reorderable: true) let gifPaneEntries = chatMediaInputPanelGifModeEntries(theme: theme, strings: strings, reactions: reactions, animatedEmojiStickers: animatedEmojiStickers, expanded: panelExpanded) var gridEntries = chatMediaInputGridEntries(view: view, savedStickers: savedStickers, recentStickers: recentStickers, peerSpecificPack: peerSpecificPack.0, canInstallPeerSpecificPack: peerSpecificPack.1, trendingPacks: trendingPacks, installedPacks: installedPacks, trendingIsDismissed: trendingIsDismissed, strings: strings, theme: theme) diff --git a/submodules/TelegramUI/Sources/ChatMediaInputPanelEntries.swift b/submodules/TelegramUI/Sources/ChatMediaInputPanelEntries.swift index 2320f8e217..bf6a9a4601 100644 --- a/submodules/TelegramUI/Sources/ChatMediaInputPanelEntries.swift +++ b/submodules/TelegramUI/Sources/ChatMediaInputPanelEntries.swift @@ -37,7 +37,7 @@ enum ChatMediaInputPanelEntry: Comparable, Identifiable { case trending(Bool, PresentationTheme, PresentationStrings, Bool) case settings(PresentationTheme, PresentationStrings, Bool) case peerSpecific(theme: PresentationTheme, peer: Peer, expanded: Bool) - case stickerPack(index: Int, info: StickerPackCollectionInfo, topItem: StickerPackItem?, theme: PresentationTheme, expanded: Bool) + case stickerPack(index: Int, info: StickerPackCollectionInfo, topItem: StickerPackItem?, theme: PresentationTheme, expanded: Bool, reorderable: Bool) case stickersMode(PresentationTheme, PresentationStrings, Bool) case savedGifs(PresentationTheme, PresentationStrings, Bool) @@ -58,7 +58,7 @@ enum ChatMediaInputPanelEntry: Comparable, Identifiable { return .settings case .peerSpecific: return .peerSpecific - case let .stickerPack(_, info, _, _, _): + case let .stickerPack(_, info, _, _, _, _): return .stickerPack(info.id.id) case .stickersMode: return .stickersMode @@ -109,8 +109,8 @@ enum ChatMediaInputPanelEntry: Comparable, Identifiable { } else { return false } - case let .stickerPack(index, info, topItem, lhsTheme, lhsExpanded): - if case let .stickerPack(rhsIndex, rhsInfo, rhsTopItem, rhsTheme, rhsExpanded) = rhs, index == rhsIndex, info == rhsInfo, topItem == rhsTopItem, lhsTheme === rhsTheme, lhsExpanded == rhsExpanded { + case let .stickerPack(index, info, topItem, lhsTheme, lhsExpanded, lhsReorderable): + if case let .stickerPack(rhsIndex, rhsInfo, rhsTopItem, rhsTheme, rhsExpanded, rhsReorderable) = rhs, index == rhsIndex, info == rhsInfo, topItem == rhsTopItem, lhsTheme === rhsTheme, lhsExpanded == rhsExpanded, lhsReorderable == rhsReorderable { return true } else { return false @@ -134,7 +134,7 @@ enum ChatMediaInputPanelEntry: Comparable, Identifiable { return false } case let .gifEmotion(lhsIndex, lhsTheme, lhsStrings, lhsEmoji, lhsFile, lhsExpanded): - if case let .gifEmotion(rhsIndex, rhsTheme, rhsStrings, rhsEmoji, rhsFile, rhsExpanded) = rhs, lhsIndex == rhsIndex, lhsTheme === rhsTheme, lhsEmoji == rhsEmoji, lhsExpanded == rhsExpanded { + if case let .gifEmotion(rhsIndex, rhsTheme, rhsStrings, rhsEmoji, rhsFile, rhsExpanded) = rhs, lhsIndex == rhsIndex, lhsTheme === rhsTheme, lhsStrings === rhsStrings, lhsEmoji == rhsEmoji, lhsExpanded == rhsExpanded { if let lhsFile = lhsFile, let rhsFile = rhsFile { if !lhsFile.isEqual(to: rhsFile) { return false @@ -185,7 +185,7 @@ enum ChatMediaInputPanelEntry: Comparable, Identifiable { default: return true } - case let .stickerPack(lhsIndex, lhsInfo, _, _, _): + case let .stickerPack(lhsIndex, lhsInfo, _, _, _, _): switch rhs { case .recentGifs, .savedStickers, .recentPacks, .peerSpecific: return false @@ -197,7 +197,7 @@ enum ChatMediaInputPanelEntry: Comparable, Identifiable { } case .settings: return true - case let .stickerPack(rhsIndex, rhsInfo, _, _, _): + case let .stickerPack(rhsIndex, rhsInfo, _, _, _, _): if lhsIndex == rhsIndex { return lhsInfo.id.id < rhsInfo.id.id } else { @@ -286,8 +286,8 @@ enum ChatMediaInputPanelEntry: Comparable, Identifiable { return ChatMediaInputPeerSpecificItem(context: context, inputNodeInteraction: inputNodeInteraction, collectionId: collectionId, peer: peer, theme: theme, expanded: expanded, selected: { inputNodeInteraction.navigateToCollectionId(collectionId) }) - case let .stickerPack(index, info, topItem, theme, expanded): - return ChatMediaInputStickerPackItem(account: context.account, inputNodeInteraction: inputNodeInteraction, collectionId: info.id, collectionInfo: info, stickerPackItem: topItem, index: index, theme: theme, expanded: expanded, selected: { + case let .stickerPack(index, info, topItem, theme, expanded, reorderable): + return ChatMediaInputStickerPackItem(account: context.account, inputNodeInteraction: inputNodeInteraction, collectionId: info.id, collectionInfo: info, stickerPackItem: topItem, index: index, theme: theme, expanded: expanded, reorderable: reorderable, selected: { inputNodeInteraction.navigateToCollectionId(info.id) }) case let .stickersMode(theme, strings, expanded): diff --git a/submodules/TelegramUI/Sources/ChatMediaInputStickerPackItem.swift b/submodules/TelegramUI/Sources/ChatMediaInputStickerPackItem.swift index 2ce93f285c..f1f4ecd228 100644 --- a/submodules/TelegramUI/Sources/ChatMediaInputStickerPackItem.swift +++ b/submodules/TelegramUI/Sources/ChatMediaInputStickerPackItem.swift @@ -22,12 +22,13 @@ final class ChatMediaInputStickerPackItem: ListViewItem { let index: Int let theme: PresentationTheme let expanded: Bool + let reorderable: Bool var selectable: Bool { return true } - init(account: Account, inputNodeInteraction: ChatMediaInputNodeInteraction, collectionId: ItemCollectionId, collectionInfo: StickerPackCollectionInfo, stickerPackItem: StickerPackItem?, index: Int, theme: PresentationTheme, expanded: Bool, selected: @escaping () -> Void) { + init(account: Account, inputNodeInteraction: ChatMediaInputNodeInteraction, collectionId: ItemCollectionId, collectionInfo: StickerPackCollectionInfo, stickerPackItem: StickerPackItem?, index: Int, theme: PresentationTheme, expanded: Bool, reorderable: Bool, selected: @escaping () -> Void) { self.account = account self.inputNodeInteraction = inputNodeInteraction self.collectionId = collectionId @@ -37,6 +38,7 @@ final class ChatMediaInputStickerPackItem: ListViewItem { self.index = index self.theme = theme self.expanded = expanded + self.reorderable = reorderable } func nodeConfiguredForParams(async: @escaping (@escaping () -> Void) -> Void, params: ListViewItemLayoutParams, synchronousLoads: Bool, previousItem: ListViewItem?, nextItem: ListViewItem?, completion: @escaping (ListViewItemNode, @escaping () -> (Signal?, (ListViewItemApply) -> Void)) -> Void) { @@ -48,7 +50,7 @@ final class ChatMediaInputStickerPackItem: ListViewItem { Queue.mainQueue().async { completion(node, { return (nil, { _ in - node.updateStickerPackItem(account: self.account, info: self.collectionInfo, item: self.stickerPackItem, collectionId: self.collectionId, theme: self.theme, expanded: self.expanded) + node.updateStickerPackItem(account: self.account, info: self.collectionInfo, item: self.stickerPackItem, collectionId: self.collectionId, theme: self.theme, expanded: self.expanded, reorderable: self.reorderable) node.updateAppearanceTransition(transition: .immediate) }) }) @@ -59,7 +61,7 @@ final class ChatMediaInputStickerPackItem: ListViewItem { public func updateNode(async: @escaping (@escaping () -> Void) -> Void, node: @escaping () -> ListViewItemNode, params: ListViewItemLayoutParams, previousItem: ListViewItem?, nextItem: ListViewItem?, animation: ListViewItemUpdateAnimation, completion: @escaping (ListViewItemNodeLayout, @escaping (ListViewItemApply) -> Void) -> Void) { Queue.mainQueue().async { completion(ListViewItemNodeLayout(contentSize: self.expanded ? expandedBoundingSize : boundingSize, insets: ChatMediaInputNode.setupPanelIconInsets(item: self, previousItem: previousItem, nextItem: nextItem)), { _ in - (node() as? ChatMediaInputStickerPackItemNode)?.updateStickerPackItem(account: self.account, info: self.collectionInfo, item: self.stickerPackItem, collectionId: self.collectionId, theme: self.theme, expanded: self.expanded) + (node() as? ChatMediaInputStickerPackItemNode)?.updateStickerPackItem(account: self.account, info: self.collectionInfo, item: self.stickerPackItem, collectionId: self.collectionId, theme: self.theme, expanded: self.expanded, reorderable: self.reorderable) }) } } @@ -91,6 +93,7 @@ final class ChatMediaInputStickerPackItemNode: ListViewItemNode { private var currentThumbnailItem: StickerPackThumbnailItem? private var currentExpanded = false private var theme: PresentationTheme? + private var reorderable = false private let stickerFetchedDisposable = MetaDisposable() @@ -171,9 +174,10 @@ final class ChatMediaInputStickerPackItemNode: ListViewItemNode { } } - func updateStickerPackItem(account: Account, info: StickerPackCollectionInfo, item: StickerPackItem?, collectionId: ItemCollectionId, theme: PresentationTheme, expanded: Bool) { + func updateStickerPackItem(account: Account, info: StickerPackCollectionInfo, item: StickerPackItem?, collectionId: ItemCollectionId, theme: PresentationTheme, expanded: Bool, reorderable: Bool) { self.currentCollectionId = collectionId self.account = account + self.reorderable = reorderable var themeUpdated = false if self.theme !== theme { self.theme = theme @@ -319,6 +323,9 @@ final class ChatMediaInputStickerPackItemNode: ListViewItemNode { } override func isReorderable(at point: CGPoint) -> Bool { + guard self.reorderable else { + return false + } if self.bounds.inset(by: UIEdgeInsets(top: 0.0, left: 0.0, bottom: 0.0, right: -28.0)).contains(point) { return true } diff --git a/submodules/TelegramUI/Sources/ChatMessageBubbleItemNode.swift b/submodules/TelegramUI/Sources/ChatMessageBubbleItemNode.swift index ff1afcb8a4..84e05988ae 100644 --- a/submodules/TelegramUI/Sources/ChatMessageBubbleItemNode.swift +++ b/submodules/TelegramUI/Sources/ChatMessageBubbleItemNode.swift @@ -1167,7 +1167,7 @@ class ChatMessageBubbleItemNode: ChatMessageItemView, ChatMessagePreviewItemNode ignoreForward = true effectiveAuthor = forwardInfo.author if effectiveAuthor == nil, let authorSignature = forwardInfo.authorSignature { - effectiveAuthor = TelegramUser(id: PeerId(namespace: Namespaces.Peer.Empty, id: PeerId.Id._internalFromInt32Value(Int32(clamping: authorSignature.persistentHashValue))), accessHash: nil, firstName: authorSignature, lastName: nil, username: nil, phone: nil, photo: [], botInfo: nil, restrictionInfo: nil, flags: UserInfoFlags()) + effectiveAuthor = TelegramUser(id: PeerId(namespace: Namespaces.Peer.Empty, id: PeerId.Id._internalFromInt64Value(Int64(authorSignature.persistentHashValue))), accessHash: nil, firstName: authorSignature, lastName: nil, username: nil, phone: nil, photo: [], botInfo: nil, restrictionInfo: nil, flags: UserInfoFlags()) } } displayAuthorInfo = !mergedTop.merged && incoming && effectiveAuthor != nil @@ -1183,7 +1183,7 @@ class ChatMessageBubbleItemNode: ChatMessageItemView, ChatMessagePreviewItemNode displayAuthorInfo = !mergedTop.merged && incoming } else if let forwardInfo = item.content.firstMessage.forwardInfo, forwardInfo.flags.contains(.isImported), let authorSignature = forwardInfo.authorSignature { ignoreForward = true - effectiveAuthor = TelegramUser(id: PeerId(namespace: Namespaces.Peer.Empty, id: PeerId.Id._internalFromInt32Value(Int32(clamping: authorSignature.persistentHashValue))), accessHash: nil, firstName: authorSignature, lastName: nil, username: nil, phone: nil, photo: [], botInfo: nil, restrictionInfo: nil, flags: UserInfoFlags()) + effectiveAuthor = TelegramUser(id: PeerId(namespace: Namespaces.Peer.Empty, id: PeerId.Id._internalFromInt64Value(Int64(authorSignature.persistentHashValue))), accessHash: nil, firstName: authorSignature, lastName: nil, username: nil, phone: nil, photo: [], botInfo: nil, restrictionInfo: nil, flags: UserInfoFlags()) displayAuthorInfo = !mergedTop.merged && incoming } else if let _ = item.content.firstMessage.adAttribute, let author = item.content.firstMessage.author { ignoreForward = true @@ -1572,12 +1572,12 @@ class ChatMessageBubbleItemNode: ChatMessageItemView, ChatMessagePreviewItemNode if initialDisplayHeader && displayAuthorInfo { if let peer = firstMessage.peers[firstMessage.id.peerId] as? TelegramChannel, case .broadcast = peer.info, item.content.firstMessage.adAttribute == nil { authorNameString = peer.displayTitle(strings: item.presentationData.strings, displayOrder: item.presentationData.nameDisplayOrder) - authorNameColor = chatMessagePeerIdColors[Int(peer.id.id._internalGetInt32Value() % 7)] + authorNameColor = chatMessagePeerIdColors[Int(clamping: peer.id.id._internalGetInt64Value() % 7)] } else if let effectiveAuthor = effectiveAuthor { authorNameString = effectiveAuthor.displayTitle(strings: item.presentationData.strings, displayOrder: item.presentationData.nameDisplayOrder) if incoming { - authorNameColor = chatMessagePeerIdColors[Int(effectiveAuthor.id.id._internalGetInt32Value() % 7)] + authorNameColor = chatMessagePeerIdColors[Int(clamping: effectiveAuthor.id.id._internalGetInt64Value() % 7)] } else { authorNameColor = item.presentationData.theme.theme.chat.message.outgoing.accentTextColor } diff --git a/submodules/TelegramUI/Sources/ChatMessageItem.swift b/submodules/TelegramUI/Sources/ChatMessageItem.swift index d4db0237a4..02c67b230a 100644 --- a/submodules/TelegramUI/Sources/ChatMessageItem.swift +++ b/submodules/TelegramUI/Sources/ChatMessageItem.swift @@ -305,7 +305,7 @@ public final class ChatMessageItem: ListViewItem, CustomStringConvertible { if let forwardInfo = content.firstMessage.forwardInfo { effectiveAuthor = forwardInfo.author if effectiveAuthor == nil, let authorSignature = forwardInfo.authorSignature { - effectiveAuthor = TelegramUser(id: PeerId(namespace: Namespaces.Peer.Empty, id: PeerId.Id._internalFromInt32Value(Int32(clamping: authorSignature.persistentHashValue))), accessHash: nil, firstName: authorSignature, lastName: nil, username: nil, phone: nil, photo: [], botInfo: nil, restrictionInfo: nil, flags: UserInfoFlags()) + effectiveAuthor = TelegramUser(id: PeerId(namespace: Namespaces.Peer.Empty, id: PeerId.Id._internalFromInt64Value(Int64(authorSignature.persistentHashValue))), accessHash: nil, firstName: authorSignature, lastName: nil, username: nil, phone: nil, photo: [], botInfo: nil, restrictionInfo: nil, flags: UserInfoFlags()) } } displayAuthorInfo = incoming && effectiveAuthor != nil diff --git a/submodules/TelegramUI/Sources/ChatMessageItemView.swift b/submodules/TelegramUI/Sources/ChatMessageItemView.swift index 5011479b34..614713e13d 100644 --- a/submodules/TelegramUI/Sources/ChatMessageItemView.swift +++ b/submodules/TelegramUI/Sources/ChatMessageItemView.swift @@ -610,8 +610,8 @@ final class ChatMessageAccessibilityData { replyLabel = item.presentationData.strings.VoiceOver_Chat_ReplyToYourMessage } - let (replyMessageLabel, replyMessageValue) = dataForMessage(replyMessage, true) - replyLabel += "\(replyLabel): \(replyMessageLabel), \(replyMessageValue)" +// let (replyMessageLabel, replyMessageValue) = dataForMessage(replyMessage, true) +// replyLabel += "\(replyLabel): \(replyMessageLabel), \(replyMessageValue)" label = "\(replyLabel) . \(label)" } diff --git a/submodules/TelegramUI/Sources/ChatRecentActionsHistoryTransition.swift b/submodules/TelegramUI/Sources/ChatRecentActionsHistoryTransition.swift index 3b92d64542..7155a6e7cc 100644 --- a/submodules/TelegramUI/Sources/ChatRecentActionsHistoryTransition.swift +++ b/submodules/TelegramUI/Sources/ChatRecentActionsHistoryTransition.swift @@ -281,7 +281,7 @@ struct ChatRecentActionsEntry: Comparable, Identifiable { case .header: var peers = SimpleDictionary() var author: Peer? - if self.entry.event.peerId == PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt32Value(136817688)) { + if self.entry.event.peerId == PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt64Value(136817688)) { author = message?.effectiveAuthor } else if let peer = self.entry.peers[self.entry.event.peerId] { author = peer diff --git a/submodules/TelegramUI/Sources/ChatScheduleTimeController.swift b/submodules/TelegramUI/Sources/ChatScheduleTimeController.swift index 4c0cfeb958..e3dd91b81b 100644 --- a/submodules/TelegramUI/Sources/ChatScheduleTimeController.swift +++ b/submodules/TelegramUI/Sources/ChatScheduleTimeController.swift @@ -6,6 +6,7 @@ import Postbox import TelegramCore import SwiftSignalKit import AccountContext +import TelegramPresentationData enum ChatScheduleTimeControllerMode { case scheduledMessages(sendWhenOnlineAvailable: Bool) @@ -33,9 +34,10 @@ final class ChatScheduleTimeController: ViewController { private let dismissByTapOutside: Bool private let completion: (Int32) -> Void + private var presentationData: PresentationData private var presentationDataDisposable: Disposable? - init(context: AccountContext, peerId: PeerId, mode: ChatScheduleTimeControllerMode, style: ChatScheduleTimeControllerStyle, currentTime: Int32? = nil, minimalTime: Int32? = nil, dismissByTapOutside: Bool = true, completion: @escaping (Int32) -> Void) { + init(context: AccountContext, updatedPresentationData: (initial: PresentationData, signal: Signal)? = nil, peerId: PeerId, mode: ChatScheduleTimeControllerMode, style: ChatScheduleTimeControllerStyle, currentTime: Int32? = nil, minimalTime: Int32? = nil, dismissByTapOutside: Bool = true, completion: @escaping (Int32) -> Void) { self.context = context self.peerId = peerId self.mode = mode @@ -45,15 +47,18 @@ final class ChatScheduleTimeController: ViewController { self.dismissByTapOutside = dismissByTapOutside self.completion = completion + self.presentationData = updatedPresentationData?.initial ?? context.sharedContext.currentPresentationData.with { $0 } + super.init(navigationBarPresentationData: nil) self.statusBar.statusBarStyle = .Ignore self.blocksBackgroundWhenInOverlay = true - self.presentationDataDisposable = (context.sharedContext.presentationData + self.presentationDataDisposable = ((updatedPresentationData?.signal ?? context.sharedContext.presentationData) |> deliverOnMainQueue).start(next: { [weak self] presentationData in if let strongSelf = self { + strongSelf.presentationData = presentationData strongSelf.controllerNode.updatePresentationData(presentationData) } }) @@ -70,7 +75,7 @@ final class ChatScheduleTimeController: ViewController { } override public func loadDisplayNode() { - self.displayNode = ChatScheduleTimeControllerNode(context: self.context, mode: self.mode, style: self.style, currentTime: self.currentTime, minimalTime: self.minimalTime, dismissByTapOutside: self.dismissByTapOutside) + self.displayNode = ChatScheduleTimeControllerNode(context: self.context, presentationData: self.presentationData, mode: self.mode, style: self.style, currentTime: self.currentTime, minimalTime: self.minimalTime, dismissByTapOutside: self.dismissByTapOutside) self.controllerNode.completion = { [weak self] time in guard let strongSelf = self else { return diff --git a/submodules/TelegramUI/Sources/ChatScheduleTimeControllerNode.swift b/submodules/TelegramUI/Sources/ChatScheduleTimeControllerNode.swift index a3a70637cf..36e4ef5fe1 100644 --- a/submodules/TelegramUI/Sources/ChatScheduleTimeControllerNode.swift +++ b/submodules/TelegramUI/Sources/ChatScheduleTimeControllerNode.swift @@ -39,11 +39,11 @@ class ChatScheduleTimeControllerNode: ViewControllerTracingNode, UIScrollViewDel var dismiss: (() -> Void)? var cancel: (() -> Void)? - init(context: AccountContext, mode: ChatScheduleTimeControllerMode, style: ChatScheduleTimeControllerStyle, currentTime: Int32?, minimalTime: Int32?, dismissByTapOutside: Bool) { + init(context: AccountContext, presentationData: PresentationData, mode: ChatScheduleTimeControllerMode, style: ChatScheduleTimeControllerStyle, currentTime: Int32?, minimalTime: Int32?, dismissByTapOutside: Bool) { self.context = context self.mode = mode self.controllerStyle = style - self.presentationData = context.sharedContext.currentPresentationData.with { $0 } + self.presentationData = presentationData self.dismissByTapOutside = dismissByTapOutside self.minimalTime = minimalTime diff --git a/submodules/TelegramUI/Sources/ChatSendMessageActionSheetController.swift b/submodules/TelegramUI/Sources/ChatSendMessageActionSheetController.swift index a90f364189..6c18bb09a9 100644 --- a/submodules/TelegramUI/Sources/ChatSendMessageActionSheetController.swift +++ b/submodules/TelegramUI/Sources/ChatSendMessageActionSheetController.swift @@ -22,6 +22,7 @@ final class ChatSendMessageActionSheetController: ViewController { private let sendMessage: (Bool) -> Void private let schedule: () -> Void + private var presentationData: PresentationData private var presentationDataDisposable: Disposable? private var didPlayPresentationAnimation = false @@ -30,7 +31,7 @@ final class ChatSendMessageActionSheetController: ViewController { private let hapticFeedback = HapticFeedback() - init(context: AccountContext, interfaceState: ChatPresentationInterfaceState, gesture: ContextGesture, sourceSendButton: ASDisplayNode, textInputNode: EditableTextNode, completion: @escaping () -> Void, sendMessage: @escaping (Bool) -> Void, schedule: @escaping () -> Void) { + init(context: AccountContext, updatedPresentationData: (initial: PresentationData, signal: Signal)? = nil, interfaceState: ChatPresentationInterfaceState, gesture: ContextGesture, sourceSendButton: ASDisplayNode, textInputNode: EditableTextNode, completion: @escaping () -> Void, sendMessage: @escaping (Bool) -> Void, schedule: @escaping () -> Void) { self.context = context self.interfaceState = interfaceState self.gesture = gesture @@ -40,13 +41,16 @@ final class ChatSendMessageActionSheetController: ViewController { self.sendMessage = sendMessage self.schedule = schedule + self.presentationData = updatedPresentationData?.initial ?? context.sharedContext.currentPresentationData.with { $0 } + super.init(navigationBarPresentationData: nil) self.blocksBackgroundWhenInOverlay = true - self.presentationDataDisposable = (context.sharedContext.presentationData + self.presentationDataDisposable = ((updatedPresentationData?.signal ?? context.sharedContext.presentationData) |> deliverOnMainQueue).start(next: { [weak self] presentationData in if let strongSelf = self { + strongSelf.presentationData = presentationData strongSelf.controllerNode.updatePresentationData(presentationData) } }) @@ -78,7 +82,7 @@ final class ChatSendMessageActionSheetController: ViewController { canSchedule = !isSecret } - self.displayNode = ChatSendMessageActionSheetControllerNode(context: self.context, reminders: reminders, gesture: gesture, sourceSendButton: self.sourceSendButton, textInputNode: self.textInputNode, forwardedCount: forwardedCount, send: { [weak self] in + self.displayNode = ChatSendMessageActionSheetControllerNode(context: self.context, presentationData: self.presentationData, reminders: reminders, gesture: gesture, sourceSendButton: self.sourceSendButton, textInputNode: self.textInputNode, forwardedCount: forwardedCount, send: { [weak self] in self?.sendMessage(false) self?.dismiss(cancel: false) }, sendSilently: { [weak self] in diff --git a/submodules/TelegramUI/Sources/ChatSendMessageActionSheetControllerNode.swift b/submodules/TelegramUI/Sources/ChatSendMessageActionSheetControllerNode.swift index 784ef26bc8..010be7821f 100644 --- a/submodules/TelegramUI/Sources/ChatSendMessageActionSheetControllerNode.swift +++ b/submodules/TelegramUI/Sources/ChatSendMessageActionSheetControllerNode.swift @@ -181,9 +181,9 @@ final class ChatSendMessageActionSheetControllerNode: ViewControllerTracingNode, return self.sourceSendButton.view.convert(self.sourceSendButton.bounds, to: nil) } - init(context: AccountContext, reminders: Bool, gesture: ContextGesture, sourceSendButton: ASDisplayNode, textInputNode: EditableTextNode, forwardedCount: Int?, send: (() -> Void)?, sendSilently: (() -> Void)?, schedule: (() -> Void)?, cancel: (() -> Void)?) { + init(context: AccountContext, presentationData: PresentationData, reminders: Bool, gesture: ContextGesture, sourceSendButton: ASDisplayNode, textInputNode: EditableTextNode, forwardedCount: Int?, send: (() -> Void)?, sendSilently: (() -> Void)?, schedule: (() -> Void)?, cancel: (() -> Void)?) { self.context = context - self.presentationData = context.sharedContext.currentPresentationData.with { $0 } + self.presentationData = presentationData self.sourceSendButton = sourceSendButton self.textFieldFrame = textInputNode.convert(textInputNode.bounds, to: nil) self.textInputNode = textInputNode diff --git a/submodules/TelegramUI/Sources/ChatThemeScreen.swift b/submodules/TelegramUI/Sources/ChatThemeScreen.swift index 8729b5fd1b..ba1a617c2c 100644 --- a/submodules/TelegramUI/Sources/ChatThemeScreen.swift +++ b/submodules/TelegramUI/Sources/ChatThemeScreen.swift @@ -628,12 +628,12 @@ private class ChatThemeScreenNode: ViewControllerTracingNode, UIScrollViewDelega self.backgroundNode.addSubnode(self.contentBackgroundNode) self.contentContainerNode.addSubnode(self.titleNode) self.contentContainerNode.addSubnode(self.textNode) - self.contentContainerNode.addSubnode(self.cancelButton) self.contentContainerNode.addSubnode(self.doneButton) self.topContentContainerNode.addSubnode(self.animationNode) self.topContentContainerNode.addSubnode(self.switchThemeButton) self.topContentContainerNode.addSubnode(self.listNode) + self.topContentContainerNode.addSubnode(self.cancelButton) self.switchThemeButton.addTarget(self, action: #selector(self.switchThemePressed), forControlEvents: .touchUpInside) self.cancelButton.addTarget(self, action: #selector(self.cancelButtonPressed), forControlEvents: .touchUpInside) @@ -814,6 +814,15 @@ private class ChatThemeScreenNode: ViewControllerTracingNode, UIScrollViewDelega }) } + if animateBackground, let snapshotView = self.cancelButton.view.snapshotView(afterScreenUpdates: false) { + snapshotView.frame = self.cancelButton.frame + self.cancelButton.view.superview?.insertSubview(snapshotView, aboveSubview: self.cancelButton.view) + + snapshotView.layer.animateAlpha(from: 1.0, to: 0.0, duration: 0.3, delay: delay, removeOnCompletion: false, completion: { [weak snapshotView] _ in + snapshotView?.removeFromSuperview() + }) + } + self.listNode.forEachVisibleItemNode { node in if let node = node as? ThemeSettingsThemeItemIconNode { node.crossfade() diff --git a/submodules/TelegramUI/Sources/ChatTimerScreen.swift b/submodules/TelegramUI/Sources/ChatTimerScreen.swift index b161cb846e..8879721270 100644 --- a/submodules/TelegramUI/Sources/ChatTimerScreen.swift +++ b/submodules/TelegramUI/Sources/ChatTimerScreen.swift @@ -29,9 +29,10 @@ final class ChatTimerScreen: ViewController { private let dismissByTapOutside: Bool private let completion: (Int32) -> Void + private var presentationData: PresentationData private var presentationDataDisposable: Disposable? - init(context: AccountContext, peerId: PeerId, style: ChatTimerScreenStyle, currentTime: Int32? = nil, dismissByTapOutside: Bool = true, completion: @escaping (Int32) -> Void) { + init(context: AccountContext, updatedPresentationData: (initial: PresentationData, signal: Signal)? = nil, peerId: PeerId, style: ChatTimerScreenStyle, currentTime: Int32? = nil, dismissByTapOutside: Bool = true, completion: @escaping (Int32) -> Void) { self.context = context self.peerId = peerId self.style = style @@ -39,15 +40,18 @@ final class ChatTimerScreen: ViewController { self.dismissByTapOutside = dismissByTapOutside self.completion = completion + self.presentationData = updatedPresentationData?.initial ?? context.sharedContext.currentPresentationData.with { $0 } + super.init(navigationBarPresentationData: nil) self.statusBar.statusBarStyle = .Ignore self.blocksBackgroundWhenInOverlay = true - self.presentationDataDisposable = (context.sharedContext.presentationData + self.presentationDataDisposable = ((updatedPresentationData?.signal ?? context.sharedContext.presentationData) |> deliverOnMainQueue).start(next: { [weak self] presentationData in if let strongSelf = self { + strongSelf.presentationData = presentationData strongSelf.controllerNode.updatePresentationData(presentationData) } }) @@ -64,7 +68,7 @@ final class ChatTimerScreen: ViewController { } override public func loadDisplayNode() { - self.displayNode = ChatTimerScreenNode(context: self.context, style: self.style, currentTime: self.currentTime, dismissByTapOutside: self.dismissByTapOutside) + self.displayNode = ChatTimerScreenNode(context: self.context, presentationData: presentationData, style: self.style, currentTime: self.currentTime, dismissByTapOutside: self.dismissByTapOutside) self.controllerNode.completion = { [weak self] time in guard let strongSelf = self else { return @@ -229,10 +233,10 @@ class ChatTimerScreenNode: ViewControllerTracingNode, UIScrollViewDelegate, UIPi var dismiss: (() -> Void)? var cancel: (() -> Void)? - init(context: AccountContext, style: ChatTimerScreenStyle, currentTime: Int32?, dismissByTapOutside: Bool) { + init(context: AccountContext, presentationData: PresentationData, style: ChatTimerScreenStyle, currentTime: Int32?, dismissByTapOutside: Bool) { self.context = context self.controllerStyle = style - self.presentationData = context.sharedContext.currentPresentationData.with { $0 } + self.presentationData = presentationData self.dismissByTapOutside = dismissByTapOutside self.wrappingScrollNode = ASScrollNode() diff --git a/submodules/TelegramUI/Sources/CreateChannelController.swift b/submodules/TelegramUI/Sources/CreateChannelController.swift index 78f87fadb4..9e907e7507 100644 --- a/submodules/TelegramUI/Sources/CreateChannelController.swift +++ b/submodules/TelegramUI/Sources/CreateChannelController.swift @@ -196,7 +196,7 @@ private func CreateChannelEntries(presentationData: PresentationData, state: Cre let groupInfoState = ItemListAvatarAndNameInfoItemState(editingName: state.editingName, updatingName: nil) - let peer = TelegramGroup(id: PeerId(namespace: .max, id: PeerId.Id._internalFromInt32Value(0)), title: state.editingName.composedTitle, photo: [], participantCount: 0, role: .creator(rank: nil), membership: .Member, flags: [], defaultBannedRights: nil, migrationReference: nil, creationDate: 0, version: 0) + let peer = TelegramGroup(id: PeerId(namespace: .max, id: PeerId.Id._internalFromInt64Value(0)), title: state.editingName.composedTitle, photo: [], participantCount: 0, role: .creator(rank: nil), membership: .Member, flags: [], defaultBannedRights: nil, migrationReference: nil, creationDate: 0, version: 0) entries.append(.channelInfo(presentationData.theme, presentationData.strings, presentationData.dateTimeFormat, peer, groupInfoState, state.avatar)) diff --git a/submodules/TelegramUI/Sources/CreateGroupController.swift b/submodules/TelegramUI/Sources/CreateGroupController.swift index b3f79558bd..0df811dd31 100644 --- a/submodules/TelegramUI/Sources/CreateGroupController.swift +++ b/submodules/TelegramUI/Sources/CreateGroupController.swift @@ -297,7 +297,7 @@ private func createGroupEntries(presentationData: PresentationData, state: Creat let groupInfoState = ItemListAvatarAndNameInfoItemState(editingName: state.editingName, updatingName: nil) - let peer = TelegramGroup(id: PeerId(namespace: .max, id: PeerId.Id._internalFromInt32Value(0)), title: state.editingName.composedTitle, photo: [], participantCount: 0, role: .creator(rank: nil), membership: .Member, flags: [], defaultBannedRights: nil, migrationReference: nil, creationDate: 0, version: 0) + let peer = TelegramGroup(id: PeerId(namespace: .max, id: PeerId.Id._internalFromInt64Value(0)), title: state.editingName.composedTitle, photo: [], participantCount: 0, role: .creator(rank: nil), membership: .Member, flags: [], defaultBannedRights: nil, migrationReference: nil, creationDate: 0, version: 0) entries.append(.groupInfo(presentationData.theme, presentationData.strings, presentationData.dateTimeFormat, peer, groupInfoState, state.avatar)) diff --git a/submodules/TelegramUI/Sources/DeclareEncodables.swift b/submodules/TelegramUI/Sources/DeclareEncodables.swift index 5eaaa38693..444cfa1312 100644 --- a/submodules/TelegramUI/Sources/DeclareEncodables.swift +++ b/submodules/TelegramUI/Sources/DeclareEncodables.swift @@ -28,6 +28,7 @@ private var telegramUIDeclaredEncodables: Void = { declareEncodable(ApplicationSpecificVariantNotice.self, f: { ApplicationSpecificVariantNotice(decoder: $0) }) declareEncodable(ApplicationSpecificCounterNotice.self, f: { ApplicationSpecificCounterNotice(decoder: $0) }) declareEncodable(ApplicationSpecificTimestampNotice.self, f: { ApplicationSpecificTimestampNotice(decoder: $0) }) + declareEncodable(ApplicationSpecificInt64ArrayNotice.self, f: { ApplicationSpecificInt64ArrayNotice(decoder: $0) }) declareEncodable(CallListSettings.self, f: { CallListSettings(decoder: $0) }) declareEncodable(VoiceCallSettings.self, f: { VoiceCallSettings(decoder: $0) }) declareEncodable(ExperimentalSettings.self, f: { ExperimentalSettings(decoder: $0) }) diff --git a/submodules/TelegramUI/Sources/FetchCachedRepresentations.swift b/submodules/TelegramUI/Sources/FetchCachedRepresentations.swift index 111afb89c4..36b87087c2 100644 --- a/submodules/TelegramUI/Sources/FetchCachedRepresentations.swift +++ b/submodules/TelegramUI/Sources/FetchCachedRepresentations.swift @@ -18,6 +18,7 @@ import WallpaperResources import GZip import TelegramUniversalVideoContent import GradientBackground +import Svg public func fetchCachedResourceRepresentation(account: Account, resource: MediaResource, representation: CachedMediaResourceRepresentation) -> Signal { if let representation = representation as? CachedStickerAJpegRepresentation { @@ -122,6 +123,14 @@ public func fetchCachedResourceRepresentation(account: Account, resource: MediaR return fetchMapSnapshotResource(resource: resource) } else if let resource = resource as? YoutubeEmbedStoryboardMediaResource, let _ = representation as? YoutubeEmbedStoryboardMediaResourceRepresentation { return fetchYoutubeEmbedStoryboardResource(resource: resource) + } else if let representation = representation as? CachedPreparedPatternWallpaperRepresentation { + return account.postbox.mediaBox.resourceData(resource, option: .complete(waitUntilFetchStatus: false)) + |> mapToSignal { data -> Signal in + if !data.complete { + return .complete() + } + return fetchPreparedPatternWallpaperRepresentation(resource: resource, resourceData: data, representation: representation) + } } return .never() } @@ -719,3 +728,18 @@ private func fetchAnimatedStickerRepresentation(account: Account, resource: Medi |> runOn(Queue.concurrentDefaultQueue()) } + +private func fetchPreparedPatternWallpaperRepresentation(resource: MediaResource, resourceData: MediaResourceData, representation: CachedPreparedPatternWallpaperRepresentation) -> Signal { + return Signal({ subscriber in + if let data = try? Data(contentsOf: URL(fileURLWithPath: resourceData.path), options: [.mappedIfSafe]) { + if let unpackedData = TGGUnzipData(data, 2 * 1024 * 1024), let data = prepareSvgImage(unpackedData) { + let path = NSTemporaryDirectory() + "\(Int64.random(in: Int64.min ... Int64.max))" + let url = URL(fileURLWithPath: path) + let _ = try? data.write(to: url) + subscriber.putNext(.temporaryPath(path)) + subscriber.putCompletion() + } + } + return EmptyDisposable + }) |> runOn(Queue.concurrentDefaultQueue()) +} diff --git a/submodules/TelegramUI/Sources/OpenChatMessage.swift b/submodules/TelegramUI/Sources/OpenChatMessage.swift index c705e9bbcb..5dbd3605bf 100644 --- a/submodules/TelegramUI/Sources/OpenChatMessage.swift +++ b/submodules/TelegramUI/Sources/OpenChatMessage.swift @@ -73,7 +73,7 @@ func openChatMessageImpl(_ params: OpenChatMessageParams) -> Bool { }, openUrl: params.openUrl, openPeer: { peer in params.openPeer(peer, .info) }, showAll: params.modal) - let controller = LocationViewController(context: params.context, subject: params.message, params: controllerParams) + let controller = LocationViewController(context: params.context, updatedPresentationData: params.updatedPresentationData, subject: params.message, params: controllerParams) controller.navigationPresentation = .modal params.navigationController?.pushViewController(controller) return true diff --git a/submodules/TelegramUI/Sources/OpenUrl.swift b/submodules/TelegramUI/Sources/OpenUrl.swift index 9f3775d5f6..5114643757 100644 --- a/submodules/TelegramUI/Sources/OpenUrl.swift +++ b/submodules/TelegramUI/Sources/OpenUrl.swift @@ -41,7 +41,7 @@ public func parseSecureIdUrl(_ url: URL) -> ParsedSecureIdUrl? { if url.host == "passport" || url.host == "resolve" { if let components = URLComponents(string: "/?" + query) { var domain: String? - var botId: Int32? + var botId: Int64? var scope: String? var publicKey: String? var callbackUrl: String? @@ -53,7 +53,7 @@ public func parseSecureIdUrl(_ url: URL) -> ParsedSecureIdUrl? { if queryItem.name == "domain" { domain = value } else if queryItem.name == "bot_id" { - botId = Int32(value) + botId = Int64(value) } else if queryItem.name == "scope" { scope = value } else if queryItem.name == "public_key" { @@ -95,7 +95,7 @@ public func parseSecureIdUrl(_ url: URL) -> ParsedSecureIdUrl? { return nil } - return ParsedSecureIdUrl(peerId: PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt32Value(botId)), scope: scope, publicKey: publicKey, callbackUrl: callbackUrl, opaquePayload: opaquePayload, opaqueNonce: opaqueNonce) + return ParsedSecureIdUrl(peerId: PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt64Value(botId)), scope: scope, publicKey: publicKey, callbackUrl: callbackUrl, opaquePayload: opaquePayload, opaqueNonce: opaqueNonce) } } } @@ -394,7 +394,7 @@ func openExternalUrlImpl(context: AccountContext, urlContext: OpenURLContext, ur } else if parsedUrl.host == "passport" || parsedUrl.host == "resolve" { if let components = URLComponents(string: "/?" + query) { var domain: String? - var botId: Int32? + var botId: Int64? var scope: String? var publicKey: String? var callbackUrl: String? @@ -406,7 +406,7 @@ func openExternalUrlImpl(context: AccountContext, urlContext: OpenURLContext, ur if queryItem.name == "domain" { domain = value } else if queryItem.name == "bot_id" { - botId = Int32(value) + botId = Int64(value) } else if queryItem.name == "scope" { scope = value } else if queryItem.name == "public_key" { @@ -450,7 +450,7 @@ func openExternalUrlImpl(context: AccountContext, urlContext: OpenURLContext, ur if case .chat = urlContext { return } - let controller = SecureIdAuthController(context: context, mode: .form(peerId: PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt32Value(botId)), scope: scope, publicKey: publicKey, callbackUrl: callbackUrl, opaquePayload: opaquePayload, opaqueNonce: opaqueNonce)) + let controller = SecureIdAuthController(context: context, mode: .form(peerId: PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt64Value(botId)), scope: scope, publicKey: publicKey, callbackUrl: callbackUrl, opaquePayload: opaquePayload, opaqueNonce: opaqueNonce)) if let navigationController = navigationController { context.sharedContext.applicationBindings.dismissNativeController() @@ -475,9 +475,9 @@ func openExternalUrlImpl(context: AccountContext, urlContext: OpenURLContext, ur } } - if let id = id, !id.isEmpty, let idValue = Int32(id), idValue > 0 { + if let id = id, !id.isEmpty, let idValue = Int64(id), idValue > 0 { let _ = (context.account.postbox.transaction { transaction -> Peer? in - return transaction.getPeer(PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt32Value(idValue))) + return transaction.getPeer(PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt64Value(idValue))) } |> deliverOnMainQueue).start(next: { peer in if let peer = peer, let controller = context.sharedContext.makePeerInfoController(context: context, updatedPresentationData: nil, peer: peer, mode: .generic, avatarInitiallyExpanded: false, fromChat: false) { diff --git a/submodules/TelegramUI/Sources/PeerInfo/PeerInfoHeaderNode.swift b/submodules/TelegramUI/Sources/PeerInfo/PeerInfoHeaderNode.swift index f4d788d26a..758a112568 100644 --- a/submodules/TelegramUI/Sources/PeerInfo/PeerInfoHeaderNode.swift +++ b/submodules/TelegramUI/Sources/PeerInfo/PeerInfoHeaderNode.swift @@ -414,7 +414,7 @@ final class PeerInfoAvatarTransformContainerNode: ASDisplayNode { representations = topRepresentations videoRepresentations = videoRepresentationsValue immediateThumbnailData = immediateThumbnail - id = Int64(peer.id.id._internalGetInt32Value()) + id = peer.id.id._internalGetInt64Value() if let resource = videoRepresentations.first?.representation.resource as? CloudPhotoSizeMediaResource { id = id &+ resource.photoId } @@ -425,7 +425,7 @@ final class PeerInfoAvatarTransformContainerNode: ASDisplayNode { if case let .cloud(imageId, _, _) = reference { id = imageId } else { - id = Int64(peer.id.id._internalGetInt32Value()) + id = peer.id.id._internalGetInt64Value() } } @@ -709,7 +709,7 @@ final class PeerInfoEditingAvatarNode: ASDisplayNode { representations = topRepresentations videoRepresentations = videoRepresentationsValue immediateThumbnailData = immediateThumbnail - id = Int64(peer.id.id._internalGetInt32Value()) + id = peer.id.id._internalGetInt64Value() if let resource = videoRepresentations.first?.representation.resource as? CloudPhotoSizeMediaResource { id = id &+ resource.photoId } @@ -720,7 +720,7 @@ final class PeerInfoEditingAvatarNode: ASDisplayNode { if case let .cloud(imageId, _, _) = reference { id = imageId } else { - id = Int64(peer.id.id._internalGetInt32Value()) + id = peer.id.id._internalGetInt64Value() } } diff --git a/submodules/TelegramUI/Sources/PeerInfo/PeerInfoScreen.swift b/submodules/TelegramUI/Sources/PeerInfo/PeerInfoScreen.swift index 59d23b6996..a155558446 100644 --- a/submodules/TelegramUI/Sources/PeerInfo/PeerInfoScreen.swift +++ b/submodules/TelegramUI/Sources/PeerInfo/PeerInfoScreen.swift @@ -3495,7 +3495,7 @@ private final class PeerInfoScreenNode: ViewControllerTracingNode, UIScrollViewD canChangeColors = false } - if false, canChangeColors { + if canChangeColors { items.append(.action(ContextMenuActionItem(text: presentationData.strings.UserInfo_ChangeColors, icon: { theme in generateTintedImage(image: UIImage(bundleImageName: "Chat/Context Menu/ApplyTheme"), color: theme.contextMenu.primaryColor) }, action: { [weak self] _, f in @@ -3585,7 +3585,7 @@ private final class PeerInfoScreenNode: ViewControllerTracingNode, UIScrollViewD if let strongSelf = self, let peer = strongSelf.data?.peer as? TelegramUser, let phone = peer.phone { let contact = TelegramMediaContact(firstName: peer.firstName ?? "", lastName: peer.lastName ?? "", phoneNumber: phone, peerId: peer.id, vCardData: nil) - let shareController = ShareController(context: strongSelf.context, subject: .media(.standalone(media: contact))) + let shareController = ShareController(context: strongSelf.context, subject: .media(.standalone(media: contact)), updatedPresentationData: strongSelf.controller?.updatedPresentationData) shareController.completed = { [weak self] peerIds in if let strongSelf = self { let _ = (strongSelf.context.account.postbox.transaction { transaction -> [Peer] in @@ -3916,7 +3916,7 @@ private final class PeerInfoScreenNode: ViewControllerTracingNode, UIScrollViewD } private func openUsername(value: String) { - let shareController = ShareController(context: self.context, subject: .url("https://t.me/\(value)")) + let shareController = ShareController(context: self.context, subject: .url("https://t.me/\(value)"), updatedPresentationData: self.controller?.updatedPresentationData) shareController.completed = { [weak self] peerIds in if let strongSelf = self { let _ = (strongSelf.context.account.postbox.transaction { transaction -> [Peer] in @@ -4588,7 +4588,7 @@ private final class PeerInfoScreenNode: ViewControllerTracingNode, UIScrollViewD return } if let peer = peer as? TelegramUser, let username = peer.username { - let shareController = ShareController(context: strongSelf.context, subject: .url("https://t.me/\(username)")) + let shareController = ShareController(context: strongSelf.context, subject: .url("https://t.me/\(username)"), updatedPresentationData: strongSelf.controller?.updatedPresentationData) shareController.completed = { [weak self] peerIds in if let strongSelf = self { let _ = (strongSelf.context.account.postbox.transaction { transaction -> [Peer] in @@ -4776,7 +4776,7 @@ private final class PeerInfoScreenNode: ViewControllerTracingNode, UIScrollViewD let message = Message(stableId: 0, stableVersion: 0, id: MessageId(peerId: peer.id, namespace: 0, id: 0), globallyUniqueId: nil, groupingKey: nil, groupInfo: nil, threadId: nil, timestamp: 0, flags: [], tags: [], globalTags: [], localTags: [], forwardInfo: nil, author: peer, text: "", attributes: [], media: [map], peers: SimpleDictionary(), associatedMessages: SimpleDictionary(), associatedMessageIds: []) - let controller = LocationViewController(context: context, subject: message, params: controllerParams) + let controller = LocationViewController(context: context, updatedPresentationData: self.controller?.updatedPresentationData, subject: message, params: controllerParams) self.controller?.push(controller) } @@ -4785,7 +4785,7 @@ private final class PeerInfoScreenNode: ViewControllerTracingNode, UIScrollViewD return } - let controller = LocationPickerController(context: self.context, mode: .pick, completion: { [weak self] location, address in + let controller = LocationPickerController(context: self.context, updatedPresentationData: self.controller?.updatedPresentationData, mode: .pick, completion: { [weak self] location, address in guard let strongSelf = self else { return } @@ -6125,7 +6125,7 @@ private final class PeerInfoScreenNode: ViewControllerTracingNode, UIScrollViewD let shareController = ShareController(context: strongSelf.context, subject: .messages(messages.sorted(by: { lhs, rhs in return lhs.index < rhs.index - })), externalShare: true, immediateExternalShare: true) + })), externalShare: true, immediateExternalShare: true, updatedPresentationData: strongSelf.controller?.updatedPresentationData) strongSelf.view.endEditing(true) strongSelf.controller?.present(shareController, in: .window(.root)) } @@ -6491,6 +6491,7 @@ private final class PeerInfoScreenNode: ViewControllerTracingNode, UIScrollViewD public final class PeerInfoScreenImpl: ViewController, PeerInfoScreen { private let context: AccountContext + fileprivate let updatedPresentationData: (initial: PresentationData, signal: Signal)? private let peerId: PeerId private let avatarInitiallyExpanded: Bool private let isOpenedFromChat: Bool @@ -6523,6 +6524,7 @@ public final class PeerInfoScreenImpl: ViewController, PeerInfoScreen { public init(context: AccountContext, updatedPresentationData: (initial: PresentationData, signal: Signal)?, peerId: PeerId, avatarInitiallyExpanded: Bool, isOpenedFromChat: Bool, nearbyPeerDistance: Int32?, callMessages: [Message], isSettings: Bool = false, ignoreGroupInCommon: PeerId? = nil) { self.context = context + self.updatedPresentationData = updatedPresentationData self.peerId = peerId self.avatarInitiallyExpanded = avatarInitiallyExpanded self.isOpenedFromChat = isOpenedFromChat diff --git a/submodules/TelegramUI/Sources/PollResultsController.swift b/submodules/TelegramUI/Sources/PollResultsController.swift index e669d85ee7..a6e213ab76 100644 --- a/submodules/TelegramUI/Sources/PollResultsController.swift +++ b/submodules/TelegramUI/Sources/PollResultsController.swift @@ -251,7 +251,7 @@ private func pollResultsControllerEntries(presentationData: PresentationData, po displayCount = Int(voterCount) } for peerIndex in 0 ..< displayCount { - let fakeUser = TelegramUser(id: PeerId(namespace: .max, id: PeerId.Id._internalFromInt32Value(0)), accessHash: nil, firstName: "", lastName: "", username: nil, phone: nil, photo: [], botInfo: nil, restrictionInfo: nil, flags: []) + let fakeUser = TelegramUser(id: PeerId(namespace: .max, id: PeerId.Id._internalFromInt64Value(0)), accessHash: nil, firstName: "", lastName: "", username: nil, phone: nil, photo: [], botInfo: nil, restrictionInfo: nil, flags: []) let peer = RenderedPeer(peer: fakeUser) entries.append(.optionPeer(optionId: i, index: peerIndex, peer: peer, optionText: optionTextHeader, optionAdditionalText: optionAdditionalTextHeader, optionCount: voterCount, optionExpanded: false, opaqueIdentifier: option.opaqueIdentifier, shimmeringAlternation: peerIndex % 2, isFirstInOption: peerIndex == 0)) } diff --git a/submodules/TelegramUI/Sources/SharedAccountContext.swift b/submodules/TelegramUI/Sources/SharedAccountContext.swift index a58ea0267c..46928694bf 100644 --- a/submodules/TelegramUI/Sources/SharedAccountContext.swift +++ b/submodules/TelegramUI/Sources/SharedAccountContext.swift @@ -563,7 +563,8 @@ public final class SharedAccountContextImpl: SharedAccountContext { } if self.activeAccountsValue!.primary == nil && self.activeAccountsValue!.currentAuth == nil { - self.beginNewAuth(testingEnvironment: false) + //TODO:change to production after merging + self.beginNewAuth(testingEnvironment: true) } })) }) diff --git a/submodules/TelegramUI/Sources/SharedNotificationManager.swift b/submodules/TelegramUI/Sources/SharedNotificationManager.swift index a6c89c34d7..51118a6d08 100644 --- a/submodules/TelegramUI/Sources/SharedNotificationManager.swift +++ b/submodules/TelegramUI/Sources/SharedNotificationManager.swift @@ -249,13 +249,13 @@ public final class SharedNotificationManager { var peerId: PeerId? if let fromId = payload["from_id"] { let fromIdValue = fromId as! NSString - peerId = PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt32Value(Int32(fromIdValue.intValue))) + peerId = PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt64Value(Int64(fromIdValue as String) ?? 0)) } else if let fromId = payload["chat_id"] { let fromIdValue = fromId as! NSString - peerId = PeerId(namespace: Namespaces.Peer.CloudGroup, id: PeerId.Id._internalFromInt32Value(Int32(fromIdValue.intValue))) + peerId = PeerId(namespace: Namespaces.Peer.CloudGroup, id: PeerId.Id._internalFromInt64Value(Int64(fromIdValue as String) ?? 0)) } else if let fromId = payload["channel_id"] { let fromIdValue = fromId as! NSString - peerId = PeerId(namespace: Namespaces.Peer.CloudChannel, id: PeerId.Id._internalFromInt32Value(Int32(fromIdValue.intValue))) + peerId = PeerId(namespace: Namespaces.Peer.CloudChannel, id: PeerId.Id._internalFromInt64Value(Int64(fromIdValue as String) ?? 0)) } if let peerId = peerId { if let messageIds = payload["messages"] as? String { @@ -313,13 +313,13 @@ public final class SharedNotificationManager { if let fromId = payload["from_id"] { let fromIdValue = fromId as! NSString - peerId = PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt32Value(Int32(fromIdValue.intValue))) + peerId = PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt64Value(Int64(fromIdValue as String) ?? 0)) } else if let fromId = payload["chat_id"] { let fromIdValue = fromId as! NSString - peerId = PeerId(namespace: Namespaces.Peer.CloudGroup, id: PeerId.Id._internalFromInt32Value(Int32(fromIdValue.intValue))) + peerId = PeerId(namespace: Namespaces.Peer.CloudGroup, id: PeerId.Id._internalFromInt64Value(Int64(fromIdValue as String) ?? 0)) } else if let fromId = payload["channel_id"] { let fromIdValue = fromId as! NSString - peerId = PeerId(namespace: Namespaces.Peer.CloudChannel, id: PeerId.Id._internalFromInt32Value(Int32(fromIdValue.intValue))) + peerId = PeerId(namespace: Namespaces.Peer.CloudChannel, id: PeerId.Id._internalFromInt64Value(Int64(fromIdValue as String) ?? 0)) } if let msgId = payload["msg_id"] { @@ -330,8 +330,8 @@ public final class SharedNotificationManager { } else if let randomId = payload["random_id"] { let randomIdValue = randomId as! NSString var peerId: PeerId? - if let encryptionIdString = payload["encryption_id"] as? String, let encryptionId = Int32(encryptionIdString) { - peerId = PeerId(namespace: Namespaces.Peer.SecretChat, id: PeerId.Id._internalFromInt32Value(encryptionId)) + if let encryptionIdString = payload["encryption_id"] as? String, let encryptionId = Int64(encryptionIdString) { + peerId = PeerId(namespace: Namespaces.Peer.SecretChat, id: PeerId.Id._internalFromInt64Value(encryptionId)) } notificationRequestId = .globallyUniqueId(randomIdValue.longLongValue, peerId) } else { @@ -343,13 +343,13 @@ public final class SharedNotificationManager { if let fromId = payload["from_id"] { let fromIdValue = fromId as! NSString - peerId = PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt32Value(Int32(fromIdValue.intValue))) + peerId = PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt64Value(Int64(fromIdValue as String) ?? 0)) } else if let fromId = payload["chat_id"] { let fromIdValue = fromId as! NSString - peerId = PeerId(namespace: Namespaces.Peer.CloudGroup, id: PeerId.Id._internalFromInt32Value(Int32(fromIdValue.intValue))) + peerId = PeerId(namespace: Namespaces.Peer.CloudGroup, id: PeerId.Id._internalFromInt64Value(Int64(fromIdValue as String) ?? 0)) } else if let fromId = payload["channel_id"] { let fromIdValue = fromId as! NSString - peerId = PeerId(namespace: Namespaces.Peer.CloudChannel, id: PeerId.Id._internalFromInt32Value(Int32(fromIdValue.intValue))) + peerId = PeerId(namespace: Namespaces.Peer.CloudChannel, id: PeerId.Id._internalFromInt64Value(Int64(fromIdValue as String) ?? 0)) } if let peerId = peerId { diff --git a/submodules/TelegramUI/Sources/WebpagePreviewAccessoryPanelNode.swift b/submodules/TelegramUI/Sources/WebpagePreviewAccessoryPanelNode.swift index c8df794cfc..e8c472d253 100644 --- a/submodules/TelegramUI/Sources/WebpagePreviewAccessoryPanelNode.swift +++ b/submodules/TelegramUI/Sources/WebpagePreviewAccessoryPanelNode.swift @@ -62,6 +62,7 @@ final class WebpagePreviewAccessoryPanelNode: AccessoryPanelNode { self.addSubnode(self.closeButton) self.addSubnode(self.lineNode) + self.addSubnode(self.iconNode) self.addSubnode(self.titleNode) self.addSubnode(self.textNode) diff --git a/submodules/TelegramUIPreferences/Sources/CallListSettings.swift b/submodules/TelegramUIPreferences/Sources/CallListSettings.swift index 55383bcdbc..aa7b6ce9cb 100644 --- a/submodules/TelegramUIPreferences/Sources/CallListSettings.swift +++ b/submodules/TelegramUIPreferences/Sources/CallListSettings.swift @@ -3,7 +3,7 @@ import Postbox import TelegramCore import SwiftSignalKit -public struct CallListSettings: PreferencesEntry, Equatable { +public struct CallListSettings: Codable, Equatable { public var _showTab: Bool? public var defaultShowTab: Bool? @@ -34,33 +34,29 @@ public struct CallListSettings: PreferencesEntry, Equatable { self.defaultShowTab = defaultShowTab } - public init(decoder: PostboxDecoder) { - if let alternativeDefaultValue = decoder.decodeOptionalInt32ForKey("defaultShowTab") { + public init(from decoder: Decoder) throws { + let container = try decoder.container(keyedBy: StringCodingKey.self) + + if let alternativeDefaultValue = try container.decodeIfPresent(Int32.self, forKey: "defaultShowTab") { self.defaultShowTab = alternativeDefaultValue != 0 } - if let value = decoder.decodeOptionalInt32ForKey("showTab") { + if let value = try container.decodeIfPresent(Int32.self, forKey: "showTab") { self._showTab = value != 0 } } - public func encode(_ encoder: PostboxEncoder) { + public func encode(to encoder: Encoder) throws { + var container = encoder.container(keyedBy: StringCodingKey.self) + if let defaultShowTab = self.defaultShowTab { - encoder.encodeInt32(defaultShowTab ? 1 : 0, forKey: "defaultShowTab") + try container.encode((defaultShowTab ? 1 : 0) as Int32, forKey: "defaultShowTab") } else { - encoder.encodeNil(forKey: "defaultShowTab") + try container.encodeNil(forKey: "defaultShowTab") } if let showTab = self._showTab { - encoder.encodeInt32(showTab ? 1 : 0, forKey: "showTab") + try container.encode((showTab ? 1 : 0) as Int32, forKey: "showTab") } else { - encoder.encodeNil(forKey: "showTab") - } - } - - public func isEqual(to: PreferencesEntry) -> Bool { - if let to = to as? CallListSettings { - return self == to - } else { - return false + try container.encodeNil(forKey: "showTab") } } @@ -77,12 +73,12 @@ public func updateCallListSettingsInteractively(accountManager: AccountManager Void in transaction.updateSharedData(ApplicationSpecificSharedDataKeys.callListSettings, { entry in let currentSettings: CallListSettings - if let entry = entry as? CallListSettings { + if let entry = entry?.get(CallListSettings.self) { currentSettings = entry } else { currentSettings = CallListSettings.defaultSettings } - return f(currentSettings) + return PreferencesEntry(f(currentSettings)) }) } } diff --git a/submodules/TelegramUIPreferences/Sources/ChatArchiveSettings.swift b/submodules/TelegramUIPreferences/Sources/ChatArchiveSettings.swift index 57de71b45a..3dbbaa1cd8 100644 --- a/submodules/TelegramUIPreferences/Sources/ChatArchiveSettings.swift +++ b/submodules/TelegramUIPreferences/Sources/ChatArchiveSettings.swift @@ -2,7 +2,7 @@ import Foundation import Postbox import SwiftSignalKit -public struct ChatArchiveSettings: Equatable, PreferencesEntry { +public struct ChatArchiveSettings: Equatable, Codable { public var isHiddenByDefault: Bool public var hiddenPsaPeerId: PeerId? @@ -15,25 +15,21 @@ public struct ChatArchiveSettings: Equatable, PreferencesEntry { self.hiddenPsaPeerId = hiddenPsaPeerId } - public init(decoder: PostboxDecoder) { - self.isHiddenByDefault = decoder.decodeInt32ForKey("isHiddenByDefault", orElse: 1) != 0 - self.hiddenPsaPeerId = decoder.decodeOptionalInt64ForKey("hiddenPsaPeerId").flatMap(PeerId.init) + public init(from decoder: Decoder) throws { + let container = try decoder.container(keyedBy: StringCodingKey.self) + + self.isHiddenByDefault = (try container.decode(Int32.self, forKey: "isHiddenByDefault")) != 0 + self.hiddenPsaPeerId = (try container.decodeIfPresent(Int64.self), forKey: "hiddenPsaPeerId").flatMap(PeerId.init) } - public func encode(_ encoder: PostboxEncoder) { - encoder.encodeInt32(self.isHiddenByDefault ? 1 : 0, forKey: "isHiddenByDefault") + public func encode(to encoder: Encoder) throws { + var container = encoder.container(keyedBy: StringCodingKeys.self) + + try container.encode((self.isHiddenByDefault ? 1 : 0) as Int32, forKey: "isHiddenByDefault") if let hiddenPsaPeerId = self.hiddenPsaPeerId { - encoder.encodeInt64(hiddenPsaPeerId.toInt64(), forKey: "hiddenPsaPeerId") + try container.encode(hiddenPsaPeerId.toInt64(), forKey: "hiddenPsaPeerId") } else { - encoder.encodeNil(forKey: "hiddenPsaPeerId") - } - } - - public func isEqual(to: PreferencesEntry) -> Bool { - if let to = to as? ChatArchiveSettings { - return self == to - } else { - return false + try container.encodeNil(forKey: "hiddenPsaPeerId") } } } @@ -41,11 +37,11 @@ public struct ChatArchiveSettings: Equatable, PreferencesEntry { public func updateChatArchiveSettings(transaction: Transaction, _ f: @escaping (ChatArchiveSettings) -> ChatArchiveSettings) { transaction.updatePreferencesEntry(key: ApplicationSpecificPreferencesKeys.chatArchiveSettings, { entry in let currentSettings: ChatArchiveSettings - if let entry = entry as? ChatArchiveSettings { + if let entry = entry?.get(ChatArchiveSettings.self) { currentSettings = entry } else { currentSettings = .default } - return f(currentSettings) + return PreferncesEntry(f(currentSettings)) }) } diff --git a/submodules/TelegramUIPreferences/Sources/ChatListFilterSettings.swift b/submodules/TelegramUIPreferences/Sources/ChatListFilterSettings.swift index dca12977f6..98b88ca7e5 100644 --- a/submodules/TelegramUIPreferences/Sources/ChatListFilterSettings.swift +++ b/submodules/TelegramUIPreferences/Sources/ChatListFilterSettings.swift @@ -2,7 +2,7 @@ import Foundation import Postbox import SwiftSignalKit -public struct ChatListFilterSettings: Equatable, PreferencesEntry { +public struct ChatListFilterSettings: Equatable, Codable { public static var `default`: ChatListFilterSettings { return ChatListFilterSettings() } @@ -10,29 +10,21 @@ public struct ChatListFilterSettings: Equatable, PreferencesEntry { public init() { } - public init(decoder: PostboxDecoder) { + public init(from decoder: Decoder) throws { } - public func encode(_ encoder: PostboxEncoder) { - } - - public func isEqual(to: PreferencesEntry) -> Bool { - if let to = to as? ChatListFilterSettings { - return self == to - } else { - return false - } + public func encode(to encoder: Encoder) throws { } } public func updateChatListFilterSettings(transaction: Transaction, _ f: @escaping (ChatListFilterSettings) -> ChatListFilterSettings) { transaction.updatePreferencesEntry(key: ApplicationSpecificPreferencesKeys.chatListFilterSettings, { entry in let currentSettings: ChatListFilterSettings - if let entry = entry as? ChatListFilterSettings { + if let entry = entry?.get(ChatListFilterSettings.self) { currentSettings = entry } else { currentSettings = .default } - return f(currentSettings) + return PreferencesEntry(f(currentSettings)) }) } diff --git a/submodules/TelegramUIPreferences/Sources/ContactSynchronizationSettings.swift b/submodules/TelegramUIPreferences/Sources/ContactSynchronizationSettings.swift index f80a3851a4..6436039375 100644 --- a/submodules/TelegramUIPreferences/Sources/ContactSynchronizationSettings.swift +++ b/submodules/TelegramUIPreferences/Sources/ContactSynchronizationSettings.swift @@ -13,7 +13,7 @@ public enum PresentationPersonNameOrder: Int32 { case lastFirst = 1 } -public struct ContactSynchronizationSettings: Equatable, PreferencesEntry { +public struct ContactSynchronizationSettings: Equatable, Codable { public var _legacySynchronizeDeviceContacts: Bool public var nameDisplayOrder: PresentationPersonNameOrder public var sortOrder: ContactsSortOrder @@ -28,24 +28,20 @@ public struct ContactSynchronizationSettings: Equatable, PreferencesEntry { self.sortOrder = sortOrder } - public init(decoder: PostboxDecoder) { - self._legacySynchronizeDeviceContacts = decoder.decodeInt32ForKey("synchronizeDeviceContacts", orElse: 0) != 0 - self.nameDisplayOrder = PresentationPersonNameOrder(rawValue: decoder.decodeInt32ForKey("nameDisplayOrder", orElse: 0)) ?? .firstLast - self.sortOrder = ContactsSortOrder(rawValue: decoder.decodeInt32ForKey("sortOrder", orElse: 0)) ?? .presence + public init(from decoder: Decoder) throws { + let container = decoder.container(keyedBy: StringCodingKey.self) + + self._legacySynchronizeDeviceContacts = (try container.decode(Int32.self, forKey: "synchronizeDeviceContacts")) != 0 + self.nameDisplayOrder = PresentationPersonNameOrder(rawValue: try container.decode(Int32.self, forKey: "nameDisplayOrder")) ?? .firstLast + self.sortOrder = ContactsSortOrder(rawValue: try container.decode(Int32.self, forKey: "sortOrder", orElse: 0)) ?? .presence } - public func encode(_ encoder: PostboxEncoder) { - encoder.encodeInt32(self._legacySynchronizeDeviceContacts ? 1 : 0, forKey: "synchronizeDeviceContacts") - encoder.encodeInt32(self.nameDisplayOrder.rawValue, forKey: "nameDisplayOrder") - encoder.encodeInt32(self.sortOrder.rawValue, forKey: "sortOrder") - } - - public func isEqual(to: PreferencesEntry) -> Bool { - if let to = to as? ContactSynchronizationSettings { - return self == to - } else { - return false - } + public func encode(to encoder: Encoder) throws { + var container = encoder.container(keyedBy: StringCodingKey.self) + + try container.encode((self._legacySynchronizeDeviceContacts ? 1 : 0) as Int32, forKey: "synchronizeDeviceContacts") + try container.encode(self.nameDisplayOrder.rawValue, forKey: "nameDisplayOrder") + try container.encode(self.sortOrder.rawValue, forKey: "sortOrder") } } @@ -53,12 +49,12 @@ public func updateContactSettingsInteractively(accountManager: AccountManager Void in transaction.updateSharedData(ApplicationSpecificSharedDataKeys.contactSynchronizationSettings, { entry in let currentSettings: ContactSynchronizationSettings - if let entry = entry as? ContactSynchronizationSettings { + if let entry = entry?.get(ContactSynchronizationSettings.self) { currentSettings = entry } else { currentSettings = .defaultSettings } - return f(currentSettings) + return PreferencesEntry(f(currentSettings)) }) } } diff --git a/submodules/TelegramUIPreferences/Sources/ExperimentalSettings.swift b/submodules/TelegramUIPreferences/Sources/ExperimentalSettings.swift index ace0e5f197..a534fea5b8 100644 --- a/submodules/TelegramUIPreferences/Sources/ExperimentalSettings.swift +++ b/submodules/TelegramUIPreferences/Sources/ExperimentalSettings.swift @@ -3,35 +3,22 @@ import Postbox import TelegramCore import SwiftSignalKit -public struct ExperimentalSettings: PreferencesEntry, Equatable { - public var enableFeed: Bool - +public struct ExperimentalSettings: Codable, Equatable { public static var defaultSettings: ExperimentalSettings { - return ExperimentalSettings(decoder: PostboxDecoder(buffer: MemoryBuffer())) + return ExperimentalSettings() } - public init(enableFeed: Bool) { - self.enableFeed = enableFeed + public init() { } - public init(decoder: PostboxDecoder) { - self.enableFeed = decoder.decodeInt32ForKey("enableFeed", orElse: 0) != 0 + public init(from decoder: Decoder) throws { } - public func encode(_ encoder: PostboxEncoder) { - encoder.encodeInt32(self.enableFeed ? 1 : 0, forKey: "enableFeed") - } - - public func isEqual(to: PreferencesEntry) -> Bool { - if let to = to as? ExperimentalSettings { - return self == to - } else { - return false - } + public func encode(to encoder: Encoder) throws { } public static func ==(lhs: ExperimentalSettings, rhs: ExperimentalSettings) -> Bool { - return lhs.enableFeed == rhs.enableFeed + return true } } @@ -39,12 +26,12 @@ public func updateExperimentalSettingsInteractively(accountManager: AccountManag return accountManager.transaction { transaction -> Void in transaction.updateSharedData(ApplicationSpecificSharedDataKeys.experimentalSettings, { entry in let currentSettings: ExperimentalSettings - if let entry = entry as? ExperimentalSettings { + if let entry = entry?.get(ExperimentalSettings.self) { currentSettings = entry } else { currentSettings = ExperimentalSettings.defaultSettings } - return f(currentSettings) + return PreferencesEntry(f(currentSettings)) }) } } diff --git a/submodules/TelegramUIPreferences/Sources/ExperimentalUISettings.swift b/submodules/TelegramUIPreferences/Sources/ExperimentalUISettings.swift index bece6cae74..863057468a 100644 --- a/submodules/TelegramUIPreferences/Sources/ExperimentalUISettings.swift +++ b/submodules/TelegramUIPreferences/Sources/ExperimentalUISettings.swift @@ -3,7 +3,7 @@ import Postbox import TelegramCore import SwiftSignalKit -public struct ExperimentalUISettings: Equatable, PreferencesEntry { +public struct ExperimentalUISettings: Equatable, Codable { public var keepChatNavigationStack: Bool public var skipReadHistory: Bool public var crashOnLongQueries: Bool @@ -70,7 +70,9 @@ public struct ExperimentalUISettings: Equatable, PreferencesEntry { self.enableDebugDataDisplay = enableDebugDataDisplay } - public init(decoder: PostboxDecoder) { + public init(from decoder: Decoder) throws { + + self.keepChatNavigationStack = decoder.decodeInt32ForKey("keepChatNavigationStack", orElse: 0) != 0 self.skipReadHistory = decoder.decodeInt32ForKey("skipReadHistory", orElse: 0) != 0 self.crashOnLongQueries = decoder.decodeInt32ForKey("crashOnLongQueries", orElse: 0) != 0 @@ -87,7 +89,8 @@ public struct ExperimentalUISettings: Equatable, PreferencesEntry { self.enableDebugDataDisplay = decoder.decodeInt32ForKey("enableDebugDataDisplay", orElse: 0) != 0 } - public func encode(_ encoder: PostboxEncoder) { + public func encode(to encoder: Encoder) throws { + encoder.encodeInt32(self.keepChatNavigationStack ? 1 : 0, forKey: "keepChatNavigationStack") encoder.encodeInt32(self.skipReadHistory ? 1 : 0, forKey: "skipReadHistory") encoder.encodeInt32(self.crashOnLongQueries ? 1 : 0, forKey: "crashOnLongQueries") diff --git a/submodules/TelegramUIPreferences/Sources/PresentationThemeSettings.swift b/submodules/TelegramUIPreferences/Sources/PresentationThemeSettings.swift index 6c36304629..fa7a55fe50 100644 --- a/submodules/TelegramUIPreferences/Sources/PresentationThemeSettings.swift +++ b/submodules/TelegramUIPreferences/Sources/PresentationThemeSettings.swift @@ -210,7 +210,7 @@ public enum PresentationThemeReference: PostboxCoding, Equatable { let high = UInt32((UInt64(bitPattern: id) >> 32) & (0xffffffff as UInt64)) acc = (acc &* 20261) &+ high acc = (acc &* 20261) &+ low - + return Int32(bitPattern: acc & UInt32(0x7fffffff)) } diff --git a/submodules/TemporaryCachedPeerDataManager/Sources/ChannelMemberCategoryListContext.swift b/submodules/TemporaryCachedPeerDataManager/Sources/ChannelMemberCategoryListContext.swift index d2054d3fb5..55766dd473 100644 --- a/submodules/TemporaryCachedPeerDataManager/Sources/ChannelMemberCategoryListContext.swift +++ b/submodules/TemporaryCachedPeerDataManager/Sources/ChannelMemberCategoryListContext.swift @@ -205,7 +205,7 @@ private final class ChannelMemberSingleCategoryListContext: ChannelMemberCategor } } - private func loadSignal(offset: Int32, count: Int32, hash: Int32) -> Signal<[RenderedChannelParticipant]?, NoError> { + private func loadSignal(offset: Int32, count: Int32, hash: Int64) -> Signal<[RenderedChannelParticipant]?, NoError> { let requestCategory: ChannelMembersCategory var adminQuery: String? = nil switch self.category { @@ -312,14 +312,14 @@ private final class ChannelMemberSingleCategoryListContext: ChannelMemberCategor return } - var hash: UInt32 = 0 + var acc: UInt64 = 0 for i in 0 ..< min(strongSelf.listStateValue.list.count, Int(initialBatchSize)) { let peerId = strongSelf.listStateValue.list[i].peer.id - hash = (hash &* 20261) &+ UInt32(bitPattern: peerId.id._internalGetInt32Value()) + combineInt64Hash(&acc, with: peerId) } - hash = hash % 0x7FFFFFFF - strongSelf.headUpdateDisposable.set((strongSelf.loadSignal(offset: 0, count: initialBatchSize, hash: Int32(bitPattern: hash)) + let hashResult = finalizeInt64Hash(acc) + strongSelf.headUpdateDisposable.set((strongSelf.loadSignal(offset: 0, count: initialBatchSize, hash: hashResult) |> deliverOnMainQueue).start(next: { members in self?.updateHeadMembers(members) })) diff --git a/submodules/TgVoipWebrtc/tgcalls b/submodules/TgVoipWebrtc/tgcalls index d32407171f..aaede253be 160000 --- a/submodules/TgVoipWebrtc/tgcalls +++ b/submodules/TgVoipWebrtc/tgcalls @@ -1 +1 @@ -Subproject commit d32407171f21ee8055a9621cf67238a8996eaaa4 +Subproject commit aaede253be4dbfdfcb2258cdb6faa843785192e6 diff --git a/submodules/UrlHandling/Sources/UrlHandling.swift b/submodules/UrlHandling/Sources/UrlHandling.swift index fe9b8aefdf..bed77ec35c 100644 --- a/submodules/UrlHandling/Sources/UrlHandling.swift +++ b/submodules/UrlHandling/Sources/UrlHandling.swift @@ -144,8 +144,8 @@ public func parseInternalUrl(query: String) -> ParsedInternalUrl? { } } } - } else if pathComponents[0].hasPrefix(phonebookUsernamePathPrefix), let idValue = Int32(String(pathComponents[0][pathComponents[0].index(pathComponents[0].startIndex, offsetBy: phonebookUsernamePathPrefix.count)...])) { - return .peerId(PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt32Value(idValue))) + } else if pathComponents[0].hasPrefix(phonebookUsernamePathPrefix), let idValue = Int64(String(pathComponents[0][pathComponents[0].index(pathComponents[0].startIndex, offsetBy: phonebookUsernamePathPrefix.count)...])) { + return .peerId(PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt64Value(idValue))) } else if pathComponents[0].hasPrefix("+") || pathComponents[0].hasPrefix("%20") { return .join(String(pathComponents[0].dropFirst())) } @@ -278,7 +278,7 @@ public func parseInternalUrl(query: String) -> ParsedInternalUrl? { } else if pathComponents[0] == "addtheme" { return .theme(pathComponents[1]) } else if pathComponents.count == 3 && pathComponents[0] == "c" { - if let channelId = Int32(pathComponents[1]), let messageId = Int32(pathComponents[2]) { + if let channelId = Int64(pathComponents[1]), let messageId = Int32(pathComponents[2]) { var threadId: Int32? var timecode: Double? if let queryItems = components.queryItems { @@ -296,7 +296,7 @@ public func parseInternalUrl(query: String) -> ParsedInternalUrl? { } } } - return .privateMessage(messageId: MessageId(peerId: PeerId(namespace: Namespaces.Peer.CloudChannel, id: PeerId.Id._internalFromInt32Value(channelId)), namespace: Namespaces.Message.Cloud, id: messageId), threadId: threadId, timecode: timecode) + return .privateMessage(messageId: MessageId(peerId: PeerId(namespace: Namespaces.Peer.CloudChannel, id: PeerId.Id._internalFromInt64Value(channelId)), namespace: Namespaces.Message.Cloud, id: messageId), threadId: threadId, timecode: timecode) } else { return nil } @@ -406,7 +406,7 @@ private func resolveInternalUrl(context: AccountContext, url: ParsedInternalUrl) if let peer = peer { foundPeer = .single(peer) } else { - foundPeer = TelegramEngine(account: context.account).peers.findChannelById(channelId: messageId.peerId.id._internalGetInt32Value()) + foundPeer = TelegramEngine(account: context.account).peers.findChannelById(channelId: messageId.peerId.id._internalGetInt64Value()) } return foundPeer |> mapToSignal { foundPeer -> Signal in diff --git a/submodules/WallpaperResources/Sources/WallpaperResources.swift b/submodules/WallpaperResources/Sources/WallpaperResources.swift index 020645aa1d..9a1e895d25 100644 --- a/submodules/WallpaperResources/Sources/WallpaperResources.swift +++ b/submodules/WallpaperResources/Sources/WallpaperResources.swift @@ -366,10 +366,11 @@ private func patternWallpaperDatas(account: Account, accountManager: AccountMana if let targetRepresentation = targetRepresentation { let maybeFullSize = combineLatest( - accountManager.mediaBox.resourceData(targetRepresentation.representation.resource), - account.postbox.mediaBox.resourceData(targetRepresentation.representation.resource) + accountManager.mediaBox.cachedResourceRepresentation(targetRepresentation.representation.resource, representation: CachedPreparedPatternWallpaperRepresentation(), complete: false, fetch: true), + account.postbox.mediaBox.cachedResourceRepresentation(targetRepresentation.representation.resource, representation: CachedPreparedPatternWallpaperRepresentation(), complete: false, fetch: true) ) + let signal = maybeFullSize |> take(1) |> mapToSignal { maybeSharedData, maybeData -> Signal<(Data?, Bool), NoError> in @@ -387,11 +388,11 @@ private func patternWallpaperDatas(account: Account, accountManager: AccountMana let accountFullSizeData = Signal<(Data?, Bool), NoError> { subscriber in let fetchedFullSizeDisposable = fetchedFullSize.start() - let fullSizeDisposable = account.postbox.mediaBox.resourceData(targetRepresentation.representation.resource).start(next: { next in + let fullSizeDisposable = account.postbox.mediaBox.cachedResourceRepresentation(targetRepresentation.representation.resource, representation: CachedPreparedPatternWallpaperRepresentation(), complete: false, fetch: true).start(next: { next in subscriber.putNext((next.size == 0 ? nil : try? Data(contentsOf: URL(fileURLWithPath: next.path), options: []), next.complete)) if next.complete, let data = try? Data(contentsOf: URL(fileURLWithPath: next.path), options: .mappedRead) { - accountManager.mediaBox.storeResourceData(targetRepresentation.representation.resource.id, data: data) + accountManager.mediaBox.storeCachedResourceRepresentation(targetRepresentation.representation.resource, representation: CachedPreparedPatternWallpaperRepresentation(), data: data) } }, error: subscriber.putError, completed: subscriber.putCompletion) @@ -402,7 +403,7 @@ private func patternWallpaperDatas(account: Account, accountManager: AccountMana } let sharedFullSizeData = Signal<(Data?, Bool), NoError> { subscriber in - let fullSizeDisposable = accountManager.mediaBox.resourceData(targetRepresentation.representation.resource).start(next: { next in + let fullSizeDisposable = accountManager.mediaBox.cachedResourceRepresentation(targetRepresentation.representation.resource, representation: CachedPreparedPatternWallpaperRepresentation(), complete: false, fetch: true).start(next: { next in subscriber.putNext((next.size == 0 ? nil : try? Data(contentsOf: URL(fileURLWithPath: next.path), options: []), next.complete)) }, error: subscriber.putError, completed: subscriber.putCompletion) @@ -450,7 +451,7 @@ public func patternWallpaperImage(account: Account, accountManager: AccountManag if !autoFetchFullSize || fullSizeComplete { return patternWallpaperImageInternal(fullSizeData: fullSizeData, fullSizeComplete: fullSizeComplete, mode: mode) } else { - return .complete() + return .single(nil) } } } @@ -526,11 +527,17 @@ private func patternWallpaperImageInternal(fullSizeData: Data?, fullSizeComplete let overlayImage = generateImage(arguments.drawingRect.size, rotatedContext: { size, c in c.clear(CGRect(origin: CGPoint(), size: size)) var image: UIImage? - if let fullSizeData = fullSizeData, let unpackedData = TGGUnzipData(fullSizeData, 2 * 1024 * 1024) { - image = drawSvgImage(unpackedData, CGSize(width: size.width * context.scale, height: size.height * context.scale), .black, .white) - } else if let fullSizeData = fullSizeData { - image = UIImage(data: fullSizeData) + if let fullSizeData = fullSizeData { + image = renderPreparedImage(fullSizeData, CGSize(width: size.width * context.scale, height: size.height * context.scale)) } +// if let fullSizeData = fullSizeData, let unpackedData = TGGUnzipData(fullSizeData, 2 * 1024 * 1024) { +// let preparedData = prepareSvgImage(unpackedData) +// image = renderPreparedImage(preparedData!, CGSize(width: size.width * context.scale, height: size.height * context.scale)) +// +//// image = drawSvgImage(unpackedData, CGSize(width: size.width * context.scale, height: size.height * context.scale), .black, .white) +// } else if let fullSizeData = fullSizeData { +// image = UIImage(data: fullSizeData) +// } if let customPatternColor = customArguments.customPatternColor, customPatternColor.alpha < 1.0 { c.setBlendMode(.copy) diff --git a/submodules/WatchBridge/Impl/PublicHeaders/WatchBridgeImpl/TGBridgeServer.h b/submodules/WatchBridge/Impl/PublicHeaders/WatchBridgeImpl/TGBridgeServer.h index af60186ca5..d28a8b0320 100644 --- a/submodules/WatchBridge/Impl/PublicHeaders/WatchBridgeImpl/TGBridgeServer.h +++ b/submodules/WatchBridge/Impl/PublicHeaders/WatchBridgeImpl/TGBridgeServer.h @@ -15,7 +15,7 @@ - (SSignal * _Nonnull)watchAppInstalledSignal; - (SSignal * _Nonnull)runningRequestsSignal; -- (void)setAuthorized:(bool)authorized userId:(int32_t)userId; +- (void)setAuthorized:(bool)authorized userId:(int64_t)userId; - (void)setMicAccessAllowed:(bool)allowed; - (void)setStartupData:(NSDictionary * _Nullable)data; - (void)pushContext; diff --git a/submodules/WatchBridge/Impl/Sources/TGBridgeServer.m b/submodules/WatchBridge/Impl/Sources/TGBridgeServer.m index 6bbf49c4de..7cca68f376 100644 --- a/submodules/WatchBridge/Impl/Sources/TGBridgeServer.m +++ b/submodules/WatchBridge/Impl/Sources/TGBridgeServer.m @@ -135,7 +135,7 @@ #pragma mark - -- (void)setAuthorized:(bool)authorized userId:(int32_t)userId +- (void)setAuthorized:(bool)authorized userId:(int64_t)userId { _activeContext = [_activeContext updatedWithAuthorized:authorized peerId:userId]; } diff --git a/submodules/WatchBridge/Sources/WatchBridge.swift b/submodules/WatchBridge/Sources/WatchBridge.swift index 18a6502fbc..9b914000cc 100644 --- a/submodules/WatchBridge/Sources/WatchBridge.swift +++ b/submodules/WatchBridge/Sources/WatchBridge.swift @@ -8,11 +8,11 @@ import PhoneNumberFormat func makePeerIdFromBridgeIdentifier(_ identifier: Int64) -> PeerId? { if identifier < 0 && identifier > Int32.min { - return PeerId(namespace: Namespaces.Peer.CloudGroup, id: PeerId.Id._internalFromInt32Value(Int32(clamping: -identifier))) + return PeerId(namespace: Namespaces.Peer.CloudGroup, id: PeerId.Id._internalFromInt64Value(-identifier)) } else if identifier < Int64(Int32.min) * 2 && identifier > Int64(Int32.min) * 3 { - return PeerId(namespace: Namespaces.Peer.CloudChannel, id: PeerId.Id._internalFromInt32Value(Int32(clamping: Int64(Int32.min) &* 2 &- identifier))) + return PeerId(namespace: Namespaces.Peer.CloudChannel, id: PeerId.Id._internalFromInt64Value(Int64(Int32.min) &* 2 &- identifier)) } else if identifier > 0 && identifier < Int32.max { - return PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt32Value(Int32(clamping: identifier))) + return PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt64Value(identifier)) } else { return nil } @@ -21,11 +21,11 @@ func makePeerIdFromBridgeIdentifier(_ identifier: Int64) -> PeerId? { func makeBridgeIdentifier(_ peerId: PeerId) -> Int64 { switch peerId.namespace { case Namespaces.Peer.CloudGroup: - return -Int64(peerId.id._internalGetInt32Value()) + return -Int64(peerId.id._internalGetInt64Value()) case Namespaces.Peer.CloudChannel: - return Int64(Int32.min) * 2 - Int64(peerId.id._internalGetInt32Value()) + return Int64(Int32.min) * 2 - Int64(peerId.id._internalGetInt64Value()) default: - return Int64(peerId.id._internalGetInt32Value()) + return Int64(peerId.id._internalGetInt64Value()) } } diff --git a/submodules/WatchBridge/Sources/WatchCommunicationManager.swift b/submodules/WatchBridge/Sources/WatchCommunicationManager.swift index 8739700b5b..fdc6f30dfa 100644 --- a/submodules/WatchBridge/Sources/WatchCommunicationManager.swift +++ b/submodules/WatchBridge/Sources/WatchCommunicationManager.swift @@ -88,7 +88,7 @@ public final class WatchCommunicationManager { } if let context = appContext { strongSelf.accountContext.set(.single(context.context)) - strongSelf.server.setAuthorized(true, userId: context.context.account.peerId.id._internalGetInt32Value()) + strongSelf.server.setAuthorized(true, userId: context.context.account.peerId.id._internalGetInt64Value()) strongSelf.server.setMicAccessAllowed(false) strongSelf.server.pushContext() strongSelf.server.setMicAccessAllowed(true)