From 70d148102bca00e3d323b33fd56c6fa91e8b13f7 Mon Sep 17 00:00:00 2001 From: Ali <> Date: Mon, 22 Mar 2021 21:45:04 +0400 Subject: [PATCH] Update API --- submodules/TelegramApi/Sources/Api0.swift | 3 +- submodules/TelegramApi/Sources/Api2.swift | 40 +++++-------------- .../Sources/CachedChannelParticipants.swift | 2 +- .../Sources/ChannelBlacklist.swift | 12 +----- .../Sources/TelegramChannelBannedRights.swift | 3 -- 5 files changed, 15 insertions(+), 45 deletions(-) diff --git a/submodules/TelegramApi/Sources/Api0.swift b/submodules/TelegramApi/Sources/Api0.swift index fe4197b10a..7e1902600a 100644 --- a/submodules/TelegramApi/Sources/Api0.swift +++ b/submodules/TelegramApi/Sources/Api0.swift @@ -288,7 +288,7 @@ fileprivate let parsers: [Int32 : (BufferReader) -> Any?] = { dict[1149094475] = { return Api.ChannelParticipant.parse_channelParticipantCreator($0) } dict[-859915345] = { return Api.ChannelParticipant.parse_channelParticipantAdmin($0) } dict[1352785878] = { return Api.ChannelParticipant.parse_channelParticipantBanned($0) } - dict[-1010402965] = { return Api.ChannelParticipant.parse_channelParticipantLeft($0) } + dict[453242886] = { return Api.ChannelParticipant.parse_channelParticipantLeft($0) } dict[-1567730343] = { return Api.MessageUserVote.parse_messageUserVote($0) } dict[909603888] = { return Api.MessageUserVote.parse_messageUserVoteInputOption($0) } dict[244310238] = { return Api.MessageUserVote.parse_messageUserVoteMultiple($0) } @@ -471,7 +471,6 @@ fileprivate let parsers: [Int32 : (BufferReader) -> Any?] = { dict[-1036572727] = { return Api.account.PasswordInputSettings.parse_passwordInputSettings($0) } dict[878078826] = { return Api.PageTableCell.parse_pageTableCell($0) } dict[-1626209256] = { return Api.ChatBannedRights.parse_chatBannedRights($0) } - dict[423690591] = { return Api.ChatBannedRights.parse_chatBannedRightsChannel($0) } dict[1968737087] = { return Api.InputClientProxy.parse_inputClientProxy($0) } dict[649453030] = { return Api.messages.MessageEditData.parse_messageEditData($0) } dict[-886477832] = { return Api.LabeledPrice.parse_labeledPrice($0) } diff --git a/submodules/TelegramApi/Sources/Api2.swift b/submodules/TelegramApi/Sources/Api2.swift index dccf805d97..9466f52bb2 100644 --- a/submodules/TelegramApi/Sources/Api2.swift +++ b/submodules/TelegramApi/Sources/Api2.swift @@ -7363,7 +7363,7 @@ public extension Api { case channelParticipantCreator(flags: Int32, userId: Int32, adminRights: Api.ChatAdminRights, rank: String?) case channelParticipantAdmin(flags: Int32, userId: Int32, inviterId: Int32?, promotedBy: Int32, date: Int32, adminRights: Api.ChatAdminRights, rank: String?) case channelParticipantBanned(flags: Int32, peer: Api.Peer, kickedBy: Int32, date: Int32, bannedRights: Api.ChatBannedRights) - case channelParticipantLeft(userId: Int32) + case channelParticipantLeft(peer: Api.Peer) public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) { switch self { @@ -7413,11 +7413,11 @@ public extension Api { serializeInt32(date, buffer: buffer, boxed: false) bannedRights.serialize(buffer, true) break - case .channelParticipantLeft(let userId): + case .channelParticipantLeft(let peer): if boxed { - buffer.appendInt32(-1010402965) + buffer.appendInt32(453242886) } - serializeInt32(userId, buffer: buffer, boxed: false) + peer.serialize(buffer, true) break } } @@ -7434,8 +7434,8 @@ public extension Api { return ("channelParticipantAdmin", [("flags", flags), ("userId", userId), ("inviterId", inviterId), ("promotedBy", promotedBy), ("date", date), ("adminRights", adminRights), ("rank", rank)]) case .channelParticipantBanned(let flags, let peer, let kickedBy, let date, let bannedRights): return ("channelParticipantBanned", [("flags", flags), ("peer", peer), ("kickedBy", kickedBy), ("date", date), ("bannedRights", bannedRights)]) - case .channelParticipantLeft(let userId): - return ("channelParticipantLeft", [("userId", userId)]) + case .channelParticipantLeft(let peer): + return ("channelParticipantLeft", [("peer", peer)]) } } @@ -7551,11 +7551,13 @@ public extension Api { } } public static func parse_channelParticipantLeft(_ reader: BufferReader) -> ChannelParticipant? { - var _1: Int32? - _1 = reader.readInt32() + var _1: Api.Peer? + if let signature = reader.readInt32() { + _1 = Api.parse(reader, signature: signature) as? Api.Peer + } let _c1 = _1 != nil if _c1 { - return Api.ChannelParticipant.channelParticipantLeft(userId: _1!) + return Api.ChannelParticipant.channelParticipantLeft(peer: _1!) } else { return nil @@ -12069,7 +12071,6 @@ public extension Api { } public enum ChatBannedRights: TypeConstructorDescription { case chatBannedRights(flags: Int32, untilDate: Int32) - case chatBannedRightsChannel(flags: Int32) public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) { switch self { @@ -12080,12 +12081,6 @@ public extension Api { serializeInt32(flags, buffer: buffer, boxed: false) serializeInt32(untilDate, buffer: buffer, boxed: false) break - case .chatBannedRightsChannel(let flags): - if boxed { - buffer.appendInt32(423690591) - } - serializeInt32(flags, buffer: buffer, boxed: false) - break } } @@ -12093,8 +12088,6 @@ public extension Api { switch self { case .chatBannedRights(let flags, let untilDate): return ("chatBannedRights", [("flags", flags), ("untilDate", untilDate)]) - case .chatBannedRightsChannel(let flags): - return ("chatBannedRightsChannel", [("flags", flags)]) } } @@ -12112,17 +12105,6 @@ public extension Api { return nil } } - public static func parse_chatBannedRightsChannel(_ reader: BufferReader) -> ChatBannedRights? { - var _1: Int32? - _1 = reader.readInt32() - let _c1 = _1 != nil - if _c1 { - return Api.ChatBannedRights.chatBannedRightsChannel(flags: _1!) - } - else { - return nil - } - } } public enum InputClientProxy: TypeConstructorDescription { diff --git a/submodules/TelegramCore/Sources/CachedChannelParticipants.swift b/submodules/TelegramCore/Sources/CachedChannelParticipants.swift index c19c3e13c4..316e401263 100644 --- a/submodules/TelegramCore/Sources/CachedChannelParticipants.swift +++ b/submodules/TelegramCore/Sources/CachedChannelParticipants.swift @@ -211,7 +211,7 @@ extension ChannelParticipant { case let .channelParticipantSelf(userId, _, date): self = .member(id: PeerId(namespace: Namespaces.Peer.CloudUser, id: userId), invitedAt: date, adminInfo: nil, banInfo: nil, rank: nil) case let .channelParticipantLeft(userId): - self = .member(id: PeerId(namespace: Namespaces.Peer.CloudUser, id: userId), invitedAt: 0, adminInfo: nil, banInfo: nil, rank: nil) + self = .member(id: userId.peerId, invitedAt: 0, adminInfo: nil, banInfo: nil, rank: nil) } } } diff --git a/submodules/TelegramCore/Sources/ChannelBlacklist.swift b/submodules/TelegramCore/Sources/ChannelBlacklist.swift index 2f0cfe4bfa..67eaaa4c24 100644 --- a/submodules/TelegramCore/Sources/ChannelBlacklist.swift +++ b/submodules/TelegramCore/Sources/ChannelBlacklist.swift @@ -160,17 +160,9 @@ public func updateChannelMemberBannedRights(account: Account, peerId: PeerId, me let apiRights: Api.ChatBannedRights if let rights = rights, !rights.flags.isEmpty { - if memberId.namespace == Namespaces.Peer.CloudChannel { - apiRights = .chatBannedRightsChannel(flags: 1 << 0) - } else { - apiRights = rights.apiBannedRights - } + apiRights = rights.apiBannedRights } else { - if memberId.namespace == Namespaces.Peer.CloudChannel { - apiRights = .chatBannedRightsChannel(flags: 0) - } else { - apiRights = .chatBannedRights(flags: 0, untilDate: 0) - } + apiRights = .chatBannedRights(flags: 0, untilDate: 0) } return account.network.request(Api.functions.channels.editBanned(channel: inputChannel, participant: inputPeer, bannedRights: apiRights)) diff --git a/submodules/TelegramCore/Sources/TelegramChannelBannedRights.swift b/submodules/TelegramCore/Sources/TelegramChannelBannedRights.swift index 59ccc7f22b..1c9c2dd520 100644 --- a/submodules/TelegramCore/Sources/TelegramChannelBannedRights.swift +++ b/submodules/TelegramCore/Sources/TelegramChannelBannedRights.swift @@ -9,9 +9,6 @@ extension TelegramChatBannedRights { switch apiBannedRights { case let .chatBannedRights(flags, untilDate): self.init(flags: TelegramChatBannedRightsFlags(rawValue: flags), untilDate: untilDate) - case let .chatBannedRightsChannel(flags): - let isKicked = (flags & (1 << 0)) != 0 - self.init(flags: [.banReadMessages], untilDate: Int32.max) } }