mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-10-09 11:23:48 +00:00
Update API
This commit is contained in:
parent
37eb57779e
commit
c1018d3656
@ -993,6 +993,8 @@ fileprivate let parsers: [Int32 : (BufferReader) -> Any?] = {
|
||||
dict[1891070632] = { return Api.contacts.TopPeers.parse_topPeers($0) }
|
||||
dict[-1255369827] = { return Api.contacts.TopPeers.parse_topPeersDisabled($0) }
|
||||
dict[-567906571] = { return Api.contacts.TopPeers.parse_topPeersNotModified($0) }
|
||||
dict[-585598930] = { return Api.help.AppConfig.parse_appConfig($0) }
|
||||
dict[2094949405] = { return Api.help.AppConfig.parse_appConfigNotModified($0) }
|
||||
dict[-860107216] = { return Api.help.AppUpdate.parse_appUpdate($0) }
|
||||
dict[-1000708810] = { return Api.help.AppUpdate.parse_noAppUpdate($0) }
|
||||
dict[-2016381538] = { return Api.help.CountriesList.parse_countriesList($0) }
|
||||
@ -1775,6 +1777,8 @@ public extension Api {
|
||||
_1.serialize(buffer, boxed)
|
||||
case let _1 as Api.contacts.TopPeers:
|
||||
_1.serialize(buffer, boxed)
|
||||
case let _1 as Api.help.AppConfig:
|
||||
_1.serialize(buffer, boxed)
|
||||
case let _1 as Api.help.AppUpdate:
|
||||
_1.serialize(buffer, boxed)
|
||||
case let _1 as Api.help.CountriesList:
|
||||
|
@ -214,6 +214,60 @@ public extension Api.contacts {
|
||||
|
||||
}
|
||||
}
|
||||
public extension Api.help {
|
||||
enum AppConfig: TypeConstructorDescription {
|
||||
case appConfig(hash: Int32, config: Api.JSONValue)
|
||||
case appConfigNotModified
|
||||
|
||||
public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) {
|
||||
switch self {
|
||||
case .appConfig(let hash, let config):
|
||||
if boxed {
|
||||
buffer.appendInt32(-585598930)
|
||||
}
|
||||
serializeInt32(hash, buffer: buffer, boxed: false)
|
||||
config.serialize(buffer, true)
|
||||
break
|
||||
case .appConfigNotModified:
|
||||
if boxed {
|
||||
buffer.appendInt32(2094949405)
|
||||
}
|
||||
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
public func descriptionFields() -> (String, [(String, Any)]) {
|
||||
switch self {
|
||||
case .appConfig(let hash, let config):
|
||||
return ("appConfig", [("hash", hash as Any), ("config", config as Any)])
|
||||
case .appConfigNotModified:
|
||||
return ("appConfigNotModified", [])
|
||||
}
|
||||
}
|
||||
|
||||
public static func parse_appConfig(_ reader: BufferReader) -> AppConfig? {
|
||||
var _1: Int32?
|
||||
_1 = reader.readInt32()
|
||||
var _2: Api.JSONValue?
|
||||
if let signature = reader.readInt32() {
|
||||
_2 = Api.parse(reader, signature: signature) as? Api.JSONValue
|
||||
}
|
||||
let _c1 = _1 != nil
|
||||
let _c2 = _2 != nil
|
||||
if _c1 && _c2 {
|
||||
return Api.help.AppConfig.appConfig(hash: _1!, config: _2!)
|
||||
}
|
||||
else {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
public static func parse_appConfigNotModified(_ reader: BufferReader) -> AppConfig? {
|
||||
return Api.help.AppConfig.appConfigNotModified
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
public extension Api.help {
|
||||
enum AppUpdate: TypeConstructorDescription {
|
||||
case appUpdate(flags: Int32, id: Int32, version: String, text: String, entities: [Api.MessageEntity], document: Api.Document?, url: String?, sticker: Api.Document?)
|
||||
@ -1274,61 +1328,3 @@ public extension Api.messages {
|
||||
|
||||
}
|
||||
}
|
||||
public extension Api.messages {
|
||||
enum AllStickers: TypeConstructorDescription {
|
||||
case allStickers(hash: Int64, sets: [Api.StickerSet])
|
||||
case allStickersNotModified
|
||||
|
||||
public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) {
|
||||
switch self {
|
||||
case .allStickers(let hash, let sets):
|
||||
if boxed {
|
||||
buffer.appendInt32(-843329861)
|
||||
}
|
||||
serializeInt64(hash, buffer: buffer, boxed: false)
|
||||
buffer.appendInt32(481674261)
|
||||
buffer.appendInt32(Int32(sets.count))
|
||||
for item in sets {
|
||||
item.serialize(buffer, true)
|
||||
}
|
||||
break
|
||||
case .allStickersNotModified:
|
||||
if boxed {
|
||||
buffer.appendInt32(-395967805)
|
||||
}
|
||||
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
public func descriptionFields() -> (String, [(String, Any)]) {
|
||||
switch self {
|
||||
case .allStickers(let hash, let sets):
|
||||
return ("allStickers", [("hash", hash as Any), ("sets", sets as Any)])
|
||||
case .allStickersNotModified:
|
||||
return ("allStickersNotModified", [])
|
||||
}
|
||||
}
|
||||
|
||||
public static func parse_allStickers(_ reader: BufferReader) -> AllStickers? {
|
||||
var _1: Int64?
|
||||
_1 = reader.readInt64()
|
||||
var _2: [Api.StickerSet]?
|
||||
if let _ = reader.readInt32() {
|
||||
_2 = Api.parseVector(reader, elementSignature: 0, elementType: Api.StickerSet.self)
|
||||
}
|
||||
let _c1 = _1 != nil
|
||||
let _c2 = _2 != nil
|
||||
if _c1 && _c2 {
|
||||
return Api.messages.AllStickers.allStickers(hash: _1!, sets: _2!)
|
||||
}
|
||||
else {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
public static func parse_allStickersNotModified(_ reader: BufferReader) -> AllStickers? {
|
||||
return Api.messages.AllStickers.allStickersNotModified
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -1,3 +1,61 @@
|
||||
public extension Api.messages {
|
||||
enum AllStickers: TypeConstructorDescription {
|
||||
case allStickers(hash: Int64, sets: [Api.StickerSet])
|
||||
case allStickersNotModified
|
||||
|
||||
public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) {
|
||||
switch self {
|
||||
case .allStickers(let hash, let sets):
|
||||
if boxed {
|
||||
buffer.appendInt32(-843329861)
|
||||
}
|
||||
serializeInt64(hash, buffer: buffer, boxed: false)
|
||||
buffer.appendInt32(481674261)
|
||||
buffer.appendInt32(Int32(sets.count))
|
||||
for item in sets {
|
||||
item.serialize(buffer, true)
|
||||
}
|
||||
break
|
||||
case .allStickersNotModified:
|
||||
if boxed {
|
||||
buffer.appendInt32(-395967805)
|
||||
}
|
||||
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
public func descriptionFields() -> (String, [(String, Any)]) {
|
||||
switch self {
|
||||
case .allStickers(let hash, let sets):
|
||||
return ("allStickers", [("hash", hash as Any), ("sets", sets as Any)])
|
||||
case .allStickersNotModified:
|
||||
return ("allStickersNotModified", [])
|
||||
}
|
||||
}
|
||||
|
||||
public static func parse_allStickers(_ reader: BufferReader) -> AllStickers? {
|
||||
var _1: Int64?
|
||||
_1 = reader.readInt64()
|
||||
var _2: [Api.StickerSet]?
|
||||
if let _ = reader.readInt32() {
|
||||
_2 = Api.parseVector(reader, elementSignature: 0, elementType: Api.StickerSet.self)
|
||||
}
|
||||
let _c1 = _1 != nil
|
||||
let _c2 = _2 != nil
|
||||
if _c1 && _c2 {
|
||||
return Api.messages.AllStickers.allStickers(hash: _1!, sets: _2!)
|
||||
}
|
||||
else {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
public static func parse_allStickersNotModified(_ reader: BufferReader) -> AllStickers? {
|
||||
return Api.messages.AllStickers.allStickersNotModified
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
public extension Api.messages {
|
||||
enum ArchivedStickers: TypeConstructorDescription {
|
||||
case archivedStickers(count: Int32, sets: [Api.StickerSetCovered])
|
||||
@ -1346,79 +1404,3 @@ public extension Api.messages {
|
||||
|
||||
}
|
||||
}
|
||||
public extension Api.messages {
|
||||
enum HistoryImport: TypeConstructorDescription {
|
||||
case historyImport(id: Int64)
|
||||
|
||||
public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) {
|
||||
switch self {
|
||||
case .historyImport(let id):
|
||||
if boxed {
|
||||
buffer.appendInt32(375566091)
|
||||
}
|
||||
serializeInt64(id, buffer: buffer, boxed: false)
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
public func descriptionFields() -> (String, [(String, Any)]) {
|
||||
switch self {
|
||||
case .historyImport(let id):
|
||||
return ("historyImport", [("id", id as Any)])
|
||||
}
|
||||
}
|
||||
|
||||
public static func parse_historyImport(_ reader: BufferReader) -> HistoryImport? {
|
||||
var _1: Int64?
|
||||
_1 = reader.readInt64()
|
||||
let _c1 = _1 != nil
|
||||
if _c1 {
|
||||
return Api.messages.HistoryImport.historyImport(id: _1!)
|
||||
}
|
||||
else {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
public extension Api.messages {
|
||||
enum HistoryImportParsed: TypeConstructorDescription {
|
||||
case historyImportParsed(flags: Int32, title: String?)
|
||||
|
||||
public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) {
|
||||
switch self {
|
||||
case .historyImportParsed(let flags, let title):
|
||||
if boxed {
|
||||
buffer.appendInt32(1578088377)
|
||||
}
|
||||
serializeInt32(flags, buffer: buffer, boxed: false)
|
||||
if Int(flags) & Int(1 << 2) != 0 {serializeString(title!, buffer: buffer, boxed: false)}
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
public func descriptionFields() -> (String, [(String, Any)]) {
|
||||
switch self {
|
||||
case .historyImportParsed(let flags, let title):
|
||||
return ("historyImportParsed", [("flags", flags as Any), ("title", title as Any)])
|
||||
}
|
||||
}
|
||||
|
||||
public static func parse_historyImportParsed(_ reader: BufferReader) -> HistoryImportParsed? {
|
||||
var _1: Int32?
|
||||
_1 = reader.readInt32()
|
||||
var _2: String?
|
||||
if Int(_1!) & Int(1 << 2) != 0 {_2 = parseString(reader) }
|
||||
let _c1 = _1 != nil
|
||||
let _c2 = (Int(_1!) & Int(1 << 2) == 0) || _2 != nil
|
||||
if _c1 && _c2 {
|
||||
return Api.messages.HistoryImportParsed.historyImportParsed(flags: _1!, title: _2)
|
||||
}
|
||||
else {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -1,3 +1,79 @@
|
||||
public extension Api.messages {
|
||||
enum HistoryImport: TypeConstructorDescription {
|
||||
case historyImport(id: Int64)
|
||||
|
||||
public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) {
|
||||
switch self {
|
||||
case .historyImport(let id):
|
||||
if boxed {
|
||||
buffer.appendInt32(375566091)
|
||||
}
|
||||
serializeInt64(id, buffer: buffer, boxed: false)
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
public func descriptionFields() -> (String, [(String, Any)]) {
|
||||
switch self {
|
||||
case .historyImport(let id):
|
||||
return ("historyImport", [("id", id as Any)])
|
||||
}
|
||||
}
|
||||
|
||||
public static func parse_historyImport(_ reader: BufferReader) -> HistoryImport? {
|
||||
var _1: Int64?
|
||||
_1 = reader.readInt64()
|
||||
let _c1 = _1 != nil
|
||||
if _c1 {
|
||||
return Api.messages.HistoryImport.historyImport(id: _1!)
|
||||
}
|
||||
else {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
public extension Api.messages {
|
||||
enum HistoryImportParsed: TypeConstructorDescription {
|
||||
case historyImportParsed(flags: Int32, title: String?)
|
||||
|
||||
public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) {
|
||||
switch self {
|
||||
case .historyImportParsed(let flags, let title):
|
||||
if boxed {
|
||||
buffer.appendInt32(1578088377)
|
||||
}
|
||||
serializeInt32(flags, buffer: buffer, boxed: false)
|
||||
if Int(flags) & Int(1 << 2) != 0 {serializeString(title!, buffer: buffer, boxed: false)}
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
public func descriptionFields() -> (String, [(String, Any)]) {
|
||||
switch self {
|
||||
case .historyImportParsed(let flags, let title):
|
||||
return ("historyImportParsed", [("flags", flags as Any), ("title", title as Any)])
|
||||
}
|
||||
}
|
||||
|
||||
public static func parse_historyImportParsed(_ reader: BufferReader) -> HistoryImportParsed? {
|
||||
var _1: Int32?
|
||||
_1 = reader.readInt32()
|
||||
var _2: String?
|
||||
if Int(_1!) & Int(1 << 2) != 0 {_2 = parseString(reader) }
|
||||
let _c1 = _1 != nil
|
||||
let _c2 = (Int(_1!) & Int(1 << 2) == 0) || _2 != nil
|
||||
if _c1 && _c2 {
|
||||
return Api.messages.HistoryImportParsed.historyImportParsed(flags: _1!, title: _2)
|
||||
}
|
||||
else {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
public extension Api.messages {
|
||||
enum InactiveChats: TypeConstructorDescription {
|
||||
case inactiveChats(dates: [Int32], chats: [Api.Chat], users: [Api.User])
|
||||
@ -1342,109 +1418,3 @@ public extension Api.messages {
|
||||
|
||||
}
|
||||
}
|
||||
public extension Api.messages {
|
||||
enum TranslatedText: TypeConstructorDescription {
|
||||
case translateResult(result: [Api.TextWithEntities])
|
||||
|
||||
public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) {
|
||||
switch self {
|
||||
case .translateResult(let result):
|
||||
if boxed {
|
||||
buffer.appendInt32(870003448)
|
||||
}
|
||||
buffer.appendInt32(481674261)
|
||||
buffer.appendInt32(Int32(result.count))
|
||||
for item in result {
|
||||
item.serialize(buffer, true)
|
||||
}
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
public func descriptionFields() -> (String, [(String, Any)]) {
|
||||
switch self {
|
||||
case .translateResult(let result):
|
||||
return ("translateResult", [("result", result as Any)])
|
||||
}
|
||||
}
|
||||
|
||||
public static func parse_translateResult(_ reader: BufferReader) -> TranslatedText? {
|
||||
var _1: [Api.TextWithEntities]?
|
||||
if let _ = reader.readInt32() {
|
||||
_1 = Api.parseVector(reader, elementSignature: 0, elementType: Api.TextWithEntities.self)
|
||||
}
|
||||
let _c1 = _1 != nil
|
||||
if _c1 {
|
||||
return Api.messages.TranslatedText.translateResult(result: _1!)
|
||||
}
|
||||
else {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
public extension Api.messages {
|
||||
enum VotesList: TypeConstructorDescription {
|
||||
case votesList(flags: Int32, count: Int32, votes: [Api.MessageUserVote], users: [Api.User], nextOffset: String?)
|
||||
|
||||
public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) {
|
||||
switch self {
|
||||
case .votesList(let flags, let count, let votes, let users, let nextOffset):
|
||||
if boxed {
|
||||
buffer.appendInt32(136574537)
|
||||
}
|
||||
serializeInt32(flags, buffer: buffer, boxed: false)
|
||||
serializeInt32(count, buffer: buffer, boxed: false)
|
||||
buffer.appendInt32(481674261)
|
||||
buffer.appendInt32(Int32(votes.count))
|
||||
for item in votes {
|
||||
item.serialize(buffer, true)
|
||||
}
|
||||
buffer.appendInt32(481674261)
|
||||
buffer.appendInt32(Int32(users.count))
|
||||
for item in users {
|
||||
item.serialize(buffer, true)
|
||||
}
|
||||
if Int(flags) & Int(1 << 0) != 0 {serializeString(nextOffset!, buffer: buffer, boxed: false)}
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
public func descriptionFields() -> (String, [(String, Any)]) {
|
||||
switch self {
|
||||
case .votesList(let flags, let count, let votes, let users, let nextOffset):
|
||||
return ("votesList", [("flags", flags as Any), ("count", count as Any), ("votes", votes as Any), ("users", users as Any), ("nextOffset", nextOffset as Any)])
|
||||
}
|
||||
}
|
||||
|
||||
public static func parse_votesList(_ reader: BufferReader) -> VotesList? {
|
||||
var _1: Int32?
|
||||
_1 = reader.readInt32()
|
||||
var _2: Int32?
|
||||
_2 = reader.readInt32()
|
||||
var _3: [Api.MessageUserVote]?
|
||||
if let _ = reader.readInt32() {
|
||||
_3 = Api.parseVector(reader, elementSignature: 0, elementType: Api.MessageUserVote.self)
|
||||
}
|
||||
var _4: [Api.User]?
|
||||
if let _ = reader.readInt32() {
|
||||
_4 = Api.parseVector(reader, elementSignature: 0, elementType: Api.User.self)
|
||||
}
|
||||
var _5: String?
|
||||
if Int(_1!) & Int(1 << 0) != 0 {_5 = parseString(reader) }
|
||||
let _c1 = _1 != nil
|
||||
let _c2 = _2 != nil
|
||||
let _c3 = _3 != nil
|
||||
let _c4 = _4 != nil
|
||||
let _c5 = (Int(_1!) & Int(1 << 0) == 0) || _5 != nil
|
||||
if _c1 && _c2 && _c3 && _c4 && _c5 {
|
||||
return Api.messages.VotesList.votesList(flags: _1!, count: _2!, votes: _3!, users: _4!, nextOffset: _5)
|
||||
}
|
||||
else {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -1,3 +1,109 @@
|
||||
public extension Api.messages {
|
||||
enum TranslatedText: TypeConstructorDescription {
|
||||
case translateResult(result: [Api.TextWithEntities])
|
||||
|
||||
public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) {
|
||||
switch self {
|
||||
case .translateResult(let result):
|
||||
if boxed {
|
||||
buffer.appendInt32(870003448)
|
||||
}
|
||||
buffer.appendInt32(481674261)
|
||||
buffer.appendInt32(Int32(result.count))
|
||||
for item in result {
|
||||
item.serialize(buffer, true)
|
||||
}
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
public func descriptionFields() -> (String, [(String, Any)]) {
|
||||
switch self {
|
||||
case .translateResult(let result):
|
||||
return ("translateResult", [("result", result as Any)])
|
||||
}
|
||||
}
|
||||
|
||||
public static func parse_translateResult(_ reader: BufferReader) -> TranslatedText? {
|
||||
var _1: [Api.TextWithEntities]?
|
||||
if let _ = reader.readInt32() {
|
||||
_1 = Api.parseVector(reader, elementSignature: 0, elementType: Api.TextWithEntities.self)
|
||||
}
|
||||
let _c1 = _1 != nil
|
||||
if _c1 {
|
||||
return Api.messages.TranslatedText.translateResult(result: _1!)
|
||||
}
|
||||
else {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
public extension Api.messages {
|
||||
enum VotesList: TypeConstructorDescription {
|
||||
case votesList(flags: Int32, count: Int32, votes: [Api.MessageUserVote], users: [Api.User], nextOffset: String?)
|
||||
|
||||
public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) {
|
||||
switch self {
|
||||
case .votesList(let flags, let count, let votes, let users, let nextOffset):
|
||||
if boxed {
|
||||
buffer.appendInt32(136574537)
|
||||
}
|
||||
serializeInt32(flags, buffer: buffer, boxed: false)
|
||||
serializeInt32(count, buffer: buffer, boxed: false)
|
||||
buffer.appendInt32(481674261)
|
||||
buffer.appendInt32(Int32(votes.count))
|
||||
for item in votes {
|
||||
item.serialize(buffer, true)
|
||||
}
|
||||
buffer.appendInt32(481674261)
|
||||
buffer.appendInt32(Int32(users.count))
|
||||
for item in users {
|
||||
item.serialize(buffer, true)
|
||||
}
|
||||
if Int(flags) & Int(1 << 0) != 0 {serializeString(nextOffset!, buffer: buffer, boxed: false)}
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
public func descriptionFields() -> (String, [(String, Any)]) {
|
||||
switch self {
|
||||
case .votesList(let flags, let count, let votes, let users, let nextOffset):
|
||||
return ("votesList", [("flags", flags as Any), ("count", count as Any), ("votes", votes as Any), ("users", users as Any), ("nextOffset", nextOffset as Any)])
|
||||
}
|
||||
}
|
||||
|
||||
public static func parse_votesList(_ reader: BufferReader) -> VotesList? {
|
||||
var _1: Int32?
|
||||
_1 = reader.readInt32()
|
||||
var _2: Int32?
|
||||
_2 = reader.readInt32()
|
||||
var _3: [Api.MessageUserVote]?
|
||||
if let _ = reader.readInt32() {
|
||||
_3 = Api.parseVector(reader, elementSignature: 0, elementType: Api.MessageUserVote.self)
|
||||
}
|
||||
var _4: [Api.User]?
|
||||
if let _ = reader.readInt32() {
|
||||
_4 = Api.parseVector(reader, elementSignature: 0, elementType: Api.User.self)
|
||||
}
|
||||
var _5: String?
|
||||
if Int(_1!) & Int(1 << 0) != 0 {_5 = parseString(reader) }
|
||||
let _c1 = _1 != nil
|
||||
let _c2 = _2 != nil
|
||||
let _c3 = _3 != nil
|
||||
let _c4 = _4 != nil
|
||||
let _c5 = (Int(_1!) & Int(1 << 0) == 0) || _5 != nil
|
||||
if _c1 && _c2 && _c3 && _c4 && _c5 {
|
||||
return Api.messages.VotesList.votesList(flags: _1!, count: _2!, votes: _3!, users: _4!, nextOffset: _5)
|
||||
}
|
||||
else {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
public extension Api.payments {
|
||||
enum BankCardData: TypeConstructorDescription {
|
||||
case bankCardData(title: String, openUrls: [Api.BankCardOpenUrl])
|
||||
|
@ -3334,15 +3334,15 @@ public extension Api.functions.help {
|
||||
}
|
||||
}
|
||||
public extension Api.functions.help {
|
||||
static func getAppConfig() -> (FunctionDescription, Buffer, DeserializeFunctionResponse<Api.JSONValue>) {
|
||||
static func getAppConfig(hash: Int32) -> (FunctionDescription, Buffer, DeserializeFunctionResponse<Api.help.AppConfig>) {
|
||||
let buffer = Buffer()
|
||||
buffer.appendInt32(-1735311088)
|
||||
|
||||
return (FunctionDescription(name: "help.getAppConfig", parameters: []), buffer, DeserializeFunctionResponse { (buffer: Buffer) -> Api.JSONValue? in
|
||||
buffer.appendInt32(1642330196)
|
||||
serializeInt32(hash, buffer: buffer, boxed: false)
|
||||
return (FunctionDescription(name: "help.getAppConfig", parameters: [("hash", String(describing: hash))]), buffer, DeserializeFunctionResponse { (buffer: Buffer) -> Api.help.AppConfig? in
|
||||
let reader = BufferReader(buffer)
|
||||
var result: Api.JSONValue?
|
||||
var result: Api.help.AppConfig?
|
||||
if let signature = reader.readInt32() {
|
||||
result = Api.parse(reader, signature: signature) as? Api.JSONValue
|
||||
result = Api.parse(reader, signature: signature) as? Api.help.AppConfig
|
||||
}
|
||||
return result
|
||||
})
|
||||
|
@ -1,6 +1,6 @@
|
||||
import Postbox
|
||||
|
||||
private func currentAppConfiguration(transaction: Transaction) -> AppConfiguration {
|
||||
func currentAppConfiguration(transaction: Transaction) -> AppConfiguration {
|
||||
if let entry = transaction.getPreferencesEntry(key: PreferencesKeys.appConfiguration)?.get(AppConfiguration.self) {
|
||||
return entry
|
||||
} else {
|
||||
|
@ -5,9 +5,20 @@ import TelegramApi
|
||||
import MtProtoKit
|
||||
|
||||
func updateAppConfigurationOnce(postbox: Postbox, network: Network) -> Signal<Void, NoError> {
|
||||
return network.request(Api.functions.help.getAppConfig())
|
||||
|> map(Optional.init)
|
||||
|> `catch` { _ -> Signal<Api.JSONValue?, NoError> in
|
||||
return postbox.transaction { transaction -> Int32 in
|
||||
return currentAppConfiguration(transaction: transaction).hash
|
||||
}
|
||||
|> mapToSignal { hash -> Signal<Void, NoError> in
|
||||
return network.request(Api.functions.help.getAppConfig(hash: hash))
|
||||
|> map { result -> (data: Api.JSONValue, hash: Int32)? in
|
||||
switch result {
|
||||
case let .appConfig(updatedHash, config):
|
||||
return (config, updatedHash)
|
||||
case .appConfigNotModified:
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|> `catch` { _ -> Signal<(data: Api.JSONValue, hash: Int32)?, NoError> in
|
||||
return .single(nil)
|
||||
}
|
||||
|> mapToSignal { result -> Signal<Void, NoError> in
|
||||
@ -15,15 +26,17 @@ func updateAppConfigurationOnce(postbox: Postbox, network: Network) -> Signal<Vo
|
||||
return .complete()
|
||||
}
|
||||
return postbox.transaction { transaction -> Void in
|
||||
if let data = JSON(apiJson: result) {
|
||||
if let data = JSON(apiJson: result.data) {
|
||||
updateAppConfiguration(transaction: transaction, { configuration -> AppConfiguration in
|
||||
var configuration = configuration
|
||||
configuration.data = data
|
||||
configuration.hash = result.hash
|
||||
return configuration
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func managedAppConfigurationUpdates(postbox: Postbox, network: Network) -> Signal<Void, NoError> {
|
||||
|
@ -3,24 +3,28 @@ import Postbox
|
||||
|
||||
public struct AppConfiguration: Codable, Equatable {
|
||||
public var data: JSON?
|
||||
public var hash: Int32
|
||||
|
||||
public static var defaultValue: AppConfiguration {
|
||||
return AppConfiguration(data: nil)
|
||||
return AppConfiguration(data: nil, hash: 0)
|
||||
}
|
||||
|
||||
init(data: JSON?) {
|
||||
init(data: JSON?, hash: Int32) {
|
||||
self.data = data
|
||||
self.hash = hash
|
||||
}
|
||||
|
||||
public init(from decoder: Decoder) throws {
|
||||
let container = try decoder.container(keyedBy: StringCodingKey.self)
|
||||
|
||||
self.data = try container.decodeIfPresent(JSON.self, forKey: "data")
|
||||
self.hash = (try container.decodeIfPresent(Int32.self, forKey: "storedHash")) ?? 0
|
||||
}
|
||||
|
||||
public func encode(to encoder: Encoder) throws {
|
||||
var container = encoder.container(keyedBy: StringCodingKey.self)
|
||||
|
||||
try container.encodeIfPresent(self.data, forKey: "data")
|
||||
try container.encode(self.hash, forKey: "storedHash")
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user