API update [skip ci]

This commit is contained in:
Ilya Laktyushin 2019-09-02 21:29:05 +03:00
parent 85c1b270ff
commit e4a472f246
4 changed files with 27 additions and 11 deletions

View File

@ -721,7 +721,7 @@ fileprivate let parsers: [Int32 : (BufferReader) -> Any?] = {
dict[-104284986] = { return Api.WebDocument.parse_webDocumentNoProxy($0) } dict[-104284986] = { return Api.WebDocument.parse_webDocumentNoProxy($0) }
dict[475467473] = { return Api.WebDocument.parse_webDocument($0) } dict[475467473] = { return Api.WebDocument.parse_webDocument($0) }
dict[1211967244] = { return Api.Theme.parse_themeDocumentNotModified($0) } dict[1211967244] = { return Api.Theme.parse_themeDocumentNotModified($0) }
dict[975846885] = { return Api.Theme.parse_theme($0) } dict[-136770336] = { return Api.Theme.parse_theme($0) }
dict[-1290580579] = { return Api.contacts.Found.parse_found($0) } dict[-1290580579] = { return Api.contacts.Found.parse_found($0) }
dict[-368018716] = { return Api.ChannelAdminLogEventsFilter.parse_channelAdminLogEventsFilter($0) } dict[-368018716] = { return Api.ChannelAdminLogEventsFilter.parse_channelAdminLogEventsFilter($0) }
dict[1889961234] = { return Api.PeerNotifySettings.parse_peerNotifySettingsEmpty($0) } dict[1889961234] = { return Api.PeerNotifySettings.parse_peerNotifySettingsEmpty($0) }

View File

@ -18231,7 +18231,7 @@ public extension Api {
} }
public enum Theme: TypeConstructorDescription { public enum Theme: TypeConstructorDescription {
case themeDocumentNotModified case themeDocumentNotModified
case theme(flags: Int32, id: Int64, accessHash: Int64, slug: String, title: String, document: Api.Document?) case theme(flags: Int32, id: Int64, accessHash: Int64, slug: String, title: String, document: Api.Document?, installsCount: Int32)
public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) { public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) {
switch self { switch self {
@ -18241,9 +18241,9 @@ public extension Api {
} }
break break
case .theme(let flags, let id, let accessHash, let slug, let title, let document): case .theme(let flags, let id, let accessHash, let slug, let title, let document, let installsCount):
if boxed { if boxed {
buffer.appendInt32(975846885) buffer.appendInt32(-136770336)
} }
serializeInt32(flags, buffer: buffer, boxed: false) serializeInt32(flags, buffer: buffer, boxed: false)
serializeInt64(id, buffer: buffer, boxed: false) serializeInt64(id, buffer: buffer, boxed: false)
@ -18251,6 +18251,7 @@ public extension Api {
serializeString(slug, buffer: buffer, boxed: false) serializeString(slug, buffer: buffer, boxed: false)
serializeString(title, buffer: buffer, boxed: false) serializeString(title, buffer: buffer, boxed: false)
if Int(flags) & Int(1 << 2) != 0 {document!.serialize(buffer, true)} if Int(flags) & Int(1 << 2) != 0 {document!.serialize(buffer, true)}
serializeInt32(installsCount, buffer: buffer, boxed: false)
break break
} }
} }
@ -18259,8 +18260,8 @@ public extension Api {
switch self { switch self {
case .themeDocumentNotModified: case .themeDocumentNotModified:
return ("themeDocumentNotModified", []) return ("themeDocumentNotModified", [])
case .theme(let flags, let id, let accessHash, let slug, let title, let document): case .theme(let flags, let id, let accessHash, let slug, let title, let document, let installsCount):
return ("theme", [("flags", flags), ("id", id), ("accessHash", accessHash), ("slug", slug), ("title", title), ("document", document)]) return ("theme", [("flags", flags), ("id", id), ("accessHash", accessHash), ("slug", slug), ("title", title), ("document", document), ("installsCount", installsCount)])
} }
} }
@ -18282,14 +18283,17 @@ public extension Api {
if Int(_1!) & Int(1 << 2) != 0 {if let signature = reader.readInt32() { if Int(_1!) & Int(1 << 2) != 0 {if let signature = reader.readInt32() {
_6 = Api.parse(reader, signature: signature) as? Api.Document _6 = Api.parse(reader, signature: signature) as? Api.Document
} } } }
var _7: Int32?
_7 = reader.readInt32()
let _c1 = _1 != nil let _c1 = _1 != nil
let _c2 = _2 != nil let _c2 = _2 != nil
let _c3 = _3 != nil let _c3 = _3 != nil
let _c4 = _4 != nil let _c4 = _4 != nil
let _c5 = _5 != nil let _c5 = _5 != nil
let _c6 = (Int(_1!) & Int(1 << 2) == 0) || _6 != nil let _c6 = (Int(_1!) & Int(1 << 2) == 0) || _6 != nil
if _c1 && _c2 && _c3 && _c4 && _c5 && _c6 { let _c7 = _7 != nil
return Api.Theme.theme(flags: _1!, id: _2!, accessHash: _3!, slug: _4!, title: _5!, document: _6) if _c1 && _c2 && _c3 && _c4 && _c5 && _c6 && _c7 {
return Api.Theme.theme(flags: _1!, id: _2!, accessHash: _3!, slug: _4!, title: _5!, document: _6, installsCount: _7!)
} }
else { else {
return nil return nil

View File

@ -17,8 +17,9 @@ public final class TelegramTheme: OrderedItemListEntryContents, Equatable {
public let file: TelegramMediaFile? public let file: TelegramMediaFile?
public let isCreator: Bool public let isCreator: Bool
public let isDefault: Bool public let isDefault: Bool
public let installCount: Int32
public init(id: Int64, accessHash: Int64, slug: String, title: String, file: TelegramMediaFile?, isCreator: Bool, isDefault: Bool) { public init(id: Int64, accessHash: Int64, slug: String, title: String, file: TelegramMediaFile?, isCreator: Bool, isDefault: Bool, installCount: Int32) {
self.id = id self.id = id
self.accessHash = accessHash self.accessHash = accessHash
self.slug = slug self.slug = slug
@ -26,6 +27,7 @@ public final class TelegramTheme: OrderedItemListEntryContents, Equatable {
self.file = file self.file = file
self.isCreator = isCreator self.isCreator = isCreator
self.isDefault = isDefault self.isDefault = isDefault
self.installCount = installCount
} }
public init(decoder: PostboxDecoder) { public init(decoder: PostboxDecoder) {
@ -36,6 +38,7 @@ public final class TelegramTheme: OrderedItemListEntryContents, Equatable {
self.file = decoder.decodeObjectForKey("file", decoder: { TelegramMediaFile(decoder: $0) }) as? TelegramMediaFile self.file = decoder.decodeObjectForKey("file", decoder: { TelegramMediaFile(decoder: $0) }) as? TelegramMediaFile
self.isCreator = decoder.decodeInt32ForKey("isCreator", orElse: 0) != 0 self.isCreator = decoder.decodeInt32ForKey("isCreator", orElse: 0) != 0
self.isDefault = decoder.decodeInt32ForKey("isDefault", orElse: 0) != 0 self.isDefault = decoder.decodeInt32ForKey("isDefault", orElse: 0) != 0
self.installCount = decoder.decodeInt32ForKey("installCount", orElse: 0)
} }
public func encode(_ encoder: PostboxEncoder) { public func encode(_ encoder: PostboxEncoder) {
@ -50,6 +53,7 @@ public final class TelegramTheme: OrderedItemListEntryContents, Equatable {
} }
encoder.encodeInt32(self.isCreator ? 1 : 0, forKey: "isCreator") encoder.encodeInt32(self.isCreator ? 1 : 0, forKey: "isCreator")
encoder.encodeInt32(self.isDefault ? 1 : 0, forKey: "isDefault") encoder.encodeInt32(self.isDefault ? 1 : 0, forKey: "isDefault")
encoder.encodeInt32(self.installCount, forKey: "installCount")
} }
public static func ==(lhs: TelegramTheme, rhs: TelegramTheme) -> Bool { public static func ==(lhs: TelegramTheme, rhs: TelegramTheme) -> Bool {
@ -74,6 +78,9 @@ public final class TelegramTheme: OrderedItemListEntryContents, Equatable {
if lhs.isDefault != rhs.isDefault { if lhs.isDefault != rhs.isDefault {
return false return false
} }
if lhs.installCount != rhs.installCount {
return false
}
return true return true
} }
} }
@ -81,8 +88,8 @@ public final class TelegramTheme: OrderedItemListEntryContents, Equatable {
extension TelegramTheme { extension TelegramTheme {
convenience init?(apiTheme: Api.Theme) { convenience init?(apiTheme: Api.Theme) {
switch apiTheme { switch apiTheme {
case let .theme(flags, id, accessHash, slug, title, document): case let .theme(flags, id, accessHash, slug, title, document, installCount):
self.init(id: id, accessHash: accessHash, slug: slug, title: title, file: document.flatMap(telegramMediaFileFromApiDocument), isCreator: (flags & 1 << 0) != 0, isDefault: (flags & 1 << 1) != 0) self.init(id: id, accessHash: accessHash, slug: slug, title: title, file: document.flatMap(telegramMediaFileFromApiDocument), isCreator: (flags & 1 << 0) != 0, isDefault: (flags & 1 << 1) != 0, installCount: installCount)
default: default:
return nil return nil
} }

View File

@ -278,6 +278,7 @@ private func uploadTheme(account: Account, resource: MediaResource, thumbnailDat
public enum CreateThemeError { public enum CreateThemeError {
case generic case generic
case slugInvalid case slugInvalid
case slugOccupied
} }
public enum CreateThemeResult { public enum CreateThemeResult {
@ -296,6 +297,8 @@ public func createTheme(account: Account, title: String, resource: MediaResource
|> mapError { error in |> mapError { error in
if error.errorDescription == "THEME_SLUG_INVALID" { if error.errorDescription == "THEME_SLUG_INVALID" {
return .slugInvalid return .slugInvalid
} else if error.errorDescription == "THEME_SLUG_OCCUPIED" {
return .slugOccupied
} }
return .generic return .generic
} }
@ -375,6 +378,8 @@ public func updateTheme(account: Account, accountManager: AccountManager, theme:
|> mapError { error in |> mapError { error in
if error.errorDescription == "THEME_SLUG_INVALID" { if error.errorDescription == "THEME_SLUG_INVALID" {
return .slugInvalid return .slugInvalid
} else if error.errorDescription == "THEME_SLUG_OCCUPIED" {
return .slugOccupied
} }
return .generic return .generic
} }