mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-12-16 19:30:29 +00:00
Merge commit 'b09f4647600fc7b3a89090332f1e1e8d7741bf66'
This commit is contained in:
commit
d01053229d
@ -8,6 +8,7 @@ private let typeAnimated: Int32 = 3
|
|||||||
private let typeVideo: Int32 = 4
|
private let typeVideo: Int32 = 4
|
||||||
private let typeAudio: Int32 = 5
|
private let typeAudio: Int32 = 5
|
||||||
private let typeHasLinkedStickers: Int32 = 6
|
private let typeHasLinkedStickers: Int32 = 6
|
||||||
|
private let typeHintFileIsLarge: Int32 = 7
|
||||||
|
|
||||||
public enum StickerPackReference: PostboxCoding, Hashable, Equatable {
|
public enum StickerPackReference: PostboxCoding, Hashable, Equatable {
|
||||||
case id(id: Int64, accessHash: Int64)
|
case id(id: Int64, accessHash: Int64)
|
||||||
@ -129,6 +130,7 @@ public enum TelegramMediaFileAttribute: PostboxCoding {
|
|||||||
case Video(duration: Int, size: PixelDimensions, flags: TelegramMediaVideoFlags)
|
case Video(duration: Int, size: PixelDimensions, flags: TelegramMediaVideoFlags)
|
||||||
case Audio(isVoice: Bool, duration: Int, title: String?, performer: String?, waveform: MemoryBuffer?)
|
case Audio(isVoice: Bool, duration: Int, title: String?, performer: String?, waveform: MemoryBuffer?)
|
||||||
case HasLinkedStickers
|
case HasLinkedStickers
|
||||||
|
case hintFileIsLarge
|
||||||
|
|
||||||
public init(decoder: PostboxDecoder) {
|
public init(decoder: PostboxDecoder) {
|
||||||
let type: Int32 = decoder.decodeInt32ForKey("t", orElse: 0)
|
let type: Int32 = decoder.decodeInt32ForKey("t", orElse: 0)
|
||||||
@ -152,6 +154,8 @@ public enum TelegramMediaFileAttribute: PostboxCoding {
|
|||||||
self = .Audio(isVoice: decoder.decodeInt32ForKey("iv", orElse: 0) != 0, duration: Int(decoder.decodeInt32ForKey("du", orElse: 0)), title: decoder.decodeOptionalStringForKey("ti"), performer: decoder.decodeOptionalStringForKey("pe"), waveform: waveform)
|
self = .Audio(isVoice: decoder.decodeInt32ForKey("iv", orElse: 0) != 0, duration: Int(decoder.decodeInt32ForKey("du", orElse: 0)), title: decoder.decodeOptionalStringForKey("ti"), performer: decoder.decodeOptionalStringForKey("pe"), waveform: waveform)
|
||||||
case typeHasLinkedStickers:
|
case typeHasLinkedStickers:
|
||||||
self = .HasLinkedStickers
|
self = .HasLinkedStickers
|
||||||
|
case typeHintFileIsLarge:
|
||||||
|
self = .hintFileIsLarge
|
||||||
default:
|
default:
|
||||||
preconditionFailure()
|
preconditionFailure()
|
||||||
}
|
}
|
||||||
@ -202,6 +206,8 @@ public enum TelegramMediaFileAttribute: PostboxCoding {
|
|||||||
}
|
}
|
||||||
case .HasLinkedStickers:
|
case .HasLinkedStickers:
|
||||||
encoder.encodeInt32(typeHasLinkedStickers, forKey: "t")
|
encoder.encodeInt32(typeHasLinkedStickers, forKey: "t")
|
||||||
|
case .hintFileIsLarge:
|
||||||
|
encoder.encodeInt32(typeHintFileIsLarge, forKey: "t")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -521,6 +521,8 @@ private func decryptedAttributes46(_ attributes: [TelegramMediaFileAttribute], t
|
|||||||
result.append(.documentAttributeAudio(flags: flags, duration: Int32(duration), title: title, performer: performer, waveform: waveformBuffer))
|
result.append(.documentAttributeAudio(flags: flags, duration: Int32(duration), title: title, performer: performer, waveform: waveformBuffer))
|
||||||
case .HasLinkedStickers:
|
case .HasLinkedStickers:
|
||||||
break
|
break
|
||||||
|
case .hintFileIsLarge:
|
||||||
|
break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return result
|
return result
|
||||||
@ -576,6 +578,8 @@ private func decryptedAttributes73(_ attributes: [TelegramMediaFileAttribute], t
|
|||||||
result.append(.documentAttributeAudio(flags: flags, duration: Int32(duration), title: title, performer: performer, waveform: waveformBuffer))
|
result.append(.documentAttributeAudio(flags: flags, duration: Int32(duration), title: title, performer: performer, waveform: waveformBuffer))
|
||||||
case .HasLinkedStickers:
|
case .HasLinkedStickers:
|
||||||
break
|
break
|
||||||
|
case .hintFileIsLarge:
|
||||||
|
break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return result
|
return result
|
||||||
@ -631,6 +635,8 @@ private func decryptedAttributes101(_ attributes: [TelegramMediaFileAttribute],
|
|||||||
result.append(.documentAttributeAudio(flags: flags, duration: Int32(duration), title: title, performer: performer, waveform: waveformBuffer))
|
result.append(.documentAttributeAudio(flags: flags, duration: Int32(duration), title: title, performer: performer, waveform: waveformBuffer))
|
||||||
case .HasLinkedStickers:
|
case .HasLinkedStickers:
|
||||||
break
|
break
|
||||||
|
case .hintFileIsLarge:
|
||||||
|
break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return result
|
return result
|
||||||
|
|||||||
@ -487,6 +487,8 @@ func inputDocumentAttributesFromFileAttributes(_ fileAttributes: [TelegramMediaF
|
|||||||
attributes.append(.documentAttributeSticker(flags: flags, alt: displayText, stickerset: stickerSet, maskCoords: inputMaskCoords))
|
attributes.append(.documentAttributeSticker(flags: flags, alt: displayText, stickerset: stickerSet, maskCoords: inputMaskCoords))
|
||||||
case .HasLinkedStickers:
|
case .HasLinkedStickers:
|
||||||
attributes.append(.documentAttributeHasStickers)
|
attributes.append(.documentAttributeHasStickers)
|
||||||
|
case .hintFileIsLarge:
|
||||||
|
break
|
||||||
case let .Video(duration, size, videoFlags):
|
case let .Video(duration, size, videoFlags):
|
||||||
var flags: Int32 = 0
|
var flags: Int32 = 0
|
||||||
if videoFlags.contains(.instantRoundVideo) {
|
if videoFlags.contains(.instantRoundVideo) {
|
||||||
@ -588,9 +590,18 @@ private func uploadedMediaFileContent(network: Network, postbox: Postbox, auxili
|
|||||||
} else if let resource = file.resource as? LocalFileReferenceMediaResource, let size = resource.size {
|
} else if let resource = file.resource as? LocalFileReferenceMediaResource, let size = resource.size {
|
||||||
hintSize = Int(size)
|
hintSize = Int(size)
|
||||||
}
|
}
|
||||||
if (file.resource.headerSize != 0 || file.mimeType.hasPrefix("video/mp4")) && !file.isAnimated {
|
|
||||||
|
loop: for attr in file.attributes {
|
||||||
|
switch attr {
|
||||||
|
case .hintFileIsLarge:
|
||||||
hintFileIsLarge = true
|
hintFileIsLarge = true
|
||||||
|
break loop
|
||||||
|
default:
|
||||||
|
break loop
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
let fileReference: AnyMediaReference
|
let fileReference: AnyMediaReference
|
||||||
if let partialReference = file.partialReference {
|
if let partialReference = file.partialReference {
|
||||||
fileReference = partialReference.mediaReference(file)
|
fileReference = partialReference.mediaReference(file)
|
||||||
|
|||||||
@ -136,7 +136,7 @@ public func requestChatContextResults(account: Account, botId: PeerId, peerId: P
|
|||||||
}
|
}
|
||||||
|
|
||||||
return account.postbox.transaction { transaction -> RequestChatContextResultsResult? in
|
return account.postbox.transaction { transaction -> RequestChatContextResultsResult? in
|
||||||
if result.cacheTimeout > 10 {
|
if result.cacheTimeout > 10, offset.isEmpty && location == nil {
|
||||||
if let resultData = try? JSONEncoder().encode(result) {
|
if let resultData = try? JSONEncoder().encode(result) {
|
||||||
let requestData = RequestData(version: requestVersion, botId: botId, peerId: peerId, query: query)
|
let requestData = RequestData(version: requestVersion, botId: botId, peerId: peerId, query: query)
|
||||||
if let keyData = try? JSONEncoder().encode(requestData) {
|
if let keyData = try? JSONEncoder().encode(requestData) {
|
||||||
|
|||||||
@ -299,15 +299,19 @@ public func searchStickerSets(postbox: Postbox, query: String) -> Signal<FoundSt
|
|||||||
} |> switchToLatest
|
} |> switchToLatest
|
||||||
}
|
}
|
||||||
|
|
||||||
public func searchGifs(account: Account, query: String) -> Signal<ChatContextResultCollection?, NoError> {
|
public func searchGifs(account: Account, query: String, nextOffset: String = "") -> Signal<ChatContextResultCollection?, NoError> {
|
||||||
return resolvePeerByName(account: account, name: "gif")
|
return account.postbox.transaction { transaction -> String in
|
||||||
|> filter { $0 != nil }
|
let configuration = currentSearchBotsConfiguration(transaction: transaction)
|
||||||
|
return configuration.gifBotUsername ?? "gif"
|
||||||
|
} |> mapToSignal {
|
||||||
|
return resolvePeerByName(account: account, name: $0)
|
||||||
|
} |> filter { $0 != nil }
|
||||||
|> map { $0! }
|
|> map { $0! }
|
||||||
|> mapToSignal { peerId -> Signal<Peer, NoError> in
|
|> mapToSignal { peerId -> Signal<Peer, NoError> in
|
||||||
return account.postbox.loadedPeerWithId(peerId)
|
return account.postbox.loadedPeerWithId(peerId)
|
||||||
}
|
}
|
||||||
|> mapToSignal { peer -> Signal<ChatContextResultCollection?, NoError> in
|
|> mapToSignal { peer -> Signal<ChatContextResultCollection?, NoError> in
|
||||||
return requestChatContextResults(account: account, botId: peer.id, peerId: account.peerId, query: query, offset: "")
|
return requestChatContextResults(account: account, botId: peer.id, peerId: account.peerId, query: query, offset: nextOffset)
|
||||||
|> map { results -> ChatContextResultCollection? in
|
|> map { results -> ChatContextResultCollection? in
|
||||||
return results?.results
|
return results?.results
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user