From f6c2a515df0ca33837323554b81ab2c6fa2a8622 Mon Sep 17 00:00:00 2001 From: Peter Iakovlev Date: Wed, 7 Feb 2018 13:53:57 +0400 Subject: [PATCH] no message --- .../AccountStateManagementUtils.swift | 4 +- TelegramCore/AccountStateReset.swift | 2 +- TelegramCore/AccountViewTracker.swift | 4 +- TelegramCore/Api.swift | 240 ++++++++++++++---- TelegramCore/FetchChatList.swift | 2 +- TelegramCore/LoadMessagesIfNecessary.swift | 4 +- TelegramCore/LoadedPeerFromMessage.swift | 4 +- ...agedGroupFeedReadStateSyncOperations.swift | 2 +- ...agedSynchronizePinnedChatsOperations.swift | 2 +- TelegramCore/MultipartFetch.swift | 4 +- TelegramCore/PendingMessageManager.swift | 2 +- TelegramCore/SearchMessages.swift | 4 +- TelegramCore/SingleMessageView.swift | 4 +- TelegramCore/StoreMessage_Telegram.swift | 6 +- TelegramCore/TelegramMediaAction.swift | 14 + 15 files changed, 223 insertions(+), 75 deletions(-) diff --git a/TelegramCore/AccountStateManagementUtils.swift b/TelegramCore/AccountStateManagementUtils.swift index 0cb461e935..1a25a1dfd0 100644 --- a/TelegramCore/AccountStateManagementUtils.swift +++ b/TelegramCore/AccountStateManagementUtils.swift @@ -1141,10 +1141,10 @@ private func resolveAssociatedMessages(account: Account, state: AccountMutableSt if let peer = state.peers[peerId] { var signal: Signal? if peerId.namespace == Namespaces.Peer.CloudUser || peerId.namespace == Namespaces.Peer.CloudGroup { - signal = account.network.request(Api.functions.messages.getMessages(id: messageIds.map({ $0.id }))) + signal = account.network.request(Api.functions.messages.getMessages(id: messageIds.map({ Api.InputMessage.inputMessageID(id: $0.id) }))) } else if peerId.namespace == Namespaces.Peer.CloudChannel { if let inputChannel = apiInputChannel(peer) { - signal = account.network.request(Api.functions.channels.getMessages(channel: inputChannel, id: messageIds.map({ $0.id }))) + signal = account.network.request(Api.functions.channels.getMessages(channel: inputChannel, id: messageIds.map({ Api.InputMessage.inputMessageID(id: $0.id) }))) } } if let signal = signal { diff --git a/TelegramCore/AccountStateReset.swift b/TelegramCore/AccountStateReset.swift index a4c6b3457c..72d0666e20 100644 --- a/TelegramCore/AccountStateReset.swift +++ b/TelegramCore/AccountStateReset.swift @@ -54,7 +54,7 @@ func accountStateReset(postbox: Postbox, network: Network) -> Signal Signal switch inputPeer { case let .inputPeerChannel(channelId, accessHash): - messages = account.network.request(Api.functions.channels.getMessages(channel: Api.InputChannel.inputChannel(channelId: channelId, accessHash: accessHash), id: [messageId.id])) + messages = account.network.request(Api.functions.channels.getMessages(channel: Api.InputChannel.inputChannel(channelId: channelId, accessHash: accessHash), id: [Api.InputMessage.inputMessageID(id: messageId.id)])) default: - messages = account.network.request(Api.functions.messages.getMessages(id: [messageId.id])) + messages = account.network.request(Api.functions.messages.getMessages(id: [Api.InputMessage.inputMessageID(id: messageId.id)])) } return messages |> retryRequest diff --git a/TelegramCore/Api.swift b/TelegramCore/Api.swift index 4f603f8f68..40e3db2d90 100644 --- a/TelegramCore/Api.swift +++ b/TelegramCore/Api.swift @@ -126,7 +126,7 @@ fileprivate let parsers: [Int32 : (BufferReader) -> Any?] = { dict[129960444] = { return Api.UserStatus.parse_userStatusLastWeek($0) } dict[2011940674] = { return Api.UserStatus.parse_userStatusLastMonth($0) } dict[-455150117] = { return Api.Dialog.parse_dialog($0) } - dict[906521922] = { return Api.Dialog.parse_dialogFeed($0) } + dict[-1871228700] = { return Api.Dialog.parse_dialogFeed($0) } dict[1330637553] = { return Api.FeedBroadcasts.parse_feedBroadcasts($0) } dict[-1704428358] = { return Api.FeedBroadcasts.parse_feedBroadcastsUngrouped($0) } dict[381645902] = { return Api.SendMessageAction.parse_sendMessageTypingAction($0) } @@ -311,7 +311,7 @@ fileprivate let parsers: [Int32 : (BufferReader) -> Any?] = { dict[1694474197] = { return Api.messages.Chats.parse_chats($0) } dict[-1663561404] = { return Api.messages.Chats.parse_chatsSlice($0) } dict[1348066419] = { return Api.FeedPosition.parse_feedPosition($0) } - dict[834420005] = { return Api.InputSingleMedia.parse_inputSingleMedia($0) } + dict[482797855] = { return Api.InputSingleMedia.parse_inputSingleMedia($0) } dict[218751099] = { return Api.InputPrivacyRule.parse_inputPrivacyValueAllowContacts($0) } dict[407582158] = { return Api.InputPrivacyRule.parse_inputPrivacyValueAllowAll($0) } dict[320652927] = { return Api.InputPrivacyRule.parse_inputPrivacyValueAllowUsers($0) } @@ -396,6 +396,9 @@ fileprivate let parsers: [Int32 : (BufferReader) -> Any?] = { dict[-914167110] = { return Api.CdnPublicKey.parse_cdnPublicKey($0) } dict[53231223] = { return Api.InputGame.parse_inputGameID($0) } dict[-1020139510] = { return Api.InputGame.parse_inputGameShortName($0) } + dict[-1502174430] = { return Api.InputMessage.parse_inputMessageID($0) } + dict[-1160215659] = { return Api.InputMessage.parse_inputMessageReplyTo($0) } + dict[-2037963464] = { return Api.InputMessage.parse_inputMessagePinned($0) } dict[-1564789301] = { return Api.PhoneCallProtocol.parse_phoneCallProtocol($0) } dict[-860866985] = { return Api.WallPaper.parse_wallPaper($0) } dict[1662091044] = { return Api.WallPaper.parse_wallPaperSolid($0) } @@ -572,6 +575,7 @@ fileprivate let parsers: [Int32 : (BufferReader) -> Any?] = { dict[-2132731265] = { return Api.MessageAction.parse_messageActionPhoneCall($0) } dict[1200788123] = { return Api.MessageAction.parse_messageActionScreenshotTaken($0) } dict[-85549226] = { return Api.MessageAction.parse_messageActionCustomAction($0) } + dict[-1410748418] = { return Api.MessageAction.parse_messageActionBotAllowed($0) } dict[1399245077] = { return Api.PhoneCall.parse_phoneCallEmpty($0) } dict[462375633] = { return Api.PhoneCall.parse_phoneCallWaiting($0) } dict[-2089411356] = { return Api.PhoneCall.parse_phoneCallRequested($0) } @@ -614,6 +618,8 @@ fileprivate let parsers: [Int32 : (BufferReader) -> Any?] = { dict[1990644519] = { return Api.MessageEntity.parse_messageEntityTextUrl($0) } dict[892193368] = { return Api.MessageEntity.parse_messageEntityMentionName($0) } dict[546203849] = { return Api.MessageEntity.parse_inputMessageEntityMentionName($0) } + dict[-1687559349] = { return Api.MessageEntity.parse_messageEntityPhone($0) } + dict[1280209983] = { return Api.MessageEntity.parse_messageEntityCashtag($0) } dict[483901197] = { return Api.InputPhoto.parse_inputPhotoEmpty($0) } dict[-74070332] = { return Api.InputPhoto.parse_inputPhoto($0) } dict[-567906571] = { return Api.contacts.TopPeers.parse_topPeersNotModified($0) } @@ -923,6 +929,8 @@ public struct Api { _1.serialize(buffer, boxed) case let _1 as Api.InputGame: _1.serialize(buffer, boxed) + case let _1 as Api.InputMessage: + _1.serialize(buffer, boxed) case let _1 as Api.PhoneCallProtocol: _1.serialize(buffer, boxed) case let _1 as Api.WallPaper: @@ -4824,7 +4832,7 @@ public struct Api { public enum Dialog { case dialog(flags: Int32, peer: Api.Peer, topMessage: Int32, readInboxMaxId: Int32, readOutboxMaxId: Int32, unreadCount: Int32, unreadMentionsCount: Int32, notifySettings: Api.PeerNotifySettings, pts: Int32?, draft: Api.DraftMessage?) - case dialogFeed(flags: Int32, peer: Api.Peer, topMessage: Int32, feedId: Int32, feedOtherChannels: [Int32], readMaxPosition: Api.FeedPosition?, unreadCount: Int32, unreadMutedCount: Int32) + case dialogFeed(flags: Int32, peer: Api.Peer, topMessage: Int32, feedId: Int32, feedOtherChannels: [Int32], readMaxPosition: Api.FeedPosition?, unreadCount: Int32, unreadMutedCount: Int32, sourcesHash: Int32) public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) { switch self { @@ -4843,9 +4851,9 @@ public struct Api { if Int(flags) & Int(1 << 0) != 0 {serializeInt32(pts!, buffer: buffer, boxed: false)} if Int(flags) & Int(1 << 1) != 0 {draft!.serialize(buffer, true)} break - case .dialogFeed(let flags, let peer, let topMessage, let feedId, let feedOtherChannels, let readMaxPosition, let unreadCount, let unreadMutedCount): + case .dialogFeed(let flags, let peer, let topMessage, let feedId, let feedOtherChannels, let readMaxPosition, let unreadCount, let unreadMutedCount, let sourcesHash): if boxed { - buffer.appendInt32(906521922) + buffer.appendInt32(-1871228700) } serializeInt32(flags, buffer: buffer, boxed: false) peer.serialize(buffer, true) @@ -4859,6 +4867,7 @@ public struct Api { if Int(flags) & Int(1 << 3) != 0 {readMaxPosition!.serialize(buffer, true)} serializeInt32(unreadCount, buffer: buffer, boxed: false) serializeInt32(unreadMutedCount, buffer: buffer, boxed: false) + serializeInt32(sourcesHash, buffer: buffer, boxed: false) break } } @@ -4930,6 +4939,8 @@ public struct Api { _7 = reader.readInt32() var _8: Int32? _8 = reader.readInt32() + var _9: Int32? + _9 = reader.readInt32() let _c1 = _1 != nil let _c2 = _2 != nil let _c3 = _3 != nil @@ -4938,8 +4949,9 @@ public struct Api { let _c6 = (Int(_1!) & Int(1 << 3) == 0) || _6 != nil let _c7 = _7 != nil let _c8 = _8 != nil - if _c1 && _c2 && _c3 && _c4 && _c5 && _c6 && _c7 && _c8 { - return Api.Dialog.dialogFeed(flags: _1!, peer: _2!, topMessage: _3!, feedId: _4!, feedOtherChannels: _5!, readMaxPosition: _6, unreadCount: _7!, unreadMutedCount: _8!) + let _c9 = _9 != nil + if _c1 && _c2 && _c3 && _c4 && _c5 && _c6 && _c7 && _c8 && _c9 { + return Api.Dialog.dialogFeed(flags: _1!, peer: _2!, topMessage: _3!, feedId: _4!, feedOtherChannels: _5!, readMaxPosition: _6, unreadCount: _7!, unreadMutedCount: _8!, sourcesHash: _9!) } else { return nil @@ -9253,16 +9265,16 @@ public struct Api { } public enum InputSingleMedia { - case inputSingleMedia(media: Api.InputMedia, flags: Int32, randomId: Int64, message: String, entities: [Api.MessageEntity]?) + case inputSingleMedia(flags: Int32, media: Api.InputMedia, randomId: Int64, message: String, entities: [Api.MessageEntity]?) public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) { switch self { - case .inputSingleMedia(let media, let flags, let randomId, let message, let entities): + case .inputSingleMedia(let flags, let media, let randomId, let message, let entities): if boxed { - buffer.appendInt32(834420005) + buffer.appendInt32(482797855) } - media.serialize(buffer, true) serializeInt32(flags, buffer: buffer, boxed: false) + media.serialize(buffer, true) serializeInt64(randomId, buffer: buffer, boxed: false) serializeString(message, buffer: buffer, boxed: false) if Int(flags) & Int(1 << 0) != 0 {buffer.appendInt32(481674261) @@ -9275,27 +9287,27 @@ public struct Api { } fileprivate static func parse_inputSingleMedia(_ reader: BufferReader) -> InputSingleMedia? { - var _1: Api.InputMedia? + var _1: Int32? + _1 = reader.readInt32() + var _2: Api.InputMedia? if let signature = reader.readInt32() { - _1 = Api.parse(reader, signature: signature) as? Api.InputMedia + _2 = Api.parse(reader, signature: signature) as? Api.InputMedia } - var _2: Int32? - _2 = reader.readInt32() var _3: Int64? _3 = reader.readInt64() var _4: String? _4 = parseString(reader) var _5: [Api.MessageEntity]? - if Int(_2!) & Int(1 << 0) != 0 {if let _ = reader.readInt32() { + if Int(_1!) & Int(1 << 0) != 0 {if let _ = reader.readInt32() { _5 = Api.parseVector(reader, elementSignature: 0, elementType: Api.MessageEntity.self) } } let _c1 = _1 != nil let _c2 = _2 != nil let _c3 = _3 != nil let _c4 = _4 != nil - let _c5 = (Int(_2!) & Int(1 << 0) == 0) || _5 != nil + let _c5 = (Int(_1!) & Int(1 << 0) == 0) || _5 != nil if _c1 && _c2 && _c3 && _c4 && _c5 { - return Api.InputSingleMedia.inputSingleMedia(media: _1!, flags: _2!, randomId: _3!, message: _4!, entities: _5) + return Api.InputSingleMedia.inputSingleMedia(flags: _1!, media: _2!, randomId: _3!, message: _4!, entities: _5) } else { return nil @@ -10992,6 +11004,62 @@ public struct Api { } + public enum InputMessage { + case inputMessageID(id: Int32) + case inputMessageReplyTo(id: Int32) + case inputMessagePinned + + public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) { + switch self { + case .inputMessageID(let id): + if boxed { + buffer.appendInt32(-1502174430) + } + serializeInt32(id, buffer: buffer, boxed: false) + break + case .inputMessageReplyTo(let id): + if boxed { + buffer.appendInt32(-1160215659) + } + serializeInt32(id, buffer: buffer, boxed: false) + break + case .inputMessagePinned: + if boxed { + buffer.appendInt32(-2037963464) + } + + break + } + } + + fileprivate static func parse_inputMessageID(_ reader: BufferReader) -> InputMessage? { + var _1: Int32? + _1 = reader.readInt32() + let _c1 = _1 != nil + if _c1 { + return Api.InputMessage.inputMessageID(id: _1!) + } + else { + return nil + } + } + fileprivate static func parse_inputMessageReplyTo(_ reader: BufferReader) -> InputMessage? { + var _1: Int32? + _1 = reader.readInt32() + let _c1 = _1 != nil + if _c1 { + return Api.InputMessage.inputMessageReplyTo(id: _1!) + } + else { + return nil + } + } + fileprivate static func parse_inputMessagePinned(_ reader: BufferReader) -> InputMessage? { + return Api.InputMessage.inputMessagePinned + } + + } + public enum PhoneCallProtocol { case phoneCallProtocol(flags: Int32, minLayer: Int32, maxLayer: Int32) @@ -14482,6 +14550,7 @@ public struct Api { case messageActionPhoneCall(flags: Int32, callId: Int64, reason: Api.PhoneCallDiscardReason?, duration: Int32?) case messageActionScreenshotTaken case messageActionCustomAction(message: String) + case messageActionBotAllowed(domain: String) public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) { switch self { @@ -14620,6 +14689,12 @@ public struct Api { } serializeString(message, buffer: buffer, boxed: false) break + case .messageActionBotAllowed(let domain): + if boxed { + buffer.appendInt32(-1410748418) + } + serializeString(domain, buffer: buffer, boxed: false) + break } } @@ -14843,6 +14918,17 @@ public struct Api { return nil } } + fileprivate static func parse_messageActionBotAllowed(_ reader: BufferReader) -> MessageAction? { + var _1: String? + _1 = parseString(reader) + let _c1 = _1 != nil + if _c1 { + return Api.MessageAction.messageActionBotAllowed(domain: _1!) + } + else { + return nil + } + } } @@ -15544,6 +15630,8 @@ public struct Api { case messageEntityTextUrl(offset: Int32, length: Int32, url: String) case messageEntityMentionName(offset: Int32, length: Int32, userId: Int32) case inputMessageEntityMentionName(offset: Int32, length: Int32, userId: Api.InputUser) + case messageEntityPhone(offset: Int32, length: Int32) + case messageEntityCashtag(offset: Int32, length: Int32) public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) { switch self { @@ -15642,6 +15730,20 @@ public struct Api { serializeInt32(length, buffer: buffer, boxed: false) userId.serialize(buffer, true) break + case .messageEntityPhone(let offset, let length): + if boxed { + buffer.appendInt32(-1687559349) + } + serializeInt32(offset, buffer: buffer, boxed: false) + serializeInt32(length, buffer: buffer, boxed: false) + break + case .messageEntityCashtag(let offset, let length): + if boxed { + buffer.appendInt32(1280209983) + } + serializeInt32(offset, buffer: buffer, boxed: false) + serializeInt32(length, buffer: buffer, boxed: false) + break } } @@ -15841,6 +15943,34 @@ public struct Api { return nil } } + fileprivate static func parse_messageEntityPhone(_ reader: BufferReader) -> MessageEntity? { + var _1: Int32? + _1 = reader.readInt32() + var _2: Int32? + _2 = reader.readInt32() + let _c1 = _1 != nil + let _c2 = _2 != nil + if _c1 && _c2 { + return Api.MessageEntity.messageEntityPhone(offset: _1!, length: _2!) + } + else { + return nil + } + } + fileprivate static func parse_messageEntityCashtag(_ reader: BufferReader) -> MessageEntity? { + var _1: Int32? + _1 = reader.readInt32() + var _2: Int32? + _2 = reader.readInt32() + let _c1 = _1 != nil + let _c2 = _2 != nil + if _c1 && _c2 { + return Api.MessageEntity.messageEntityCashtag(offset: _1!, length: _2!) + } + else { + return nil + } + } } @@ -18820,24 +18950,6 @@ public struct Api { public struct functions { public struct messages { - public static func getMessages(id: [Int32]) -> (CustomStringConvertible, Buffer, (Buffer) -> Api.messages.Messages?) { - let buffer = Buffer() - buffer.appendInt32(1109588596) - buffer.appendInt32(481674261) - buffer.appendInt32(Int32(id.count)) - for item in id { - serializeInt32(item, buffer: buffer, boxed: false) - } - return (FunctionDescription({return "(messages.getMessages id: \(id))"}), buffer, { (buffer: Buffer) -> Api.messages.Messages? in - let reader = BufferReader(buffer) - var result: Api.messages.Messages? - if let signature = reader.readInt32() { - result = Api.parse(reader, signature: signature) as? Api.messages.Messages - } - return result - }) - } - public static func getHistory(peer: Api.InputPeer, offsetId: Int32, offsetDate: Int32, addOffset: Int32, limit: Int32, maxId: Int32, minId: Int32, hash: Int32) -> (CustomStringConvertible, Buffer, (Buffer) -> Api.messages.Messages?) { let buffer = Buffer() buffer.appendInt32(-591691168) @@ -20293,6 +20405,24 @@ public struct Api { }) } + public static func getMessages(id: [Api.InputMessage]) -> (CustomStringConvertible, Buffer, (Buffer) -> Api.messages.Messages?) { + let buffer = Buffer() + buffer.appendInt32(1673946374) + buffer.appendInt32(481674261) + buffer.appendInt32(Int32(id.count)) + for item in id { + item.serialize(buffer, true) + } + return (FunctionDescription({return "(messages.getMessages id: \(id))"}), buffer, { (buffer: Buffer) -> Api.messages.Messages? in + let reader = BufferReader(buffer) + var result: Api.messages.Messages? + if let signature = reader.readInt32() { + result = Api.parse(reader, signature: signature) as? Api.messages.Messages + } + return result + }) + } + public static func getDialogs(flags: Int32, feedId: Int32?, offsetDate: Int32, offsetId: Int32, offsetPeer: Api.InputPeer, limit: Int32) -> (CustomStringConvertible, Buffer, (Buffer) -> Api.messages.Dialogs?) { let buffer = Buffer() buffer.appendInt32(96533218) @@ -20492,25 +20622,6 @@ public struct Api { }) } - public static func getMessages(channel: Api.InputChannel, id: [Int32]) -> (CustomStringConvertible, Buffer, (Buffer) -> Api.messages.Messages?) { - let buffer = Buffer() - buffer.appendInt32(-1814580409) - channel.serialize(buffer, true) - buffer.appendInt32(481674261) - buffer.appendInt32(Int32(id.count)) - for item in id { - serializeInt32(item, buffer: buffer, boxed: false) - } - return (FunctionDescription({return "(channels.getMessages channel: \(channel), id: \(id))"}), buffer, { (buffer: Buffer) -> Api.messages.Messages? in - let reader = BufferReader(buffer) - var result: Api.messages.Messages? - if let signature = reader.readInt32() { - result = Api.parse(reader, signature: signature) as? Api.messages.Messages - } - return result - }) - } - public static func getParticipant(channel: Api.InputChannel, userId: Api.InputUser) -> (CustomStringConvertible, Buffer, (Buffer) -> Api.channels.ChannelParticipant?) { let buffer = Buffer() buffer.appendInt32(1416484774) @@ -20955,6 +21066,25 @@ public struct Api { }) } + public static func getMessages(channel: Api.InputChannel, id: [Api.InputMessage]) -> (CustomStringConvertible, Buffer, (Buffer) -> Api.messages.Messages?) { + let buffer = Buffer() + buffer.appendInt32(-1383294429) + channel.serialize(buffer, true) + buffer.appendInt32(481674261) + buffer.appendInt32(Int32(id.count)) + for item in id { + item.serialize(buffer, true) + } + return (FunctionDescription({return "(channels.getMessages channel: \(channel), id: \(id))"}), buffer, { (buffer: Buffer) -> Api.messages.Messages? in + let reader = BufferReader(buffer) + var result: Api.messages.Messages? + if let signature = reader.readInt32() { + result = Api.parse(reader, signature: signature) as? Api.messages.Messages + } + return result + }) + } + public static func getFeed(flags: Int32, feedId: Int32, offsetPosition: Api.FeedPosition?, addOffset: Int32, limit: Int32, maxPosition: Api.FeedPosition?, minPosition: Api.FeedPosition?, sourcesHash: Int32, hash: Int32) -> (CustomStringConvertible, Buffer, (Buffer) -> Api.messages.FeedMessages?) { let buffer = Buffer() buffer.appendInt32(403799538) diff --git a/TelegramCore/FetchChatList.swift b/TelegramCore/FetchChatList.swift index 337b31237a..e0d4565582 100644 --- a/TelegramCore/FetchChatList.swift +++ b/TelegramCore/FetchChatList.swift @@ -106,7 +106,7 @@ private func parseDialogs(apiDialogs: [Api.Dialog], apiMessages: [Api.Message], } notificationSettings[peerId] = TelegramPeerNotificationSettings(apiSettings: apiNotificationSettings) - case let .dialogFeed(_, _, _, feedId, _, _, _, _): + case let .dialogFeed(_, _, _, feedId, _, _, _, _, _): itemIds.append(.group(PeerGroupId(rawValue: feedId))) referencedFeeds.insert(PeerGroupId(rawValue: feedId)) } diff --git a/TelegramCore/LoadMessagesIfNecessary.swift b/TelegramCore/LoadMessagesIfNecessary.swift index 68982f8ff3..83151b3199 100644 --- a/TelegramCore/LoadMessagesIfNecessary.swift +++ b/TelegramCore/LoadMessagesIfNecessary.swift @@ -51,10 +51,10 @@ public func getMessagesLoadIfNecessary(_ messageIds:[MessageId], postbox:Postbox if let peer = supportPeers[peerId] { var signal: Signal? if peerId.namespace == Namespaces.Peer.CloudUser || peerId.namespace == Namespaces.Peer.CloudGroup { - signal = network.request(Api.functions.messages.getMessages(id: messageIds.map({ $0.id }))) + signal = network.request(Api.functions.messages.getMessages(id: messageIds.map({ Api.InputMessage.inputMessageID(id: $0.id) }))) } else if peerId.namespace == Namespaces.Peer.CloudChannel { if let inputChannel = apiInputChannel(peer) { - signal = network.request(Api.functions.channels.getMessages(channel: inputChannel, id: messageIds.map({ $0.id }))) + signal = network.request(Api.functions.channels.getMessages(channel: inputChannel, id: messageIds.map({ Api.InputMessage.inputMessageID(id: $0.id) }))) } } if let signal = signal { diff --git a/TelegramCore/LoadedPeerFromMessage.swift b/TelegramCore/LoadedPeerFromMessage.swift index d38e3cf2d4..ff1fe565e5 100644 --- a/TelegramCore/LoadedPeerFromMessage.swift +++ b/TelegramCore/LoadedPeerFromMessage.swift @@ -16,13 +16,13 @@ public func loadedPeerFromMessage(account: Account, peerId: PeerId, messageId: M } else { let messageSignal: Signal? if messageId.peerId.namespace == Namespaces.Peer.CloudUser || messageId.peerId.namespace == Namespaces.Peer.CloudGroup { - messageSignal = account.network.request(Api.functions.messages.getMessages(id: [messageId.id])) + messageSignal = account.network.request(Api.functions.messages.getMessages(id: [Api.InputMessage.inputMessageID(id: messageId.id)])) |> map { Optional($0) } |> `catch` { _ -> Signal in return .single(nil) } } else if messageId.peerId.namespace == Namespaces.Peer.CloudChannel, let channelPeer = modifier.getPeer(messageId.peerId), let inputChannel = apiInputChannel(channelPeer) { - messageSignal = account.network.request(Api.functions.channels.getMessages(channel: inputChannel, id: [messageId.id])) + messageSignal = account.network.request(Api.functions.channels.getMessages(channel: inputChannel, id: [Api.InputMessage.inputMessageID(id: messageId.id)])) |> map { Optional($0) } |> `catch` { _ -> Signal in return .single(nil) diff --git a/TelegramCore/ManagedGroupFeedReadStateSyncOperations.swift b/TelegramCore/ManagedGroupFeedReadStateSyncOperations.swift index 70f37e91e0..244781a3b9 100644 --- a/TelegramCore/ManagedGroupFeedReadStateSyncOperations.swift +++ b/TelegramCore/ManagedGroupFeedReadStateSyncOperations.swift @@ -100,7 +100,7 @@ private func fetchReadStateNext(network: Network, groupId: PeerGroupId) -> Signa switch result { case let .peerDialogs(dialogs, messages, _, _, _): for dialog in dialogs { - if case let .dialogFeed(_, _, topMessage, feedId, _, resultMaxReadPosition, _, _) = dialog { + if case let .dialogFeed(_, _, topMessage, feedId, _, resultMaxReadPosition, _, _, _) = dialog { assert(feedId == groupId.rawValue) if let resultMaxReadPosition = resultMaxReadPosition { switch resultMaxReadPosition { diff --git a/TelegramCore/ManagedSynchronizePinnedChatsOperations.swift b/TelegramCore/ManagedSynchronizePinnedChatsOperations.swift index a548513889..069f556a8d 100644 --- a/TelegramCore/ManagedSynchronizePinnedChatsOperations.swift +++ b/TelegramCore/ManagedSynchronizePinnedChatsOperations.swift @@ -185,7 +185,7 @@ private func synchronizePinnedChats(modifier: Modifier, postbox: Postbox, networ apiUnreadCount = unreadCount apiNotificationSettings = peerNotificationSettings apiChannelPts = pts - case let .dialogFeed(_, _, _, feedId, _, _, _, _): + case let .dialogFeed(_, _, _, feedId, _, _, _, _, _): remoteItemIds.append(.group(PeerGroupId(rawValue: feedId))) continue loop } diff --git a/TelegramCore/MultipartFetch.swift b/TelegramCore/MultipartFetch.swift index 5a44bd97e8..dfb8f51095 100644 --- a/TelegramCore/MultipartFetch.swift +++ b/TelegramCore/MultipartFetch.swift @@ -453,8 +453,8 @@ private final class MultipartFetchManager { self.rangesDisposable = (ranges |> deliverOn(self.queue)).start(next: { [weak self] ranges in if let strongSelf = self { - if let currentRanges = strongSelf.currentRanges { - let updatedRanges = currentRanges.subtracting(strongSelf.currentFilledRanges) + if let _ = strongSelf.currentRanges { + let updatedRanges = ranges.subtracting(strongSelf.currentFilledRanges) strongSelf.currentRanges = updatedRanges strongSelf.checkState() } else { diff --git a/TelegramCore/PendingMessageManager.swift b/TelegramCore/PendingMessageManager.swift index f3150bf8bf..946e41462c 100644 --- a/TelegramCore/PendingMessageManager.swift +++ b/TelegramCore/PendingMessageManager.swift @@ -564,7 +564,7 @@ public final class PendingMessageManager { singleFlags |= 1 << 0 } - singleMedias.append(.inputSingleMedia(media: inputMedia, flags: singleFlags, randomId: uniqueId, message: text, entities: messageEntities)) + singleMedias.append(.inputSingleMedia(flags: singleFlags, media: inputMedia, randomId: uniqueId, message: text, entities: messageEntities)) default: return .complete() } diff --git a/TelegramCore/SearchMessages.swift b/TelegramCore/SearchMessages.swift index a0029d9eaa..198848bd46 100644 --- a/TelegramCore/SearchMessages.swift +++ b/TelegramCore/SearchMessages.swift @@ -174,12 +174,12 @@ public func downloadMessage(account: Account, messageId: MessageId) -> Signal if messageId.peerId.namespace == Namespaces.Peer.CloudChannel { if let channel = apiInputChannel(peer) { - signal = account.network.request(Api.functions.channels.getMessages(channel: channel, id: [messageId.id])) + signal = account.network.request(Api.functions.channels.getMessages(channel: channel, id: [Api.InputMessage.inputMessageID(id: messageId.id)])) } else { signal = .complete() } } else { - signal = account.network.request(Api.functions.messages.getMessages(id: [messageId.id])) + signal = account.network.request(Api.functions.messages.getMessages(id: [Api.InputMessage.inputMessageID(id: messageId.id)])) } return signal |> mapError {_ in} |> mapToSignal { result -> Signal in diff --git a/TelegramCore/SingleMessageView.swift b/TelegramCore/SingleMessageView.swift index b3cea87cf5..04c5fa419d 100644 --- a/TelegramCore/SingleMessageView.swift +++ b/TelegramCore/SingleMessageView.swift @@ -35,10 +35,10 @@ private func fetchMessage(modifier: Modifier, account: Account, messageId: Messa if let peer = modifier.getPeer(messageId.peerId) { var signal: Signal? if messageId.peerId.namespace == Namespaces.Peer.CloudUser || messageId.peerId.namespace == Namespaces.Peer.CloudGroup { - signal = account.network.request(Api.functions.messages.getMessages(id: [messageId.id])) + signal = account.network.request(Api.functions.messages.getMessages(id: [Api.InputMessage.inputMessageID(id: messageId.id)])) } else if messageId.peerId.namespace == Namespaces.Peer.CloudChannel { if let inputChannel = apiInputChannel(peer) { - signal = account.network.request(Api.functions.channels.getMessages(channel: inputChannel, id: [messageId.id])) + signal = account.network.request(Api.functions.channels.getMessages(channel: inputChannel, id: [Api.InputMessage.inputMessageID(id: messageId.id)])) } } if let signal = signal { diff --git a/TelegramCore/StoreMessage_Telegram.swift b/TelegramCore/StoreMessage_Telegram.swift index 1086325c5b..78d4c51261 100644 --- a/TelegramCore/StoreMessage_Telegram.swift +++ b/TelegramCore/StoreMessage_Telegram.swift @@ -205,7 +205,7 @@ extension Api.Message { } switch action { - case .messageActionChannelCreate, .messageActionChatDeletePhoto, .messageActionChatEditPhoto, .messageActionChatEditTitle, .messageActionEmpty, .messageActionPinMessage, .messageActionHistoryClear, .messageActionGameScore, .messageActionPaymentSent, .messageActionPaymentSentMe, .messageActionPhoneCall, .messageActionScreenshotTaken, .messageActionCustomAction: + case .messageActionChannelCreate, .messageActionChatDeletePhoto, .messageActionChatEditPhoto, .messageActionChatEditTitle, .messageActionEmpty, .messageActionPinMessage, .messageActionHistoryClear, .messageActionGameScore, .messageActionPaymentSent, .messageActionPaymentSentMe, .messageActionPhoneCall, .messageActionScreenshotTaken, .messageActionCustomAction, .messageActionBotAllowed: break case let .messageActionChannelMigrateFrom(_, chatId): result.append(PeerId(namespace: Namespaces.Peer.CloudGroup, id: chatId)) @@ -351,6 +351,10 @@ func messageTextEntitiesFromApiEntities(_ entities: [Api.MessageEntity]) -> [Mes result.append(MessageTextEntity(range: Int(offset) ..< Int(offset + length), type: .TextUrl(url: url))) case let .messageEntityMentionName(offset, length, userId): result.append(MessageTextEntity(range: Int(offset) ..< Int(offset + length), type: .TextMention(peerId: PeerId(namespace: Namespaces.Peer.CloudUser, id: userId)))) + case let .messageEntityPhone(offset, length): + result.append(MessageTextEntity(range: Int(offset) ..< Int(offset + length), type: .PhoneNumber)) + case let .messageEntityCashtag(offset, length): + result.append(MessageTextEntity(range: Int(offset) ..< Int(offset + length), type: .Hashtag)) } } return result diff --git a/TelegramCore/TelegramMediaAction.swift b/TelegramCore/TelegramMediaAction.swift index 8303c93081..b4ac204458 100644 --- a/TelegramCore/TelegramMediaAction.swift +++ b/TelegramCore/TelegramMediaAction.swift @@ -30,6 +30,7 @@ public enum TelegramMediaActionType: PostboxCoding, Equatable { case phoneCall(callId: Int64, discardReason: PhoneCallDiscardReason?, duration: Int32?) case paymentSent(currency: String, totalAmount: Int64) case customText(text: String, entities: [MessageTextEntity]) + case botDomainAccessGranted(domain: String) public init(decoder: PostboxDecoder) { let rawValue: Int32 = decoder.decodeInt32ForKey("_rawValue", orElse: 0) @@ -70,6 +71,8 @@ public enum TelegramMediaActionType: PostboxCoding, Equatable { self = .paymentSent(currency: decoder.decodeStringForKey("currency", orElse: ""), totalAmount: decoder.decodeInt64ForKey("ta", orElse: 0)) case 16: self = .customText(text: decoder.decodeStringForKey("text", orElse: ""), entities: decoder.decodeObjectArrayWithDecoderForKey("ent")) + case 17: + self = .botDomainAccessGranted(domain: decoder.decodeStringForKey("do", orElse: "")) default: self = .unknown } @@ -144,6 +147,9 @@ public enum TelegramMediaActionType: PostboxCoding, Equatable { encoder.encodeInt32(16, forKey: "_rawValue") encoder.encodeString(text, forKey: "text") encoder.encodeObjectArray(entities, forKey: "ent") + case let .botDomainAccessGranted(domain): + encoder.encodeInt32(17, forKey: "_rawValue") + encoder.encodeString(domain, forKey: "do") } } @@ -269,6 +275,12 @@ public func ==(lhs: TelegramMediaActionType, rhs: TelegramMediaActionType) -> Bo } else { return false } + case let .botDomainAccessGranted(domain): + if case .botDomainAccessGranted(domain) = rhs { + return true + } else { + return false + } } return false } @@ -345,6 +357,8 @@ func telegramMediaActionFromApiAction(_ action: Api.MessageAction) -> TelegramMe return TelegramMediaAction(action: .historyScreenshot) case let .messageActionCustomAction(message): return TelegramMediaAction(action: .customText(text: message, entities: [])) + case let .messageActionBotAllowed(domain): + return TelegramMediaAction(action: .botDomainAccessGranted(domain: domain)) } }