mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-12-16 11:20:18 +00:00
API update
This commit is contained in:
parent
fa34786f68
commit
4529402de7
@ -353,6 +353,8 @@ fileprivate let parsers: [Int32 : (BufferReader) -> Any?] = {
|
|||||||
dict[-714643696] = { return Api.ChannelAdminLogEventAction.parse_channelAdminLogEventActionParticipantToggleAdmin($0) }
|
dict[-714643696] = { return Api.ChannelAdminLogEventAction.parse_channelAdminLogEventActionParticipantToggleAdmin($0) }
|
||||||
dict[-1312568665] = { return Api.ChannelAdminLogEventAction.parse_channelAdminLogEventActionChangeStickerSet($0) }
|
dict[-1312568665] = { return Api.ChannelAdminLogEventAction.parse_channelAdminLogEventActionChangeStickerSet($0) }
|
||||||
dict[1599903217] = { return Api.ChannelAdminLogEventAction.parse_channelAdminLogEventActionTogglePreHistoryHidden($0) }
|
dict[1599903217] = { return Api.ChannelAdminLogEventAction.parse_channelAdminLogEventActionTogglePreHistoryHidden($0) }
|
||||||
|
dict[771095562] = { return Api.ChannelAdminLogEventAction.parse_channelAdminLogEventActionDefaultBannedRights($0) }
|
||||||
|
dict[-1895328189] = { return Api.ChannelAdminLogEventAction.parse_channelAdminLogEventActionStopPoll($0) }
|
||||||
dict[-526508104] = { return Api.help.ProxyData.parse_proxyDataEmpty($0) }
|
dict[-526508104] = { return Api.help.ProxyData.parse_proxyDataEmpty($0) }
|
||||||
dict[737668643] = { return Api.help.ProxyData.parse_proxyDataPromo($0) }
|
dict[737668643] = { return Api.help.ProxyData.parse_proxyDataPromo($0) }
|
||||||
dict[-543777747] = { return Api.auth.ExportedAuthorization.parse_exportedAuthorization($0) }
|
dict[-543777747] = { return Api.auth.ExportedAuthorization.parse_exportedAuthorization($0) }
|
||||||
|
|||||||
@ -8468,6 +8468,8 @@ extension Api {
|
|||||||
case channelAdminLogEventActionParticipantToggleAdmin(prevParticipant: Api.ChannelParticipant, newParticipant: Api.ChannelParticipant)
|
case channelAdminLogEventActionParticipantToggleAdmin(prevParticipant: Api.ChannelParticipant, newParticipant: Api.ChannelParticipant)
|
||||||
case channelAdminLogEventActionChangeStickerSet(prevStickerset: Api.InputStickerSet, newStickerset: Api.InputStickerSet)
|
case channelAdminLogEventActionChangeStickerSet(prevStickerset: Api.InputStickerSet, newStickerset: Api.InputStickerSet)
|
||||||
case channelAdminLogEventActionTogglePreHistoryHidden(newValue: Api.Bool)
|
case channelAdminLogEventActionTogglePreHistoryHidden(newValue: Api.Bool)
|
||||||
|
case channelAdminLogEventActionDefaultBannedRights(prevBannedRights: Api.ChatBannedRights, newBannedRights: Api.ChatBannedRights)
|
||||||
|
case channelAdminLogEventActionStopPoll(message: Api.Message)
|
||||||
|
|
||||||
func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) {
|
func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) {
|
||||||
switch self {
|
switch self {
|
||||||
@ -8575,6 +8577,19 @@ extension Api {
|
|||||||
}
|
}
|
||||||
newValue.serialize(buffer, true)
|
newValue.serialize(buffer, true)
|
||||||
break
|
break
|
||||||
|
case .channelAdminLogEventActionDefaultBannedRights(let prevBannedRights, let newBannedRights):
|
||||||
|
if boxed {
|
||||||
|
buffer.appendInt32(771095562)
|
||||||
|
}
|
||||||
|
prevBannedRights.serialize(buffer, true)
|
||||||
|
newBannedRights.serialize(buffer, true)
|
||||||
|
break
|
||||||
|
case .channelAdminLogEventActionStopPoll(let message):
|
||||||
|
if boxed {
|
||||||
|
buffer.appendInt32(-1895328189)
|
||||||
|
}
|
||||||
|
message.serialize(buffer, true)
|
||||||
|
break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -8612,6 +8627,10 @@ extension Api {
|
|||||||
return ("channelAdminLogEventActionChangeStickerSet", [("prevStickerset", prevStickerset), ("newStickerset", newStickerset)])
|
return ("channelAdminLogEventActionChangeStickerSet", [("prevStickerset", prevStickerset), ("newStickerset", newStickerset)])
|
||||||
case .channelAdminLogEventActionTogglePreHistoryHidden(let newValue):
|
case .channelAdminLogEventActionTogglePreHistoryHidden(let newValue):
|
||||||
return ("channelAdminLogEventActionTogglePreHistoryHidden", [("newValue", newValue)])
|
return ("channelAdminLogEventActionTogglePreHistoryHidden", [("newValue", newValue)])
|
||||||
|
case .channelAdminLogEventActionDefaultBannedRights(let prevBannedRights, let newBannedRights):
|
||||||
|
return ("channelAdminLogEventActionDefaultBannedRights", [("prevBannedRights", prevBannedRights), ("newBannedRights", newBannedRights)])
|
||||||
|
case .channelAdminLogEventActionStopPoll(let message):
|
||||||
|
return ("channelAdminLogEventActionStopPoll", [("message", message)])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -8831,6 +8850,37 @@ extension Api {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
static func parse_channelAdminLogEventActionDefaultBannedRights(_ reader: BufferReader) -> ChannelAdminLogEventAction? {
|
||||||
|
var _1: Api.ChatBannedRights?
|
||||||
|
if let signature = reader.readInt32() {
|
||||||
|
_1 = Api.parse(reader, signature: signature) as? Api.ChatBannedRights
|
||||||
|
}
|
||||||
|
var _2: Api.ChatBannedRights?
|
||||||
|
if let signature = reader.readInt32() {
|
||||||
|
_2 = Api.parse(reader, signature: signature) as? Api.ChatBannedRights
|
||||||
|
}
|
||||||
|
let _c1 = _1 != nil
|
||||||
|
let _c2 = _2 != nil
|
||||||
|
if _c1 && _c2 {
|
||||||
|
return Api.ChannelAdminLogEventAction.channelAdminLogEventActionDefaultBannedRights(prevBannedRights: _1!, newBannedRights: _2!)
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
}
|
||||||
|
static func parse_channelAdminLogEventActionStopPoll(_ reader: BufferReader) -> ChannelAdminLogEventAction? {
|
||||||
|
var _1: Api.Message?
|
||||||
|
if let signature = reader.readInt32() {
|
||||||
|
_1 = Api.parse(reader, signature: signature) as? Api.Message
|
||||||
|
}
|
||||||
|
let _c1 = _1 != nil
|
||||||
|
if _c1 {
|
||||||
|
return Api.ChannelAdminLogEventAction.channelAdminLogEventActionStopPoll(message: _1!)
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
enum SecurePlainData: TypeConstructorDescription {
|
enum SecurePlainData: TypeConstructorDescription {
|
||||||
|
|||||||
@ -52,6 +52,9 @@ public enum AdminLogEventAction {
|
|||||||
case participantToggleAdmin(prev: RenderedChannelParticipant, new: RenderedChannelParticipant)
|
case participantToggleAdmin(prev: RenderedChannelParticipant, new: RenderedChannelParticipant)
|
||||||
case changeStickerPack(prev: StickerPackReference?, new: StickerPackReference?)
|
case changeStickerPack(prev: StickerPackReference?, new: StickerPackReference?)
|
||||||
case togglePreHistoryHidden(Bool)
|
case togglePreHistoryHidden(Bool)
|
||||||
|
case updateDefaultBannedRights(prev: TelegramChatBannedRights, new: TelegramChatBannedRights
|
||||||
|
)
|
||||||
|
case pollStopped(Message)
|
||||||
}
|
}
|
||||||
|
|
||||||
public enum ChannelAdminLogEventError {
|
public enum ChannelAdminLogEventError {
|
||||||
@ -102,12 +105,12 @@ private func boolFromApiValue(_ value: Api.Bool) -> Bool {
|
|||||||
|
|
||||||
public func channelAdminLogEvents(postbox: Postbox, network: Network, peerId: PeerId, maxId: AdminLogEventId, minId: AdminLogEventId, limit: Int32 = 100, query: String? = nil, filter: AdminLogEventsFlags? = nil, admins: [PeerId]? = nil) -> Signal<AdminLogEventsResult, ChannelAdminLogEventError> {
|
public func channelAdminLogEvents(postbox: Postbox, network: Network, peerId: PeerId, maxId: AdminLogEventId, minId: AdminLogEventId, limit: Int32 = 100, query: String? = nil, filter: AdminLogEventsFlags? = nil, admins: [PeerId]? = nil) -> Signal<AdminLogEventsResult, ChannelAdminLogEventError> {
|
||||||
return postbox.transaction { transaction -> (Peer?, [Peer]?) in
|
return postbox.transaction { transaction -> (Peer?, [Peer]?) in
|
||||||
return (transaction.getPeer(peerId), admins?.flatMap { transaction.getPeer($0) })
|
return (transaction.getPeer(peerId), admins?.compactMap { transaction.getPeer($0) })
|
||||||
}
|
}
|
||||||
|> introduceError(ChannelAdminLogEventError.self)
|
|> introduceError(ChannelAdminLogEventError.self)
|
||||||
|> mapToSignal { (peer, admins) -> Signal<AdminLogEventsResult, ChannelAdminLogEventError> in
|
|> mapToSignal { (peer, admins) -> Signal<AdminLogEventsResult, ChannelAdminLogEventError> in
|
||||||
if let peer = peer, let inputChannel = apiInputChannel(peer) {
|
if let peer = peer, let inputChannel = apiInputChannel(peer) {
|
||||||
let inputAdmins = admins?.flatMap {apiInputUser($0)}
|
let inputAdmins = admins?.compactMap { apiInputUser($0) }
|
||||||
|
|
||||||
var flags: Int32 = 0
|
var flags: Int32 = 0
|
||||||
var eventsFilter: Api.ChannelAdminLogEventsFilter? = nil
|
var eventsFilter: Api.ChannelAdminLogEventsFilter? = nil
|
||||||
@ -122,7 +125,7 @@ public func channelAdminLogEvents(postbox: Postbox, network: Network, peerId: Pe
|
|||||||
|
|
||||||
switch result {
|
switch result {
|
||||||
case let .adminLogResults(apiEvents, apiChats, apiUsers):
|
case let .adminLogResults(apiEvents, apiChats, apiUsers):
|
||||||
let peers = (apiChats.flatMap {parseTelegramGroupOrChannel(chat: $0)} + apiUsers.flatMap { TelegramUser(user: $0) } + Array(arrayLiteral: peer)).reduce([:], { current, peer -> [PeerId : Peer] in
|
let peers = (apiChats.flatMap { parseTelegramGroupOrChannel(chat: $0) } + apiUsers.flatMap { TelegramUser(user: $0) } + Array(arrayLiteral: peer)).reduce([:], { current, peer -> [PeerId : Peer] in
|
||||||
var current = current
|
var current = current
|
||||||
current[peer.id] = peer
|
current[peer.id] = peer
|
||||||
return current
|
return current
|
||||||
@ -193,6 +196,12 @@ public func channelAdminLogEvents(postbox: Postbox, network: Network, peerId: Pe
|
|||||||
action = .changeStickerPack(prev: StickerPackReference(apiInputSet: prevStickerset), new: StickerPackReference(apiInputSet: newStickerset))
|
action = .changeStickerPack(prev: StickerPackReference(apiInputSet: prevStickerset), new: StickerPackReference(apiInputSet: newStickerset))
|
||||||
case let .channelAdminLogEventActionTogglePreHistoryHidden(value):
|
case let .channelAdminLogEventActionTogglePreHistoryHidden(value):
|
||||||
action = .togglePreHistoryHidden(value == .boolTrue)
|
action = .togglePreHistoryHidden(value == .boolTrue)
|
||||||
|
case let .channelAdminLogEventActionDefaultBannedRights(prevBannedRights, newBannedRights):
|
||||||
|
action = .updateDefaultBannedRights(prev: TelegramChatBannedRights(apiBannedRights: prevBannedRights), new: TelegramChatBannedRights(apiBannedRights: newBannedRights))
|
||||||
|
case let .channelAdminLogEventActionStopPoll(message):
|
||||||
|
if let message = StoreMessage(apiMessage: message), let rendered = locallyRenderedMessage(message: message, peers: peers) {
|
||||||
|
action = .pollStopped(rendered)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
let peerId = PeerId(namespace: Namespaces.Peer.CloudUser, id: userId)
|
let peerId = PeerId(namespace: Namespaces.Peer.CloudUser, id: userId)
|
||||||
if let action = action {
|
if let action = action {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user