From 9d30f02b767acb942bcdc22913398b61fd57c1a8 Mon Sep 17 00:00:00 2001 From: Ali <> Date: Tue, 24 Oct 2023 23:35:34 +0400 Subject: [PATCH] Update API --- submodules/TelegramApi/Sources/Api0.swift | 2 +- submodules/TelegramApi/Sources/Api5.swift | 12 +++--- .../State/AccountStateManagementUtils.swift | 38 +++++++++++++------ 3 files changed, 34 insertions(+), 18 deletions(-) diff --git a/submodules/TelegramApi/Sources/Api0.swift b/submodules/TelegramApi/Sources/Api0.swift index b1797c5ec8..cbb6492fe0 100644 --- a/submodules/TelegramApi/Sources/Api0.swift +++ b/submodules/TelegramApi/Sources/Api0.swift @@ -216,7 +216,7 @@ fileprivate let parsers: [Int32 : (BufferReader) -> Any?] = { dict[1815593308] = { return Api.DocumentAttribute.parse_documentAttributeImageSize($0) } dict[1662637586] = { return Api.DocumentAttribute.parse_documentAttributeSticker($0) } dict[-745541182] = { return Api.DocumentAttribute.parse_documentAttributeVideo($0) } - dict[-620277848] = { return Api.DraftMessage.parse_draftMessage($0) } + dict[1070397423] = { return Api.DraftMessage.parse_draftMessage($0) } dict[453805082] = { return Api.DraftMessage.parse_draftMessageEmpty($0) } dict[-1764723459] = { return Api.EmailVerification.parse_emailVerificationApple($0) } dict[-1842457175] = { return Api.EmailVerification.parse_emailVerificationCode($0) } diff --git a/submodules/TelegramApi/Sources/Api5.swift b/submodules/TelegramApi/Sources/Api5.swift index 8918bec605..b54c445aa2 100644 --- a/submodules/TelegramApi/Sources/Api5.swift +++ b/submodules/TelegramApi/Sources/Api5.swift @@ -1,13 +1,13 @@ public extension Api { indirect enum DraftMessage: TypeConstructorDescription { - case draftMessage(flags: Int32, replyTo: Api.MessageReplyHeader?, message: String, entities: [Api.MessageEntity]?, media: Api.MessageMedia?, date: Int32) + case draftMessage(flags: Int32, replyTo: Api.InputReplyTo?, message: String, entities: [Api.MessageEntity]?, media: Api.InputMedia?, date: Int32) case draftMessageEmpty(flags: Int32, date: Int32?) public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) { switch self { case .draftMessage(let flags, let replyTo, let message, let entities, let media, let date): if boxed { - buffer.appendInt32(-620277848) + buffer.appendInt32(1070397423) } serializeInt32(flags, buffer: buffer, boxed: false) if Int(flags) & Int(1 << 4) != 0 {replyTo!.serialize(buffer, true)} @@ -42,9 +42,9 @@ public extension Api { public static func parse_draftMessage(_ reader: BufferReader) -> DraftMessage? { var _1: Int32? _1 = reader.readInt32() - var _2: Api.MessageReplyHeader? + var _2: Api.InputReplyTo? if Int(_1!) & Int(1 << 4) != 0 {if let signature = reader.readInt32() { - _2 = Api.parse(reader, signature: signature) as? Api.MessageReplyHeader + _2 = Api.parse(reader, signature: signature) as? Api.InputReplyTo } } var _3: String? _3 = parseString(reader) @@ -52,9 +52,9 @@ public extension Api { if Int(_1!) & Int(1 << 3) != 0 {if let _ = reader.readInt32() { _4 = Api.parseVector(reader, elementSignature: 0, elementType: Api.MessageEntity.self) } } - var _5: Api.MessageMedia? + var _5: Api.InputMedia? if Int(_1!) & Int(1 << 5) != 0 {if let signature = reader.readInt32() { - _5 = Api.parse(reader, signature: signature) as? Api.MessageMedia + _5 = Api.parse(reader, signature: signature) as? Api.InputMedia } } var _6: Int32? _6 = reader.readInt32() diff --git a/submodules/TelegramCore/Sources/State/AccountStateManagementUtils.swift b/submodules/TelegramCore/Sources/State/AccountStateManagementUtils.swift index 8f1d291d91..f195353990 100644 --- a/submodules/TelegramCore/Sources/State/AccountStateManagementUtils.swift +++ b/submodules/TelegramCore/Sources/State/AccountStateManagementUtils.swift @@ -1538,27 +1538,43 @@ private func finalStateWithUpdatesAndServerTime(accountPeerId: PeerId, postbox: var replySubject: EngineMessageReplySubject? if let replyToMsgHeader = replyToMsgHeader { switch replyToMsgHeader { - case let .messageReplyHeader(_, replyToMsgId, replyToPeerId, replyHeader, replyMedia, replyToTopId, quoteText, quoteEntities): - let _ = replyHeader - let _ = replyMedia - let _ = replyToTopId + case let .inputReplyToMessage(_, replyToMsgId, topMsgId, replyToPeerId, quoteText, quoteEntities): + let _ = topMsgId var quote: EngineMessageReplyQuote? if let quoteText = quoteText { quote = EngineMessageReplyQuote( text: quoteText, entities: messageTextEntitiesFromApiEntities(quoteEntities ?? []), - media: textMediaAndExpirationTimerFromApiMedia(replyMedia, accountPeerId).media + media: nil ) } - if let replyToMsgId = replyToMsgId { - replySubject = EngineMessageReplySubject( - messageId: MessageId(peerId: replyToPeerId?.peerId ?? peer.peerId, namespace: Namespaces.Message.Cloud, id: replyToMsgId), - quote: quote - ) + var parsedReplyToPeerId: PeerId? + switch replyToPeerId { + case let .inputPeerChannel(channelId, _): + parsedReplyToPeerId = PeerId(namespace: Namespaces.Peer.CloudChannel, id: PeerId.Id._internalFromInt64Value(channelId)) + case let .inputPeerChannelFromMessage(_, _, channelId): + parsedReplyToPeerId = PeerId(namespace: Namespaces.Peer.CloudChannel, id: PeerId.Id._internalFromInt64Value(channelId)) + case let .inputPeerChat(chatId): + parsedReplyToPeerId = PeerId(namespace: Namespaces.Peer.CloudGroup, id: PeerId.Id._internalFromInt64Value(chatId)) + case .inputPeerEmpty: + break + case .inputPeerSelf: + parsedReplyToPeerId = accountPeerId + case let .inputPeerUser(userId, _): + parsedReplyToPeerId = PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt64Value(userId)) + case let .inputPeerUserFromMessage(_, _, userId): + parsedReplyToPeerId = PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt64Value(userId)) + case .none: + break } - case .messageReplyStoryHeader: + + replySubject = EngineMessageReplySubject( + messageId: MessageId(peerId: parsedReplyToPeerId ?? peer.peerId, namespace: Namespaces.Message.Cloud, id: replyToMsgId), + quote: quote + ) + case .inputReplyToStory: break } }