mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-12-04 21:41:45 +00:00
Update API
This commit is contained in:
parent
e89f808e42
commit
956a918d48
@ -442,8 +442,9 @@ fileprivate let parsers: [Int32 : (BufferReader) -> Any?] = {
|
||||
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) }
|
||||
dict[-1948219267] = { return Api.WallPaper.parse_wallPaper($0) }
|
||||
dict[-821868985] = { return Api.WallPaper.parse_wallPaperDocument($0) }
|
||||
dict[-1938715001] = { return Api.messages.Messages.parse_messages($0) }
|
||||
dict[1951620897] = { return Api.messages.Messages.parse_messagesNotModified($0) }
|
||||
dict[-1497072982] = { return Api.messages.Messages.parse_messagesSlice($0) }
|
||||
|
||||
@ -11168,11 +11168,25 @@ extension Api {
|
||||
|
||||
}
|
||||
enum WallPaper: TypeConstructorDescription {
|
||||
case wallPaper(id: Int32, title: String, sizes: [Api.PhotoSize], color: Int32)
|
||||
case wallPaperSolid(id: Int32, title: String, bgColor: Int32, color: Int32)
|
||||
case wallPaper(flags: Int32, id: Int64, accessHash: Int64, title: String, slug: String?, sizes: [Api.PhotoSize], color: Int32?)
|
||||
case wallPaperDocument(flags: Int32, id: Int64, accessHash: Int64, title: String, slug: String?, document: Api.Document, color: Int32?)
|
||||
|
||||
func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) {
|
||||
switch self {
|
||||
case .wallPaper(let id, let title, let sizes, let color):
|
||||
if boxed {
|
||||
buffer.appendInt32(-860866985)
|
||||
}
|
||||
serializeInt32(id, buffer: buffer, boxed: false)
|
||||
serializeString(title, buffer: buffer, boxed: false)
|
||||
buffer.appendInt32(481674261)
|
||||
buffer.appendInt32(Int32(sizes.count))
|
||||
for item in sizes {
|
||||
item.serialize(buffer, true)
|
||||
}
|
||||
serializeInt32(color, buffer: buffer, boxed: false)
|
||||
break
|
||||
case .wallPaperSolid(let id, let title, let bgColor, let color):
|
||||
if boxed {
|
||||
buffer.appendInt32(1662091044)
|
||||
@ -11182,20 +11196,16 @@ extension Api {
|
||||
serializeInt32(bgColor, buffer: buffer, boxed: false)
|
||||
serializeInt32(color, buffer: buffer, boxed: false)
|
||||
break
|
||||
case .wallPaper(let flags, let id, let accessHash, let title, let slug, let sizes, let color):
|
||||
case .wallPaperDocument(let flags, let id, let accessHash, let title, let slug, let document, let color):
|
||||
if boxed {
|
||||
buffer.appendInt32(-1948219267)
|
||||
buffer.appendInt32(-821868985)
|
||||
}
|
||||
serializeInt32(flags, buffer: buffer, boxed: false)
|
||||
serializeInt64(id, buffer: buffer, boxed: false)
|
||||
serializeInt64(accessHash, buffer: buffer, boxed: false)
|
||||
serializeString(title, buffer: buffer, boxed: false)
|
||||
if Int(flags) & Int(1 << 1) != 0 {serializeString(slug!, buffer: buffer, boxed: false)}
|
||||
buffer.appendInt32(481674261)
|
||||
buffer.appendInt32(Int32(sizes.count))
|
||||
for item in sizes {
|
||||
item.serialize(buffer, true)
|
||||
}
|
||||
document.serialize(buffer, true)
|
||||
if Int(flags) & Int(1 << 2) != 0 {serializeInt32(color!, buffer: buffer, boxed: false)}
|
||||
break
|
||||
}
|
||||
@ -11203,13 +11213,37 @@ extension Api {
|
||||
|
||||
func descriptionFields() -> (String, [(String, Any)]) {
|
||||
switch self {
|
||||
case .wallPaper(let id, let title, let sizes, let color):
|
||||
return ("wallPaper", [("id", id), ("title", title), ("sizes", sizes), ("color", color)])
|
||||
case .wallPaperSolid(let id, let title, let bgColor, let color):
|
||||
return ("wallPaperSolid", [("id", id), ("title", title), ("bgColor", bgColor), ("color", color)])
|
||||
case .wallPaper(let flags, let id, let accessHash, let title, let slug, let sizes, let color):
|
||||
return ("wallPaper", [("flags", flags), ("id", id), ("accessHash", accessHash), ("title", title), ("slug", slug), ("sizes", sizes), ("color", color)])
|
||||
case .wallPaperDocument(let flags, let id, let accessHash, let title, let slug, let document, let color):
|
||||
return ("wallPaperDocument", [("flags", flags), ("id", id), ("accessHash", accessHash), ("title", title), ("slug", slug), ("document", document), ("color", color)])
|
||||
}
|
||||
}
|
||||
|
||||
static func parse_wallPaper(_ reader: BufferReader) -> WallPaper? {
|
||||
var _1: Int32?
|
||||
_1 = reader.readInt32()
|
||||
var _2: String?
|
||||
_2 = parseString(reader)
|
||||
var _3: [Api.PhotoSize]?
|
||||
if let _ = reader.readInt32() {
|
||||
_3 = Api.parseVector(reader, elementSignature: 0, elementType: Api.PhotoSize.self)
|
||||
}
|
||||
var _4: Int32?
|
||||
_4 = reader.readInt32()
|
||||
let _c1 = _1 != nil
|
||||
let _c2 = _2 != nil
|
||||
let _c3 = _3 != nil
|
||||
let _c4 = _4 != nil
|
||||
if _c1 && _c2 && _c3 && _c4 {
|
||||
return Api.WallPaper.wallPaper(id: _1!, title: _2!, sizes: _3!, color: _4!)
|
||||
}
|
||||
else {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
static func parse_wallPaperSolid(_ reader: BufferReader) -> WallPaper? {
|
||||
var _1: Int32?
|
||||
_1 = reader.readInt32()
|
||||
@ -11230,7 +11264,7 @@ extension Api {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
static func parse_wallPaper(_ reader: BufferReader) -> WallPaper? {
|
||||
static func parse_wallPaperDocument(_ reader: BufferReader) -> WallPaper? {
|
||||
var _1: Int32?
|
||||
_1 = reader.readInt32()
|
||||
var _2: Int64?
|
||||
@ -11241,9 +11275,9 @@ extension Api {
|
||||
_4 = parseString(reader)
|
||||
var _5: String?
|
||||
if Int(_1!) & Int(1 << 1) != 0 {_5 = parseString(reader) }
|
||||
var _6: [Api.PhotoSize]?
|
||||
if let _ = reader.readInt32() {
|
||||
_6 = Api.parseVector(reader, elementSignature: 0, elementType: Api.PhotoSize.self)
|
||||
var _6: Api.Document?
|
||||
if let signature = reader.readInt32() {
|
||||
_6 = Api.parse(reader, signature: signature) as? Api.Document
|
||||
}
|
||||
var _7: Int32?
|
||||
if Int(_1!) & Int(1 << 2) != 0 {_7 = reader.readInt32() }
|
||||
@ -11255,7 +11289,7 @@ extension Api {
|
||||
let _c6 = _6 != nil
|
||||
let _c7 = (Int(_1!) & Int(1 << 2) == 0) || _7 != nil
|
||||
if _c1 && _c2 && _c3 && _c4 && _c5 && _c6 && _c7 {
|
||||
return Api.WallPaper.wallPaper(flags: _1!, id: _2!, accessHash: _3!, title: _4!, slug: _5, sizes: _6!, color: _7)
|
||||
return Api.WallPaper.wallPaperDocument(flags: _1!, id: _2!, accessHash: _3!, title: _4!, slug: _5, document: _6!, color: _7)
|
||||
}
|
||||
else {
|
||||
return nil
|
||||
|
||||
@ -5037,11 +5037,11 @@ extension Api {
|
||||
})
|
||||
}
|
||||
|
||||
static func uploadWallpaper(file: Api.InputFile) -> (FunctionDescription, Buffer, DeserializeFunctionResponse<Api.WallPaper>) {
|
||||
static func uploadWallPaper(file: Api.InputFile) -> (FunctionDescription, Buffer, DeserializeFunctionResponse<Api.WallPaper>) {
|
||||
let buffer = Buffer()
|
||||
buffer.appendInt32(-372068105)
|
||||
buffer.appendInt32(-748655323)
|
||||
file.serialize(buffer, true)
|
||||
return (FunctionDescription(name: "account.uploadWallpaper", parameters: [("file", file)]), buffer, DeserializeFunctionResponse { (buffer: Buffer) -> Api.WallPaper? in
|
||||
return (FunctionDescription(name: "account.uploadWallPaper", parameters: [("file", file)]), buffer, DeserializeFunctionResponse { (buffer: Buffer) -> Api.WallPaper? in
|
||||
let reader = BufferReader(buffer)
|
||||
var result: Api.WallPaper?
|
||||
if let signature = reader.readInt32() {
|
||||
|
||||
@ -96,7 +96,7 @@ func parseTelegramGroupOrChannel(chat: Api.Chat) -> Peer? {
|
||||
info = .broadcast(TelegramChannelBroadcastInfo(flags: []))
|
||||
}
|
||||
|
||||
return TelegramChannel(id: PeerId(namespace: Namespaces.Peer.CloudChannel, id: id), accessHash: accessHash, title: title, username: nil, photo: [], creationDate: 0, version: 0, participationStatus: .kicked, info: info, flags: TelegramChannelFlags(), restrictionInfo: nil, adminRights: nil, bannedRights: TelegramChatBannedRights(flags: [.banReadMessages], untilDate: untilDate ?? Int32.max), peerGroupId: nil)
|
||||
return TelegramChannel(id: PeerId(namespace: Namespaces.Peer.CloudChannel, id: id), accessHash: accessHash, title: title, username: nil, photo: [], creationDate: 0, version: 0, participationStatus: .kicked, info: info, flags: TelegramChannelFlags(), restrictionInfo: nil, adminRights: nil, bannedRights: TelegramChatBannedRights(flags: [.banReadMessages], personal: true, untilDate: untilDate ?? Int32.max), peerGroupId: nil)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -11,7 +11,7 @@ import Foundation
|
||||
|
||||
public func removePeerMember(account: Account, peerId: PeerId, memberId: PeerId) -> Signal<Void, NoError> {
|
||||
if peerId.namespace == Namespaces.Peer.CloudChannel {
|
||||
return updateChannelMemberBannedRights(account: account, peerId: peerId, memberId: memberId, rights: TelegramChatBannedRights(flags: [.banReadMessages], untilDate: 0))
|
||||
return updateChannelMemberBannedRights(account: account, peerId: peerId, memberId: memberId, rights: TelegramChatBannedRights(flags: [.banReadMessages], personal: false, untilDate: 0))
|
||||
|> mapToSignal { _ -> Signal<Void, NoError> in
|
||||
return .complete()
|
||||
}
|
||||
|
||||
@ -32,25 +32,29 @@ public struct TelegramChatBannedRightsFlags: OptionSet {
|
||||
|
||||
public struct TelegramChatBannedRights: PostboxCoding, Equatable {
|
||||
public let flags: TelegramChatBannedRightsFlags
|
||||
public let personal: Bool
|
||||
public let untilDate: Int32
|
||||
|
||||
public init(flags: TelegramChatBannedRightsFlags, untilDate: Int32) {
|
||||
public init(flags: TelegramChatBannedRightsFlags, personal: Bool, untilDate: Int32) {
|
||||
self.flags = flags
|
||||
self.personal = personal
|
||||
self.untilDate = untilDate
|
||||
}
|
||||
|
||||
public init(decoder: PostboxDecoder) {
|
||||
self.flags = TelegramChatBannedRightsFlags(rawValue: decoder.decodeInt32ForKey("f", orElse: 0))
|
||||
self.personal = decoder.decodeInt32ForKey("per", orElse: 0) != 0
|
||||
self.untilDate = decoder.decodeInt32ForKey("d", orElse: 0)
|
||||
}
|
||||
|
||||
public func encode(_ encoder: PostboxEncoder) {
|
||||
encoder.encodeInt32(self.flags.rawValue, forKey: "f")
|
||||
encoder.encodeInt32(self.personal ? 1 : 0, forKey: "per")
|
||||
encoder.encodeInt32(self.untilDate, forKey: "d")
|
||||
}
|
||||
|
||||
public static func ==(lhs: TelegramChatBannedRights, rhs: TelegramChatBannedRights) -> Bool {
|
||||
return lhs.flags == rhs.flags && lhs.untilDate == rhs.untilDate
|
||||
return lhs.flags == rhs.flags && lhs.personal == rhs.personal && lhs.untilDate == rhs.untilDate
|
||||
}
|
||||
}
|
||||
|
||||
@ -58,7 +62,7 @@ extension TelegramChatBannedRights {
|
||||
init(apiBannedRights: Api.ChatBannedRights) {
|
||||
switch apiBannedRights {
|
||||
case let .chatBannedRights(flags, untilDate):
|
||||
self.init(flags: TelegramChatBannedRightsFlags(rawValue: flags), untilDate: untilDate)
|
||||
self.init(flags: TelegramChatBannedRightsFlags(rawValue: flags), personal: (flags & 1 << 30) != 0, untilDate: untilDate)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -7,10 +7,13 @@ import Postbox
|
||||
import SwiftSignalKit
|
||||
#endif
|
||||
|
||||
//wallPaperDocument flags:# id:long creator:flags.0?true access_hash:long title:string slug:flags.1?string document:Document color:flags.2?int = WallPaper;
|
||||
|
||||
public enum TelegramWallpaper: OrderedItemListEntryContents, Equatable {
|
||||
case builtin
|
||||
case color(Int32)
|
||||
case image([TelegramMediaImageRepresentation])
|
||||
case file(id: Int64, accessHash: Int64, isCreator: Bool, title: String, slug: String?, file: TelegramMediaFile, color: Int32?)
|
||||
|
||||
public init(decoder: PostboxDecoder) {
|
||||
switch decoder.decodeInt32ForKey("v", orElse: 0) {
|
||||
@ -20,6 +23,8 @@ public enum TelegramWallpaper: OrderedItemListEntryContents, Equatable {
|
||||
self = .color(decoder.decodeInt32ForKey("c", orElse: 0))
|
||||
case 2:
|
||||
self = .image(decoder.decodeObjectArrayWithDecoderForKey("i"))
|
||||
case 3:
|
||||
self = .file(id: decoder.decodeInt64ForKey("id", orElse: 0), accessHash: decoder.decodeInt64ForKey("accessHash", orElse: 0), isCreator: decoder.decodeInt32ForKey("isCreator", orElse: 0) != 0, title: decoder.decodeStringForKey("title", orElse: ""), slug: decoder.decodeOptionalStringForKey("slug"), file: decoder.decodeObjectForKey("file", decoder: { TelegramMediaFile(decoder: $0) }) as! TelegramMediaFile, color: decoder.decodeOptionalInt32ForKey("color"))
|
||||
default:
|
||||
assertionFailure()
|
||||
self = .color(0xffffff)
|
||||
@ -45,6 +50,23 @@ public enum TelegramWallpaper: OrderedItemListEntryContents, Equatable {
|
||||
case let .image(representations):
|
||||
encoder.encodeInt32(2, forKey: "v")
|
||||
encoder.encodeObjectArray(representations, forKey: "i")
|
||||
case let .file(id, accessHash, isCreator, title, slug, file, color):
|
||||
encoder.encodeInt32(3, forKey: "v")
|
||||
encoder.encodeInt64(id, forKey: "id")
|
||||
encoder.encodeInt64(accessHash, forKey: "accessHash")
|
||||
encoder.encodeInt32(isCreator ? 1 : 0, forKey: "isCreator")
|
||||
encoder.encodeString(title, forKey: "title")
|
||||
if let slug = slug {
|
||||
encoder.encodeString(slug, forKey: "slug")
|
||||
} else {
|
||||
encoder.encodeNil(forKey: "slug")
|
||||
}
|
||||
encoder.encodeObject(file, forKey: "file")
|
||||
if let color = color {
|
||||
encoder.encodeInt32(color, forKey: "color")
|
||||
} else {
|
||||
encoder.encodeNil(forKey: "color")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -68,6 +90,10 @@ public func telegramWallpapers(postbox: Postbox, network: Network) -> Signal<[Te
|
||||
items.append(.image(telegramMediaImageRepresentationsFromApiSizes(wallPaper.sizes).1))
|
||||
case let .wallPaperSolid(_, _, bgColor, _):
|
||||
items.append(.color(bgColor))
|
||||
case let .wallPaperDocument(flags, id, accessHash, title, slug, document, color):
|
||||
if let file = telegramMediaFileFromApiDocument(document) {
|
||||
items.append(.file(id: id, accessHash: accessHash, isCreator: (flags & 1 << 0) != 0, title: title, slug: slug, file: file, color: color))
|
||||
}
|
||||
}
|
||||
}
|
||||
items.removeFirst()
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user