diff --git a/submodules/TelegramCore/Sources/MacInternalUpdater.swift b/submodules/TelegramCore/Sources/MacInternalUpdater.swift index 68a02b46e4..f9d48f6746 100644 --- a/submodules/TelegramCore/Sources/MacInternalUpdater.swift +++ b/submodules/TelegramCore/Sources/MacInternalUpdater.swift @@ -17,7 +17,7 @@ public func requestUpdatesXml(account: Account, source: String) -> Signal mapToSignal { peerId -> Signal in return account.postbox.transaction { transaction in return peerId != nil ? transaction.getPeer(peerId!) : nil - } |> castError(InternalUpdaterError.self) + } |> castError(InternalUpdaterError.self) } |> mapToSignal { peer in if let peer = peer, let inputPeer = apiInputPeer(peer) { @@ -78,7 +78,7 @@ public enum AppUpdateDownloadResult { case finished(String) } -public func downloadAppUpdate(account: Account, source: String, fileName: String) -> Signal { +public func downloadAppUpdate(account: Account, source: String, messageId: Int32) -> Signal { return resolvePeerByName(account: account, name: source) |> castError(InternalUpdaterError.self) |> mapToSignal { peerId -> Signal in @@ -87,12 +87,12 @@ public func downloadAppUpdate(account: Account, source: String, fileName: String } |> castError(InternalUpdaterError.self) } |> mapToSignal { peer in - if let peer = peer, let inputPeer = apiInputPeer(peer) { - return account.network.request(Api.functions.messages.getHistory(peer: inputPeer, offsetId: 0, offsetDate: 0, addOffset: 0, limit: 10, maxId: Int32.max, minId: 0, hash: 0)) + if let peer = peer, let inputChannel = apiInputChannel(peer) { + return account.network.request(Api.functions.channels.getMessages(channel: inputChannel, id: [Api.InputMessage.inputMessageID(id: messageId)])) |> retryRequest |> castError(InternalUpdaterError.self) - |> mapToSignal { result in - switch result { + |> mapToSignal { messages in + switch messages { case let .channelMessages(_, _, _, apiMessages, apiChats, apiUsers): var peers: [PeerId: Peer] = [:] @@ -113,11 +113,7 @@ public func downloadAppUpdate(account: Account, source: String, fileName: String }.sorted(by: { $0.id > $1.id }).first(where: { value -> Bool in - if let file = value.media.first as? TelegramMediaFile, file.fileName == fileName { - return true - } else { - return false - } + return value.media.first is TelegramMediaFile }).map { ($0, $0.media.first as! TelegramMediaFile )} if let (message, media) = messageAndFile {