From c64a28f022c12d29bf0dcbbe7a0b2f7d65968310 Mon Sep 17 00:00:00 2001 From: Ali <> Date: Fri, 20 Nov 2020 23:20:48 +0400 Subject: [PATCH] Update API --- submodules/TelegramApi/Sources/Api0.swift | 6 +-- submodules/TelegramApi/Sources/Api1.swift | 42 +++++++++---------- submodules/TelegramApi/Sources/Api3.swift | 35 ++++++---------- .../TelegramCore/Sources/GroupCalls.swift | 10 ++--- 4 files changed, 39 insertions(+), 54 deletions(-) diff --git a/submodules/TelegramApi/Sources/Api0.swift b/submodules/TelegramApi/Sources/Api0.swift index dc4989ab65..3e2cffef91 100644 --- a/submodules/TelegramApi/Sources/Api0.swift +++ b/submodules/TelegramApi/Sources/Api0.swift @@ -7,7 +7,7 @@ fileprivate let parsers: [Int32 : (BufferReader) -> Any?] = { dict[-1255641564] = { return parseString($0) } dict[-1240849242] = { return Api.messages.StickerSet.parse_stickerSet($0) } dict[1829443076] = { return Api.GroupCall.parse_groupCallPrivate($0) } - dict[1441699306] = { return Api.GroupCall.parse_groupCall($0) } + dict[2083222527] = { return Api.GroupCall.parse_groupCall($0) } dict[2004925620] = { return Api.GroupCall.parse_groupCallDiscarded($0) } dict[-457104426] = { return Api.InputGeoPoint.parse_inputGeoPointEmpty($0) } dict[1210199983] = { return Api.InputGeoPoint.parse_inputGeoPoint($0) } @@ -503,7 +503,7 @@ fileprivate let parsers: [Int32 : (BufferReader) -> Any?] = { dict[-1495959709] = { return Api.MessageReplyHeader.parse_messageReplyHeader($0) } dict[411017418] = { return Api.SecureValue.parse_secureValue($0) } dict[-316748368] = { return Api.SecureValueHash.parse_secureValueHash($0) } - dict[1118525718] = { return Api.phone.GroupCall.parse_groupCall($0) } + dict[1447862232] = { return Api.phone.GroupCall.parse_groupCall($0) } dict[-398136321] = { return Api.messages.SearchCounter.parse_searchCounter($0) } dict[-2128698738] = { return Api.auth.CheckedPhone.parse_checkedPhone($0) } dict[-1188055347] = { return Api.PageListItem.parse_pageListItemText($0) } @@ -881,7 +881,7 @@ public struct Api { return parser(reader) } else { - telegramApiLog("Type constructor \(String(UInt32(bitPattern: signature), radix: 16, uppercase: false)) not found") + telegramApiLog("Type constructor \(String(signature, radix: 16, uppercase: false)) not found") return nil } } diff --git a/submodules/TelegramApi/Sources/Api1.swift b/submodules/TelegramApi/Sources/Api1.swift index 5a3022bcde..b228a213c0 100644 --- a/submodules/TelegramApi/Sources/Api1.swift +++ b/submodules/TelegramApi/Sources/Api1.swift @@ -1911,7 +1911,7 @@ public struct messages { public extension Api { public enum GroupCall: TypeConstructorDescription { case groupCallPrivate(flags: Int32, id: Int64, accessHash: Int64, channelId: Int32?, participantsCount: Int32, adminId: Int32) - case groupCall(flags: Int32, id: Int64, accessHash: Int64, channelId: Int32?, adminId: Int32, reflectorId: Int64, params: Api.DataJSON?, version: Int32) + case groupCall(flags: Int32, id: Int64, accessHash: Int64, adminId: Int32, reflectorId: Int64, params: Api.DataJSON?, version: Int32) case groupCallDiscarded(id: Int64, accessHash: Int64, duration: Int32) public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) { @@ -1927,17 +1927,16 @@ public extension Api { serializeInt32(participantsCount, buffer: buffer, boxed: false) serializeInt32(adminId, buffer: buffer, boxed: false) break - case .groupCall(let flags, let id, let accessHash, let channelId, let adminId, let reflectorId, let params, let version): + case .groupCall(let flags, let id, let accessHash, let adminId, let reflectorId, let params, let version): if boxed { - buffer.appendInt32(1441699306) + buffer.appendInt32(2083222527) } serializeInt32(flags, buffer: buffer, boxed: false) serializeInt64(id, buffer: buffer, boxed: false) serializeInt64(accessHash, buffer: buffer, boxed: false) - if Int(flags) & Int(1 << 0) != 0 {serializeInt32(channelId!, buffer: buffer, boxed: false)} serializeInt32(adminId, buffer: buffer, boxed: false) serializeInt64(reflectorId, buffer: buffer, boxed: false) - if Int(flags) & Int(1 << 1) != 0 {params!.serialize(buffer, true)} + if Int(flags) & Int(1 << 0) != 0 {params!.serialize(buffer, true)} serializeInt32(version, buffer: buffer, boxed: false) break case .groupCallDiscarded(let id, let accessHash, let duration): @@ -1955,8 +1954,8 @@ public extension Api { switch self { case .groupCallPrivate(let flags, let id, let accessHash, let channelId, let participantsCount, let adminId): return ("groupCallPrivate", [("flags", flags), ("id", id), ("accessHash", accessHash), ("channelId", channelId), ("participantsCount", participantsCount), ("adminId", adminId)]) - case .groupCall(let flags, let id, let accessHash, let channelId, let adminId, let reflectorId, let params, let version): - return ("groupCall", [("flags", flags), ("id", id), ("accessHash", accessHash), ("channelId", channelId), ("adminId", adminId), ("reflectorId", reflectorId), ("params", params), ("version", version)]) + case .groupCall(let flags, let id, let accessHash, let adminId, let reflectorId, let params, let version): + return ("groupCall", [("flags", flags), ("id", id), ("accessHash", accessHash), ("adminId", adminId), ("reflectorId", reflectorId), ("params", params), ("version", version)]) case .groupCallDiscarded(let id, let accessHash, let duration): return ("groupCallDiscarded", [("id", id), ("accessHash", accessHash), ("duration", duration)]) } @@ -1996,27 +1995,24 @@ public extension Api { var _3: Int64? _3 = reader.readInt64() var _4: Int32? - if Int(_1!) & Int(1 << 0) != 0 {_4 = reader.readInt32() } - var _5: Int32? - _5 = reader.readInt32() - var _6: Int64? - _6 = reader.readInt64() - var _7: Api.DataJSON? - if Int(_1!) & Int(1 << 1) != 0 {if let signature = reader.readInt32() { - _7 = Api.parse(reader, signature: signature) as? Api.DataJSON + _4 = reader.readInt32() + var _5: Int64? + _5 = reader.readInt64() + var _6: Api.DataJSON? + if Int(_1!) & Int(1 << 0) != 0 {if let signature = reader.readInt32() { + _6 = Api.parse(reader, signature: signature) as? Api.DataJSON } } - var _8: Int32? - _8 = reader.readInt32() + var _7: Int32? + _7 = reader.readInt32() let _c1 = _1 != nil let _c2 = _2 != nil let _c3 = _3 != nil - let _c4 = (Int(_1!) & Int(1 << 0) == 0) || _4 != nil + let _c4 = _4 != nil let _c5 = _5 != nil - let _c6 = _6 != nil - let _c7 = (Int(_1!) & Int(1 << 1) == 0) || _7 != nil - let _c8 = _8 != nil - if _c1 && _c2 && _c3 && _c4 && _c5 && _c6 && _c7 && _c8 { - return Api.GroupCall.groupCall(flags: _1!, id: _2!, accessHash: _3!, channelId: _4, adminId: _5!, reflectorId: _6!, params: _7, version: _8!) + let _c6 = (Int(_1!) & Int(1 << 0) == 0) || _6 != nil + let _c7 = _7 != nil + if _c1 && _c2 && _c3 && _c4 && _c5 && _c6 && _c7 { + return Api.GroupCall.groupCall(flags: _1!, id: _2!, accessHash: _3!, adminId: _4!, reflectorId: _5!, params: _6, version: _7!) } else { return nil diff --git a/submodules/TelegramApi/Sources/Api3.swift b/submodules/TelegramApi/Sources/Api3.swift index c096955a8a..44f25f5feb 100644 --- a/submodules/TelegramApi/Sources/Api3.swift +++ b/submodules/TelegramApi/Sources/Api3.swift @@ -1649,13 +1649,13 @@ public struct photos { public extension Api { public struct phone { public enum GroupCall: TypeConstructorDescription { - case groupCall(call: Api.GroupCall, sources: [Int32], participants: [Api.GroupCallParticipant], chats: [Api.Chat], users: [Api.User]) + case groupCall(call: Api.GroupCall, sources: [Int32], participants: [Api.GroupCallParticipant], users: [Api.User]) public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) { switch self { - case .groupCall(let call, let sources, let participants, let chats, let users): + case .groupCall(let call, let sources, let participants, let users): if boxed { - buffer.appendInt32(1118525718) + buffer.appendInt32(1447862232) } call.serialize(buffer, true) buffer.appendInt32(481674261) @@ -1669,11 +1669,6 @@ public struct phone { item.serialize(buffer, true) } buffer.appendInt32(481674261) - buffer.appendInt32(Int32(chats.count)) - for item in chats { - item.serialize(buffer, true) - } - buffer.appendInt32(481674261) buffer.appendInt32(Int32(users.count)) for item in users { item.serialize(buffer, true) @@ -1684,8 +1679,8 @@ public struct phone { public func descriptionFields() -> (String, [(String, Any)]) { switch self { - case .groupCall(let call, let sources, let participants, let chats, let users): - return ("groupCall", [("call", call), ("sources", sources), ("participants", participants), ("chats", chats), ("users", users)]) + case .groupCall(let call, let sources, let participants, let users): + return ("groupCall", [("call", call), ("sources", sources), ("participants", participants), ("users", users)]) } } @@ -1702,21 +1697,16 @@ public struct phone { if let _ = reader.readInt32() { _3 = Api.parseVector(reader, elementSignature: 0, elementType: Api.GroupCallParticipant.self) } - var _4: [Api.Chat]? + var _4: [Api.User]? if let _ = reader.readInt32() { - _4 = Api.parseVector(reader, elementSignature: 0, elementType: Api.Chat.self) - } - var _5: [Api.User]? - if let _ = reader.readInt32() { - _5 = Api.parseVector(reader, elementSignature: 0, elementType: Api.User.self) + _4 = Api.parseVector(reader, elementSignature: 0, elementType: Api.User.self) } let _c1 = _1 != nil let _c2 = _2 != nil let _c3 = _3 != nil let _c4 = _4 != nil - let _c5 = _5 != nil - if _c1 && _c2 && _c3 && _c4 && _c5 { - return Api.phone.GroupCall.groupCall(call: _1!, sources: _2!, participants: _3!, chats: _4!, users: _5!) + if _c1 && _c2 && _c3 && _c4 { + return Api.phone.GroupCall.groupCall(call: _1!, sources: _2!, participants: _3!, users: _4!) } else { return nil @@ -7249,13 +7239,12 @@ public extension Api { }) } - public static func createGroupCall(flags: Int32, channel: Api.InputChannel, randomId: Int32) -> (FunctionDescription, Buffer, DeserializeFunctionResponse) { + public static func createGroupCall(channel: Api.InputChannel, randomId: Int32) -> (FunctionDescription, Buffer, DeserializeFunctionResponse) { let buffer = Buffer() - buffer.appendInt32(-1542553507) - serializeInt32(flags, buffer: buffer, boxed: false) + buffer.appendInt32(-467076606) channel.serialize(buffer, true) serializeInt32(randomId, buffer: buffer, boxed: false) - return (FunctionDescription(name: "phone.createGroupCall", parameters: [("flags", flags), ("channel", channel), ("randomId", randomId)]), buffer, DeserializeFunctionResponse { (buffer: Buffer) -> Api.Updates? in + return (FunctionDescription(name: "phone.createGroupCall", parameters: [("channel", channel), ("randomId", randomId)]), buffer, DeserializeFunctionResponse { (buffer: Buffer) -> Api.Updates? in let reader = BufferReader(buffer) var result: Api.Updates? if let signature = reader.readInt32() { diff --git a/submodules/TelegramCore/Sources/GroupCalls.swift b/submodules/TelegramCore/Sources/GroupCalls.swift index f8ff085d34..c59fdd5fa8 100644 --- a/submodules/TelegramCore/Sources/GroupCalls.swift +++ b/submodules/TelegramCore/Sources/GroupCalls.swift @@ -23,7 +23,7 @@ private extension GroupCallInfo { clientParams: nil, version: nil ) - case let .groupCall(_, id, accessHash, channelId, _, _, params, version): + case let .groupCall(_, id, accessHash, _, _, params, version): var clientParams: String? if let params = params { switch params { @@ -34,7 +34,7 @@ private extension GroupCallInfo { self.init( id: id, accessHash: accessHash, - peerId: channelId.flatMap { PeerId(namespace: Namespaces.Peer.CloudChannel, id: $0) }, + peerId: nil, clientParams: clientParams, version: version ) @@ -84,7 +84,7 @@ public func getCurrentGroupCall(account: Account, peerId: PeerId) -> Signal mapToSignal { result -> Signal in switch result { - case let .groupCall(call, sources, participants, chats, users): + case let .groupCall(call, sources, participants, users): return account.postbox.transaction { transaction -> GroupCallInfo? in return GroupCallInfo(call) } @@ -110,7 +110,7 @@ public func createGroupCall(account: Account, peerId: PeerId) -> Signal mapError { _ -> CreateGroupCallError in return .generic } @@ -220,7 +220,7 @@ public func joinGroupCall(account: Account, callId: Int64, accessHash: Int64, jo } switch result { - case let .groupCall(call, sources, participants, chats, users): + case let .groupCall(call, sources, participants, users): guard let _ = GroupCallInfo(call) else { return .fail(.generic) }