diff --git a/TelegramCore/AccountIntermediateState.swift b/TelegramCore/AccountIntermediateState.swift index 2ab7916da9..11e24faffb 100644 --- a/TelegramCore/AccountIntermediateState.swift +++ b/TelegramCore/AccountIntermediateState.swift @@ -104,6 +104,7 @@ struct AccountMutableState { var namespacesWithHolesFromPreviousState: [PeerId: Set] var storedMessagesByPeerIdAndTimestamp: [PeerId: Set] + var displayAlerts: [String] = [] var insertedPeers: [PeerId: Peer] = [:] @@ -122,7 +123,7 @@ struct AccountMutableState { self.namespacesWithHolesFromPreviousState = [:] } - init(initialState: AccountInitialState, operations: [AccountStateMutationOperation], state: AuthorizedAccountState.State, peers: [PeerId: Peer], chatStates: [PeerId: PeerChatState], peerNotificationSettings: [PeerId: PeerNotificationSettings], storedMessages: Set, readInboxMaxIds: [PeerId: MessageId], storedMessagesByPeerIdAndTimestamp: [PeerId: Set], namespacesWithHolesFromPreviousState: [PeerId: Set], branchOperationIndex: Int) { + init(initialState: AccountInitialState, operations: [AccountStateMutationOperation], state: AuthorizedAccountState.State, peers: [PeerId: Peer], chatStates: [PeerId: PeerChatState], peerNotificationSettings: [PeerId: PeerNotificationSettings], storedMessages: Set, readInboxMaxIds: [PeerId: MessageId], storedMessagesByPeerIdAndTimestamp: [PeerId: Set], namespacesWithHolesFromPreviousState: [PeerId: Set], displayAlerts: [String], branchOperationIndex: Int) { self.initialState = initialState self.operations = operations self.state = state @@ -133,11 +134,12 @@ struct AccountMutableState { self.readInboxMaxIds = readInboxMaxIds self.storedMessagesByPeerIdAndTimestamp = storedMessagesByPeerIdAndTimestamp self.namespacesWithHolesFromPreviousState = namespacesWithHolesFromPreviousState + self.displayAlerts = displayAlerts self.branchOperationIndex = branchOperationIndex } func branch() -> AccountMutableState { - return AccountMutableState(initialState: self.initialState, operations: self.operations, state: self.state, peers: self.peers, chatStates: self.chatStates, peerNotificationSettings: self.peerNotificationSettings, storedMessages: self.storedMessages, readInboxMaxIds: self.readInboxMaxIds, storedMessagesByPeerIdAndTimestamp: self.storedMessagesByPeerIdAndTimestamp, namespacesWithHolesFromPreviousState: self.namespacesWithHolesFromPreviousState, branchOperationIndex: self.operations.count) + return AccountMutableState(initialState: self.initialState, operations: self.operations, state: self.state, peers: self.peers, chatStates: self.chatStates, peerNotificationSettings: self.peerNotificationSettings, storedMessages: self.storedMessages, readInboxMaxIds: self.readInboxMaxIds, storedMessagesByPeerIdAndTimestamp: self.storedMessagesByPeerIdAndTimestamp, namespacesWithHolesFromPreviousState: self.namespacesWithHolesFromPreviousState, displayAlerts: self.displayAlerts, branchOperationIndex: self.operations.count) } mutating func merge(_ other: AccountMutableState) { @@ -156,6 +158,7 @@ struct AccountMutableState { self.namespacesWithHolesFromPreviousState[peerId]!.insert(namespace) } } + self.displayAlerts.append(contentsOf: other.displayAlerts) } mutating func addPreCachedResource(_ resource: MediaResource, data: Data) { @@ -166,6 +169,10 @@ struct AccountMutableState { self.addOperation(.AddMessages(messages, location)) } + mutating func addDisplayAlert(_ text: String) { + self.displayAlerts.append(text) + } + mutating func deleteMessagesWithGlobalIds(_ globalIds: [Int32]) { self.addOperation(.DeleteMessagesWithGlobalIds(globalIds)) } @@ -385,6 +392,7 @@ struct AccountReplayedFinalState { let updatedTypingActivities: [PeerId: [PeerId: PeerInputActivity?]] let updatedWebpages: [MediaId: TelegramMediaWebpage] let updatedCalls: [Api.PhoneCall] + let delayNotificatonsUntil: Int32? } struct AccountFinalStateEvents { @@ -392,9 +400,11 @@ struct AccountFinalStateEvents { let updatedTypingActivities: [PeerId: [PeerId: PeerInputActivity?]] let updatedWebpages: [MediaId: TelegramMediaWebpage] let updatedCalls: [Api.PhoneCall] + let displayAlerts: [String] + let delayNotificatonsUntil: Int32? var isEmpty: Bool { - return self.addedIncomingMessageIds.isEmpty && self.updatedTypingActivities.isEmpty && self.updatedWebpages.isEmpty && self.updatedCalls.isEmpty + return self.addedIncomingMessageIds.isEmpty && self.updatedTypingActivities.isEmpty && self.updatedWebpages.isEmpty && self.updatedCalls.isEmpty && self.displayAlerts.isEmpty && delayNotificatonsUntil == nil } init() { @@ -402,13 +412,17 @@ struct AccountFinalStateEvents { self.updatedTypingActivities = [:] self.updatedWebpages = [:] self.updatedCalls = [] + self.displayAlerts = [] + self.delayNotificatonsUntil = nil } - init(addedIncomingMessageIds: [MessageId], updatedTypingActivities: [PeerId: [PeerId: PeerInputActivity?]], updatedWebpages: [MediaId: TelegramMediaWebpage], updatedCalls: [Api.PhoneCall]) { + init(addedIncomingMessageIds: [MessageId], updatedTypingActivities: [PeerId: [PeerId: PeerInputActivity?]], updatedWebpages: [MediaId: TelegramMediaWebpage], updatedCalls: [Api.PhoneCall], displayAlerts: [String], delayNotificatonsUntil: Int32?) { self.addedIncomingMessageIds = addedIncomingMessageIds self.updatedTypingActivities = updatedTypingActivities self.updatedWebpages = updatedWebpages self.updatedCalls = updatedCalls + self.displayAlerts = displayAlerts + self.delayNotificatonsUntil = delayNotificatonsUntil } init(state: AccountReplayedFinalState) { @@ -432,9 +446,17 @@ struct AccountFinalStateEvents { self.updatedTypingActivities = state.updatedTypingActivities self.updatedWebpages = state.updatedWebpages self.updatedCalls = state.updatedCalls + self.displayAlerts = state.state.state.displayAlerts + self.delayNotificatonsUntil = state.delayNotificatonsUntil } func union(with other: AccountFinalStateEvents) -> AccountFinalStateEvents { - return AccountFinalStateEvents(addedIncomingMessageIds: self.addedIncomingMessageIds + other.addedIncomingMessageIds, updatedTypingActivities: self.updatedTypingActivities, updatedWebpages: self.updatedWebpages, updatedCalls: self.updatedCalls + other.updatedCalls) + var delayNotificatonsUntil = self.delayNotificatonsUntil + if let other = self.delayNotificatonsUntil { + if delayNotificatonsUntil == nil || other > delayNotificatonsUntil! { + delayNotificatonsUntil = other + } + } + return AccountFinalStateEvents(addedIncomingMessageIds: self.addedIncomingMessageIds + other.addedIncomingMessageIds, updatedTypingActivities: self.updatedTypingActivities, updatedWebpages: self.updatedWebpages, updatedCalls: self.updatedCalls + other.updatedCalls, displayAlerts: self.displayAlerts + other.displayAlerts, delayNotificatonsUntil: delayNotificatonsUntil) } } diff --git a/TelegramCore/AccountStateManagementUtils.swift b/TelegramCore/AccountStateManagementUtils.swift index dcfb88f381..f4186325af 100644 --- a/TelegramCore/AccountStateManagementUtils.swift +++ b/TelegramCore/AccountStateManagementUtils.swift @@ -816,8 +816,9 @@ private func finalStateWithUpdates(account: Account, state: AccountMutableState, let message = StoreMessage(peerId: peerId, namespace: Namespaces.Message.Local, globallyUniqueId: nil, groupingKey: nil, timestamp: date, flags: [.Incoming], tags: [], globalTags: [], localTags: [], forwardInfo: nil, authorId: peerId, text: messageText, attributes: attributes, media: []) updatedState.addMessages([message], location: .UpperHistoryBlock) } + } else { + updatedState.addDisplayAlert(text) } - break case let .updateReadChannelInbox(channelId, maxId): updatedState.readInbox(MessageId(peerId: PeerId(namespace: Namespaces.Peer.CloudChannel, id: channelId), namespace: Namespaces.Message.Cloud, id: maxId)) case let .updateReadChannelOutbox(channelId, maxId): @@ -826,12 +827,13 @@ private func finalStateWithUpdates(account: Account, state: AccountMutableState, updatedState.readInbox(MessageId(peerId: peer.peerId, namespace: Namespaces.Message.Cloud, id: maxId)) case let .updateReadHistoryOutbox(peer, maxId, _, _): updatedState.readOutbox(MessageId(peerId: peer.peerId, namespace: Namespaces.Message.Cloud, id: maxId)) - case let .updateReadFeed(_, feedId, maxPosition, unreadCount, unreadMutedCount): + /*%layer76*/ + /*case let .updateReadFeed(_, feedId, maxPosition, unreadCount, unreadMutedCount): switch maxPosition { case let .feedPosition(date, peer, id): let index = MessageIndex(id: MessageId(peerId: peer.peerId, namespace: Namespaces.Message.Cloud, id: id), timestamp: date) updatedState.readGroupFeedInbox(groupId: PeerGroupId(rawValue: feedId), index: index) - } + }*/ case let .updateWebPage(apiWebpage, _, _): switch apiWebpage { case let .webPageEmpty(id): @@ -1000,12 +1002,14 @@ private func finalStateWithUpdates(account: Account, state: AccountMutableState, updatedState.addPeerInputActivity(chatPeerId: PeerId(namespace: Namespaces.Peer.SecretChat, id: chatId), peerId: nil, activity: .typingText) case let .updateDialogPinned(flags, peer): let item: PinnedItemId - switch peer { + /*%layer76*/ + /*switch peer { case let .dialogPeer(peer): item = .peer(peer.peerId) case let .dialogPeerFeed(feedId): item = .group(PeerGroupId(rawValue: feedId)) - } + }*/ + item = .peer(peer.peerId) if (flags & (1 << 0)) != 0 { updatedState.addUpdatePinnedItemIds(.pin(item)) } else { @@ -1013,13 +1017,16 @@ private func finalStateWithUpdates(account: Account, state: AccountMutableState, } case let .updatePinnedDialogs(_, order): if let order = order { - updatedState.addUpdatePinnedItemIds(.reorder(order.map { let item: PinnedItemId - switch $0 { + updatedState.addUpdatePinnedItemIds(.reorder(order.map { + let item: PinnedItemId + /*%layer76*/ + /*switch $0 { case let .dialogPeer(peer): item = .peer(peer.peerId) case let .dialogPeerFeed(feedId): item = .group(PeerGroupId(rawValue: feedId)) - } + }*/ + item = .peer($0.peerId) return item })) } else { @@ -1310,11 +1317,18 @@ func keepPollingChannel(account: Account, peerId: PeerId, stateManager: AccountS } private func resetChannels(_ account: Account, peers: [Peer], state: AccountMutableState) -> Signal { - var inputPeers: [Api.InputDialogPeer] = [] + /*%layer76*/ + /*var inputPeers: [Api.InputDialogPeer] = [] for peer in peers { if let inputPeer = apiInputPeer(peer) { inputPeers.append(.inputDialogPeer(peer: inputPeer)) } + }*/ + var inputPeers: [Api.InputPeer] = [] + for peer in peers { + if let inputPeer = apiInputPeer(peer) { + inputPeers.append(inputPeer) + } } return account.network.request(Api.functions.messages.getPeerDialogs(peers: inputPeers)) |> map(Optional.init) @@ -1362,9 +1376,10 @@ private func resetChannels(_ account: Account, peers: [Peer], state: AccountMuta apiUnreadMentionsCount = unreadMentionsCount apiNotificationSettings = peerNotificationSettings apiChannelPts = pts - case .dialogFeed: + /*%layer76*/ + /*case .dialogFeed: assertionFailure() - continue loop + continue loop*/ } let peerId: PeerId @@ -1756,6 +1771,7 @@ func replayFinalState(accountPeerId: PeerId, mediaBox: MediaBox, modifier: Modif var syncRecentGifs = false var langPackDifferences: [Api.LangPackDifference] = [] var pollLangPack = false + var delayNotificatonsUntil: Int32? var addHolesToGroupFeedIds = Set() @@ -1908,7 +1924,14 @@ func replayFinalState(accountPeerId: PeerId, mediaBox: MediaBox, modifier: Modif return f(current) }) case let .MergePeerPresences(presences): - modifier.updatePeerPresences(presences) + var filteredPresences = presences + if let accountPresence = presences[accountPeerId] { + filteredPresences.removeValue(forKey: accountPeerId) + if let presence = accountPresence as? TelegramUserPresence, case let .present(until) = presence.status { + delayNotificatonsUntil = until + 30 + } + } + modifier.updatePeerPresences(filteredPresences) case let .UpdateSecretChat(chat, _): updateSecretChat(accountPeerId: accountPeerId, modifier: modifier, chat: chat, requestData: nil) case let .AddSecretMessages(messages): @@ -2068,7 +2091,8 @@ func replayFinalState(accountPeerId: PeerId, mediaBox: MediaBox, modifier: Modif } switch set { - case let .stickerSet(flags, _, _, _, _, _, _, _): + /*%layer76*/ + case let .stickerSet(flags, _, _, _, _, _, _): if (flags & (1 << 3)) != 0 { namespace = Namespaces.ItemCollection.CloudMaskPacks } else { @@ -2216,5 +2240,5 @@ func replayFinalState(accountPeerId: PeerId, mediaBox: MediaBox, modifier: Modif } } - return AccountReplayedFinalState(state: finalState, addedSecretMessageIds: addedSecretMessageIds, updatedTypingActivities: updatedTypingActivities, updatedWebpages: updatedWebpages, updatedCalls: updatedCalls) + return AccountReplayedFinalState(state: finalState, addedSecretMessageIds: addedSecretMessageIds, updatedTypingActivities: updatedTypingActivities, updatedWebpages: updatedWebpages, updatedCalls: updatedCalls, delayNotificatonsUntil: delayNotificatonsUntil) } diff --git a/TelegramCore/AccountStateManager.swift b/TelegramCore/AccountStateManager.swift index f845b52384..3010b67572 100644 --- a/TelegramCore/AccountStateManager.swift +++ b/TelegramCore/AccountStateManager.swift @@ -80,8 +80,20 @@ public final class AccountStateManager { return self.notificationMessagesPipe.signal() } + private let displayAlertsPipe = ValuePipe<[String]>() + public var displayAlerts: Signal<[String], NoError> { + return self.displayAlertsPipe.signal() + } + + private let appliedIncomingReadMessagesPipe = ValuePipe<[MessageId]>() + public var appliedIncomingReadMessages: Signal<[MessageId], NoError> { + return self.appliedIncomingReadMessagesPipe.signal() + } + private var updatedWebpageContexts: [MediaId: UpdatedWebpageSubscriberContext] = [:] + private let delayNotificatonsUntil = Atomic(value: nil) + init(account: Account, peerInputActivityManager: PeerInputActivityManager, auxiliaryMethods: AccountAuxiliaryMethods) { self.account = account self.peerInputActivityManager = peerInputActivityManager @@ -460,6 +472,10 @@ public final class AccountStateManager { } } + if events.delayNotificatonsUntil != nil { + let _ = self.delayNotificatonsUntil.swap(events.delayNotificatonsUntil) + } + let signal = self.account.postbox.modify { modifier -> [(Message, PeerGroupId?)] in var messages: [(Message, PeerGroupId?)] = [] for id in events.addedIncomingMessageIds { @@ -484,6 +500,10 @@ public final class AccountStateManager { }, completed: { completed() }) + + if !events.displayAlerts.isEmpty { + self.displayAlertsPipe.putNext(events.displayAlerts) + } case let .pollCompletion(pollId, preMessageIds, preSubscribers): if self.operations.count > 1 { self.operations.removeFirst() @@ -685,6 +705,14 @@ public final class AccountStateManager { } } } + + func notifyAppliedIncomingReadMessages(_ ids: [MessageId]) { + self.appliedIncomingReadMessagesPipe.putNext(ids) + } + + public func getDelayNotificatonsUntil() -> Int32? { + return self.delayNotificatonsUntil.with { $0 } + } } public func messageForNotification(modifier: Modifier, id: MessageId, alwaysReturnMessage: Bool) -> (message: Message?, notify: Bool, sound: PeerMessageSound, displayContents: Bool) { diff --git a/TelegramCore/AccountStateReset.swift b/TelegramCore/AccountStateReset.swift index a4c6b3457c..251af6abd7 100644 --- a/TelegramCore/AccountStateReset.swift +++ b/TelegramCore/AccountStateReset.swift @@ -16,7 +16,8 @@ func accountStateReset(postbox: Postbox, network: Network) -> Signal retryRequest - return combineLatest(network.request(Api.functions.messages.getDialogs(flags: 0, feedId: nil, offsetDate: 0, offsetId: 0, offsetPeer: .inputPeerEmpty, limit: 100)) + /*%layer76*/ + return combineLatest(network.request(Api.functions.messages.getDialogs(flags: 0/*, feedId: nil*/, offsetDate: 0, offsetId: 0, offsetPeer: .inputPeerEmpty, limit: 100)) |> retryRequest, pinnedChats, state) |> mapToSignal { result, pinnedChats, state -> Signal in var dialogsDialogs: [Api.Dialog] = [] @@ -54,9 +55,10 @@ func accountStateReset(postbox: Postbox, network: Network) -> Signal Signal Signal Any?] = { dict[-652419756] = { return Api.Chat.parse_chat($0) } dict[120753115] = { return Api.Chat.parse_chatForbidden($0) } dict[681420594] = { return Api.Chat.parse_channelForbidden($0) } - dict[-930515796] = { return Api.Chat.parse_channel($0) } + dict[1158377749] = { return Api.Chat.parse_channel($0) } dict[1516793212] = { return Api.ChatInvite.parse_chatInviteAlready($0) } dict[-613092008] = { return Api.ChatInvite.parse_chatInvite($0) } dict[1678812626] = { return Api.StickerSetCovered.parse_stickerSetCovered($0) } @@ -126,9 +126,6 @@ fileprivate let parsers: [Int32 : (BufferReader) -> Any?] = { dict[129960444] = { return Api.UserStatus.parse_userStatusLastWeek($0) } dict[2011940674] = { return Api.UserStatus.parse_userStatusLastMonth($0) } dict[-455150117] = { return Api.Dialog.parse_dialog($0) } - dict[906521922] = { return Api.Dialog.parse_dialogFeed($0) } - dict[1330637553] = { return Api.FeedBroadcasts.parse_feedBroadcasts($0) } - dict[-1704428358] = { return Api.FeedBroadcasts.parse_feedBroadcastsUngrouped($0) } dict[381645902] = { return Api.SendMessageAction.parse_sendMessageTypingAction($0) } dict[-44119819] = { return Api.SendMessageAction.parse_sendMessageCancelAction($0) } dict[-1584933265] = { return Api.SendMessageAction.parse_sendMessageRecordVideoAction($0) } @@ -198,6 +195,8 @@ fileprivate let parsers: [Int32 : (BufferReader) -> Any?] = { 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[-686710068] = { return Api.Update.parse_updateDialogPinned($0) } + dict[-657787251] = { 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) } @@ -209,9 +208,6 @@ fileprivate let parsers: [Int32 : (BufferReader) -> Any?] = { dict[-1987495099] = { return Api.Update.parse_updateChannelReadMessagesContents($0) } dict[1887741886] = { return Api.Update.parse_updateContactsReset($0) } dict[1893427255] = { return Api.Update.parse_updateChannelAvailableMessages($0) } - dict[1873186369] = { return Api.Update.parse_updateReadFeed($0) } - dict[433225532] = { return Api.Update.parse_updateDialogPinned($0) } - dict[-364071333] = { return Api.Update.parse_updatePinnedDialogs($0) } dict[1558266229] = { return Api.PopularContact.parse_popularContact($0) } dict[367766557] = { return Api.ChannelParticipant.parse_channelParticipant($0) } dict[-1557620115] = { return Api.ChannelParticipant.parse_channelParticipantSelf($0) } @@ -220,8 +216,6 @@ fileprivate let parsers: [Int32 : (BufferReader) -> Any?] = { dict[573315206] = { return Api.ChannelParticipant.parse_channelParticipantBanned($0) } dict[471043349] = { return Api.contacts.Blocked.parse_blocked($0) } dict[-1878523231] = { return Api.contacts.Blocked.parse_blockedSlice($0) } - dict[741914831] = { return Api.InputDialogPeer.parse_inputDialogPeerFeed($0) } - dict[-55902537] = { return Api.InputDialogPeer.parse_inputDialogPeer($0) } dict[-994444869] = { return Api.Error.parse_error($0) } dict[-1560655744] = { return Api.KeyboardButton.parse_keyboardButton($0) } dict[629866245] = { return Api.KeyboardButton.parse_keyboardButtonUrl($0) } @@ -264,7 +258,7 @@ fileprivate let parsers: [Int32 : (BufferReader) -> Any?] = { dict[1262639204] = { return Api.InputBotInlineMessage.parse_inputBotInlineMessageGame($0) } dict[864077702] = { return Api.InputBotInlineMessage.parse_inputBotInlineMessageMediaAuto($0) } dict[2002815875] = { return Api.KeyboardButtonRow.parse_keyboardButtonRow($0) } - dict[1434820921] = { return Api.StickerSet.parse_stickerSet($0) } + dict[-852477119] = { return Api.StickerSet.parse_stickerSet($0) } dict[539045032] = { return Api.photos.Photo.parse_photo($0) } dict[-208488460] = { return Api.InputContact.parse_inputPhoneContact($0) } dict[-1419371685] = { return Api.TopPeerCategory.parse_topPeerCategoryBotsPM($0) } @@ -310,7 +304,6 @@ fileprivate let parsers: [Int32 : (BufferReader) -> Any?] = { dict[1800845601] = { return Api.payments.PaymentResult.parse_paymentVerficationNeeded($0) } dict[1694474197] = { return Api.messages.Chats.parse_chats($0) } dict[-1663561404] = { return Api.messages.Chats.parse_chatsSlice($0) } - dict[1348066419] = { return Api.FeedPosition.parse_feedPosition($0) } dict[834420005] = { return Api.InputSingleMedia.parse_inputSingleMedia($0) } dict[218751099] = { return Api.InputPrivacyRule.parse_inputPrivacyValueAllowContacts($0) } dict[407582158] = { return Api.InputPrivacyRule.parse_inputPrivacyValueAllowAll($0) } @@ -336,15 +329,12 @@ fileprivate let parsers: [Int32 : (BufferReader) -> Any?] = { dict[-714643696] = { return Api.ChannelAdminLogEventAction.parse_channelAdminLogEventActionParticipantToggleAdmin($0) } dict[-1312568665] = { return Api.ChannelAdminLogEventAction.parse_channelAdminLogEventActionChangeStickerSet($0) } dict[1599903217] = { return Api.ChannelAdminLogEventAction.parse_channelAdminLogEventActionTogglePreHistoryHidden($0) } - dict[1182322895] = { return Api.messages.FeedMessages.parse_feedMessagesNotModified($0) } - dict[1438884273] = { return Api.messages.FeedMessages.parse_feedMessages($0) } dict[-543777747] = { return Api.auth.ExportedAuthorization.parse_exportedAuthorization($0) } dict[-1269012015] = { return Api.messages.AffectedHistory.parse_affectedHistory($0) } dict[-2037289493] = { return Api.account.PasswordInputSettings.parse_passwordInputSettings($0) } dict[649453030] = { return Api.messages.MessageEditData.parse_messageEditData($0) } dict[-886477832] = { return Api.LabeledPrice.parse_labeledPrice($0) } dict[-438840932] = { return Api.messages.ChatFull.parse_chatFull($0) } - dict[-313079300] = { return Api.account.WebAuthorizations.parse_webAuthorizations($0) } dict[-236044656] = { return Api.help.TermsOfService.parse_termsOfService($0) } dict[1490799288] = { return Api.ReportReason.parse_inputReportReasonSpam($0) } dict[505595789] = { return Api.ReportReason.parse_inputReportReasonViolence($0) } @@ -459,7 +449,7 @@ fileprivate let parsers: [Int32 : (BufferReader) -> Any?] = { dict[-1642487306] = { return Api.Message.parse_messageService($0) } dict[1157215293] = { return Api.Message.parse_message($0) } dict[186120336] = { return Api.messages.RecentStickers.parse_recentStickersNotModified($0) } - dict[586395571] = { return Api.messages.RecentStickers.parse_recentStickers($0) } + dict[1558317424] = { return Api.messages.RecentStickers.parse_recentStickers($0) } dict[342061462] = { return Api.InputFileLocation.parse_inputFileLocation($0) } dict[-182231723] = { return Api.InputFileLocation.parse_inputEncryptedFileLocation($0) } dict[1125058340] = { return Api.InputFileLocation.parse_inputDocumentFileLocation($0) } @@ -497,8 +487,6 @@ fileprivate let parsers: [Int32 : (BufferReader) -> Any?] = { dict[1816636575] = { return Api.LangPackString.parse_langPackStringPluralized($0) } dict[695856818] = { return Api.LangPackString.parse_langPackStringDeleted($0) } dict[-1036396922] = { return Api.InputWebFileLocation.parse_inputWebFileLocation($0) } - dict[-2001655273] = { return Api.channels.FeedSources.parse_feedSourcesNotModified($0) } - dict[-1903441347] = { return Api.channels.FeedSources.parse_feedSources($0) } dict[1436466797] = { return Api.MessageFwdHeader.parse_messageFwdHeader($0) } dict[398898678] = { return Api.help.Support.parse_support($0) } dict[1474492012] = { return Api.MessagesFilter.parse_inputMessagesFilterEmpty($0) } @@ -580,8 +568,6 @@ fileprivate let parsers: [Int32 : (BufferReader) -> Any?] = { dict[1355435489] = { return Api.PhoneCall.parse_phoneCallDiscarded($0) } dict[-1378534221] = { return Api.PeerNotifyEvents.parse_peerNotifyEventsEmpty($0) } dict[1830677896] = { return Api.PeerNotifyEvents.parse_peerNotifyEventsAll($0) } - dict[-633170927] = { return Api.DialogPeer.parse_dialogPeerFeed($0) } - dict[-445792507] = { return Api.DialogPeer.parse_dialogPeer($0) } dict[1599050311] = { return Api.ContactLink.parse_contactLinkUnknown($0) } dict[-17968211] = { return Api.ContactLink.parse_contactLinkNone($0) } dict[646922073] = { return Api.ContactLink.parse_contactLinkHasPhone($0) } @@ -630,7 +616,6 @@ fileprivate let parsers: [Int32 : (BufferReader) -> Any?] = { dict[922273905] = { return Api.Document.parse_documentEmpty($0) } dict[-2027738169] = { 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) } return dict }() @@ -755,8 +740,6 @@ public struct Api { _1.serialize(buffer, boxed) case let _1 as Api.Dialog: _1.serialize(buffer, boxed) - case let _1 as Api.FeedBroadcasts: - _1.serialize(buffer, boxed) case let _1 as Api.SendMessageAction: _1.serialize(buffer, boxed) case let _1 as Api.PrivacyKey: @@ -769,8 +752,6 @@ public struct Api { _1.serialize(buffer, boxed) case let _1 as Api.contacts.Blocked: _1.serialize(buffer, boxed) - case let _1 as Api.InputDialogPeer: - _1.serialize(buffer, boxed) case let _1 as Api.Error: _1.serialize(buffer, boxed) case let _1 as Api.KeyboardButton: @@ -835,8 +816,6 @@ public struct Api { _1.serialize(buffer, boxed) case let _1 as Api.messages.Chats: _1.serialize(buffer, boxed) - case let _1 as Api.FeedPosition: - _1.serialize(buffer, boxed) case let _1 as Api.InputSingleMedia: _1.serialize(buffer, boxed) case let _1 as Api.InputPrivacyRule: @@ -845,8 +824,6 @@ public struct Api { _1.serialize(buffer, boxed) case let _1 as Api.ChannelAdminLogEventAction: _1.serialize(buffer, boxed) - case let _1 as Api.messages.FeedMessages: - _1.serialize(buffer, boxed) case let _1 as Api.auth.ExportedAuthorization: _1.serialize(buffer, boxed) case let _1 as Api.messages.AffectedHistory: @@ -859,8 +836,6 @@ public struct Api { _1.serialize(buffer, boxed) case let _1 as Api.messages.ChatFull: _1.serialize(buffer, boxed) - case let _1 as Api.account.WebAuthorizations: - _1.serialize(buffer, boxed) case let _1 as Api.help.TermsOfService: _1.serialize(buffer, boxed) case let _1 as Api.ReportReason: @@ -1017,8 +992,6 @@ public struct Api { _1.serialize(buffer, boxed) case let _1 as Api.InputWebFileLocation: _1.serialize(buffer, boxed) - case let _1 as Api.channels.FeedSources: - _1.serialize(buffer, boxed) case let _1 as Api.MessageFwdHeader: _1.serialize(buffer, boxed) case let _1 as Api.help.Support: @@ -1063,8 +1036,6 @@ public struct Api { _1.serialize(buffer, boxed) case let _1 as Api.PeerNotifyEvents: _1.serialize(buffer, boxed) - case let _1 as Api.DialogPeer: - _1.serialize(buffer, boxed) case let _1 as Api.ContactLink: _1.serialize(buffer, boxed) case let _1 as Api.WebDocument: @@ -1103,8 +1074,6 @@ public struct Api { _1.serialize(buffer, boxed) case let _1 as Api.messages.HighScores: _1.serialize(buffer, boxed) - case let _1 as Api.WebAuthorization: - _1.serialize(buffer, boxed) case let _1 as Api.ImportedContact: _1.serialize(buffer, boxed) default: @@ -1565,92 +1534,6 @@ public struct Api { } - public enum FeedMessages { - case feedMessagesNotModified - case feedMessages(flags: Int32, maxPosition: Api.FeedPosition?, minPosition: Api.FeedPosition?, readMaxPosition: Api.FeedPosition?, messages: [Api.Message], chats: [Api.Chat], users: [Api.User]) - - public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) { - switch self { - case .feedMessagesNotModified: - if boxed { - buffer.appendInt32(1182322895) - } - - break - case .feedMessages(let flags, let maxPosition, let minPosition, let readMaxPosition, let messages, let chats, let users): - if boxed { - buffer.appendInt32(1438884273) - } - serializeInt32(flags, buffer: buffer, boxed: false) - if Int(flags) & Int(1 << 0) != 0 {maxPosition!.serialize(buffer, true)} - if Int(flags) & Int(1 << 1) != 0 {minPosition!.serialize(buffer, true)} - if Int(flags) & Int(1 << 2) != 0 {readMaxPosition!.serialize(buffer, true)} - buffer.appendInt32(481674261) - buffer.appendInt32(Int32(messages.count)) - for item in messages { - item.serialize(buffer, true) - } - buffer.appendInt32(481674261) - buffer.appendInt32(Int32(chats.count)) - for item in chats { - item.serialize(buffer, true) - } - buffer.appendInt32(481674261) - buffer.appendInt32(Int32(users.count)) - for item in users { - item.serialize(buffer, true) - } - break - } - } - - fileprivate static func parse_feedMessagesNotModified(_ reader: BufferReader) -> FeedMessages? { - return Api.messages.FeedMessages.feedMessagesNotModified - } - fileprivate static func parse_feedMessages(_ reader: BufferReader) -> FeedMessages? { - var _1: Int32? - _1 = reader.readInt32() - var _2: Api.FeedPosition? - if Int(_1!) & Int(1 << 0) != 0 {if let signature = reader.readInt32() { - _2 = Api.parse(reader, signature: signature) as? Api.FeedPosition - } } - var _3: Api.FeedPosition? - if Int(_1!) & Int(1 << 1) != 0 {if let signature = reader.readInt32() { - _3 = Api.parse(reader, signature: signature) as? Api.FeedPosition - } } - var _4: Api.FeedPosition? - if Int(_1!) & Int(1 << 2) != 0 {if let signature = reader.readInt32() { - _4 = Api.parse(reader, signature: signature) as? Api.FeedPosition - } } - var _5: [Api.Message]? - if let _ = reader.readInt32() { - _5 = Api.parseVector(reader, elementSignature: 0, elementType: Api.Message.self) - } - var _6: [Api.Chat]? - if let _ = reader.readInt32() { - _6 = Api.parseVector(reader, elementSignature: 0, elementType: Api.Chat.self) - } - var _7: [Api.User]? - if let _ = reader.readInt32() { - _7 = Api.parseVector(reader, elementSignature: 0, elementType: Api.User.self) - } - let _c1 = _1 != nil - let _c2 = (Int(_1!) & Int(1 << 0) == 0) || _2 != nil - let _c3 = (Int(_1!) & Int(1 << 1) == 0) || _3 != nil - let _c4 = (Int(_1!) & Int(1 << 2) == 0) || _4 != nil - let _c5 = _5 != nil - let _c6 = _6 != nil - let _c7 = _7 != nil - if _c1 && _c2 && _c3 && _c4 && _c5 && _c6 && _c7 { - return Api.messages.FeedMessages.feedMessages(flags: _1!, maxPosition: _2, minPosition: _3, readMaxPosition: _4, messages: _5!, chats: _6!, users: _7!) - } - else { - return nil - } - } - - } - public enum AffectedHistory { case affectedHistory(pts: Int32, ptsCount: Int32, offset: Int32) @@ -2137,7 +2020,7 @@ public struct Api { public enum RecentStickers { case recentStickersNotModified - case recentStickers(hash: Int32, packs: [Api.StickerPack], stickers: [Api.Document], dates: [Int32]) + case recentStickers(hash: Int32, stickers: [Api.Document]) public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) { switch self { @@ -2147,26 +2030,16 @@ public struct Api { } break - case .recentStickers(let hash, let packs, let stickers, let dates): + case .recentStickers(let hash, let stickers): if boxed { - buffer.appendInt32(586395571) + buffer.appendInt32(1558317424) } serializeInt32(hash, buffer: buffer, boxed: false) buffer.appendInt32(481674261) - buffer.appendInt32(Int32(packs.count)) - for item in packs { - item.serialize(buffer, true) - } - buffer.appendInt32(481674261) buffer.appendInt32(Int32(stickers.count)) for item in stickers { item.serialize(buffer, true) } - buffer.appendInt32(481674261) - buffer.appendInt32(Int32(dates.count)) - for item in dates { - serializeInt32(item, buffer: buffer, boxed: false) - } break } } @@ -2177,24 +2050,14 @@ public struct Api { fileprivate static func parse_recentStickers(_ reader: BufferReader) -> RecentStickers? { var _1: Int32? _1 = reader.readInt32() - var _2: [Api.StickerPack]? + var _2: [Api.Document]? if let _ = reader.readInt32() { - _2 = Api.parseVector(reader, elementSignature: 0, elementType: Api.StickerPack.self) - } - var _3: [Api.Document]? - if let _ = reader.readInt32() { - _3 = Api.parseVector(reader, elementSignature: 0, elementType: Api.Document.self) - } - var _4: [Int32]? - if let _ = reader.readInt32() { - _4 = Api.parseVector(reader, elementSignature: -1471112230, elementType: Int32.self) + _2 = Api.parseVector(reader, elementSignature: 0, elementType: Api.Document.self) } let _c1 = _1 != nil let _c2 = _2 != nil - let _c3 = _3 != nil - let _c4 = _4 != nil - if _c1 && _c2 && _c3 && _c4 { - return Api.messages.RecentStickers.recentStickers(hash: _1!, packs: _2!, stickers: _3!, dates: _4!) + if _c1 && _c2 { + return Api.messages.RecentStickers.recentStickers(hash: _1!, stickers: _2!) } else { return nil @@ -3497,7 +3360,7 @@ public struct Api { case chat(flags: Int32, id: Int32, title: String, photo: Api.ChatPhoto, participantsCount: Int32, date: Int32, version: Int32, migratedTo: Api.InputChannel?) case chatForbidden(id: Int32, title: String) case channelForbidden(flags: Int32, id: Int32, accessHash: Int64, title: String, untilDate: Int32?) - case channel(flags: Int32, id: Int32, accessHash: Int64?, title: String, username: String?, photo: Api.ChatPhoto, date: Int32, version: Int32, restrictionReason: String?, adminRights: Api.ChannelAdminRights?, bannedRights: Api.ChannelBannedRights?, participantsCount: Int32?, feedId: Int32?) + case channel(flags: Int32, id: Int32, accessHash: Int64?, title: String, username: String?, photo: Api.ChatPhoto, date: Int32, version: Int32, restrictionReason: String?, adminRights: Api.ChannelAdminRights?, bannedRights: Api.ChannelBannedRights?, participantsCount: Int32?) public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) { switch self { @@ -3537,9 +3400,9 @@ public struct Api { serializeString(title, buffer: buffer, boxed: false) if Int(flags) & Int(1 << 16) != 0 {serializeInt32(untilDate!, 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 participantsCount, let feedId): + 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 participantsCount): if boxed { - buffer.appendInt32(-930515796) + buffer.appendInt32(1158377749) } serializeInt32(flags, buffer: buffer, boxed: false) serializeInt32(id, buffer: buffer, boxed: false) @@ -3553,7 +3416,6 @@ public struct Api { if Int(flags) & Int(1 << 14) != 0 {adminRights!.serialize(buffer, true)} if Int(flags) & Int(1 << 15) != 0 {bannedRights!.serialize(buffer, true)} if Int(flags) & Int(1 << 17) != 0 {serializeInt32(participantsCount!, buffer: buffer, boxed: false)} - if Int(flags) & Int(1 << 18) != 0 {serializeInt32(feedId!, buffer: buffer, boxed: false)} break } } @@ -3673,8 +3535,6 @@ public struct Api { } } var _12: Int32? if Int(_1!) & Int(1 << 17) != 0 {_12 = reader.readInt32() } - var _13: Int32? - if Int(_1!) & Int(1 << 18) != 0 {_13 = reader.readInt32() } let _c1 = _1 != nil let _c2 = _2 != nil let _c3 = (Int(_1!) & Int(1 << 13) == 0) || _3 != nil @@ -3687,9 +3547,8 @@ public struct Api { 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 << 17) == 0) || _12 != nil - let _c13 = (Int(_1!) & Int(1 << 18) == 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, participantsCount: _12, feedId: _13) + 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!, version: _8!, restrictionReason: _9, adminRights: _10, bannedRights: _11, participantsCount: _12) } else { return nil @@ -4824,7 +4683,6 @@ public struct Api { public enum Dialog { case dialog(flags: Int32, peer: Api.Peer, topMessage: Int32, readInboxMaxId: Int32, readOutboxMaxId: Int32, unreadCount: Int32, unreadMentionsCount: Int32, notifySettings: Api.PeerNotifySettings, pts: Int32?, draft: Api.DraftMessage?) - case dialogFeed(flags: Int32, peer: Api.Peer, topMessage: Int32, feedId: Int32, feedOtherChannels: [Int32], readMaxPosition: Api.FeedPosition?, unreadCount: Int32, unreadMutedCount: Int32) public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) { switch self { @@ -4843,23 +4701,6 @@ public struct Api { if Int(flags) & Int(1 << 0) != 0 {serializeInt32(pts!, buffer: buffer, boxed: false)} if Int(flags) & Int(1 << 1) != 0 {draft!.serialize(buffer, true)} break - case .dialogFeed(let flags, let peer, let topMessage, let feedId, let feedOtherChannels, let readMaxPosition, let unreadCount, let unreadMutedCount): - if boxed { - buffer.appendInt32(906521922) - } - serializeInt32(flags, buffer: buffer, boxed: false) - peer.serialize(buffer, true) - serializeInt32(topMessage, buffer: buffer, boxed: false) - serializeInt32(feedId, buffer: buffer, boxed: false) - buffer.appendInt32(481674261) - buffer.appendInt32(Int32(feedOtherChannels.count)) - for item in feedOtherChannels { - serializeInt32(item, buffer: buffer, boxed: false) - } - if Int(flags) & Int(1 << 3) != 0 {readMaxPosition!.serialize(buffer, true)} - serializeInt32(unreadCount, buffer: buffer, boxed: false) - serializeInt32(unreadMutedCount, buffer: buffer, boxed: false) - break } } @@ -4907,106 +4748,6 @@ public struct Api { return nil } } - fileprivate static func parse_dialogFeed(_ reader: BufferReader) -> Dialog? { - var _1: Int32? - _1 = reader.readInt32() - var _2: Api.Peer? - if let signature = reader.readInt32() { - _2 = Api.parse(reader, signature: signature) as? Api.Peer - } - var _3: Int32? - _3 = reader.readInt32() - var _4: Int32? - _4 = reader.readInt32() - var _5: [Int32]? - if let _ = reader.readInt32() { - _5 = Api.parseVector(reader, elementSignature: -1471112230, elementType: Int32.self) - } - var _6: Api.FeedPosition? - if Int(_1!) & Int(1 << 3) != 0 {if let signature = reader.readInt32() { - _6 = Api.parse(reader, signature: signature) as? Api.FeedPosition - } } - var _7: Int32? - _7 = reader.readInt32() - var _8: Int32? - _8 = reader.readInt32() - let _c1 = _1 != nil - let _c2 = _2 != nil - let _c3 = _3 != nil - let _c4 = _4 != nil - let _c5 = _5 != nil - let _c6 = (Int(_1!) & Int(1 << 3) == 0) || _6 != nil - let _c7 = _7 != nil - let _c8 = _8 != nil - if _c1 && _c2 && _c3 && _c4 && _c5 && _c6 && _c7 && _c8 { - return Api.Dialog.dialogFeed(flags: _1!, peer: _2!, topMessage: _3!, feedId: _4!, feedOtherChannels: _5!, readMaxPosition: _6, unreadCount: _7!, unreadMutedCount: _8!) - } - else { - return nil - } - } - - } - - public enum FeedBroadcasts { - case feedBroadcasts(feedId: Int32, channels: [Int32]) - case feedBroadcastsUngrouped(channels: [Int32]) - - public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) { - switch self { - case .feedBroadcasts(let feedId, let channels): - if boxed { - buffer.appendInt32(1330637553) - } - serializeInt32(feedId, buffer: buffer, boxed: false) - buffer.appendInt32(481674261) - buffer.appendInt32(Int32(channels.count)) - for item in channels { - serializeInt32(item, buffer: buffer, boxed: false) - } - break - case .feedBroadcastsUngrouped(let channels): - if boxed { - buffer.appendInt32(-1704428358) - } - buffer.appendInt32(481674261) - buffer.appendInt32(Int32(channels.count)) - for item in channels { - serializeInt32(item, buffer: buffer, boxed: false) - } - break - } - } - - fileprivate static func parse_feedBroadcasts(_ reader: BufferReader) -> FeedBroadcasts? { - var _1: Int32? - _1 = reader.readInt32() - var _2: [Int32]? - if let _ = reader.readInt32() { - _2 = Api.parseVector(reader, elementSignature: -1471112230, elementType: Int32.self) - } - let _c1 = _1 != nil - let _c2 = _2 != nil - if _c1 && _c2 { - return Api.FeedBroadcasts.feedBroadcasts(feedId: _1!, channels: _2!) - } - else { - return nil - } - } - fileprivate static func parse_feedBroadcastsUngrouped(_ reader: BufferReader) -> FeedBroadcasts? { - var _1: [Int32]? - if let _ = reader.readInt32() { - _1 = Api.parseVector(reader, elementSignature: -1471112230, elementType: Int32.self) - } - let _c1 = _1 != nil - if _c1 { - return Api.FeedBroadcasts.feedBroadcastsUngrouped(channels: _1!) - } - else { - return nil - } - } } @@ -5276,6 +5017,8 @@ public struct Api { case updateConfig case updatePtsChanged case updateChannelWebPage(channelId: Int32, webpage: Api.WebPage, pts: Int32, ptsCount: Int32) + case updateDialogPinned(flags: Int32, peer: Api.Peer) + case updatePinnedDialogs(flags: Int32, order: [Api.Peer]?) 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) @@ -5287,9 +5030,6 @@ public struct Api { case updateChannelReadMessagesContents(channelId: Int32, messages: [Int32]) case updateContactsReset case updateChannelAvailableMessages(channelId: Int32, availableMinId: Int32) - case updateReadFeed(flags: Int32, feedId: Int32, maxPosition: Api.FeedPosition, unreadCount: Int32?, unreadMutedCount: Int32?) - case updateDialogPinned(flags: Int32, peer: Api.DialogPeer) - case updatePinnedDialogs(flags: Int32, order: [Api.DialogPeer]?) public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) { switch self { @@ -5735,6 +5475,24 @@ public struct Api { serializeInt32(pts, buffer: buffer, boxed: false) serializeInt32(ptsCount, buffer: buffer, boxed: false) break + case .updateDialogPinned(let flags, let peer): + if boxed { + buffer.appendInt32(-686710068) + } + serializeInt32(flags, buffer: buffer, boxed: false) + peer.serialize(buffer, true) + break + case .updatePinnedDialogs(let flags, let order): + if boxed { + buffer.appendInt32(-657787251) + } + serializeInt32(flags, buffer: buffer, boxed: false) + if Int(flags) & Int(1 << 0) != 0 {buffer.appendInt32(481674261) + buffer.appendInt32(Int32(order!.count)) + for item in order! { + item.serialize(buffer, true) + }} + break case .updateBotWebhookJSON(let data): if boxed { buffer.appendInt32(-2095595325) @@ -5819,34 +5577,6 @@ public struct Api { serializeInt32(channelId, buffer: buffer, boxed: false) serializeInt32(availableMinId, buffer: buffer, boxed: false) break - case .updateReadFeed(let flags, let feedId, let maxPosition, let unreadCount, let unreadMutedCount): - if boxed { - buffer.appendInt32(1873186369) - } - serializeInt32(flags, buffer: buffer, boxed: false) - serializeInt32(feedId, buffer: buffer, boxed: false) - maxPosition.serialize(buffer, true) - if Int(flags) & Int(1 << 0) != 0 {serializeInt32(unreadCount!, buffer: buffer, boxed: false)} - if Int(flags) & Int(1 << 0) != 0 {serializeInt32(unreadMutedCount!, buffer: buffer, boxed: false)} - break - case .updateDialogPinned(let flags, let peer): - if boxed { - buffer.appendInt32(433225532) - } - serializeInt32(flags, buffer: buffer, boxed: false) - peer.serialize(buffer, true) - break - case .updatePinnedDialogs(let flags, let order): - if boxed { - buffer.appendInt32(-364071333) - } - serializeInt32(flags, buffer: buffer, boxed: false) - if Int(flags) & Int(1 << 0) != 0 {buffer.appendInt32(481674261) - buffer.appendInt32(Int32(order!.count)) - for item in order! { - item.serialize(buffer, true) - }} - break } } @@ -6753,6 +6483,38 @@ public struct Api { return nil } } + fileprivate static func parse_updateDialogPinned(_ reader: BufferReader) -> Update? { + var _1: Int32? + _1 = reader.readInt32() + var _2: Api.Peer? + if let signature = reader.readInt32() { + _2 = Api.parse(reader, signature: signature) as? Api.Peer + } + let _c1 = _1 != nil + let _c2 = _2 != nil + if _c1 && _c2 { + return Api.Update.updateDialogPinned(flags: _1!, peer: _2!) + } + else { + return nil + } + } + fileprivate static func parse_updatePinnedDialogs(_ reader: BufferReader) -> Update? { + var _1: Int32? + _1 = reader.readInt32() + var _2: [Api.Peer]? + if Int(_1!) & Int(1 << 0) != 0 {if let _ = reader.readInt32() { + _2 = Api.parseVector(reader, elementSignature: 0, elementType: Api.Peer.self) + } } + let _c1 = _1 != nil + let _c2 = (Int(_1!) & Int(1 << 0) == 0) || _2 != nil + if _c1 && _c2 { + return Api.Update.updatePinnedDialogs(flags: _1!, order: _2) + } + else { + return nil + } + } fileprivate static func parse_updateBotWebhookJSON(_ reader: BufferReader) -> Update? { var _1: Api.DataJSON? if let signature = reader.readInt32() { @@ -6906,63 +6668,6 @@ public struct Api { return nil } } - fileprivate static func parse_updateReadFeed(_ reader: BufferReader) -> Update? { - var _1: Int32? - _1 = reader.readInt32() - var _2: Int32? - _2 = reader.readInt32() - var _3: Api.FeedPosition? - if let signature = reader.readInt32() { - _3 = Api.parse(reader, signature: signature) as? Api.FeedPosition - } - var _4: Int32? - if Int(_1!) & Int(1 << 0) != 0 {_4 = reader.readInt32() } - var _5: Int32? - if Int(_1!) & Int(1 << 0) != 0 {_5 = reader.readInt32() } - let _c1 = _1 != nil - let _c2 = _2 != nil - let _c3 = _3 != nil - let _c4 = (Int(_1!) & Int(1 << 0) == 0) || _4 != nil - let _c5 = (Int(_1!) & Int(1 << 0) == 0) || _5 != nil - if _c1 && _c2 && _c3 && _c4 && _c5 { - return Api.Update.updateReadFeed(flags: _1!, feedId: _2!, maxPosition: _3!, unreadCount: _4, unreadMutedCount: _5) - } - else { - return nil - } - } - fileprivate static func parse_updateDialogPinned(_ reader: BufferReader) -> Update? { - var _1: Int32? - _1 = reader.readInt32() - var _2: Api.DialogPeer? - if let signature = reader.readInt32() { - _2 = Api.parse(reader, signature: signature) as? Api.DialogPeer - } - let _c1 = _1 != nil - let _c2 = _2 != nil - if _c1 && _c2 { - return Api.Update.updateDialogPinned(flags: _1!, peer: _2!) - } - else { - return nil - } - } - fileprivate static func parse_updatePinnedDialogs(_ reader: BufferReader) -> Update? { - var _1: Int32? - _1 = reader.readInt32() - var _2: [Api.DialogPeer]? - if Int(_1!) & Int(1 << 0) != 0 {if let _ = reader.readInt32() { - _2 = Api.parseVector(reader, elementSignature: 0, elementType: Api.DialogPeer.self) - } } - let _c1 = _1 != nil - let _c2 = (Int(_1!) & Int(1 << 0) == 0) || _2 != nil - if _c1 && _c2 { - return Api.Update.updatePinnedDialogs(flags: _1!, order: _2) - } - else { - return nil - } - } } @@ -7150,54 +6855,6 @@ public struct Api { } - public enum InputDialogPeer { - case inputDialogPeerFeed(feedId: Int32) - case inputDialogPeer(peer: Api.InputPeer) - - public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) { - switch self { - case .inputDialogPeerFeed(let feedId): - if boxed { - buffer.appendInt32(741914831) - } - serializeInt32(feedId, buffer: buffer, boxed: false) - break - case .inputDialogPeer(let peer): - if boxed { - buffer.appendInt32(-55902537) - } - peer.serialize(buffer, true) - break - } - } - - fileprivate static func parse_inputDialogPeerFeed(_ reader: BufferReader) -> InputDialogPeer? { - var _1: Int32? - _1 = reader.readInt32() - let _c1 = _1 != nil - if _c1 { - return Api.InputDialogPeer.inputDialogPeerFeed(feedId: _1!) - } - else { - return nil - } - } - fileprivate static func parse_inputDialogPeer(_ reader: BufferReader) -> InputDialogPeer? { - var _1: Api.InputPeer? - if let signature = reader.readInt32() { - _1 = Api.parse(reader, signature: signature) as? Api.InputPeer - } - let _c1 = _1 != nil - if _c1 { - return Api.InputDialogPeer.inputDialogPeer(peer: _1!) - } - else { - return nil - } - } - - } - public enum Error { case error(code: Int32, text: String) @@ -8271,16 +7928,15 @@ public struct Api { } public enum StickerSet { - case stickerSet(flags: Int32, installedDate: Int32?, id: Int64, accessHash: Int64, title: String, shortName: String, count: Int32, hash: Int32) + case stickerSet(flags: Int32, id: Int64, accessHash: Int64, title: String, shortName: String, count: Int32, hash: Int32) public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) { switch self { - case .stickerSet(let flags, let installedDate, let id, let accessHash, let title, let shortName, let count, let hash): + case .stickerSet(let flags, let id, let accessHash, let title, let shortName, let count, let hash): if boxed { - buffer.appendInt32(1434820921) + buffer.appendInt32(-852477119) } serializeInt32(flags, buffer: buffer, boxed: false) - if Int(flags) & Int(1 << 0) != 0 {serializeInt32(installedDate!, buffer: buffer, boxed: false)} serializeInt64(id, buffer: buffer, boxed: false) serializeInt64(accessHash, buffer: buffer, boxed: false) serializeString(title, buffer: buffer, boxed: false) @@ -8294,30 +7950,27 @@ public struct Api { fileprivate static func parse_stickerSet(_ reader: BufferReader) -> StickerSet? { var _1: Int32? _1 = reader.readInt32() - var _2: Int32? - if Int(_1!) & Int(1 << 0) != 0 {_2 = reader.readInt32() } + var _2: Int64? + _2 = reader.readInt64() var _3: Int64? _3 = reader.readInt64() - var _4: Int64? - _4 = reader.readInt64() + var _4: String? + _4 = parseString(reader) var _5: String? _5 = parseString(reader) - var _6: String? - _6 = parseString(reader) + var _6: Int32? + _6 = reader.readInt32() var _7: Int32? _7 = reader.readInt32() - var _8: Int32? - _8 = reader.readInt32() let _c1 = _1 != nil - let _c2 = (Int(_1!) & Int(1 << 0) == 0) || _2 != nil + let _c2 = _2 != nil let _c3 = _3 != nil let _c4 = _4 != nil let _c5 = _5 != nil let _c6 = _6 != nil let _c7 = _7 != nil - let _c8 = _8 != nil - if _c1 && _c2 && _c3 && _c4 && _c5 && _c6 && _c7 && _c8 { - return Api.StickerSet.stickerSet(flags: _1!, installedDate: _2, id: _3!, accessHash: _4!, title: _5!, shortName: _6!, count: _7!, hash: _8!) + if _c1 && _c2 && _c3 && _c4 && _c5 && _c6 && _c7 { + return Api.StickerSet.stickerSet(flags: _1!, id: _2!, accessHash: _3!, title: _4!, shortName: _5!, count: _6!, hash: _7!) } else { return nil @@ -9214,44 +8867,6 @@ public struct Api { } - public enum FeedPosition { - case feedPosition(date: Int32, peer: Api.Peer, id: Int32) - - public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) { - switch self { - case .feedPosition(let date, let peer, let id): - if boxed { - buffer.appendInt32(1348066419) - } - serializeInt32(date, buffer: buffer, boxed: false) - peer.serialize(buffer, true) - serializeInt32(id, buffer: buffer, boxed: false) - break - } - } - - fileprivate static func parse_feedPosition(_ reader: BufferReader) -> FeedPosition? { - var _1: Int32? - _1 = reader.readInt32() - var _2: Api.Peer? - if let signature = reader.readInt32() { - _2 = Api.parse(reader, signature: signature) as? Api.Peer - } - var _3: Int32? - _3 = reader.readInt32() - let _c1 = _1 != nil - let _c2 = _2 != nil - let _c3 = _3 != nil - if _c1 && _c2 && _c3 { - return Api.FeedPosition.feedPosition(date: _1!, peer: _2!, id: _3!) - } - else { - return nil - } - } - - } - public enum InputSingleMedia { case inputSingleMedia(media: Api.InputMedia, flags: Int32, randomId: Int64, message: String, entities: [Api.MessageEntity]?) @@ -15140,54 +14755,6 @@ public struct Api { } - public enum DialogPeer { - case dialogPeerFeed(feedId: Int32) - case dialogPeer(peer: Api.Peer) - - public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) { - switch self { - case .dialogPeerFeed(let feedId): - if boxed { - buffer.appendInt32(-633170927) - } - serializeInt32(feedId, buffer: buffer, boxed: false) - break - case .dialogPeer(let peer): - if boxed { - buffer.appendInt32(-445792507) - } - peer.serialize(buffer, true) - break - } - } - - fileprivate static func parse_dialogPeerFeed(_ reader: BufferReader) -> DialogPeer? { - var _1: Int32? - _1 = reader.readInt32() - let _c1 = _1 != nil - if _c1 { - return Api.DialogPeer.dialogPeerFeed(feedId: _1!) - } - else { - return nil - } - } - fileprivate static func parse_dialogPeer(_ reader: BufferReader) -> DialogPeer? { - var _1: Api.Peer? - if let signature = reader.readInt32() { - _1 = Api.parse(reader, signature: signature) as? Api.Peer - } - let _c1 = _1 != nil - if _c1 { - return Api.DialogPeer.dialogPeer(peer: _1!) - } - else { - return nil - } - } - - } - public enum ContactLink { case contactLinkUnknown case contactLinkNone @@ -16132,66 +15699,6 @@ public struct Api { } - public enum WebAuthorization { - case webAuthorization(hash: Int64, botId: Int32, 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) - } - serializeInt64(hash, buffer: buffer, boxed: false) - serializeInt32(botId, buffer: buffer, boxed: false) - serializeString(domain, buffer: buffer, boxed: false) - serializeString(browser, buffer: buffer, boxed: false) - serializeString(platform, buffer: buffer, boxed: false) - serializeInt32(dateCreated, buffer: buffer, boxed: false) - serializeInt32(dateActive, buffer: buffer, boxed: false) - serializeString(ip, buffer: buffer, boxed: false) - serializeString(region, buffer: buffer, boxed: false) - break - } - } - - fileprivate static func parse_webAuthorization(_ reader: BufferReader) -> WebAuthorization? { - var _1: Int64? - _1 = reader.readInt64() - var _2: Int32? - _2 = reader.readInt32() - var _3: String? - _3 = parseString(reader) - var _4: String? - _4 = parseString(reader) - var _5: String? - _5 = parseString(reader) - var _6: Int32? - _6 = reader.readInt32() - var _7: Int32? - _7 = reader.readInt32() - var _8: String? - _8 = parseString(reader) - var _9: String? - _9 = parseString(reader) - let _c1 = _1 != nil - let _c2 = _2 != nil - let _c3 = _3 != nil - let _c4 = _4 != nil - let _c5 = _5 != nil - let _c6 = _6 != nil - let _c7 = _7 != nil - let _c8 = _8 != nil - let _c9 = _9 != nil - if _c1 && _c2 && _c3 && _c4 && _c5 && _c6 && _c7 && _c8 && _c9 { - return Api.WebAuthorization.webAuthorization(hash: _1!, botId: _2!, domain: _3!, browser: _4!, platform: _5!, dateCreated: _6!, dateActive: _7!, ip: _8!, region: _9!) - } - else { - return nil - } - } - - } - public enum ImportedContact { case importedContact(userId: Int32, clientId: Int64) @@ -16323,78 +15830,6 @@ public struct Api { } - public enum FeedSources { - case feedSourcesNotModified - case feedSources(flags: Int32, newlyJoinedFeed: Int32?, feeds: [Api.FeedBroadcasts], chats: [Api.Chat], users: [Api.User]) - - public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) { - switch self { - case .feedSourcesNotModified: - if boxed { - buffer.appendInt32(-2001655273) - } - - break - case .feedSources(let flags, let newlyJoinedFeed, let feeds, let chats, let users): - if boxed { - buffer.appendInt32(-1903441347) - } - serializeInt32(flags, buffer: buffer, boxed: false) - if Int(flags) & Int(1 << 0) != 0 {serializeInt32(newlyJoinedFeed!, buffer: buffer, boxed: false)} - buffer.appendInt32(481674261) - buffer.appendInt32(Int32(feeds.count)) - for item in feeds { - item.serialize(buffer, true) - } - buffer.appendInt32(481674261) - buffer.appendInt32(Int32(chats.count)) - for item in chats { - item.serialize(buffer, true) - } - buffer.appendInt32(481674261) - buffer.appendInt32(Int32(users.count)) - for item in users { - item.serialize(buffer, true) - } - break - } - } - - fileprivate static func parse_feedSourcesNotModified(_ reader: BufferReader) -> FeedSources? { - return Api.channels.FeedSources.feedSourcesNotModified - } - fileprivate static func parse_feedSources(_ reader: BufferReader) -> FeedSources? { - var _1: Int32? - _1 = reader.readInt32() - var _2: Int32? - if Int(_1!) & Int(1 << 0) != 0 {_2 = reader.readInt32() } - var _3: [Api.FeedBroadcasts]? - if let _ = reader.readInt32() { - _3 = Api.parseVector(reader, elementSignature: 0, elementType: Api.FeedBroadcasts.self) - } - var _4: [Api.Chat]? - if let _ = reader.readInt32() { - _4 = Api.parseVector(reader, elementSignature: 0, elementType: Api.Chat.self) - } - var _5: [Api.User]? - if let _ = reader.readInt32() { - _5 = Api.parseVector(reader, elementSignature: 0, elementType: Api.User.self) - } - let _c1 = _1 != nil - let _c2 = (Int(_1!) & Int(1 << 0) == 0) || _2 != nil - let _c3 = _3 != nil - let _c4 = _4 != nil - let _c5 = _5 != nil - if _c1 && _c2 && _c3 && _c4 && _c5 { - return Api.channels.FeedSources.feedSources(flags: _1!, newlyJoinedFeed: _2, feeds: _3!, chats: _4!, users: _5!) - } - else { - return nil - } - } - - } - public enum AdminLogResults { case adminLogResults(events: [Api.ChannelAdminLogEvent], chats: [Api.Chat], users: [Api.User]) @@ -18461,50 +17896,6 @@ public struct Api { } - public enum WebAuthorizations { - case webAuthorizations(authorizations: [Api.WebAuthorization], users: [Api.User]) - - public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) { - switch self { - case .webAuthorizations(let authorizations, let users): - if boxed { - buffer.appendInt32(-313079300) - } - buffer.appendInt32(481674261) - buffer.appendInt32(Int32(authorizations.count)) - for item in authorizations { - item.serialize(buffer, true) - } - buffer.appendInt32(481674261) - buffer.appendInt32(Int32(users.count)) - for item in users { - item.serialize(buffer, true) - } - break - } - } - - fileprivate static func parse_webAuthorizations(_ reader: BufferReader) -> WebAuthorizations? { - var _1: [Api.WebAuthorization]? - if let _ = reader.readInt32() { - _1 = Api.parseVector(reader, elementSignature: 0, elementType: Api.WebAuthorization.self) - } - var _2: [Api.User]? - if let _ = reader.readInt32() { - _2 = Api.parseVector(reader, elementSignature: 0, elementType: Api.User.self) - } - let _c1 = _1 != nil - let _c2 = _2 != nil - if _c1 && _c2 { - return Api.account.WebAuthorizations.webAuthorizations(authorizations: _1!, users: _2!) - } - else { - return nil - } - } - - } - public enum Authorizations { case authorizations(authorizations: [Api.Authorization]) @@ -18838,6 +18229,24 @@ public struct Api { }) } + public static func getDialogs(flags: Int32, offsetDate: Int32, offsetId: Int32, offsetPeer: Api.InputPeer, limit: Int32) -> (CustomStringConvertible, Buffer, (Buffer) -> Api.messages.Dialogs?) { + let buffer = Buffer() + buffer.appendInt32(421243333) + serializeInt32(flags, 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) + return (FunctionDescription({return "(messages.getDialogs flags: \(flags), offsetDate: \(offsetDate), offsetId: \(offsetId), offsetPeer: \(offsetPeer), limit: \(limit))"}), buffer, { (buffer: Buffer) -> Api.messages.Dialogs? in + let reader = BufferReader(buffer) + var result: Api.messages.Dialogs? + if let signature = reader.readInt32() { + result = Api.parse(reader, signature: signature) as? Api.messages.Dialogs + } + return result + }) + } + public static func getHistory(peer: Api.InputPeer, offsetId: Int32, offsetDate: Int32, addOffset: Int32, limit: Int32, maxId: Int32, minId: Int32, hash: Int32) -> (CustomStringConvertible, Buffer, (Buffer) -> Api.messages.Messages?) { let buffer = Buffer() buffer.appendInt32(-591691168) @@ -19753,6 +19162,24 @@ public struct Api { }) } + public static func getPeerDialogs(peers: [Api.InputPeer]) -> (CustomStringConvertible, Buffer, (Buffer) -> Api.messages.PeerDialogs?) { + let buffer = Buffer() + buffer.appendInt32(764901049) + buffer.appendInt32(481674261) + buffer.appendInt32(Int32(peers.count)) + for item in peers { + item.serialize(buffer, true) + } + return (FunctionDescription({return "(messages.getPeerDialogs peers: \(peers))"}), buffer, { (buffer: Buffer) -> Api.messages.PeerDialogs? in + let reader = BufferReader(buffer) + var result: Api.messages.PeerDialogs? + if let signature = reader.readInt32() { + result = Api.parse(reader, signature: signature) as? Api.messages.PeerDialogs + } + return result + }) + } + public static func saveDraft(flags: Int32, replyToMsgId: Int32?, peer: Api.InputPeer, message: String, entities: [Api.MessageEntity]?) -> (CustomStringConvertible, Buffer, (Buffer) -> Api.Bool?) { let buffer = Buffer() buffer.appendInt32(-1137057461) @@ -20025,6 +19452,40 @@ public struct Api { }) } + public static func toggleDialogPin(flags: Int32, peer: Api.InputPeer) -> (CustomStringConvertible, Buffer, (Buffer) -> Api.Bool?) { + let buffer = Buffer() + buffer.appendInt32(847887978) + serializeInt32(flags, buffer: buffer, boxed: false) + peer.serialize(buffer, true) + return (FunctionDescription({return "(messages.toggleDialogPin flags: \(flags), peer: \(peer))"}), buffer, { (buffer: Buffer) -> Api.Bool? in + let reader = BufferReader(buffer) + var result: Api.Bool? + if let signature = reader.readInt32() { + result = Api.parse(reader, signature: signature) as? Api.Bool + } + return result + }) + } + + public static func reorderPinnedDialogs(flags: Int32, order: [Api.InputPeer]) -> (CustomStringConvertible, Buffer, (Buffer) -> Api.Bool?) { + let buffer = Buffer() + buffer.appendInt32(-1784678844) + serializeInt32(flags, buffer: buffer, boxed: false) + buffer.appendInt32(481674261) + buffer.appendInt32(Int32(order.count)) + for item in order { + item.serialize(buffer, true) + } + return (FunctionDescription({return "(messages.reorderPinnedDialogs flags: \(flags), order: \(order))"}), buffer, { (buffer: Buffer) -> Api.Bool? in + let reader = BufferReader(buffer) + var result: Api.Bool? + if let signature = reader.readInt32() { + result = Api.parse(reader, signature: signature) as? Api.Bool + } + return result + }) + } + public static func getPinnedDialogs() -> (CustomStringConvertible, Buffer, (Buffer) -> Api.messages.PeerDialogs?) { let buffer = Buffer() buffer.appendInt32(-497756594) @@ -20121,6 +19582,31 @@ public struct Api { }) } + public static func search(flags: Int32, peer: Api.InputPeer, q: String, fromId: Api.InputUser?, filter: Api.MessagesFilter, minDate: Int32, maxDate: Int32, offsetId: Int32, addOffset: Int32, limit: Int32, maxId: Int32, minId: Int32) -> (CustomStringConvertible, Buffer, (Buffer) -> Api.messages.Messages?) { + let buffer = Buffer() + buffer.appendInt32(60726944) + serializeInt32(flags, buffer: buffer, boxed: false) + peer.serialize(buffer, true) + serializeString(q, buffer: buffer, boxed: false) + if Int(flags) & Int(1 << 0) != 0 {fromId!.serialize(buffer, true)} + filter.serialize(buffer, true) + serializeInt32(minDate, buffer: buffer, boxed: false) + serializeInt32(maxDate, buffer: buffer, boxed: false) + serializeInt32(offsetId, buffer: buffer, boxed: false) + serializeInt32(addOffset, buffer: buffer, boxed: false) + serializeInt32(limit, buffer: buffer, boxed: false) + serializeInt32(maxId, buffer: buffer, boxed: false) + serializeInt32(minId, buffer: buffer, boxed: false) + return (FunctionDescription({return "(messages.search flags: \(flags), peer: \(peer), q: \(q), fromId: \(String(describing: fromId)), filter: \(filter), minDate: \(minDate), maxDate: \(maxDate), offsetId: \(offsetId), addOffset: \(addOffset), limit: \(limit), maxId: \(maxId), minId: \(minId))"}), buffer, { (buffer: Buffer) -> Api.messages.Messages? in + let reader = BufferReader(buffer) + var result: Api.messages.Messages? + if let signature = reader.readInt32() { + result = Api.parse(reader, signature: signature) as? Api.messages.Messages + } + return result + }) + } + public static func getUnreadMentions(peer: Api.InputPeer, offsetId: Int32, addOffset: Int32, limit: Int32, maxId: Int32, minId: Int32) -> (CustomStringConvertible, Buffer, (Buffer) -> Api.messages.Messages?) { let buffer = Buffer() buffer.appendInt32(1180140658) @@ -20171,6 +19657,21 @@ public struct Api { }) } + public static func getRecentLocations(peer: Api.InputPeer, limit: Int32) -> (CustomStringConvertible, Buffer, (Buffer) -> Api.messages.Messages?) { + let buffer = Buffer() + buffer.appendInt32(613691874) + peer.serialize(buffer, true) + serializeInt32(limit, buffer: buffer, boxed: false) + return (FunctionDescription({return "(messages.getRecentLocations peer: \(peer), limit: \(limit))"}), buffer, { (buffer: Buffer) -> Api.messages.Messages? in + let reader = BufferReader(buffer) + var result: Api.messages.Messages? + if let signature = reader.readInt32() { + result = Api.parse(reader, signature: signature) as? Api.messages.Messages + } + return result + }) + } + public static func uploadMedia(peer: Api.InputPeer, media: Api.InputMedia) -> (CustomStringConvertible, Buffer, (Buffer) -> Api.MessageMedia?) { let buffer = Buffer() buffer.appendInt32(1369162417) @@ -20292,135 +19793,6 @@ public struct Api { return result }) } - - public static func getDialogs(flags: Int32, feedId: Int32?, offsetDate: Int32, offsetId: Int32, offsetPeer: Api.InputPeer, limit: Int32) -> (CustomStringConvertible, Buffer, (Buffer) -> Api.messages.Dialogs?) { - let buffer = Buffer() - buffer.appendInt32(96533218) - serializeInt32(flags, buffer: buffer, boxed: false) - if Int(flags) & Int(1 << 1) != 0 {serializeInt32(feedId!, 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) - return (FunctionDescription({return "(messages.getDialogs flags: \(flags), feedId: \(String(describing: feedId)), offsetDate: \(offsetDate), offsetId: \(offsetId), offsetPeer: \(offsetPeer), limit: \(limit))"}), buffer, { (buffer: Buffer) -> Api.messages.Dialogs? in - let reader = BufferReader(buffer) - var result: Api.messages.Dialogs? - if let signature = reader.readInt32() { - result = Api.parse(reader, signature: signature) as? Api.messages.Dialogs - } - return result - }) - } - - public static func toggleDialogPin(flags: Int32, peer: Api.InputDialogPeer) -> (CustomStringConvertible, Buffer, (Buffer) -> Api.Bool?) { - let buffer = Buffer() - buffer.appendInt32(-1489903017) - serializeInt32(flags, buffer: buffer, boxed: false) - peer.serialize(buffer, true) - return (FunctionDescription({return "(messages.toggleDialogPin flags: \(flags), peer: \(peer))"}), buffer, { (buffer: Buffer) -> Api.Bool? in - let reader = BufferReader(buffer) - var result: Api.Bool? - if let signature = reader.readInt32() { - result = Api.parse(reader, signature: signature) as? Api.Bool - } - return result - }) - } - - public static func reorderPinnedDialogs(flags: Int32, order: [Api.InputDialogPeer]) -> (CustomStringConvertible, Buffer, (Buffer) -> Api.Bool?) { - let buffer = Buffer() - buffer.appendInt32(1532089919) - serializeInt32(flags, buffer: buffer, boxed: false) - buffer.appendInt32(481674261) - buffer.appendInt32(Int32(order.count)) - for item in order { - item.serialize(buffer, true) - } - return (FunctionDescription({return "(messages.reorderPinnedDialogs flags: \(flags), order: \(order))"}), buffer, { (buffer: Buffer) -> Api.Bool? in - let reader = BufferReader(buffer) - var result: Api.Bool? - if let signature = reader.readInt32() { - result = Api.parse(reader, signature: signature) as? Api.Bool - } - return result - }) - } - - public static func getPeerDialogs(peers: [Api.InputDialogPeer]) -> (CustomStringConvertible, Buffer, (Buffer) -> Api.messages.PeerDialogs?) { - let buffer = Buffer() - buffer.appendInt32(-462373635) - buffer.appendInt32(481674261) - buffer.appendInt32(Int32(peers.count)) - for item in peers { - item.serialize(buffer, true) - } - return (FunctionDescription({return "(messages.getPeerDialogs peers: \(peers))"}), buffer, { (buffer: Buffer) -> Api.messages.PeerDialogs? in - let reader = BufferReader(buffer) - var result: Api.messages.PeerDialogs? - if let signature = reader.readInt32() { - result = Api.parse(reader, signature: signature) as? Api.messages.PeerDialogs - } - return result - }) - } - - public static func getRecentLocations(peer: Api.InputPeer, limit: Int32, hash: Int32) -> (CustomStringConvertible, Buffer, (Buffer) -> Api.messages.Messages?) { - let buffer = Buffer() - buffer.appendInt32(-1144759543) - peer.serialize(buffer, true) - serializeInt32(limit, buffer: buffer, boxed: false) - serializeInt32(hash, buffer: buffer, boxed: false) - return (FunctionDescription({return "(messages.getRecentLocations peer: \(peer), limit: \(limit), hash: \(hash))"}), buffer, { (buffer: Buffer) -> Api.messages.Messages? in - let reader = BufferReader(buffer) - var result: Api.messages.Messages? - if let signature = reader.readInt32() { - result = Api.parse(reader, signature: signature) as? Api.messages.Messages - } - return result - }) - } - - public static func search(flags: Int32, peer: Api.InputPeer, q: String, fromId: Api.InputUser?, filter: Api.MessagesFilter, minDate: Int32, maxDate: Int32, offsetId: Int32, addOffset: Int32, limit: Int32, maxId: Int32, minId: Int32, hash: Int32) -> (CustomStringConvertible, Buffer, (Buffer) -> Api.messages.Messages?) { - let buffer = Buffer() - buffer.appendInt32(-2045448344) - serializeInt32(flags, buffer: buffer, boxed: false) - peer.serialize(buffer, true) - serializeString(q, buffer: buffer, boxed: false) - if Int(flags) & Int(1 << 0) != 0 {fromId!.serialize(buffer, true)} - filter.serialize(buffer, true) - serializeInt32(minDate, buffer: buffer, boxed: false) - serializeInt32(maxDate, buffer: buffer, boxed: false) - serializeInt32(offsetId, buffer: buffer, boxed: false) - serializeInt32(addOffset, buffer: buffer, boxed: false) - serializeInt32(limit, buffer: buffer, boxed: false) - serializeInt32(maxId, buffer: buffer, boxed: false) - serializeInt32(minId, buffer: buffer, boxed: false) - serializeInt32(hash, buffer: buffer, boxed: false) - return (FunctionDescription({return "(messages.search flags: \(flags), peer: \(peer), q: \(q), fromId: \(String(describing: fromId)), filter: \(filter), minDate: \(minDate), maxDate: \(maxDate), offsetId: \(offsetId), addOffset: \(addOffset), limit: \(limit), maxId: \(maxId), minId: \(minId), hash: \(hash))"}), buffer, { (buffer: Buffer) -> Api.messages.Messages? in - let reader = BufferReader(buffer) - var result: Api.messages.Messages? - if let signature = reader.readInt32() { - result = Api.parse(reader, signature: signature) as? Api.messages.Messages - } - return result - }) - } - - public static func getStickers(flags: Int32, emoticon: String, hash: String) -> (CustomStringConvertible, Buffer, (Buffer) -> Api.messages.Stickers?) { - let buffer = Buffer() - buffer.appendInt32(-2050272894) - serializeInt32(flags, buffer: buffer, boxed: false) - serializeString(emoticon, buffer: buffer, boxed: false) - serializeString(hash, buffer: buffer, boxed: false) - return (FunctionDescription({return "(messages.getStickers flags: \(flags), emoticon: \(emoticon), hash: \(hash))"}), buffer, { (buffer: Buffer) -> Api.messages.Stickers? in - let reader = BufferReader(buffer) - var result: Api.messages.Stickers? - if let signature = reader.readInt32() { - result = Api.parse(reader, signature: signature) as? Api.messages.Stickers - } - return result - }) - } } public struct channels { public static func readHistory(channel: Api.InputChannel, maxId: Int32) -> (CustomStringConvertible, Buffer, (Buffer) -> Api.Bool?) { @@ -20954,114 +20326,6 @@ public struct Api { return result }) } - - public static func getFeed(flags: Int32, feedId: Int32, offsetPosition: Api.FeedPosition?, addOffset: Int32, limit: Int32, maxPosition: Api.FeedPosition?, minPosition: Api.FeedPosition?, sourcesHash: Int32, hash: Int32) -> (CustomStringConvertible, Buffer, (Buffer) -> Api.messages.FeedMessages?) { - let buffer = Buffer() - buffer.appendInt32(403799538) - serializeInt32(flags, buffer: buffer, boxed: false) - serializeInt32(feedId, buffer: buffer, boxed: false) - if Int(flags) & Int(1 << 0) != 0 {offsetPosition!.serialize(buffer, true)} - serializeInt32(addOffset, buffer: buffer, boxed: false) - serializeInt32(limit, buffer: buffer, boxed: false) - if Int(flags) & Int(1 << 1) != 0 {maxPosition!.serialize(buffer, true)} - if Int(flags) & Int(1 << 2) != 0 {minPosition!.serialize(buffer, true)} - serializeInt32(sourcesHash, buffer: buffer, boxed: false) - serializeInt32(hash, buffer: buffer, boxed: false) - return (FunctionDescription({return "(channels.getFeed flags: \(flags), feedId: \(feedId), offsetPosition: \(String(describing: offsetPosition)), addOffset: \(addOffset), limit: \(limit), maxPosition: \(String(describing: maxPosition)), minPosition: \(String(describing: minPosition)), sourcesHash: \(sourcesHash), hash: \(hash))"}), buffer, { (buffer: Buffer) -> Api.messages.FeedMessages? in - let reader = BufferReader(buffer) - var result: Api.messages.FeedMessages? - if let signature = reader.readInt32() { - result = Api.parse(reader, signature: signature) as? Api.messages.FeedMessages - } - return result - }) - } - - public static func searchFeed(feedId: Int32, q: String, offsetDate: Int32, offsetPeer: Api.InputPeer, offsetId: Int32, limit: Int32) -> (CustomStringConvertible, Buffer, (Buffer) -> Api.messages.Messages?) { - let buffer = Buffer() - buffer.appendInt32(-2009967767) - serializeInt32(feedId, buffer: buffer, boxed: false) - serializeString(q, buffer: buffer, boxed: false) - serializeInt32(offsetDate, buffer: buffer, boxed: false) - offsetPeer.serialize(buffer, true) - serializeInt32(offsetId, buffer: buffer, boxed: false) - serializeInt32(limit, buffer: buffer, boxed: false) - return (FunctionDescription({return "(channels.searchFeed feedId: \(feedId), q: \(q), offsetDate: \(offsetDate), offsetPeer: \(offsetPeer), offsetId: \(offsetId), limit: \(limit))"}), buffer, { (buffer: Buffer) -> Api.messages.Messages? in - let reader = BufferReader(buffer) - var result: Api.messages.Messages? - if let signature = reader.readInt32() { - result = Api.parse(reader, signature: signature) as? Api.messages.Messages - } - return result - }) - } - - public static func getFeedSources(flags: Int32, feedId: Int32?, hash: Int32) -> (CustomStringConvertible, Buffer, (Buffer) -> Api.channels.FeedSources?) { - let buffer = Buffer() - buffer.appendInt32(-657579154) - serializeInt32(flags, buffer: buffer, boxed: false) - if Int(flags) & Int(1 << 0) != 0 {serializeInt32(feedId!, buffer: buffer, boxed: false)} - serializeInt32(hash, buffer: buffer, boxed: false) - return (FunctionDescription({return "(channels.getFeedSources flags: \(flags), feedId: \(String(describing: feedId)), hash: \(hash))"}), buffer, { (buffer: Buffer) -> Api.channels.FeedSources? in - let reader = BufferReader(buffer) - var result: Api.channels.FeedSources? - if let signature = reader.readInt32() { - result = Api.parse(reader, signature: signature) as? Api.channels.FeedSources - } - return result - }) - } - - public static func changeFeedBroadcast(flags: Int32, channel: Api.InputChannel, feedId: Int32?) -> (CustomStringConvertible, Buffer, (Buffer) -> Api.Bool?) { - let buffer = Buffer() - buffer.appendInt32(623413022) - serializeInt32(flags, buffer: buffer, boxed: false) - channel.serialize(buffer, true) - if Int(flags) & Int(1 << 0) != 0 {serializeInt32(feedId!, buffer: buffer, boxed: false)} - return (FunctionDescription({return "(channels.changeFeedBroadcast flags: \(flags), channel: \(channel), feedId: \(String(describing: feedId)))"}), buffer, { (buffer: Buffer) -> Api.Bool? in - let reader = BufferReader(buffer) - var result: Api.Bool? - if let signature = reader.readInt32() { - result = Api.parse(reader, signature: signature) as? Api.Bool - } - return result - }) - } - - public static func setFeedBroadcasts(feedId: Int32, channels: [Api.InputChannel], alsoNewlyJoined: Api.Bool) -> (CustomStringConvertible, Buffer, (Buffer) -> Api.Bool?) { - let buffer = Buffer() - buffer.appendInt32(2123479282) - serializeInt32(feedId, buffer: buffer, boxed: false) - buffer.appendInt32(481674261) - buffer.appendInt32(Int32(channels.count)) - for item in channels { - item.serialize(buffer, true) - } - alsoNewlyJoined.serialize(buffer, true) - return (FunctionDescription({return "(channels.setFeedBroadcasts feedId: \(feedId), channels: \(channels), alsoNewlyJoined: \(alsoNewlyJoined))"}), buffer, { (buffer: Buffer) -> Api.Bool? in - let reader = BufferReader(buffer) - var result: Api.Bool? - if let signature = reader.readInt32() { - result = Api.parse(reader, signature: signature) as? Api.Bool - } - return result - }) - } - - public static func readFeed(feedId: Int32, maxPosition: Api.FeedPosition) -> (CustomStringConvertible, Buffer, (Buffer) -> Api.Updates?) { - let buffer = Buffer() - buffer.appendInt32(163774749) - serializeInt32(feedId, buffer: buffer, boxed: false) - maxPosition.serialize(buffer, true) - return (FunctionDescription({return "(channels.readFeed feedId: \(feedId), maxPosition: \(maxPosition))"}), buffer, { (buffer: Buffer) -> Api.Updates? in - let reader = BufferReader(buffer) - var result: Api.Updates? - if let signature = reader.readInt32() { - result = Api.parse(reader, signature: signature) as? Api.Updates - } - return result - }) - } } public struct payments { public static func getPaymentForm(msgId: Int32) -> (CustomStringConvertible, Buffer, (Buffer) -> Api.payments.PaymentForm?) { @@ -22461,48 +21725,6 @@ public struct Api { return result }) } - - public static func getWebAuthorizations() -> (CustomStringConvertible, Buffer, (Buffer) -> Api.account.WebAuthorizations?) { - let buffer = Buffer() - buffer.appendInt32(405695855) - - return (FunctionDescription({return "(account.getWebAuthorizations )"}), buffer, { (buffer: Buffer) -> Api.account.WebAuthorizations? in - let reader = BufferReader(buffer) - var result: Api.account.WebAuthorizations? - if let signature = reader.readInt32() { - result = Api.parse(reader, signature: signature) as? Api.account.WebAuthorizations - } - return result - }) - } - - public static func resetWebAuthorization(hash: Int64) -> (CustomStringConvertible, Buffer, (Buffer) -> Api.Bool?) { - let buffer = Buffer() - buffer.appendInt32(755087855) - serializeInt64(hash, buffer: buffer, boxed: false) - return (FunctionDescription({return "(account.resetWebAuthorization hash: \(hash))"}), buffer, { (buffer: Buffer) -> Api.Bool? in - let reader = BufferReader(buffer) - var result: Api.Bool? - if let signature = reader.readInt32() { - result = Api.parse(reader, signature: signature) as? Api.Bool - } - return result - }) - } - - public static func resetWebAuthorizations() -> (CustomStringConvertible, Buffer, (Buffer) -> Api.Bool?) { - let buffer = Buffer() - buffer.appendInt32(1747789204) - - return (FunctionDescription({return "(account.resetWebAuthorizations )"}), buffer, { (buffer: Buffer) -> Api.Bool? in - let reader = BufferReader(buffer) - var result: Api.Bool? - if let signature = reader.readInt32() { - result = Api.parse(reader, signature: signature) as? Api.Bool - } - return result - }) - } } public struct langpack { public static func getLangPack(langCode: String) -> (CustomStringConvertible, Buffer, (Buffer) -> Api.LangPackDifference?) { diff --git a/TelegramCore/ApiGroupOrChannel.swift b/TelegramCore/ApiGroupOrChannel.swift index 2bdb6db61a..03618ba6c1 100644 --- a/TelegramCore/ApiGroupOrChannel.swift +++ b/TelegramCore/ApiGroupOrChannel.swift @@ -50,7 +50,9 @@ public func parseTelegramGroupOrChannel(chat: Api.Chat) -> Peer? { return TelegramGroup(id: PeerId(namespace: Namespaces.Peer.CloudGroup, id: id), title: "", photo: [], participantCount: 0, role: .member, membership: .Removed, flags: [], migrationReference: nil, creationDate: 0, version: 0) case let .chatForbidden(id, title): return TelegramGroup(id: PeerId(namespace: Namespaces.Peer.CloudGroup, id: id), title: title, photo: [], participantCount: 0, role: .member, membership: .Removed, flags: [], migrationReference: nil, creationDate: 0, version: 0) - case let .channel(flags, id, accessHash, title, username, photo, date, version, restrictionReason, adminRights, bannedRights, _, feedId): + /*%layer76*/ + case let .channel(flags, id, accessHash, title, username, photo, date, version, restrictionReason, adminRights, bannedRights, _): + let feedId: Int32? = nil let participationStatus: TelegramChannelParticipationStatus if (flags & Int32(1 << 1)) != 0 { participationStatus = .kicked @@ -107,7 +109,9 @@ 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, date, version, restrictionReason, adminRights, bannedRights, _, feedId): + /*%layer76*/ + case let .channel(flags, _, accessHash, title, username, photo, date, version, restrictionReason, adminRights, bannedRights, _): + let feedId: Int32? = nil if accessHash != nil && (flags & (1 << 12)) == 0 { return parseTelegramGroupOrChannel(chat: rhs) } else if let lhs = lhs as? TelegramChannel { diff --git a/TelegramCore/ApplyMaxReadIndexInteractively.swift b/TelegramCore/ApplyMaxReadIndexInteractively.swift index 9ae811633c..f59b647ba1 100644 --- a/TelegramCore/ApplyMaxReadIndexInteractively.swift +++ b/TelegramCore/ApplyMaxReadIndexInteractively.swift @@ -7,7 +7,7 @@ import Foundation import SwiftSignalKit #endif -public func applyMaxReadIndexInteractively(postbox: Postbox, network: Network, index: MessageIndex) -> Signal { +public func applyMaxReadIndexInteractively(postbox: Postbox, network: Network, stateManager: AccountStateManager, index: MessageIndex) -> Signal { return postbox.modify { modifier -> Void in let messageIds = modifier.applyInteractiveReadMaxIndex(index) if index.id.peerId.namespace == Namespaces.Peer.SecretChat { @@ -38,6 +38,8 @@ public func applyMaxReadIndexInteractively(postbox: Postbox, network: Network, i } } } + } else if index.id.peerId.namespace == Namespaces.Peer.CloudUser || index.id.peerId.namespace == Namespaces.Peer.CloudGroup || index.id.peerId.namespace == Namespaces.Peer.CloudChannel { + stateManager.notifyAppliedIncomingReadMessages([index.id]) } } } diff --git a/TelegramCore/ChangePeerNotificationSettings.swift b/TelegramCore/ChangePeerNotificationSettings.swift index 3758fab4ac..8372757e79 100644 --- a/TelegramCore/ChangePeerNotificationSettings.swift +++ b/TelegramCore/ChangePeerNotificationSettings.swift @@ -35,7 +35,7 @@ public func togglePeerMuted(account: Account, peerId: PeerId) -> Signal Signal { +public func updatePeerMuteSetting(account: Account, peerId: PeerId, muteInterval: Int32?) -> Signal { return account.postbox.modify { modifier -> Void in if let peer = modifier.getPeer(peerId) { var notificationPeerId = peerId @@ -51,14 +51,20 @@ public func mutePeer(account: Account, peerId: PeerId, for interval: Int32) -> S previousSettings = TelegramPeerNotificationSettings.defaultSettings } - let absoluteUntil: Int32 - if interval == Int32.max { - absoluteUntil = Int32.max + let muteState: PeerMuteState + if let muteInterval = muteInterval { + let absoluteUntil: Int32 + if muteInterval == Int32.max { + absoluteUntil = Int32.max + } else { + absoluteUntil = Int32(Date().timeIntervalSince1970) + muteInterval + } + muteState = .muted(until: absoluteUntil) } else { - absoluteUntil = Int32(Date().timeIntervalSince1970) + interval + muteState = .unmuted } - let updatedSettings = previousSettings.withUpdatedMuteState(.muted(until: absoluteUntil)) + let updatedSettings = previousSettings.withUpdatedMuteState(muteState) modifier.updatePendingPeerNotificationSettings(peerId: peerId, settings: updatedSettings) } } @@ -85,9 +91,3 @@ public func updatePeerNotificationSoundInteractive(account: Account, peerId: Pee } } } - -public func changePeerNotificationSettings(account: Account, peerId: PeerId, settings: TelegramPeerNotificationSettings) -> Signal { - return account.postbox.modify { modifier -> Void in - modifier.updatePendingPeerNotificationSettings(peerId: peerId, settings: settings) - } -} diff --git a/TelegramCore/FetchChatList.swift b/TelegramCore/FetchChatList.swift index 337b31237a..97d219ee49 100644 --- a/TelegramCore/FetchChatList.swift +++ b/TelegramCore/FetchChatList.swift @@ -106,9 +106,10 @@ private func parseDialogs(apiDialogs: [Api.Dialog], apiMessages: [Api.Message], } notificationSettings[peerId] = TelegramPeerNotificationSettings(apiSettings: apiNotificationSettings) - case let .dialogFeed(_, _, _, feedId, _, _, _, _): + /*%layer76*/ + /*case let .dialogFeed(_, _, _, feedId, _, _, _, _): itemIds.append(.group(PeerGroupId(rawValue: feedId))) - referencedFeeds.insert(PeerGroupId(rawValue: feedId)) + referencedFeeds.insert(PeerGroupId(rawValue: feedId))*/ } } @@ -215,7 +216,8 @@ func fetchChatList(postbox: Postbox, network: Network, location: FetchChatListLo requestFeedId = groupId.rawValue flags |= 1 << 1 } - let requestChats = network.request(Api.functions.messages.getDialogs(flags: flags, feedId: requestFeedId, offsetDate: timestamp, offsetId: id, offsetPeer: peer, limit: 100)) + /*%layer76*/ + let requestChats = network.request(Api.functions.messages.getDialogs(flags: flags/*, feedId: requestFeedId*/, offsetDate: timestamp, offsetId: id, offsetPeer: peer, limit: 100)) |> retryRequest return combineLatest(requestChats, additionalPinnedChats) @@ -235,7 +237,8 @@ func fetchChatList(postbox: Postbox, network: Network, location: FetchChatListLo } var feedSignals: [Signal<(PeerGroupId, ParsedDialogs), NoError>] = [] - if case .general = location { + /*%layer76*/ + /*if case .general = location { for groupId in combinedReferencedFeeds { let flags: Int32 = 1 << 1 let requestFeed = network.request(Api.functions.messages.getDialogs(flags: flags, feedId: groupId.rawValue, offsetDate: 0, offsetId: 0, offsetPeer: .inputPeerEmpty, limit: 4)) @@ -247,7 +250,7 @@ func fetchChatList(postbox: Postbox, network: Network, location: FetchChatListLo } feedSignals.append(requestFeed) } - } + }*/ return combineLatest(feedSignals) |> map { feeds -> FetchedChatList in diff --git a/TelegramCore/GroupFeedPeers.swift b/TelegramCore/GroupFeedPeers.swift index 34760222e2..80a2bbc80f 100644 --- a/TelegramCore/GroupFeedPeers.swift +++ b/TelegramCore/GroupFeedPeers.swift @@ -8,7 +8,9 @@ import Foundation #endif public func availableGroupFeedPeers(postbox: Postbox, network: Network, groupId: PeerGroupId) -> Signal<[(Peer, Bool)], NoError> { - return network.request(Api.functions.channels.getFeedSources(flags: 0, feedId: groupId.rawValue, hash: 0)) + /*%layer76*/ + return .single([]) + /*return network.request(Api.functions.channels.getFeedSources(flags: 0, feedId: groupId.rawValue, hash: 0)) |> retryRequest |> mapToSignal { result -> Signal<[(Peer, Bool)], NoError> in return postbox.modify { modifier -> [(Peer, Bool)] in @@ -46,5 +48,5 @@ public func availableGroupFeedPeers(postbox: Postbox, network: Network, groupId: return peers } } - } + }*/ } diff --git a/TelegramCore/Holes.swift b/TelegramCore/Holes.swift index 1284f8f4d2..f4bf5e9055 100644 --- a/TelegramCore/Holes.swift +++ b/TelegramCore/Holes.swift @@ -88,7 +88,8 @@ func fetchMessageHistoryHole(source: FetchMessageHistoryHoleSource, postbox: Pos default: assertionFailure() } - request = source.request(Api.functions.messages.getRecentLocations(peer: inputPeer, limit: Int32(selectedLimit), hash: 0)) + /*%layer76*/ + request = source.request(Api.functions.messages.getRecentLocations(peer: inputPeer, limit: Int32(selectedLimit)/*, hash: 0*/)) } else if let filter = messageFilterForTagMask(tagMask) { let offsetId: Int32 let addOffset: Int32 @@ -118,8 +119,8 @@ func fetchMessageHistoryHole(source: FetchMessageHistoryHoleSource, postbox: Pos maxId = Int32.max minId = 1 } - - request = source.request(Api.functions.messages.search(flags: 0, peer: inputPeer, q: "", fromId: nil, filter: filter, minDate: 0, maxDate: hole.maxIndex.timestamp, offsetId: offsetId, addOffset: addOffset, limit: Int32(selectedLimit), maxId: maxId, minId: minId, hash: 0)) + /*%layer76*/ + request = source.request(Api.functions.messages.search(flags: 0, peer: inputPeer, q: "", fromId: nil, filter: filter, minDate: 0, maxDate: hole.maxIndex.timestamp, offsetId: offsetId, addOffset: addOffset, limit: Int32(selectedLimit), maxId: maxId, minId: minId/*, hash: 0*/)) } else { assertionFailure() request = .never() @@ -282,7 +283,9 @@ private func groupBoundaryPeer(_ peerId: PeerId, accountPeerId: PeerId) -> Api.P } func fetchGroupFeedHole(source: FetchMessageHistoryHoleSource, accountPeerId: PeerId, postbox: Postbox, groupId: PeerGroupId, minIndex: MessageIndex, maxIndex: MessageIndex, direction: MessageHistoryViewRelativeHoleDirection, limit: Int = 100) -> Signal { - return postbox.modify { modifier -> (Peer?, Peer?) in + /*%layer76*/ + return .never() + /*return postbox.modify { modifier -> (Peer?, Peer?) in return (modifier.getPeer(minIndex.id.peerId), modifier.getPeer(maxIndex.id.peerId)) } |> mapToSignal { lowerPeer, upperPeer in @@ -448,7 +451,7 @@ func fetchGroupFeedHole(source: FetchMessageHistoryHoleSource, accountPeerId: Pe } } } - return .complete() + return .complete()*/ } func fetchChatListHole(postbox: Postbox, network: Network, groupId: PeerGroupId?, hole: ChatListHole) -> Signal { @@ -507,7 +510,8 @@ func fetchCallListHole(network: Network, postbox: Postbox, holeIndex: MessageInd offset = single((holeIndex.timestamp, min(holeIndex.id.id, Int32.max - 1) + 1, Api.InputPeer.inputPeerEmpty), NoError.self) return offset |> mapToSignal { (timestamp, id, peer) -> Signal in - let searchResult = network.request(Api.functions.messages.search(flags: 0, peer: .inputPeerEmpty, q: "", fromId: nil, filter: .inputMessagesFilterPhoneCalls(flags: 0), minDate: 0, maxDate: holeIndex.timestamp, offsetId: 0, addOffset: 0, limit: limit, maxId: holeIndex.id.id, minId: 0, hash: 0)) + /*%layer76*/ + let searchResult = network.request(Api.functions.messages.search(flags: 0, peer: .inputPeerEmpty, q: "", fromId: nil, filter: .inputMessagesFilterPhoneCalls(flags: 0), minDate: 0, maxDate: holeIndex.timestamp, offsetId: 0, addOffset: 0, limit: limit, maxId: holeIndex.id.id, minId: 0/*, hash: 0*/)) |> retryRequest |> mapToSignal { result -> Signal in let messages: [Api.Message] diff --git a/TelegramCore/LoadedStickerPack.swift b/TelegramCore/LoadedStickerPack.swift index 0a76fb535b..49035481fd 100644 --- a/TelegramCore/LoadedStickerPack.swift +++ b/TelegramCore/LoadedStickerPack.swift @@ -45,7 +45,8 @@ func remoteStickerPack(network: Network, reference: StickerPackReference) -> Sig case let .stickerSet(set, packs, documents): let namespace: ItemCollectionId.Namespace switch set { - case let .stickerSet(flags, _, _, _, _, _, _, _): + /*%layer76*/ + case let .stickerSet(flags, _, _, _, _, _, _): if (flags & (1 << 3)) != 0 { namespace = Namespaces.ItemCollection.CloudMaskPacks } else { diff --git a/TelegramCore/ManagedConsumePersonalMessagesActions.swift b/TelegramCore/ManagedConsumePersonalMessagesActions.swift index a4765a0494..2cb4d1883d 100644 --- a/TelegramCore/ManagedConsumePersonalMessagesActions.swift +++ b/TelegramCore/ManagedConsumePersonalMessagesActions.swift @@ -226,7 +226,9 @@ private func synchronizeConsumeMessageContents(modifier: Modifier, postbox: Post private func synchronizeUnseenPersonalMentionsTag(postbox: Postbox, network: Network, entry: InvalidatedMessageHistoryTagsSummaryEntry) -> Signal { return postbox.modify { modifier -> Signal in if let peer = modifier.getPeer(entry.key.peerId), let inputPeer = apiInputPeer(peer) { - return network.request(Api.functions.messages.getPeerDialogs(peers: [.inputDialogPeer(peer: inputPeer)])) + /*%layer76*/ + //return network.request(Api.functions.messages.getPeerDialogs(peers: [.inputDialogPeer(peer: inputPeer)])) + return network.request(Api.functions.messages.getPeerDialogs(peers: [inputPeer])) |> map(Optional.init) |> `catch` { _ -> Signal in return .single(nil) @@ -242,9 +244,10 @@ private func synchronizeUnseenPersonalMentionsTag(postbox: Postbox, network: Net case let .dialog(_, _, topMessage, _, _, _, unreadMentionsCount, _, _, _): apiTopMessage = topMessage apiUnreadMentionsCount = unreadMentionsCount - case .dialogFeed: + /*%layer76*/ + /*case .dialogFeed: assertionFailure() - return .complete() + return .complete()*/ } return postbox.modify { modifier -> Void in diff --git a/TelegramCore/ManagedGroupFeedReadStateSyncOperations.swift b/TelegramCore/ManagedGroupFeedReadStateSyncOperations.swift index 1143dc9882..68e4ab0289 100644 --- a/TelegramCore/ManagedGroupFeedReadStateSyncOperations.swift +++ b/TelegramCore/ManagedGroupFeedReadStateSyncOperations.swift @@ -94,7 +94,9 @@ func managedGroupFeedReadStateSyncOperations(postbox: Postbox, network: Network, } private func fetchReadStateNext(network: Network, groupId: PeerGroupId) -> Signal { - return network.request(Api.functions.messages.getPeerDialogs(peers: [.inputDialogPeerFeed(feedId: groupId.rawValue)])) + /*%layer76*/ + return .single(nil) + /*return network.request(Api.functions.messages.getPeerDialogs(peers: [.inputDialogPeerFeed(feedId: groupId.rawValue)])) |> retryRequest |> map { result -> GroupFeedReadState? in switch result { @@ -120,11 +122,13 @@ private func fetchReadStateNext(network: Network, groupId: PeerGroupId) -> Signa } return nil } - } + }*/ } private func fetchReadState(network: Network, groupId: PeerGroupId) -> Signal { - return network.request(Api.functions.channels.getFeed(flags: 0, feedId: groupId.rawValue, offsetPosition: nil, addOffset: 0, limit: 1, maxPosition: nil, minPosition: nil, sourcesHash: 0, hash: 0)) + /*%layer76*/ + return .single(nil) + /*return network.request(Api.functions.channels.getFeed(flags: 0, feedId: groupId.rawValue, offsetPosition: nil, addOffset: 0, limit: 1, maxPosition: nil, minPosition: nil, sourcesHash: 0, hash: 0)) |> retryRequest |> map { result -> GroupFeedReadState? in switch result { @@ -153,7 +157,7 @@ private func fetchReadState(network: Network, groupId: PeerGroupId) -> Signal Api.Peer { @@ -170,14 +174,16 @@ private func groupBoundaryPeer(_ peerId: PeerId, accountPeerId: PeerId) -> Api.P } private func pushReadState(network: Network, accountPeerId: PeerId, groupId: PeerGroupId, state: GroupFeedReadState) -> Signal { - let position: Api.FeedPosition = .feedPosition(date: state.maxReadIndex.timestamp, peer: groupBoundaryPeer(state.maxReadIndex.id.peerId, accountPeerId: accountPeerId), id: state.maxReadIndex.id.id) + /*%layer76*/ + return .single(nil) + /*let position: Api.FeedPosition = .feedPosition(date: state.maxReadIndex.timestamp, peer: groupBoundaryPeer(state.maxReadIndex.id.peerId, accountPeerId: accountPeerId), id: state.maxReadIndex.id.id) if GlobalTelegramCoreConfiguration.readMessages { return network.request(Api.functions.channels.readFeed(feedId: groupId.rawValue, maxPosition: position)) |> retryRequest |> map(Optional.init) } else { return .single(nil) - } + }*/ } private func performSyncOperation(postbox: Postbox, network: Network, accountPeerId: PeerId, stateManager: AccountStateManager, groupId: PeerGroupId, operation: GroupFeedReadStateSyncOperation) -> Signal { diff --git a/TelegramCore/ManagedRecentStickers.swift b/TelegramCore/ManagedRecentStickers.swift index 135809407e..587e4127cc 100644 --- a/TelegramCore/ManagedRecentStickers.swift +++ b/TelegramCore/ManagedRecentStickers.swift @@ -49,7 +49,8 @@ func managedRecentStickers(postbox: Postbox, network: Network) -> Signal Int32 { } private func synchronizeGroupedPeers(modifier: Modifier, postbox: Postbox, network: Network, operation: SynchronizeGroupedPeersOperation) -> Signal { - let initialRemotePeerIds = operation.initialPeerIds + /*%layer76*/ + return .complete() + /*let initialRemotePeerIds = operation.initialPeerIds let localPeerIds = modifier.getPeerIdsInGroup(operation.groupId) return network.request(Api.functions.channels.getFeedSources(flags: 1 << 0, feedId: operation.groupId.rawValue, hash: hashForIds(localPeerIds.map({ $0.id }).sorted()))) @@ -206,6 +208,6 @@ private func synchronizeGroupedPeers(modifier: Modifier, postbox: Postbox, netwo } } |> switchToLatest } - } + }*/ } diff --git a/TelegramCore/ManagedSynchronizePinnedChatsOperations.swift b/TelegramCore/ManagedSynchronizePinnedChatsOperations.swift index a548513889..5ffde20063 100644 --- a/TelegramCore/ManagedSynchronizePinnedChatsOperations.swift +++ b/TelegramCore/ManagedSynchronizePinnedChatsOperations.swift @@ -185,9 +185,10 @@ private func synchronizePinnedChats(modifier: Modifier, postbox: Postbox, networ apiUnreadCount = unreadCount apiNotificationSettings = peerNotificationSettings apiChannelPts = pts - case let .dialogFeed(_, _, _, feedId, _, _, _, _): + /*%layer76*/ + /*case let .dialogFeed(_, _, _, feedId, _, _, _, _): remoteItemIds.append(.group(PeerGroupId(rawValue: feedId))) - continue loop + continue loop*/ } let peerId: PeerId @@ -263,7 +264,8 @@ private func synchronizePinnedChats(modifier: Modifier, postbox: Postbox, networ if remoteItemIds == resultingItemIds { return .complete() } else { - var inputDialogPeers: [Api.InputDialogPeer] = [] + /*%layer76*/ + /*var inputDialogPeers: [Api.InputDialogPeer] = [] for itemId in resultingItemIds { switch itemId { case let .peer(peerId): @@ -273,6 +275,17 @@ private func synchronizePinnedChats(modifier: Modifier, postbox: Postbox, networ case let .group(groupId): inputDialogPeers.append(.inputDialogPeerFeed(feedId: groupId.rawValue)) } + }*/ + var inputDialogPeers: [Api.InputPeer] = [] + for itemId in resultingItemIds { + switch itemId { + case let .peer(peerId): + if let peer = modifier.getPeer(peerId), let inputPeer = apiInputPeer(peer) { + inputDialogPeers.append(inputPeer) + } + case .group: + break + } } return network.request(Api.functions.messages.reorderPinnedDialogs(flags: 1 << 0, order: inputDialogPeers)) diff --git a/TelegramCore/Network.swift b/TelegramCore/Network.swift index 34e1c66e0f..b67b78bd61 100644 --- a/TelegramCore/Network.swift +++ b/TelegramCore/Network.swift @@ -429,9 +429,11 @@ func initializedNetwork(arguments: NetworkInitializationArguments, supplementary private final class NetworkHelper: NSObject, MTContextChangeListener { private let requestPublicKeys: (Int) -> Signal + private let isContextNetworkAccessAllowedImpl: () -> Signal - init(requestPublicKeys: @escaping (Int) -> Signal) { + init(requestPublicKeys: @escaping (Int) -> Signal, isContextNetworkAccessAllowed: @escaping () -> Signal) { self.requestPublicKeys = requestPublicKeys + self.isContextNetworkAccessAllowedImpl = isContextNetworkAccessAllowed } func fetchContextDatacenterPublicKeys(_ context: MTContext!, datacenterId: Int) -> MTSignal! { @@ -446,6 +448,19 @@ private final class NetworkHelper: NSObject, MTContextChangeListener { }) } } + + func isContextNetworkAccessAllowed(_ context: MTContext!) -> MTSignal! { + return MTSignal { subscriber in + let disposable = self.isContextNetworkAccessAllowedImpl().start(next: { next in + subscriber?.putNext(next as NSNumber) + subscriber?.putCompletion() + }) + + return MTBlockDisposable(block: { + disposable.dispose() + }) + } + } } public final class Network: NSObject, MTRequestMessageServiceDelegate { @@ -519,6 +534,12 @@ public final class Network: NSObject, MTRequestMessageServiceDelegate { } else { return .never() } + }, isContextNetworkAccessAllowed: { [weak self] in + if let strongSelf = self { + return strongSelf.shouldKeepConnection.get() |> distinctUntilChanged + } else { + return .single(false) + } })) requestService.delegate = self diff --git a/TelegramCore/RecentAccountSessions.swift b/TelegramCore/RecentAccountSessions.swift index 296bae143b..24b6b6c1d8 100644 --- a/TelegramCore/RecentAccountSessions.swift +++ b/TelegramCore/RecentAccountSessions.swift @@ -22,10 +22,16 @@ public func requestRecentAccountSessions(account: Account) -> Signal<[RecentAcco } } -public func terminateAccountSession(account: Account, hash: Int64) -> Signal { +public enum TerminateAccountSessionError { + case generic +} + +public func terminateAccountSession(account: Account, hash: Int64) -> Signal { return account.network.request(Api.functions.account.resetAuthorization(hash: hash)) - |> retryRequest - |> mapToSignal { _ -> Signal in + |> mapError { error -> TerminateAccountSessionError in + return .generic + } + |> mapToSignal { _ -> Signal in return .complete() } } diff --git a/TelegramCore/RequestUserPhotos.swift b/TelegramCore/RequestUserPhotos.swift index 1632000afb..376c2f7be4 100644 --- a/TelegramCore/RequestUserPhotos.swift +++ b/TelegramCore/RequestUserPhotos.swift @@ -64,7 +64,8 @@ public func requestPeerPhotos(account:Account, peerId:PeerId) -> Signal<[Telegra } } } else if let peer = peer, let inputPeer = apiInputPeer(peer) { - return account.network.request(Api.functions.messages.search(flags: 0, peer: inputPeer, q: "", fromId: nil, filter: .inputMessagesFilterChatPhotos, minDate: 0, maxDate: 0, offsetId: 0, addOffset: 0, limit: 1000, maxId: 0, minId: 0, hash: 0)) |> map {Optional($0)} + /*%layer76*/ + return account.network.request(Api.functions.messages.search(flags: 0, peer: inputPeer, q: "", fromId: nil, filter: .inputMessagesFilterChatPhotos, minDate: 0, maxDate: 0, offsetId: 0, addOffset: 0, limit: 1000, maxId: 0, minId: 0/*, hash: 0*/)) |> map {Optional($0)} |> mapError {_ in} |> `catch` { return Signal.single(nil) diff --git a/TelegramCore/SearchGroupMembers.swift b/TelegramCore/SearchGroupMembers.swift index 06bb145803..32a75bdd00 100644 --- a/TelegramCore/SearchGroupMembers.swift +++ b/TelegramCore/SearchGroupMembers.swift @@ -12,6 +12,10 @@ private func searchLocalGroupMembers(postbox: Postbox, peerId: PeerId, query: St |> map { peers -> [Peer] in let normalizedQuery = query.lowercased() + if normalizedQuery.isEmpty { + return peers + } + return peers.filter { peer in if peer.indexName.matchesByTokens(normalizedQuery) { return true diff --git a/TelegramCore/SearchMessages.swift b/TelegramCore/SearchMessages.swift index a0029d9eaa..1ef76563ad 100644 --- a/TelegramCore/SearchMessages.swift +++ b/TelegramCore/SearchMessages.swift @@ -79,7 +79,8 @@ public func searchMessages(account: Account, location: SearchMessagesLocation, q flags |= (1 << 0) } } - return account.network.request(Api.functions.messages.search(flags: flags, peer: inputPeer, q: query, fromId: fromInputUser, filter: filter, minDate: 0, maxDate: Int32.max - 1, offsetId: 0, addOffset: 0, limit: 100, maxId: Int32.max - 1, minId: 0, hash: 0)) + /*%layer76*/ + return account.network.request(Api.functions.messages.search(flags: flags, peer: inputPeer, q: query, fromId: fromInputUser, filter: filter, minDate: 0, maxDate: Int32.max - 1, offsetId: 0, addOffset: 0, limit: 100, maxId: Int32.max - 1, minId: 0/*, hash: 0*/)) |> map {Optional($0)} |> `catch` { _ -> Signal in return .single(nil) @@ -89,8 +90,10 @@ public func searchMessages(account: Account, location: SearchMessagesLocation, q } } case let .group(groupId): - remoteSearchResult = account.network.request(Api.functions.channels.searchFeed(feedId: groupId.rawValue, q: query, offsetDate: 0, offsetPeer: Api.InputPeer.inputPeerEmpty, offsetId: 0, limit: 64)) - |> mapError { _ in } |> map(Optional.init) + /*%layer76*/ + remoteSearchResult = .single(nil) + /*remoteSearchResult = account.network.request(Api.functions.channels.searchFeed(feedId: groupId.rawValue, q: query, offsetDate: 0, offsetPeer: Api.InputPeer.inputPeerEmpty, offsetId: 0, limit: 64)) + |> mapError { _ in } |> map(Optional.init)*/ case .general: remoteSearchResult = account.network.request(Api.functions.messages.searchGlobal(q: query, offsetDate: 0, offsetPeer: Api.InputPeer.inputPeerEmpty, offsetId: 0, limit: 64)) |> mapError { _ in } |> map(Optional.init) diff --git a/TelegramCore/SearchPeers.swift b/TelegramCore/SearchPeers.swift index d75bd91c42..0cec071b0f 100644 --- a/TelegramCore/SearchPeers.swift +++ b/TelegramCore/SearchPeers.swift @@ -47,12 +47,13 @@ public func searchPeers(account: Account, query: String) -> Signal<([FoundPeer], if let groupOrChannel = parseTelegramGroupOrChannel(chat: chat) { peers[groupOrChannel.id] = groupOrChannel switch chat { - case let .channel(_, _, _, _, _, _, _, _, _, _, _, participantsCount, _): - if let participantsCount = participantsCount { - subscribers[groupOrChannel.id] = participantsCount - } - default: - break + /*%layer76*/ + case let .channel(_, _, _, _, _, _, _, _, _, _, _, participantsCount): + if let participantsCount = participantsCount { + subscribers[groupOrChannel.id] = participantsCount + } + default: + break } } } diff --git a/TelegramCore/Serialization.swift b/TelegramCore/Serialization.swift index 35146f1eb5..ce0ac83adc 100644 --- a/TelegramCore/Serialization.swift +++ b/TelegramCore/Serialization.swift @@ -20,7 +20,7 @@ public class BoxedMessage: NSObject { public class Serialization: NSObject, MTSerialization { public func currentLayer() -> UInt { - return 76 + return 75 } public func parseMessage(_ data: Data!) -> Any! { diff --git a/TelegramCore/StickerPack.swift b/TelegramCore/StickerPack.swift index c3afc014eb..eb06d87b0e 100644 --- a/TelegramCore/StickerPack.swift +++ b/TelegramCore/StickerPack.swift @@ -148,7 +148,8 @@ public final class StickerPackItem: ItemCollectionItem, Equatable { extension StickerPackCollectionInfo { convenience init(apiSet: Api.StickerSet, namespace: ItemCollectionId.Namespace) { switch apiSet { - case let .stickerSet(flags, _, id, accessHash, title, shortName, count, nHash): + /*%layer76*/ + case let .stickerSet(flags/*, _*/, id, accessHash, title, shortName, count, nHash): var setFlags: StickerPackCollectionInfoFlags = StickerPackCollectionInfoFlags() if (flags & (1 << 2)) != 0 { setFlags.insert(.official) diff --git a/TelegramCore/SynchronizePeerReadState.swift b/TelegramCore/SynchronizePeerReadState.swift index bf6657f340..6ce3043e2a 100644 --- a/TelegramCore/SynchronizePeerReadState.swift +++ b/TelegramCore/SynchronizePeerReadState.swift @@ -66,7 +66,9 @@ private func dialogTopMessage(network: Network, postbox: Postbox, peerId: PeerId } func fetchPeerCloudReadState(network: Network, postbox: Postbox, peerId: PeerId, inputPeer: Api.InputPeer) -> Signal { - return network.request(Api.functions.messages.getPeerDialogs(peers: [.inputDialogPeer(peer: inputPeer)])) + /*%layer76*/ + //return network.request(Api.functions.messages.getPeerDialogs(peers: [.inputDialogPeer(peer: inputPeer)])) + return network.request(Api.functions.messages.getPeerDialogs(peers: [inputPeer])) |> map { result -> PeerReadState? in switch result { case let .peerDialogs(dialogs, _, _, _, _): @@ -81,9 +83,10 @@ func fetchPeerCloudReadState(network: Network, postbox: Postbox, peerId: PeerId, apiReadInboxMaxId = readInboxMaxId apiReadOutboxMaxId = readOutboxMaxId apiUnreadCount = unreadCount - case .dialogFeed: + /*%layer76*/ + /*case .dialogFeed: assertionFailure() - return nil + return nil*/ } return .idBased(maxIncomingReadId: apiReadInboxMaxId, maxOutgoingReadId: apiReadOutboxMaxId, maxKnownId: apiTopMessage, count: apiUnreadCount) @@ -102,7 +105,9 @@ private func dialogReadState(network: Network, postbox: Postbox, peerId: PeerId) |> mapToSignal { topMessage -> Signal<(PeerReadState, PeerReadStateMarker), VerifyReadStateError> in return inputPeer(postbox: postbox, peerId: peerId) |> mapToSignal { inputPeer -> Signal<(PeerReadState, PeerReadStateMarker), VerifyReadStateError> in - return network.request(Api.functions.messages.getPeerDialogs(peers: [.inputDialogPeer(peer: inputPeer)])) + /*%layer76*/ + //return network.request(Api.functions.messages.getPeerDialogs(peers: [.inputDialogPeer(peer: inputPeer)])) + return network.request(Api.functions.messages.getPeerDialogs(peers: [inputPeer])) |> retryRequest |> mapToSignalPromotingError { result -> Signal<(PeerReadState, PeerReadStateMarker), VerifyReadStateError> in switch result { @@ -122,9 +127,10 @@ private func dialogReadState(network: Network, postbox: Postbox, peerId: PeerId) if let pts = pts { apiChannelPts = pts } - case .dialogFeed: + /*%layer76*/ + /*case .dialogFeed: assertionFailure() - return .fail(.Abort) + return .fail(.Abort)*/ } let marker: PeerReadStateMarker diff --git a/TelegramCore/TelegramMediaFile.swift b/TelegramCore/TelegramMediaFile.swift index 5d5bb6f591..64b70269f1 100644 --- a/TelegramCore/TelegramMediaFile.swift +++ b/TelegramCore/TelegramMediaFile.swift @@ -379,6 +379,10 @@ public final class TelegramMediaFile: Media, Equatable { public func withUpdatedPreviewRepresentations(_ previewRepresentations: [TelegramMediaImageRepresentation]) -> TelegramMediaFile { return TelegramMediaFile(fileId: self.fileId, resource: self.resource, previewRepresentations: previewRepresentations, mimeType: self.mimeType, size: self.size, attributes: self.attributes) } + + public func withUpdatedAttributes(_ attributes: [TelegramMediaFileAttribute]) -> TelegramMediaFile { + return TelegramMediaFile(fileId: self.fileId, resource: self.resource, previewRepresentations: self.previewRepresentations, mimeType: self.mimeType, size: self.size, attributes: attributes) + } } public func ==(lhs: TelegramMediaFile, rhs: TelegramMediaFile) -> Bool { diff --git a/TelegramCore/UpdateCachedPeerData.swift b/TelegramCore/UpdateCachedPeerData.swift index 81782fa21e..af4d1dcd5e 100644 --- a/TelegramCore/UpdateCachedPeerData.swift +++ b/TelegramCore/UpdateCachedPeerData.swift @@ -291,7 +291,8 @@ func fetchAndUpdateCachedPeerData(peerId: PeerId, network: Network, postbox: Pos let stickerPack: StickerPackCollectionInfo? = stickerSet.flatMap { apiSet -> StickerPackCollectionInfo in let namespace: ItemCollectionId.Namespace switch apiSet { - case let .stickerSet(flags, _, _, _, _, _, _, _): + /*%layer76*/ + case let .stickerSet(flags, _, _, _, _, _, _): if (flags & (1 << 3)) != 0 { namespace = Namespaces.ItemCollection.CloudMaskPacks } else { diff --git a/TelegramCore/UpdatesApiUtils.swift b/TelegramCore/UpdatesApiUtils.swift index bda93aa795..59cc3edc1c 100644 --- a/TelegramCore/UpdatesApiUtils.swift +++ b/TelegramCore/UpdatesApiUtils.swift @@ -122,7 +122,8 @@ extension Api.Chat { return PeerId(namespace: Namespaces.Peer.CloudGroup, id: id) case let .chatForbidden(id, _): return PeerId(namespace: Namespaces.Peer.CloudGroup, id: id) - case let .channel(_, id, _, _, _, _, _, _, _, _, _, _, _): + /*%layer76*/ + case let .channel(_, id, _, _, _, _, _, _, _, _, _, _): return PeerId(namespace: Namespaces.Peer.CloudChannel, id: id) case let .channelForbidden(_, id, _, _, _): return PeerId(namespace: Namespaces.Peer.CloudChannel, id: id) @@ -159,8 +160,9 @@ extension Api.Dialog { switch self { case let .dialog(_, peer, _, _, _, _, _, _, _, _): return peer.peerId - case .dialogFeed: - return nil + /*%layer76*/ + /*case .dialogFeed: + return nil*/ } } }