mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-11-25 01:22:41 +00:00
mac updater [skip ci]
This commit is contained in:
parent
e654d6095e
commit
eb686ae189
@ -17,7 +17,7 @@ public func requestUpdatesXml(account: Account, source: String) -> Signal<Data,
|
|||||||
|> mapToSignal { peerId -> Signal<Peer?, InternalUpdaterError> in
|
|> mapToSignal { peerId -> Signal<Peer?, InternalUpdaterError> in
|
||||||
return account.postbox.transaction { transaction in
|
return account.postbox.transaction { transaction in
|
||||||
return peerId != nil ? transaction.getPeer(peerId!) : nil
|
return peerId != nil ? transaction.getPeer(peerId!) : nil
|
||||||
} |> castError(InternalUpdaterError.self)
|
} |> castError(InternalUpdaterError.self)
|
||||||
}
|
}
|
||||||
|> mapToSignal { peer in
|
|> mapToSignal { peer in
|
||||||
if let peer = peer, let inputPeer = apiInputPeer(peer) {
|
if let peer = peer, let inputPeer = apiInputPeer(peer) {
|
||||||
@ -78,7 +78,7 @@ public enum AppUpdateDownloadResult {
|
|||||||
case finished(String)
|
case finished(String)
|
||||||
}
|
}
|
||||||
|
|
||||||
public func downloadAppUpdate(account: Account, source: String, fileName: String) -> Signal<AppUpdateDownloadResult, InternalUpdaterError> {
|
public func downloadAppUpdate(account: Account, source: String, messageId: Int32) -> Signal<AppUpdateDownloadResult, InternalUpdaterError> {
|
||||||
return resolvePeerByName(account: account, name: source)
|
return resolvePeerByName(account: account, name: source)
|
||||||
|> castError(InternalUpdaterError.self)
|
|> castError(InternalUpdaterError.self)
|
||||||
|> mapToSignal { peerId -> Signal<Peer?, InternalUpdaterError> in
|
|> mapToSignal { peerId -> Signal<Peer?, InternalUpdaterError> in
|
||||||
@ -87,12 +87,12 @@ public func downloadAppUpdate(account: Account, source: String, fileName: String
|
|||||||
} |> castError(InternalUpdaterError.self)
|
} |> castError(InternalUpdaterError.self)
|
||||||
}
|
}
|
||||||
|> mapToSignal { peer in
|
|> mapToSignal { peer in
|
||||||
if let peer = peer, let inputPeer = apiInputPeer(peer) {
|
if let peer = peer, let inputChannel = apiInputChannel(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))
|
return account.network.request(Api.functions.channels.getMessages(channel: inputChannel, id: [Api.InputMessage.inputMessageID(id: messageId)]))
|
||||||
|> retryRequest
|
|> retryRequest
|
||||||
|> castError(InternalUpdaterError.self)
|
|> castError(InternalUpdaterError.self)
|
||||||
|> mapToSignal { result in
|
|> mapToSignal { messages in
|
||||||
switch result {
|
switch messages {
|
||||||
case let .channelMessages(_, _, _, apiMessages, apiChats, apiUsers):
|
case let .channelMessages(_, _, _, apiMessages, apiChats, apiUsers):
|
||||||
|
|
||||||
var peers: [PeerId: Peer] = [:]
|
var peers: [PeerId: Peer] = [:]
|
||||||
@ -113,11 +113,7 @@ public func downloadAppUpdate(account: Account, source: String, fileName: String
|
|||||||
}.sorted(by: {
|
}.sorted(by: {
|
||||||
$0.id > $1.id
|
$0.id > $1.id
|
||||||
}).first(where: { value -> Bool in
|
}).first(where: { value -> Bool in
|
||||||
if let file = value.media.first as? TelegramMediaFile, file.fileName == fileName {
|
return value.media.first is TelegramMediaFile
|
||||||
return true
|
|
||||||
} else {
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
}).map { ($0, $0.media.first as! TelegramMediaFile )}
|
}).map { ($0, $0.media.first as! TelegramMediaFile )}
|
||||||
|
|
||||||
if let (message, media) = messageAndFile {
|
if let (message, media) = messageAndFile {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user