diff --git a/submodules/SyncCore/Sources/TelegramMediaFile.swift b/submodules/SyncCore/Sources/TelegramMediaFile.swift index 293bef9d3f..1948aa9477 100644 --- a/submodules/SyncCore/Sources/TelegramMediaFile.swift +++ b/submodules/SyncCore/Sources/TelegramMediaFile.swift @@ -8,6 +8,7 @@ private let typeAnimated: Int32 = 3 private let typeVideo: Int32 = 4 private let typeAudio: Int32 = 5 private let typeHasLinkedStickers: Int32 = 6 +private let typeHintFileIsLarge: Int32 = 7 public enum StickerPackReference: PostboxCoding, Hashable, Equatable { case id(id: Int64, accessHash: Int64) @@ -129,6 +130,7 @@ public enum TelegramMediaFileAttribute: PostboxCoding { case Video(duration: Int, size: PixelDimensions, flags: TelegramMediaVideoFlags) case Audio(isVoice: Bool, duration: Int, title: String?, performer: String?, waveform: MemoryBuffer?) case HasLinkedStickers + case hintFileIsLarge public init(decoder: PostboxDecoder) { 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) case typeHasLinkedStickers: self = .HasLinkedStickers + case typeHintFileIsLarge: + self = .hintFileIsLarge default: preconditionFailure() } @@ -202,6 +206,8 @@ public enum TelegramMediaFileAttribute: PostboxCoding { } case .HasLinkedStickers: encoder.encodeInt32(typeHasLinkedStickers, forKey: "t") + case .hintFileIsLarge: + encoder.encodeInt32(typeHintFileIsLarge, forKey: "t") } } } diff --git a/submodules/TelegramCore/Sources/ManagedSecretChatOutgoingOperations.swift b/submodules/TelegramCore/Sources/ManagedSecretChatOutgoingOperations.swift index d38214e8b0..6ab9af549c 100644 --- a/submodules/TelegramCore/Sources/ManagedSecretChatOutgoingOperations.swift +++ b/submodules/TelegramCore/Sources/ManagedSecretChatOutgoingOperations.swift @@ -521,6 +521,8 @@ private func decryptedAttributes46(_ attributes: [TelegramMediaFileAttribute], t result.append(.documentAttributeAudio(flags: flags, duration: Int32(duration), title: title, performer: performer, waveform: waveformBuffer)) case .HasLinkedStickers: break + case .hintFileIsLarge: + break } } 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)) case .HasLinkedStickers: break + case .hintFileIsLarge: + break } } 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)) case .HasLinkedStickers: break + case .hintFileIsLarge: + break } } return result diff --git a/submodules/TelegramCore/Sources/PendingMessageUploadedContent.swift b/submodules/TelegramCore/Sources/PendingMessageUploadedContent.swift index 3c885ec960..16b490b314 100644 --- a/submodules/TelegramCore/Sources/PendingMessageUploadedContent.swift +++ b/submodules/TelegramCore/Sources/PendingMessageUploadedContent.swift @@ -487,6 +487,8 @@ func inputDocumentAttributesFromFileAttributes(_ fileAttributes: [TelegramMediaF attributes.append(.documentAttributeSticker(flags: flags, alt: displayText, stickerset: stickerSet, maskCoords: inputMaskCoords)) case .HasLinkedStickers: attributes.append(.documentAttributeHasStickers) + case .hintFileIsLarge: + break case let .Video(duration, size, videoFlags): var flags: Int32 = 0 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 { hintSize = Int(size) } - if (file.resource.headerSize != 0 || file.mimeType.hasPrefix("video/mp4")) && !file.isAnimated { - hintFileIsLarge = true + + loop: for attr in file.attributes { + switch attr { + case .hintFileIsLarge: + hintFileIsLarge = true + break loop + default: + break loop + } } + + let fileReference: AnyMediaReference if let partialReference = file.partialReference { fileReference = partialReference.mediaReference(file)