API update

This commit is contained in:
Peter 2019-01-03 23:17:45 +01:00
parent fa34786f68
commit 4529402de7
3 changed files with 64 additions and 3 deletions

View File

@ -353,6 +353,8 @@ fileprivate let parsers: [Int32 : (BufferReader) -> Any?] = {
dict[-714643696] = { return Api.ChannelAdminLogEventAction.parse_channelAdminLogEventActionParticipantToggleAdmin($0) }
dict[-1312568665] = { return Api.ChannelAdminLogEventAction.parse_channelAdminLogEventActionChangeStickerSet($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[737668643] = { return Api.help.ProxyData.parse_proxyDataPromo($0) }
dict[-543777747] = { return Api.auth.ExportedAuthorization.parse_exportedAuthorization($0) }

View File

@ -8468,6 +8468,8 @@ extension Api {
case channelAdminLogEventActionParticipantToggleAdmin(prevParticipant: Api.ChannelParticipant, newParticipant: Api.ChannelParticipant)
case channelAdminLogEventActionChangeStickerSet(prevStickerset: Api.InputStickerSet, newStickerset: Api.InputStickerSet)
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) {
switch self {
@ -8575,6 +8577,19 @@ extension Api {
}
newValue.serialize(buffer, true)
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)])
case .channelAdminLogEventActionTogglePreHistoryHidden(let 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
}
}
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 {

View File

@ -52,6 +52,9 @@ public enum AdminLogEventAction {
case participantToggleAdmin(prev: RenderedChannelParticipant, new: RenderedChannelParticipant)
case changeStickerPack(prev: StickerPackReference?, new: StickerPackReference?)
case togglePreHistoryHidden(Bool)
case updateDefaultBannedRights(prev: TelegramChatBannedRights, new: TelegramChatBannedRights
)
case pollStopped(Message)
}
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> {
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)
|> mapToSignal { (peer, admins) -> Signal<AdminLogEventsResult, ChannelAdminLogEventError> in
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 eventsFilter: Api.ChannelAdminLogEventsFilter? = nil
@ -122,7 +125,7 @@ public func channelAdminLogEvents(postbox: Postbox, network: Network, peerId: Pe
switch result {
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
current[peer.id] = peer
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))
case let .channelAdminLogEventActionTogglePreHistoryHidden(value):
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)
if let action = action {