From f18f337f2c479100224a6731662fecf736cbfb45 Mon Sep 17 00:00:00 2001 From: Ilya Laktyushin Date: Fri, 13 Sep 2024 13:53:15 +0400 Subject: [PATCH 1/2] Update API --- submodules/TelegramApi/Sources/Api0.swift | 5 ++-- submodules/TelegramApi/Sources/Api13.swift | 24 +++++++++++++++++++ submodules/TelegramApi/Sources/Api15.swift | 24 +++++++++++-------- submodules/TelegramApi/Sources/Api36.swift | 7 +++--- submodules/TelegramApi/Sources/Api5.swift | 18 ++++++++------ .../ReplyMarkupMessageAttribute.swift | 2 ++ .../Sources/ApiUtils/TelegramMediaFile.swift | 3 ++- .../PendingMessageUploadedContent.swift | 2 +- .../Sources/State/Serialization.swift | 2 +- ...SyncCore_ReplyMarkupMessageAttribute.swift | 6 +++++ .../TelegramEngine/Messages/AdMessages.swift | 19 ++++++++++----- .../TelegramEngine/Messages/Stories.swift | 2 +- .../Messages/TelegramEngineMessages.swift | 5 ++-- .../Stickers/ImportStickers.swift | 2 +- .../PresentationThemeEssentialGraphics.swift | 5 ++++ .../Sources/ChatButtonKeyboardInputNode.swift | 2 ++ .../ChatMessageActionButtonsNode.swift | 2 ++ .../Sources/ChatMessageBubbleItemNode.swift | 1 + .../Sources/ChatMessageItemView.swift | 2 ++ .../TelegramUI/Sources/ChatController.swift | 4 ++-- .../ChatPinnedMessageTitlePanelNode.swift | 2 ++ 21 files changed, 102 insertions(+), 37 deletions(-) diff --git a/submodules/TelegramApi/Sources/Api0.swift b/submodules/TelegramApi/Sources/Api0.swift index f093c8b330..2f4860f756 100644 --- a/submodules/TelegramApi/Sources/Api0.swift +++ b/submodules/TelegramApi/Sources/Api0.swift @@ -245,7 +245,7 @@ fileprivate let parsers: [Int32 : (BufferReader) -> Any?] = { dict[-1744710921] = { return Api.DocumentAttribute.parse_documentAttributeHasStickers($0) } dict[1815593308] = { return Api.DocumentAttribute.parse_documentAttributeImageSize($0) } dict[1662637586] = { return Api.DocumentAttribute.parse_documentAttributeSticker($0) } - dict[389652397] = { return Api.DocumentAttribute.parse_documentAttributeVideo($0) } + dict[1137015880] = { return Api.DocumentAttribute.parse_documentAttributeVideo($0) } dict[761606687] = { return Api.DraftMessage.parse_draftMessage($0) } dict[453805082] = { return Api.DraftMessage.parse_draftMessageEmpty($0) } dict[-1764723459] = { return Api.EmailVerification.parse_emailVerificationApple($0) } @@ -500,6 +500,7 @@ fileprivate let parsers: [Int32 : (BufferReader) -> Any?] = { dict[-1560655744] = { return Api.KeyboardButton.parse_keyboardButton($0) } dict[-1344716869] = { return Api.KeyboardButton.parse_keyboardButtonBuy($0) } dict[901503851] = { return Api.KeyboardButton.parse_keyboardButtonCallback($0) } + dict[1976723854] = { return Api.KeyboardButton.parse_keyboardButtonCopy($0) } dict[1358175439] = { return Api.KeyboardButton.parse_keyboardButtonGame($0) } dict[-59151553] = { return Api.KeyboardButton.parse_keyboardButtonRequestGeoLocation($0) } dict[1406648280] = { return Api.KeyboardButton.parse_keyboardButtonRequestPeer($0) } @@ -603,7 +604,7 @@ fileprivate let parsers: [Int32 : (BufferReader) -> Any?] = { dict[1313731771] = { return Api.MessageFwdHeader.parse_messageFwdHeader($0) } dict[1882335561] = { return Api.MessageMedia.parse_messageMediaContact($0) } dict[1065280907] = { return Api.MessageMedia.parse_messageMediaDice($0) } - dict[1291114285] = { return Api.MessageMedia.parse_messageMediaDocument($0) } + dict[-581497899] = { return Api.MessageMedia.parse_messageMediaDocument($0) } dict[1038967584] = { return Api.MessageMedia.parse_messageMediaEmpty($0) } dict[-38694904] = { return Api.MessageMedia.parse_messageMediaGame($0) } dict[1457575028] = { return Api.MessageMedia.parse_messageMediaGeo($0) } diff --git a/submodules/TelegramApi/Sources/Api13.swift b/submodules/TelegramApi/Sources/Api13.swift index 3f76fc2bee..c5c11feab8 100644 --- a/submodules/TelegramApi/Sources/Api13.swift +++ b/submodules/TelegramApi/Sources/Api13.swift @@ -674,6 +674,7 @@ public extension Api { case keyboardButton(text: String) case keyboardButtonBuy(text: String) case keyboardButtonCallback(flags: Int32, text: String, data: Buffer) + case keyboardButtonCopy(text: String, copyText: String) case keyboardButtonGame(text: String) case keyboardButtonRequestGeoLocation(text: String) case keyboardButtonRequestPeer(text: String, buttonId: Int32, peerType: Api.RequestPeerType, maxQuantity: Int32) @@ -735,6 +736,13 @@ public extension Api { serializeString(text, buffer: buffer, boxed: false) serializeBytes(data, buffer: buffer, boxed: false) break + case .keyboardButtonCopy(let text, let copyText): + if boxed { + buffer.appendInt32(1976723854) + } + serializeString(text, buffer: buffer, boxed: false) + serializeString(copyText, buffer: buffer, boxed: false) + break case .keyboardButtonGame(let text): if boxed { buffer.appendInt32(1358175439) @@ -838,6 +846,8 @@ public extension Api { return ("keyboardButtonBuy", [("text", text as Any)]) case .keyboardButtonCallback(let flags, let text, let data): return ("keyboardButtonCallback", [("flags", flags as Any), ("text", text as Any), ("data", data as Any)]) + case .keyboardButtonCopy(let text, let copyText): + return ("keyboardButtonCopy", [("text", text as Any), ("copyText", copyText as Any)]) case .keyboardButtonGame(let text): return ("keyboardButtonGame", [("text", text as Any)]) case .keyboardButtonRequestGeoLocation(let text): @@ -968,6 +978,20 @@ public extension Api { return nil } } + public static func parse_keyboardButtonCopy(_ reader: BufferReader) -> KeyboardButton? { + var _1: String? + _1 = parseString(reader) + var _2: String? + _2 = parseString(reader) + let _c1 = _1 != nil + let _c2 = _2 != nil + if _c1 && _c2 { + return Api.KeyboardButton.keyboardButtonCopy(text: _1!, copyText: _2!) + } + else { + return nil + } + } public static func parse_keyboardButtonGame(_ reader: BufferReader) -> KeyboardButton? { var _1: String? _1 = parseString(reader) diff --git a/submodules/TelegramApi/Sources/Api15.swift b/submodules/TelegramApi/Sources/Api15.swift index eedd139355..77e5198937 100644 --- a/submodules/TelegramApi/Sources/Api15.swift +++ b/submodules/TelegramApi/Sources/Api15.swift @@ -710,7 +710,7 @@ public extension Api { indirect enum MessageMedia: TypeConstructorDescription { case messageMediaContact(phoneNumber: String, firstName: String, lastName: String, vcard: String, userId: Int64) case messageMediaDice(value: Int32, emoticon: String) - case messageMediaDocument(flags: Int32, document: Api.Document?, altDocument: Api.Document?, ttlSeconds: Int32?) + case messageMediaDocument(flags: Int32, document: Api.Document?, altDocuments: [Api.Document]?, ttlSeconds: Int32?) case messageMediaEmpty case messageMediaGame(game: Api.Game) case messageMediaGeo(geo: Api.GeoPoint) @@ -745,13 +745,17 @@ public extension Api { serializeInt32(value, buffer: buffer, boxed: false) serializeString(emoticon, buffer: buffer, boxed: false) break - case .messageMediaDocument(let flags, let document, let altDocument, let ttlSeconds): + case .messageMediaDocument(let flags, let document, let altDocuments, let ttlSeconds): if boxed { - buffer.appendInt32(1291114285) + buffer.appendInt32(-581497899) } serializeInt32(flags, buffer: buffer, boxed: false) if Int(flags) & Int(1 << 0) != 0 {document!.serialize(buffer, true)} - if Int(flags) & Int(1 << 5) != 0 {altDocument!.serialize(buffer, true)} + if Int(flags) & Int(1 << 5) != 0 {buffer.appendInt32(481674261) + buffer.appendInt32(Int32(altDocuments!.count)) + for item in altDocuments! { + item.serialize(buffer, true) + }} if Int(flags) & Int(1 << 2) != 0 {serializeInt32(ttlSeconds!, buffer: buffer, boxed: false)} break case .messageMediaEmpty: @@ -905,8 +909,8 @@ public extension Api { return ("messageMediaContact", [("phoneNumber", phoneNumber as Any), ("firstName", firstName as Any), ("lastName", lastName as Any), ("vcard", vcard as Any), ("userId", userId as Any)]) case .messageMediaDice(let value, let emoticon): return ("messageMediaDice", [("value", value as Any), ("emoticon", emoticon as Any)]) - case .messageMediaDocument(let flags, let document, let altDocument, let ttlSeconds): - return ("messageMediaDocument", [("flags", flags as Any), ("document", document as Any), ("altDocument", altDocument as Any), ("ttlSeconds", ttlSeconds as Any)]) + case .messageMediaDocument(let flags, let document, let altDocuments, let ttlSeconds): + return ("messageMediaDocument", [("flags", flags as Any), ("document", document as Any), ("altDocuments", altDocuments as Any), ("ttlSeconds", ttlSeconds as Any)]) case .messageMediaEmpty: return ("messageMediaEmpty", []) case .messageMediaGame(let game): @@ -982,9 +986,9 @@ public extension Api { if Int(_1!) & Int(1 << 0) != 0 {if let signature = reader.readInt32() { _2 = Api.parse(reader, signature: signature) as? Api.Document } } - var _3: Api.Document? - if Int(_1!) & Int(1 << 5) != 0 {if let signature = reader.readInt32() { - _3 = Api.parse(reader, signature: signature) as? Api.Document + var _3: [Api.Document]? + if Int(_1!) & Int(1 << 5) != 0 {if let _ = reader.readInt32() { + _3 = Api.parseVector(reader, elementSignature: 0, elementType: Api.Document.self) } } var _4: Int32? if Int(_1!) & Int(1 << 2) != 0 {_4 = reader.readInt32() } @@ -993,7 +997,7 @@ public extension Api { let _c3 = (Int(_1!) & Int(1 << 5) == 0) || _3 != nil let _c4 = (Int(_1!) & Int(1 << 2) == 0) || _4 != nil if _c1 && _c2 && _c3 && _c4 { - return Api.MessageMedia.messageMediaDocument(flags: _1!, document: _2, altDocument: _3, ttlSeconds: _4) + return Api.MessageMedia.messageMediaDocument(flags: _1!, document: _2, altDocuments: _3, ttlSeconds: _4) } else { return nil diff --git a/submodules/TelegramApi/Sources/Api36.swift b/submodules/TelegramApi/Sources/Api36.swift index 8d34e43419..a45ef83846 100644 --- a/submodules/TelegramApi/Sources/Api36.swift +++ b/submodules/TelegramApi/Sources/Api36.swift @@ -2608,12 +2608,13 @@ public extension Api.functions.channels { } } public extension Api.functions.channels { - static func clickSponsoredMessage(channel: Api.InputChannel, randomId: Buffer) -> (FunctionDescription, Buffer, DeserializeFunctionResponse) { + static func clickSponsoredMessage(flags: Int32, channel: Api.InputChannel, randomId: Buffer) -> (FunctionDescription, Buffer, DeserializeFunctionResponse) { let buffer = Buffer() - buffer.appendInt32(414170259) + buffer.appendInt32(21257589) + serializeInt32(flags, buffer: buffer, boxed: false) channel.serialize(buffer, true) serializeBytes(randomId, buffer: buffer, boxed: false) - return (FunctionDescription(name: "channels.clickSponsoredMessage", parameters: [("channel", String(describing: channel)), ("randomId", String(describing: randomId))]), buffer, DeserializeFunctionResponse { (buffer: Buffer) -> Api.Bool? in + return (FunctionDescription(name: "channels.clickSponsoredMessage", parameters: [("flags", String(describing: flags)), ("channel", String(describing: channel)), ("randomId", String(describing: randomId))]), buffer, DeserializeFunctionResponse { (buffer: Buffer) -> Api.Bool? in let reader = BufferReader(buffer) var result: Api.Bool? if let signature = reader.readInt32() { diff --git a/submodules/TelegramApi/Sources/Api5.swift b/submodules/TelegramApi/Sources/Api5.swift index bd121a4a0b..98c4ef46fc 100644 --- a/submodules/TelegramApi/Sources/Api5.swift +++ b/submodules/TelegramApi/Sources/Api5.swift @@ -1473,7 +1473,7 @@ public extension Api { case documentAttributeHasStickers case documentAttributeImageSize(w: Int32, h: Int32) case documentAttributeSticker(flags: Int32, alt: String, stickerset: Api.InputStickerSet, maskCoords: Api.MaskCoords?) - case documentAttributeVideo(flags: Int32, duration: Double, w: Int32, h: Int32, preloadPrefixSize: Int32?, videoStartTs: Double?) + case documentAttributeVideo(flags: Int32, duration: Double, w: Int32, h: Int32, preloadPrefixSize: Int32?, videoStartTs: Double?, videoCodec: String?) public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) { switch self { @@ -1529,9 +1529,9 @@ public extension Api { stickerset.serialize(buffer, true) if Int(flags) & Int(1 << 0) != 0 {maskCoords!.serialize(buffer, true)} break - case .documentAttributeVideo(let flags, let duration, let w, let h, let preloadPrefixSize, let videoStartTs): + case .documentAttributeVideo(let flags, let duration, let w, let h, let preloadPrefixSize, let videoStartTs, let videoCodec): if boxed { - buffer.appendInt32(389652397) + buffer.appendInt32(1137015880) } serializeInt32(flags, buffer: buffer, boxed: false) serializeDouble(duration, buffer: buffer, boxed: false) @@ -1539,6 +1539,7 @@ public extension Api { serializeInt32(h, buffer: buffer, boxed: false) if Int(flags) & Int(1 << 2) != 0 {serializeInt32(preloadPrefixSize!, buffer: buffer, boxed: false)} if Int(flags) & Int(1 << 4) != 0 {serializeDouble(videoStartTs!, buffer: buffer, boxed: false)} + if Int(flags) & Int(1 << 5) != 0 {serializeString(videoCodec!, buffer: buffer, boxed: false)} break } } @@ -1559,8 +1560,8 @@ public extension Api { return ("documentAttributeImageSize", [("w", w as Any), ("h", h as Any)]) case .documentAttributeSticker(let flags, let alt, let stickerset, let maskCoords): return ("documentAttributeSticker", [("flags", flags as Any), ("alt", alt as Any), ("stickerset", stickerset as Any), ("maskCoords", maskCoords as Any)]) - case .documentAttributeVideo(let flags, let duration, let w, let h, let preloadPrefixSize, let videoStartTs): - return ("documentAttributeVideo", [("flags", flags as Any), ("duration", duration as Any), ("w", w as Any), ("h", h as Any), ("preloadPrefixSize", preloadPrefixSize as Any), ("videoStartTs", videoStartTs as Any)]) + case .documentAttributeVideo(let flags, let duration, let w, let h, let preloadPrefixSize, let videoStartTs, let videoCodec): + return ("documentAttributeVideo", [("flags", flags as Any), ("duration", duration as Any), ("w", w as Any), ("h", h as Any), ("preloadPrefixSize", preloadPrefixSize as Any), ("videoStartTs", videoStartTs as Any), ("videoCodec", videoCodec as Any)]) } } @@ -1674,14 +1675,17 @@ public extension Api { if Int(_1!) & Int(1 << 2) != 0 {_5 = reader.readInt32() } var _6: Double? if Int(_1!) & Int(1 << 4) != 0 {_6 = reader.readDouble() } + var _7: String? + if Int(_1!) & Int(1 << 5) != 0 {_7 = parseString(reader) } let _c1 = _1 != nil let _c2 = _2 != nil let _c3 = _3 != nil let _c4 = _4 != nil let _c5 = (Int(_1!) & Int(1 << 2) == 0) || _5 != nil let _c6 = (Int(_1!) & Int(1 << 4) == 0) || _6 != nil - if _c1 && _c2 && _c3 && _c4 && _c5 && _c6 { - return Api.DocumentAttribute.documentAttributeVideo(flags: _1!, duration: _2!, w: _3!, h: _4!, preloadPrefixSize: _5, videoStartTs: _6) + let _c7 = (Int(_1!) & Int(1 << 5) == 0) || _7 != nil + if _c1 && _c2 && _c3 && _c4 && _c5 && _c6 && _c7 { + return Api.DocumentAttribute.documentAttributeVideo(flags: _1!, duration: _2!, w: _3!, h: _4!, preloadPrefixSize: _5, videoStartTs: _6, videoCodec: _7) } else { return nil diff --git a/submodules/TelegramCore/Sources/ApiUtils/ReplyMarkupMessageAttribute.swift b/submodules/TelegramCore/Sources/ApiUtils/ReplyMarkupMessageAttribute.swift index 9c1e70ad3d..581d20ecfb 100644 --- a/submodules/TelegramCore/Sources/ApiUtils/ReplyMarkupMessageAttribute.swift +++ b/submodules/TelegramCore/Sources/ApiUtils/ReplyMarkupMessageAttribute.swift @@ -89,6 +89,8 @@ extension ReplyMarkupButton { )) } self.init(title: text, titleWhenForwarded: nil, action: .requestPeer(peerType: mappedPeerType, buttonId: buttonId, maxQuantity: maxQuantity)) + case let .keyboardButtonCopy(text, payload): + self.init(title: text, titleWhenForwarded: nil, action: .copyText(payload: payload)) } } } diff --git a/submodules/TelegramCore/Sources/ApiUtils/TelegramMediaFile.swift b/submodules/TelegramCore/Sources/ApiUtils/TelegramMediaFile.swift index 611db7cedc..eb13b6699d 100644 --- a/submodules/TelegramCore/Sources/ApiUtils/TelegramMediaFile.swift +++ b/submodules/TelegramCore/Sources/ApiUtils/TelegramMediaFile.swift @@ -99,7 +99,8 @@ func telegramMediaFileAttributesFromApiAttributes(_ attributes: [Api.DocumentAtt result.append(.ImageSize(size: PixelDimensions(width: w, height: h))) case .documentAttributeAnimated: result.append(.Animated) - case let .documentAttributeVideo(flags, duration, w, h, preloadSize, videoStart): + case let .documentAttributeVideo(flags, duration, w, h, preloadSize, videoStart, codec): + let _ = codec var videoFlags = TelegramMediaVideoFlags() if (flags & (1 << 0)) != 0 { videoFlags.insert(.instantRoundVideo) diff --git a/submodules/TelegramCore/Sources/PendingMessages/PendingMessageUploadedContent.swift b/submodules/TelegramCore/Sources/PendingMessages/PendingMessageUploadedContent.swift index 63df2625db..51bd80a51f 100644 --- a/submodules/TelegramCore/Sources/PendingMessages/PendingMessageUploadedContent.swift +++ b/submodules/TelegramCore/Sources/PendingMessages/PendingMessageUploadedContent.swift @@ -720,7 +720,7 @@ func inputDocumentAttributesFromFileAttributes(_ fileAttributes: [TelegramMediaF if let coverTime = coverTime, coverTime > 0.0 { flags |= (1 << 4) } - attributes.append(.documentAttributeVideo(flags: flags, duration: duration, w: Int32(size.width), h: Int32(size.height), preloadPrefixSize: preloadSize, videoStartTs: coverTime)) + attributes.append(.documentAttributeVideo(flags: flags, duration: duration, w: Int32(size.width), h: Int32(size.height), preloadPrefixSize: preloadSize, videoStartTs: coverTime, videoCodec: nil)) case let .Audio(isVoice, duration, title, performer, waveform): var flags: Int32 = 0 if isVoice { diff --git a/submodules/TelegramCore/Sources/State/Serialization.swift b/submodules/TelegramCore/Sources/State/Serialization.swift index 46d4d1b6fe..a50963f612 100644 --- a/submodules/TelegramCore/Sources/State/Serialization.swift +++ b/submodules/TelegramCore/Sources/State/Serialization.swift @@ -210,7 +210,7 @@ public class BoxedMessage: NSObject { public class Serialization: NSObject, MTSerialization { public func currentLayer() -> UInt { - return 187 + return 188 } public func parseMessage(_ data: Data!) -> Any! { diff --git a/submodules/TelegramCore/Sources/SyncCore/SyncCore_ReplyMarkupMessageAttribute.swift b/submodules/TelegramCore/Sources/SyncCore/SyncCore_ReplyMarkupMessageAttribute.swift index acd70cce70..5b7a5302c1 100644 --- a/submodules/TelegramCore/Sources/SyncCore/SyncCore_ReplyMarkupMessageAttribute.swift +++ b/submodules/TelegramCore/Sources/SyncCore/SyncCore_ReplyMarkupMessageAttribute.swift @@ -232,6 +232,7 @@ public enum ReplyMarkupButtonAction: PostboxCoding, Equatable { case openUserProfile(peerId: PeerId) case openWebView(url: String, simple: Bool) case requestPeer(peerType: ReplyMarkupButtonRequestPeerType, buttonId: Int32, maxQuantity: Int32) + case copyText(payload: String) public init(decoder: PostboxDecoder) { switch decoder.decodeInt32ForKey("v", orElse: 0) { @@ -261,6 +262,8 @@ public enum ReplyMarkupButtonAction: PostboxCoding, Equatable { self = .openWebView(url: decoder.decodeStringForKey("u", orElse: ""), simple: decoder.decodeInt32ForKey("s", orElse: 0) != 0) case 12: self = .requestPeer(peerType: decoder.decode(ReplyMarkupButtonRequestPeerType.self, forKey: "pt") ?? ReplyMarkupButtonRequestPeerType.user(ReplyMarkupButtonRequestPeerType.User(isBot: nil, isPremium: nil)), buttonId: decoder.decodeInt32ForKey("b", orElse: 0), maxQuantity: decoder.decodeInt32ForKey("q", orElse: 1)) + case 13: + self = .copyText(payload: decoder.decodeStringForKey("p", orElse: "")) default: self = .text } @@ -313,6 +316,9 @@ public enum ReplyMarkupButtonAction: PostboxCoding, Equatable { encoder.encodeInt32(buttonId, forKey: "b") encoder.encode(peerType, forKey: "pt") encoder.encodeInt32(maxQuantity, forKey: "q") + case let .copyText(payload): + encoder.encodeInt32(13, forKey: "v") + encoder.encodeString(payload, forKey: "p") } } } diff --git a/submodules/TelegramCore/Sources/TelegramEngine/Messages/AdMessages.swift b/submodules/TelegramCore/Sources/TelegramEngine/Messages/AdMessages.swift index acc75aa7db..ee9351f768 100644 --- a/submodules/TelegramCore/Sources/TelegramEngine/Messages/AdMessages.swift +++ b/submodules/TelegramCore/Sources/TelegramEngine/Messages/AdMessages.swift @@ -531,8 +531,8 @@ private class AdMessagesHistoryContextImpl { self.maskAsSeenDisposables.set(signal.start(), forKey: opaqueId) } - func markAction(opaqueId: Data) { - _internal_markAdAction(account: self.account, peerId: self.peerId, opaqueId: opaqueId) + func markAction(opaqueId: Data, media: Bool, fullscreen: Bool) { + _internal_markAdAction(account: self.account, peerId: self.peerId, opaqueId: opaqueId, media: media, fullscreen: fullscreen) } func remove(opaqueId: Data) { @@ -593,9 +593,9 @@ public class AdMessagesHistoryContext { } } - public func markAction(opaqueId: Data) { + public func markAction(opaqueId: Data, media: Bool, fullscreen: Bool) { self.impl.with { impl in - impl.markAction(opaqueId: opaqueId) + impl.markAction(opaqueId: opaqueId, media: media, fullscreen: fullscreen) } } @@ -607,7 +607,7 @@ public class AdMessagesHistoryContext { } -func _internal_markAdAction(account: Account, peerId: EnginePeer.Id, opaqueId: Data) { +func _internal_markAdAction(account: Account, peerId: EnginePeer.Id, opaqueId: Data, media: Bool, fullscreen: Bool) { let signal: Signal = account.postbox.transaction { transaction -> Api.InputChannel? in return transaction.getPeer(peerId).flatMap(apiInputChannel) } @@ -615,7 +615,14 @@ func _internal_markAdAction(account: Account, peerId: EnginePeer.Id, opaqueId: D guard let inputChannel = inputChannel else { return .complete() } - return account.network.request(Api.functions.channels.clickSponsoredMessage(channel: inputChannel, randomId: Buffer(data: opaqueId))) + var flags: Int32 = 0 + if media { + flags |= (1 << 0) + } + if fullscreen { + flags |= (1 << 1) + } + return account.network.request(Api.functions.channels.clickSponsoredMessage(flags: flags, channel: inputChannel, randomId: Buffer(data: opaqueId))) |> `catch` { _ -> Signal in return .single(.boolFalse) } diff --git a/submodules/TelegramCore/Sources/TelegramEngine/Messages/Stories.swift b/submodules/TelegramCore/Sources/TelegramEngine/Messages/Stories.swift index d26c411426..db9cfc0cbf 100644 --- a/submodules/TelegramCore/Sources/TelegramEngine/Messages/Stories.swift +++ b/submodules/TelegramCore/Sources/TelegramEngine/Messages/Stories.swift @@ -2096,7 +2096,7 @@ extension Stories.StoredItem { var parsedAlternativeMedia: Media? switch media { case let .messageMediaDocument(_, _, altDocument, _): - if let altDocument = altDocument { + if let altDocument = altDocument?.first { parsedAlternativeMedia = telegramMediaFileFromApiDocument(altDocument) } default: diff --git a/submodules/TelegramCore/Sources/TelegramEngine/Messages/TelegramEngineMessages.swift b/submodules/TelegramCore/Sources/TelegramEngine/Messages/TelegramEngineMessages.swift index cec07550e2..6378ef5988 100644 --- a/submodules/TelegramCore/Sources/TelegramEngine/Messages/TelegramEngineMessages.swift +++ b/submodules/TelegramCore/Sources/TelegramEngine/Messages/TelegramEngineMessages.swift @@ -1466,8 +1466,9 @@ public extension TelegramEngine { public func updateExtendedMedia(messageIds: [EngineMessage.Id]) -> Signal { return _internal_updateExtendedMedia(account: self.account, messageIds: messageIds) } - public func markAdAction(peerId: EnginePeer.Id, opaqueId: Data) { - _internal_markAdAction(account: self.account, peerId: peerId, opaqueId: opaqueId) + + public func markAdAction(peerId: EnginePeer.Id, opaqueId: Data, media: Bool, fullscreen: Bool) { + _internal_markAdAction(account: self.account, peerId: peerId, opaqueId: opaqueId, media: media, fullscreen: fullscreen) } public func getAllLocalChannels(count: Int) -> Signal<[EnginePeer.Id], NoError> { diff --git a/submodules/TelegramCore/Sources/TelegramEngine/Stickers/ImportStickers.swift b/submodules/TelegramCore/Sources/TelegramEngine/Stickers/ImportStickers.swift index 6ba7171906..1965ed1812 100644 --- a/submodules/TelegramCore/Sources/TelegramEngine/Stickers/ImportStickers.swift +++ b/submodules/TelegramCore/Sources/TelegramEngine/Stickers/ImportStickers.swift @@ -80,7 +80,7 @@ func _internal_uploadSticker(account: Account, peer: Peer, resource: MediaResour var attributes: [Api.DocumentAttribute] = [] attributes.append(.documentAttributeSticker(flags: 0, alt: alt, stickerset: .inputStickerSetEmpty, maskCoords: nil)) if let duration { - attributes.append(.documentAttributeVideo(flags: 0, duration: duration, w: dimensions.width, h: dimensions.height, preloadPrefixSize: nil, videoStartTs: nil)) + attributes.append(.documentAttributeVideo(flags: 0, duration: duration, w: dimensions.width, h: dimensions.height, preloadPrefixSize: nil, videoStartTs: nil, videoCodec: nil)) } attributes.append(.documentAttributeImageSize(w: dimensions.width, h: dimensions.height)) return account.network.request(Api.functions.messages.uploadMedia(flags: 0, businessConnectionId: nil, peer: inputPeer, media: Api.InputMedia.inputMediaUploadedDocument(flags: flags, file: file, thumb: thumbnailFile, mimeType: mimeType, attributes: attributes, stickers: nil, ttlSeconds: nil))) diff --git a/submodules/TelegramPresentationData/Sources/PresentationThemeEssentialGraphics.swift b/submodules/TelegramPresentationData/Sources/PresentationThemeEssentialGraphics.swift index da4a919a0e..5143dcad64 100644 --- a/submodules/TelegramPresentationData/Sources/PresentationThemeEssentialGraphics.swift +++ b/submodules/TelegramPresentationData/Sources/PresentationThemeEssentialGraphics.swift @@ -543,6 +543,7 @@ public final class PrincipalThemeAdditionalGraphics { public let chatBubbleActionButtonIncomingProfileIconImage: UIImage public let chatBubbleActionButtonIncomingAddToChatIconImage: UIImage public let chatBubbleActionButtonIncomingWebAppIconImage: UIImage + public let chatBubbleActionButtonIncomingCopyIconImage: UIImage public let chatBubbleActionButtonOutgoingMessageIconImage: UIImage public let chatBubbleActionButtonOutgoingLinkIconImage: UIImage @@ -553,6 +554,7 @@ public final class PrincipalThemeAdditionalGraphics { public let chatBubbleActionButtonOutgoingProfileIconImage: UIImage public let chatBubbleActionButtonOutgoingAddToChatIconImage: UIImage public let chatBubbleActionButtonOutgoingWebAppIconImage: UIImage + public let chatBubbleActionButtonOutgoingCopyIconImage: UIImage public let chatEmptyItemLockIcon: UIImage public let emptyChatListCheckIcon: UIImage @@ -598,6 +600,8 @@ public final class PrincipalThemeAdditionalGraphics { self.chatBubbleActionButtonIncomingProfileIconImage = generateTintedImage(image: UIImage(bundleImageName: "Chat/Message/BotProfile"), color: bubbleVariableColor(variableColor: theme.message.incoming.actionButtonsTextColor, wallpaper: wallpaper))! self.chatBubbleActionButtonIncomingAddToChatIconImage = generateTintedImage(image: UIImage(bundleImageName: "Chat/Message/BotAddToChat"), color: bubbleVariableColor(variableColor: theme.message.incoming.actionButtonsTextColor, wallpaper: wallpaper))! self.chatBubbleActionButtonIncomingWebAppIconImage = generateTintedImage(image: UIImage(bundleImageName: "Chat/Message/BotWebApp"), color: bubbleVariableColor(variableColor: theme.message.incoming.actionButtonsTextColor, wallpaper: wallpaper))! + self.chatBubbleActionButtonIncomingCopyIconImage = generateTintedImage(image: UIImage(bundleImageName: "Chat/Message/BotCopy"), color: bubbleVariableColor(variableColor: theme.message.incoming.actionButtonsTextColor, wallpaper: wallpaper))! + self.chatBubbleActionButtonOutgoingMessageIconImage = generateTintedImage(image: UIImage(bundleImageName: "Chat/Message/BotMessage"), color: bubbleVariableColor(variableColor: theme.message.outgoing.actionButtonsTextColor, wallpaper: wallpaper))! self.chatBubbleActionButtonOutgoingLinkIconImage = generateTintedImage(image: UIImage(bundleImageName: "Chat/Message/BotLink"), color: bubbleVariableColor(variableColor: theme.message.outgoing.actionButtonsTextColor, wallpaper: wallpaper))! self.chatBubbleActionButtonOutgoingShareIconImage = generateTintedImage(image: UIImage(bundleImageName: "Chat/Message/BotShare"), color: bubbleVariableColor(variableColor: theme.message.outgoing.actionButtonsTextColor, wallpaper: wallpaper))! @@ -607,6 +611,7 @@ public final class PrincipalThemeAdditionalGraphics { self.chatBubbleActionButtonOutgoingProfileIconImage = generateTintedImage(image: UIImage(bundleImageName: "Chat/Message/BotProfile"), color: bubbleVariableColor(variableColor: theme.message.outgoing.actionButtonsTextColor, wallpaper: wallpaper))! self.chatBubbleActionButtonOutgoingAddToChatIconImage = generateTintedImage(image: UIImage(bundleImageName: "Chat/Message/BotAddToChat"), color: bubbleVariableColor(variableColor: theme.message.outgoing.actionButtonsTextColor, wallpaper: wallpaper))! self.chatBubbleActionButtonOutgoingWebAppIconImage = generateTintedImage(image: UIImage(bundleImageName: "Chat/Message/BotWebApp"), color: bubbleVariableColor(variableColor: theme.message.outgoing.actionButtonsTextColor, wallpaper: wallpaper))! + self.chatBubbleActionButtonOutgoingCopyIconImage = generateTintedImage(image: UIImage(bundleImageName: "Chat/Message/BotCopy"), color: bubbleVariableColor(variableColor: theme.message.outgoing.actionButtonsTextColor, wallpaper: wallpaper))! self.chatEmptyItemLockIcon = generateImage(CGSize(width: 9.0, height: 13.0), rotatedContext: { size, context in context.clear(CGRect(origin: CGPoint(), size: size)) diff --git a/submodules/TelegramUI/Components/Chat/ChatButtonKeyboardInputNode/Sources/ChatButtonKeyboardInputNode.swift b/submodules/TelegramUI/Components/Chat/ChatButtonKeyboardInputNode/Sources/ChatButtonKeyboardInputNode.swift index 269f0a80d2..f58859eb8e 100644 --- a/submodules/TelegramUI/Components/Chat/ChatButtonKeyboardInputNode/Sources/ChatButtonKeyboardInputNode.swift +++ b/submodules/TelegramUI/Components/Chat/ChatButtonKeyboardInputNode/Sources/ChatButtonKeyboardInputNode.swift @@ -438,6 +438,8 @@ public final class ChatButtonKeyboardInputNode: ChatInputNode { if let message = self.message { self.controllerInteraction.openRequestedPeerSelection(message.id, peerType, buttonId, maxQuantity) } + case let .copyText(payload): + self.controllerInteraction.copyText(payload) } if dismissIfOnce { if let message = self.message { diff --git a/submodules/TelegramUI/Components/Chat/ChatMessageActionButtonsNode/Sources/ChatMessageActionButtonsNode.swift b/submodules/TelegramUI/Components/Chat/ChatMessageActionButtonsNode/Sources/ChatMessageActionButtonsNode.swift index b52bbbe978..9c71bdb71b 100644 --- a/submodules/TelegramUI/Components/Chat/ChatMessageActionButtonsNode/Sources/ChatMessageActionButtonsNode.swift +++ b/submodules/TelegramUI/Components/Chat/ChatMessageActionButtonsNode/Sources/ChatMessageActionButtonsNode.swift @@ -215,6 +215,8 @@ private final class ChatMessageActionButtonNode: ASDisplayNode { iconImage = incoming ? graphics.chatBubbleActionButtonIncomingProfileIconImage : graphics.chatBubbleActionButtonOutgoingProfileIconImage case .openWebView: iconImage = incoming ? graphics.chatBubbleActionButtonIncomingWebAppIconImage : graphics.chatBubbleActionButtonOutgoingWebAppIconImage + case .copyText: + iconImage = incoming ? graphics.chatBubbleActionButtonIncomingCopyIconImage : graphics.chatBubbleActionButtonOutgoingCopyIconImage default: iconImage = nil } diff --git a/submodules/TelegramUI/Components/Chat/ChatMessageBubbleItemNode/Sources/ChatMessageBubbleItemNode.swift b/submodules/TelegramUI/Components/Chat/ChatMessageBubbleItemNode/Sources/ChatMessageBubbleItemNode.swift index 67c152fff5..eca22e7b7f 100644 --- a/submodules/TelegramUI/Components/Chat/ChatMessageBubbleItemNode/Sources/ChatMessageBubbleItemNode.swift +++ b/submodules/TelegramUI/Components/Chat/ChatMessageBubbleItemNode/Sources/ChatMessageBubbleItemNode.swift @@ -205,6 +205,7 @@ private func contentNodeMessagesAndClassesForItem(_ item: ChatMessageItem) -> ([ result.append((message, ChatMessageGiftBubbleContentNode.self, itemAttributes, BubbleItemAttributes(isAttachment: false, neighborType: .text, neighborSpacing: .default))) } else if case .giftStars = action.action { result.append((message, ChatMessageGiftBubbleContentNode.self, itemAttributes, BubbleItemAttributes(isAttachment: false, neighborType: .text, neighborSpacing: .default))) + skipText = true } else if case .suggestedProfilePhoto = action.action { result.append((message, ChatMessageProfilePhotoSuggestionContentNode.self, itemAttributes, BubbleItemAttributes(isAttachment: false, neighborType: .text, neighborSpacing: .default))) } else if case .setChatWallpaper = action.action { diff --git a/submodules/TelegramUI/Components/Chat/ChatMessageItemView/Sources/ChatMessageItemView.swift b/submodules/TelegramUI/Components/Chat/ChatMessageItemView/Sources/ChatMessageItemView.swift index 9424d985ab..0a99196ab3 100644 --- a/submodules/TelegramUI/Components/Chat/ChatMessageItemView/Sources/ChatMessageItemView.swift +++ b/submodules/TelegramUI/Components/Chat/ChatMessageItemView/Sources/ChatMessageItemView.swift @@ -863,6 +863,8 @@ open class ChatMessageItemView: ListViewItemNode, ChatMessageItemNodeProtocol { item.controllerInteraction.openWebView(button.title, url, simple, .generic) case .requestPeer: break + case let .copyText(payload): + item.controllerInteraction.copyText(payload) } } } diff --git a/submodules/TelegramUI/Sources/ChatController.swift b/submodules/TelegramUI/Sources/ChatController.swift index 99161ab2d3..8ab7dc49e5 100644 --- a/submodules/TelegramUI/Sources/ChatController.swift +++ b/submodules/TelegramUI/Sources/ChatController.swift @@ -2589,7 +2589,7 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G } if let message, let adAttribute = message.attributes.first(where: { $0 is AdMessageAttribute }) as? AdMessageAttribute { - strongSelf.chatDisplayNode.historyNode.adMessagesContext?.markAction(opaqueId: adAttribute.opaqueId) + strongSelf.chatDisplayNode.historyNode.adMessagesContext?.markAction(opaqueId: adAttribute.opaqueId, media: false, fullscreen: false) } if let performOpenURL = strongSelf.performOpenURL { @@ -3917,7 +3917,7 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G } } - self.chatDisplayNode.historyNode.adMessagesContext?.markAction(opaqueId: adAttribute.opaqueId) + self.chatDisplayNode.historyNode.adMessagesContext?.markAction(opaqueId: adAttribute.opaqueId, media: false, fullscreen: false) self.controllerInteraction?.openUrl(ChatControllerInteraction.OpenUrl(url: adAttribute.url, concealed: false, external: true, progress: progress)) }, openRequestedPeerSelection: { [weak self] messageId, peerType, buttonId, maxQuantity in guard let self else { diff --git a/submodules/TelegramUI/Sources/ChatPinnedMessageTitlePanelNode.swift b/submodules/TelegramUI/Sources/ChatPinnedMessageTitlePanelNode.swift index 9163d271b5..172cc9ef83 100644 --- a/submodules/TelegramUI/Sources/ChatPinnedMessageTitlePanelNode.swift +++ b/submodules/TelegramUI/Sources/ChatPinnedMessageTitlePanelNode.swift @@ -971,6 +971,8 @@ final class ChatPinnedMessageTitlePanelNode: ChatTitleAccessoryPanelNode { controllerInteraction.openWebView(button.title, url, simple, .generic) case .requestPeer: break + case let .copyText(payload): + controllerInteraction.copyText(payload) } break From d92249deba7c728dcb01f3b8f905f6d607c03b7b Mon Sep 17 00:00:00 2001 From: Ilya Laktyushin Date: Wed, 18 Sep 2024 01:26:06 +0400 Subject: [PATCH 2/2] Fix graphics --- .../Message/BotCopy.imageset/Contents.json | 12 ++++ .../Chat/Message/BotCopy.imageset/copy_10.pdf | 65 +++++++++++++++++++ 2 files changed, 77 insertions(+) create mode 100644 submodules/TelegramUI/Images.xcassets/Chat/Message/BotCopy.imageset/Contents.json create mode 100644 submodules/TelegramUI/Images.xcassets/Chat/Message/BotCopy.imageset/copy_10.pdf diff --git a/submodules/TelegramUI/Images.xcassets/Chat/Message/BotCopy.imageset/Contents.json b/submodules/TelegramUI/Images.xcassets/Chat/Message/BotCopy.imageset/Contents.json new file mode 100644 index 0000000000..ff2c7d7a8b --- /dev/null +++ b/submodules/TelegramUI/Images.xcassets/Chat/Message/BotCopy.imageset/Contents.json @@ -0,0 +1,12 @@ +{ + "images" : [ + { + "filename" : "copy_10.pdf", + "idiom" : "universal" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/submodules/TelegramUI/Images.xcassets/Chat/Message/BotCopy.imageset/copy_10.pdf b/submodules/TelegramUI/Images.xcassets/Chat/Message/BotCopy.imageset/copy_10.pdf new file mode 100644 index 0000000000..e8ae82e284 --- /dev/null +++ b/submodules/TelegramUI/Images.xcassets/Chat/Message/BotCopy.imageset/copy_10.pdf @@ -0,0 +1,65 @@ +%PDF-1.7 + +1 0 obj + << >> +endobj + +2 0 obj + << /Filter /FlateDecode + /Length 3 0 R + >> +stream +x͎$5{Fi_3]4Z Luiw3?˗z|ן>~}瓻?z|^||;™Xgټ,,X.gbg-z#յZ@|qQTbbUZ0̱yKBo'rO[ӆZ7Y,eoľJe²ZdIH5@\-[*`5eWJ.Z \UdS f`"8 YvKE bƲ)<>racIn<Ȯ] ڮ4H*:FEWUȅ yZ t[jB jq,MI(pQD;(;Sz[IJbCf+|HWbۗZN9c[z|;~E-L K,ww{aI}GZjn_dGye- +l'vlC̲YeT|Xɤ`GrjD!x# y_Dz3[0Qf鮦_QiYAXȗt5Cm'iRQ6ҤC[X"O)/Q)0Att +/LB $G+-$ ]$A|az?XP4u1 +JEu߁ LtYQ=Z^&D;"3tλҼ6{jM[G8Z pH"q+$z'؂*1-˗qkӲQ Kq':bpZ&"4oj̙B)萷J2~ +@N<-6o|R%p)ʧ U ekNPCU5nJJ?_ +wC `Nx]tʀ( PÖO/FTk! +sU^RC"N)3/L~+ i{-&TA(OIK)_LRRgݭ>Bst4@f|Ϝl_$6ʶ! dC6ըK|sCfˉj`C/C.BM1ʃv4Uv8!t Pu|]'ԿT +endstream +endobj + +3 0 obj + 1308 +endobj + +4 0 obj + << /Annots [] + /Type /Page + /MediaBox [ 0.000000 0.000000 10.000000 10.000000 ] + /Resources 1 0 R + /Contents 2 0 R + /Parent 5 0 R + >> +endobj + +5 0 obj + << /Kids [ 4 0 R ] + /Count 1 + /Type /Pages + >> +endobj + +6 0 obj + << /Pages 5 0 R + /Type /Catalog + >> +endobj + +xref +0 7 +0000000000 65535 f +0000000010 00000 n +0000000034 00000 n +0000001426 00000 n +0000001449 00000 n +0000001622 00000 n +0000001696 00000 n +trailer +<< /ID [ (some) (id) ] + /Root 6 0 R + /Size 7 +>> +startxref +1755 +%%EOF \ No newline at end of file