mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-06-16 05:55:20 +00:00
Merge commit '8f6767c010a78a1d5dad2b8172561095d828ab90'
This commit is contained in:
commit
d6180b23b6
@ -970,7 +970,13 @@ final class BotCheckoutControllerNode: ItemListControllerNode, PKPaymentAuthoriz
|
||||
strongSelf.present(controller, ViewControllerPresentationArguments(presentationAnimation: .modalSheet))
|
||||
} else {
|
||||
var dismissImpl: (() -> Void)?
|
||||
let controller = BotCheckoutWebInteractionController(context: context, url: customUrl ?? paymentForm.url, intent: .addPaymentMethod(customTitle: customTitle, completion: { [weak self] token in
|
||||
let url: String
|
||||
if let customUrl {
|
||||
url = customUrl
|
||||
} else {
|
||||
url = paymentForm.url ?? ""
|
||||
}
|
||||
let controller = BotCheckoutWebInteractionController(context: context, url: url, intent: .addPaymentMethod(customTitle: customTitle, completion: { [weak self] token in
|
||||
dismissImpl?()
|
||||
|
||||
guard let strongSelf = self else {
|
||||
@ -1455,12 +1461,12 @@ final class BotCheckoutControllerNode: ItemListControllerNode, PKPaymentAuthoriz
|
||||
}
|
||||
|
||||
if !liabilityNoticeAccepted {
|
||||
let botPeer: Signal<EnginePeer?, NoError> = context.engine.data.get(
|
||||
let botPeer: Signal<EnginePeer?, NoError> = self.context.engine.data.get(
|
||||
TelegramEngine.EngineData.Item.Peer.Peer(id: paymentForm.paymentBotId)
|
||||
)
|
||||
let providerPeer: Signal<EnginePeer?, NoError> = context.engine.data.get(
|
||||
TelegramEngine.EngineData.Item.Peer.Peer(id: paymentForm.providerId)
|
||||
)
|
||||
let providerPeer: Signal<EnginePeer?, NoError> = paymentForm.providerId.flatMap {
|
||||
self.context.engine.data.get(TelegramEngine.EngineData.Item.Peer.Peer(id: $0))
|
||||
} ?? .single(nil)
|
||||
let _ = (combineLatest(
|
||||
ApplicationSpecificNotice.getBotPaymentLiability(accountManager: self.context.sharedContext.accountManager, peerId: paymentForm.paymentBotId),
|
||||
botPeer,
|
||||
|
@ -26,7 +26,21 @@ private let productIdentifiers = [
|
||||
|
||||
"org.telegram.telegramPremium.threeMonths.code_x10",
|
||||
"org.telegram.telegramPremium.sixMonths.code_x10",
|
||||
"org.telegram.telegramPremium.twelveMonths.code_x10"
|
||||
"org.telegram.telegramPremium.twelveMonths.code_x10",
|
||||
|
||||
"org.telegram.telegramStars.topup.x15",
|
||||
"org.telegram.telegramStars.topup.x25",
|
||||
"org.telegram.telegramStars.topup.x50",
|
||||
"org.telegram.telegramStars.topup.x75",
|
||||
"org.telegram.telegramStars.topup.x100",
|
||||
"org.telegram.telegramStars.topup.x150",
|
||||
"org.telegram.telegramStars.topup.x250",
|
||||
"org.telegram.telegramStars.topup.x350",
|
||||
"org.telegram.telegramStars.topup.x500",
|
||||
"org.telegram.telegramStars.topup.x750",
|
||||
"org.telegram.telegramStars.topup.x1000",
|
||||
"org.telegram.telegramStars.topup.x1500",
|
||||
"org.telegram.telegramStars.topup.x2500"
|
||||
]
|
||||
|
||||
private extension NSDecimalNumber {
|
||||
|
@ -380,7 +380,7 @@ fileprivate let parsers: [Int32 : (BufferReader) -> Any?] = {
|
||||
dict[-750828557] = { return Api.InputMedia.parse_inputMediaGame($0) }
|
||||
dict[-1759532989] = { return Api.InputMedia.parse_inputMediaGeoLive($0) }
|
||||
dict[-104578748] = { return Api.InputMedia.parse_inputMediaGeoPoint($0) }
|
||||
dict[-1900697899] = { return Api.InputMedia.parse_inputMediaInvoice($0) }
|
||||
dict[1080028941] = { return Api.InputMedia.parse_inputMediaInvoice($0) }
|
||||
dict[-1279654347] = { return Api.InputMedia.parse_inputMediaPhoto($0) }
|
||||
dict[-440664550] = { return Api.InputMedia.parse_inputMediaPhotoExternal($0) }
|
||||
dict[261416433] = { return Api.InputMedia.parse_inputMediaPoll($0) }
|
||||
@ -869,7 +869,11 @@ fileprivate let parsers: [Int32 : (BufferReader) -> Any?] = {
|
||||
dict[-1108478618] = { return Api.SponsoredMessage.parse_sponsoredMessage($0) }
|
||||
dict[1124938064] = { return Api.SponsoredMessageReportOption.parse_sponsoredMessageReportOption($0) }
|
||||
dict[198776256] = { return Api.StarsTopupOption.parse_starsTopupOption($0) }
|
||||
dict[1939194818] = { return Api.StarsTransaction.parse_starsTransaction($0) }
|
||||
dict[1600878860] = { return Api.StarsTransaction.parse_starsTransaction($0) }
|
||||
dict[-670195363] = { return Api.StarsTransactionPeer.parse_starsTransactionPeer($0) }
|
||||
dict[-1269320843] = { return Api.StarsTransactionPeer.parse_starsTransactionPeerAppStore($0) }
|
||||
dict[-382740222] = { return Api.StarsTransactionPeer.parse_starsTransactionPeerFragment($0) }
|
||||
dict[2069236235] = { return Api.StarsTransactionPeer.parse_starsTransactionPeerPlayMarket($0) }
|
||||
dict[-884757282] = { return Api.StatsAbsValueAndPrev.parse_statsAbsValueAndPrev($0) }
|
||||
dict[-1237848657] = { return Api.StatsDateRangeDays.parse_statsDateRangeDays($0) }
|
||||
dict[-1901828938] = { return Api.StatsGraph.parse_statsGraph($0) }
|
||||
@ -1293,6 +1297,7 @@ fileprivate let parsers: [Int32 : (BufferReader) -> Any?] = {
|
||||
dict[1130879648] = { return Api.payments.GiveawayInfo.parse_giveawayInfo($0) }
|
||||
dict[13456752] = { return Api.payments.GiveawayInfo.parse_giveawayInfoResults($0) }
|
||||
dict[-1610250415] = { return Api.payments.PaymentForm.parse_paymentForm($0) }
|
||||
dict[2079764828] = { return Api.payments.PaymentForm.parse_paymentFormStars($0) }
|
||||
dict[1891958275] = { return Api.payments.PaymentReceipt.parse_paymentReceipt($0) }
|
||||
dict[1314881805] = { return Api.payments.PaymentResult.parse_paymentResult($0) }
|
||||
dict[-666824391] = { return Api.payments.PaymentResult.parse_paymentVerificationNeeded($0) }
|
||||
@ -1963,6 +1968,8 @@ public extension Api {
|
||||
_1.serialize(buffer, boxed)
|
||||
case let _1 as Api.StarsTransaction:
|
||||
_1.serialize(buffer, boxed)
|
||||
case let _1 as Api.StarsTransactionPeer:
|
||||
_1.serialize(buffer, boxed)
|
||||
case let _1 as Api.StatsAbsValueAndPrev:
|
||||
_1.serialize(buffer, boxed)
|
||||
case let _1 as Api.StatsDateRangeDays:
|
||||
|
@ -8,7 +8,7 @@ public extension Api {
|
||||
case inputMediaGame(id: Api.InputGame)
|
||||
case inputMediaGeoLive(flags: Int32, geoPoint: Api.InputGeoPoint, heading: Int32?, period: Int32?, proximityNotificationRadius: Int32?)
|
||||
case inputMediaGeoPoint(geoPoint: Api.InputGeoPoint)
|
||||
case inputMediaInvoice(flags: Int32, title: String, description: String, photo: Api.InputWebDocument?, invoice: Api.Invoice, payload: Buffer, provider: String, providerData: Api.DataJSON, startParam: String?, extendedMedia: Api.InputMedia?)
|
||||
case inputMediaInvoice(flags: Int32, title: String, description: String, photo: Api.InputWebDocument?, invoice: Api.Invoice, payload: Buffer, provider: String?, providerData: Api.DataJSON, startParam: String?, extendedMedia: Api.InputMedia?)
|
||||
case inputMediaPhoto(flags: Int32, id: Api.InputPhoto, ttlSeconds: Int32?)
|
||||
case inputMediaPhotoExternal(flags: Int32, url: String, ttlSeconds: Int32?)
|
||||
case inputMediaPoll(flags: Int32, poll: Api.Poll, correctAnswers: [Buffer]?, solution: String?, solutionEntities: [Api.MessageEntity]?)
|
||||
@ -82,7 +82,7 @@ public extension Api {
|
||||
break
|
||||
case .inputMediaInvoice(let flags, let title, let description, let photo, let invoice, let payload, let provider, let providerData, let startParam, let extendedMedia):
|
||||
if boxed {
|
||||
buffer.appendInt32(-1900697899)
|
||||
buffer.appendInt32(1080028941)
|
||||
}
|
||||
serializeInt32(flags, buffer: buffer, boxed: false)
|
||||
serializeString(title, buffer: buffer, boxed: false)
|
||||
@ -90,7 +90,7 @@ public extension Api {
|
||||
if Int(flags) & Int(1 << 0) != 0 {photo!.serialize(buffer, true)}
|
||||
invoice.serialize(buffer, true)
|
||||
serializeBytes(payload, buffer: buffer, boxed: false)
|
||||
serializeString(provider, buffer: buffer, boxed: false)
|
||||
if Int(flags) & Int(1 << 3) != 0 {serializeString(provider!, buffer: buffer, boxed: false)}
|
||||
providerData.serialize(buffer, true)
|
||||
if Int(flags) & Int(1 << 1) != 0 {serializeString(startParam!, buffer: buffer, boxed: false)}
|
||||
if Int(flags) & Int(1 << 2) != 0 {extendedMedia!.serialize(buffer, true)}
|
||||
@ -371,7 +371,7 @@ public extension Api {
|
||||
var _6: Buffer?
|
||||
_6 = parseBytes(reader)
|
||||
var _7: String?
|
||||
_7 = parseString(reader)
|
||||
if Int(_1!) & Int(1 << 3) != 0 {_7 = parseString(reader) }
|
||||
var _8: Api.DataJSON?
|
||||
if let signature = reader.readInt32() {
|
||||
_8 = Api.parse(reader, signature: signature) as? Api.DataJSON
|
||||
@ -388,12 +388,12 @@ public extension Api {
|
||||
let _c4 = (Int(_1!) & Int(1 << 0) == 0) || _4 != nil
|
||||
let _c5 = _5 != nil
|
||||
let _c6 = _6 != nil
|
||||
let _c7 = _7 != nil
|
||||
let _c7 = (Int(_1!) & Int(1 << 3) == 0) || _7 != nil
|
||||
let _c8 = _8 != nil
|
||||
let _c9 = (Int(_1!) & Int(1 << 1) == 0) || _9 != nil
|
||||
let _c10 = (Int(_1!) & Int(1 << 2) == 0) || _10 != nil
|
||||
if _c1 && _c2 && _c3 && _c4 && _c5 && _c6 && _c7 && _c8 && _c9 && _c10 {
|
||||
return Api.InputMedia.inputMediaInvoice(flags: _1!, title: _2!, description: _3!, photo: _4, invoice: _5!, payload: _6!, provider: _7!, providerData: _8!, startParam: _9, extendedMedia: _10)
|
||||
return Api.InputMedia.inputMediaInvoice(flags: _1!, title: _2!, description: _3!, photo: _4, invoice: _5!, payload: _6!, provider: _7, providerData: _8!, startParam: _9, extendedMedia: _10)
|
||||
}
|
||||
else {
|
||||
return nil
|
||||
|
@ -656,13 +656,13 @@ public extension Api {
|
||||
}
|
||||
public extension Api {
|
||||
enum StarsTransaction: TypeConstructorDescription {
|
||||
case starsTransaction(id: String, stars: Int64, date: Int32, peer: Api.Peer)
|
||||
case starsTransaction(id: String, stars: Int64, date: Int32, peer: Api.StarsTransactionPeer)
|
||||
|
||||
public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) {
|
||||
switch self {
|
||||
case .starsTransaction(let id, let stars, let date, let peer):
|
||||
if boxed {
|
||||
buffer.appendInt32(1939194818)
|
||||
buffer.appendInt32(1600878860)
|
||||
}
|
||||
serializeString(id, buffer: buffer, boxed: false)
|
||||
serializeInt64(stars, buffer: buffer, boxed: false)
|
||||
@ -686,9 +686,9 @@ public extension Api {
|
||||
_2 = reader.readInt64()
|
||||
var _3: Int32?
|
||||
_3 = reader.readInt32()
|
||||
var _4: Api.Peer?
|
||||
var _4: Api.StarsTransactionPeer?
|
||||
if let signature = reader.readInt32() {
|
||||
_4 = Api.parse(reader, signature: signature) as? Api.Peer
|
||||
_4 = Api.parse(reader, signature: signature) as? Api.StarsTransactionPeer
|
||||
}
|
||||
let _c1 = _1 != nil
|
||||
let _c2 = _2 != nil
|
||||
@ -704,6 +704,80 @@ public extension Api {
|
||||
|
||||
}
|
||||
}
|
||||
public extension Api {
|
||||
enum StarsTransactionPeer: TypeConstructorDescription {
|
||||
case starsTransactionPeer(peer: Api.Peer)
|
||||
case starsTransactionPeerAppStore
|
||||
case starsTransactionPeerFragment
|
||||
case starsTransactionPeerPlayMarket
|
||||
|
||||
public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) {
|
||||
switch self {
|
||||
case .starsTransactionPeer(let peer):
|
||||
if boxed {
|
||||
buffer.appendInt32(-670195363)
|
||||
}
|
||||
peer.serialize(buffer, true)
|
||||
break
|
||||
case .starsTransactionPeerAppStore:
|
||||
if boxed {
|
||||
buffer.appendInt32(-1269320843)
|
||||
}
|
||||
|
||||
break
|
||||
case .starsTransactionPeerFragment:
|
||||
if boxed {
|
||||
buffer.appendInt32(-382740222)
|
||||
}
|
||||
|
||||
break
|
||||
case .starsTransactionPeerPlayMarket:
|
||||
if boxed {
|
||||
buffer.appendInt32(2069236235)
|
||||
}
|
||||
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
public func descriptionFields() -> (String, [(String, Any)]) {
|
||||
switch self {
|
||||
case .starsTransactionPeer(let peer):
|
||||
return ("starsTransactionPeer", [("peer", peer as Any)])
|
||||
case .starsTransactionPeerAppStore:
|
||||
return ("starsTransactionPeerAppStore", [])
|
||||
case .starsTransactionPeerFragment:
|
||||
return ("starsTransactionPeerFragment", [])
|
||||
case .starsTransactionPeerPlayMarket:
|
||||
return ("starsTransactionPeerPlayMarket", [])
|
||||
}
|
||||
}
|
||||
|
||||
public static func parse_starsTransactionPeer(_ reader: BufferReader) -> StarsTransactionPeer? {
|
||||
var _1: Api.Peer?
|
||||
if let signature = reader.readInt32() {
|
||||
_1 = Api.parse(reader, signature: signature) as? Api.Peer
|
||||
}
|
||||
let _c1 = _1 != nil
|
||||
if _c1 {
|
||||
return Api.StarsTransactionPeer.starsTransactionPeer(peer: _1!)
|
||||
}
|
||||
else {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
public static func parse_starsTransactionPeerAppStore(_ reader: BufferReader) -> StarsTransactionPeer? {
|
||||
return Api.StarsTransactionPeer.starsTransactionPeerAppStore
|
||||
}
|
||||
public static func parse_starsTransactionPeerFragment(_ reader: BufferReader) -> StarsTransactionPeer? {
|
||||
return Api.StarsTransactionPeer.starsTransactionPeerFragment
|
||||
}
|
||||
public static func parse_starsTransactionPeerPlayMarket(_ reader: BufferReader) -> StarsTransactionPeer? {
|
||||
return Api.StarsTransactionPeer.starsTransactionPeerPlayMarket
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
public extension Api {
|
||||
enum StatsAbsValueAndPrev: TypeConstructorDescription {
|
||||
case statsAbsValueAndPrev(current: Double, previous: Double)
|
||||
@ -784,137 +858,3 @@ public extension Api {
|
||||
|
||||
}
|
||||
}
|
||||
public extension Api {
|
||||
enum StatsGraph: TypeConstructorDescription {
|
||||
case statsGraph(flags: Int32, json: Api.DataJSON, zoomToken: String?)
|
||||
case statsGraphAsync(token: String)
|
||||
case statsGraphError(error: String)
|
||||
|
||||
public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) {
|
||||
switch self {
|
||||
case .statsGraph(let flags, let json, let zoomToken):
|
||||
if boxed {
|
||||
buffer.appendInt32(-1901828938)
|
||||
}
|
||||
serializeInt32(flags, buffer: buffer, boxed: false)
|
||||
json.serialize(buffer, true)
|
||||
if Int(flags) & Int(1 << 0) != 0 {serializeString(zoomToken!, buffer: buffer, boxed: false)}
|
||||
break
|
||||
case .statsGraphAsync(let token):
|
||||
if boxed {
|
||||
buffer.appendInt32(1244130093)
|
||||
}
|
||||
serializeString(token, buffer: buffer, boxed: false)
|
||||
break
|
||||
case .statsGraphError(let error):
|
||||
if boxed {
|
||||
buffer.appendInt32(-1092839390)
|
||||
}
|
||||
serializeString(error, buffer: buffer, boxed: false)
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
public func descriptionFields() -> (String, [(String, Any)]) {
|
||||
switch self {
|
||||
case .statsGraph(let flags, let json, let zoomToken):
|
||||
return ("statsGraph", [("flags", flags as Any), ("json", json as Any), ("zoomToken", zoomToken as Any)])
|
||||
case .statsGraphAsync(let token):
|
||||
return ("statsGraphAsync", [("token", token as Any)])
|
||||
case .statsGraphError(let error):
|
||||
return ("statsGraphError", [("error", error as Any)])
|
||||
}
|
||||
}
|
||||
|
||||
public static func parse_statsGraph(_ reader: BufferReader) -> StatsGraph? {
|
||||
var _1: Int32?
|
||||
_1 = reader.readInt32()
|
||||
var _2: Api.DataJSON?
|
||||
if let signature = reader.readInt32() {
|
||||
_2 = Api.parse(reader, signature: signature) as? Api.DataJSON
|
||||
}
|
||||
var _3: String?
|
||||
if Int(_1!) & Int(1 << 0) != 0 {_3 = parseString(reader) }
|
||||
let _c1 = _1 != nil
|
||||
let _c2 = _2 != nil
|
||||
let _c3 = (Int(_1!) & Int(1 << 0) == 0) || _3 != nil
|
||||
if _c1 && _c2 && _c3 {
|
||||
return Api.StatsGraph.statsGraph(flags: _1!, json: _2!, zoomToken: _3)
|
||||
}
|
||||
else {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
public static func parse_statsGraphAsync(_ reader: BufferReader) -> StatsGraph? {
|
||||
var _1: String?
|
||||
_1 = parseString(reader)
|
||||
let _c1 = _1 != nil
|
||||
if _c1 {
|
||||
return Api.StatsGraph.statsGraphAsync(token: _1!)
|
||||
}
|
||||
else {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
public static func parse_statsGraphError(_ reader: BufferReader) -> StatsGraph? {
|
||||
var _1: String?
|
||||
_1 = parseString(reader)
|
||||
let _c1 = _1 != nil
|
||||
if _c1 {
|
||||
return Api.StatsGraph.statsGraphError(error: _1!)
|
||||
}
|
||||
else {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
public extension Api {
|
||||
enum StatsGroupTopAdmin: TypeConstructorDescription {
|
||||
case statsGroupTopAdmin(userId: Int64, deleted: Int32, kicked: Int32, banned: Int32)
|
||||
|
||||
public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) {
|
||||
switch self {
|
||||
case .statsGroupTopAdmin(let userId, let deleted, let kicked, let banned):
|
||||
if boxed {
|
||||
buffer.appendInt32(-682079097)
|
||||
}
|
||||
serializeInt64(userId, buffer: buffer, boxed: false)
|
||||
serializeInt32(deleted, buffer: buffer, boxed: false)
|
||||
serializeInt32(kicked, buffer: buffer, boxed: false)
|
||||
serializeInt32(banned, buffer: buffer, boxed: false)
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
public func descriptionFields() -> (String, [(String, Any)]) {
|
||||
switch self {
|
||||
case .statsGroupTopAdmin(let userId, let deleted, let kicked, let banned):
|
||||
return ("statsGroupTopAdmin", [("userId", userId as Any), ("deleted", deleted as Any), ("kicked", kicked as Any), ("banned", banned as Any)])
|
||||
}
|
||||
}
|
||||
|
||||
public static func parse_statsGroupTopAdmin(_ reader: BufferReader) -> StatsGroupTopAdmin? {
|
||||
var _1: Int64?
|
||||
_1 = reader.readInt64()
|
||||
var _2: Int32?
|
||||
_2 = reader.readInt32()
|
||||
var _3: Int32?
|
||||
_3 = reader.readInt32()
|
||||
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.StatsGroupTopAdmin.statsGroupTopAdmin(userId: _1!, deleted: _2!, kicked: _3!, banned: _4!)
|
||||
}
|
||||
else {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -1,3 +1,137 @@
|
||||
public extension Api {
|
||||
enum StatsGraph: TypeConstructorDescription {
|
||||
case statsGraph(flags: Int32, json: Api.DataJSON, zoomToken: String?)
|
||||
case statsGraphAsync(token: String)
|
||||
case statsGraphError(error: String)
|
||||
|
||||
public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) {
|
||||
switch self {
|
||||
case .statsGraph(let flags, let json, let zoomToken):
|
||||
if boxed {
|
||||
buffer.appendInt32(-1901828938)
|
||||
}
|
||||
serializeInt32(flags, buffer: buffer, boxed: false)
|
||||
json.serialize(buffer, true)
|
||||
if Int(flags) & Int(1 << 0) != 0 {serializeString(zoomToken!, buffer: buffer, boxed: false)}
|
||||
break
|
||||
case .statsGraphAsync(let token):
|
||||
if boxed {
|
||||
buffer.appendInt32(1244130093)
|
||||
}
|
||||
serializeString(token, buffer: buffer, boxed: false)
|
||||
break
|
||||
case .statsGraphError(let error):
|
||||
if boxed {
|
||||
buffer.appendInt32(-1092839390)
|
||||
}
|
||||
serializeString(error, buffer: buffer, boxed: false)
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
public func descriptionFields() -> (String, [(String, Any)]) {
|
||||
switch self {
|
||||
case .statsGraph(let flags, let json, let zoomToken):
|
||||
return ("statsGraph", [("flags", flags as Any), ("json", json as Any), ("zoomToken", zoomToken as Any)])
|
||||
case .statsGraphAsync(let token):
|
||||
return ("statsGraphAsync", [("token", token as Any)])
|
||||
case .statsGraphError(let error):
|
||||
return ("statsGraphError", [("error", error as Any)])
|
||||
}
|
||||
}
|
||||
|
||||
public static func parse_statsGraph(_ reader: BufferReader) -> StatsGraph? {
|
||||
var _1: Int32?
|
||||
_1 = reader.readInt32()
|
||||
var _2: Api.DataJSON?
|
||||
if let signature = reader.readInt32() {
|
||||
_2 = Api.parse(reader, signature: signature) as? Api.DataJSON
|
||||
}
|
||||
var _3: String?
|
||||
if Int(_1!) & Int(1 << 0) != 0 {_3 = parseString(reader) }
|
||||
let _c1 = _1 != nil
|
||||
let _c2 = _2 != nil
|
||||
let _c3 = (Int(_1!) & Int(1 << 0) == 0) || _3 != nil
|
||||
if _c1 && _c2 && _c3 {
|
||||
return Api.StatsGraph.statsGraph(flags: _1!, json: _2!, zoomToken: _3)
|
||||
}
|
||||
else {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
public static func parse_statsGraphAsync(_ reader: BufferReader) -> StatsGraph? {
|
||||
var _1: String?
|
||||
_1 = parseString(reader)
|
||||
let _c1 = _1 != nil
|
||||
if _c1 {
|
||||
return Api.StatsGraph.statsGraphAsync(token: _1!)
|
||||
}
|
||||
else {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
public static func parse_statsGraphError(_ reader: BufferReader) -> StatsGraph? {
|
||||
var _1: String?
|
||||
_1 = parseString(reader)
|
||||
let _c1 = _1 != nil
|
||||
if _c1 {
|
||||
return Api.StatsGraph.statsGraphError(error: _1!)
|
||||
}
|
||||
else {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
public extension Api {
|
||||
enum StatsGroupTopAdmin: TypeConstructorDescription {
|
||||
case statsGroupTopAdmin(userId: Int64, deleted: Int32, kicked: Int32, banned: Int32)
|
||||
|
||||
public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) {
|
||||
switch self {
|
||||
case .statsGroupTopAdmin(let userId, let deleted, let kicked, let banned):
|
||||
if boxed {
|
||||
buffer.appendInt32(-682079097)
|
||||
}
|
||||
serializeInt64(userId, buffer: buffer, boxed: false)
|
||||
serializeInt32(deleted, buffer: buffer, boxed: false)
|
||||
serializeInt32(kicked, buffer: buffer, boxed: false)
|
||||
serializeInt32(banned, buffer: buffer, boxed: false)
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
public func descriptionFields() -> (String, [(String, Any)]) {
|
||||
switch self {
|
||||
case .statsGroupTopAdmin(let userId, let deleted, let kicked, let banned):
|
||||
return ("statsGroupTopAdmin", [("userId", userId as Any), ("deleted", deleted as Any), ("kicked", kicked as Any), ("banned", banned as Any)])
|
||||
}
|
||||
}
|
||||
|
||||
public static func parse_statsGroupTopAdmin(_ reader: BufferReader) -> StatsGroupTopAdmin? {
|
||||
var _1: Int64?
|
||||
_1 = reader.readInt64()
|
||||
var _2: Int32?
|
||||
_2 = reader.readInt32()
|
||||
var _3: Int32?
|
||||
_3 = reader.readInt32()
|
||||
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.StatsGroupTopAdmin.statsGroupTopAdmin(userId: _1!, deleted: _2!, kicked: _3!, banned: _4!)
|
||||
}
|
||||
else {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
public extension Api {
|
||||
enum StatsGroupTopInviter: TypeConstructorDescription {
|
||||
case statsGroupTopInviter(userId: Int64, invitations: Int32)
|
||||
@ -1292,115 +1426,3 @@ public extension Api {
|
||||
|
||||
}
|
||||
}
|
||||
public extension Api {
|
||||
enum TopPeerCategory: TypeConstructorDescription {
|
||||
case topPeerCategoryBotsInline
|
||||
case topPeerCategoryBotsPM
|
||||
case topPeerCategoryChannels
|
||||
case topPeerCategoryCorrespondents
|
||||
case topPeerCategoryForwardChats
|
||||
case topPeerCategoryForwardUsers
|
||||
case topPeerCategoryGroups
|
||||
case topPeerCategoryPhoneCalls
|
||||
|
||||
public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) {
|
||||
switch self {
|
||||
case .topPeerCategoryBotsInline:
|
||||
if boxed {
|
||||
buffer.appendInt32(344356834)
|
||||
}
|
||||
|
||||
break
|
||||
case .topPeerCategoryBotsPM:
|
||||
if boxed {
|
||||
buffer.appendInt32(-1419371685)
|
||||
}
|
||||
|
||||
break
|
||||
case .topPeerCategoryChannels:
|
||||
if boxed {
|
||||
buffer.appendInt32(371037736)
|
||||
}
|
||||
|
||||
break
|
||||
case .topPeerCategoryCorrespondents:
|
||||
if boxed {
|
||||
buffer.appendInt32(104314861)
|
||||
}
|
||||
|
||||
break
|
||||
case .topPeerCategoryForwardChats:
|
||||
if boxed {
|
||||
buffer.appendInt32(-68239120)
|
||||
}
|
||||
|
||||
break
|
||||
case .topPeerCategoryForwardUsers:
|
||||
if boxed {
|
||||
buffer.appendInt32(-1472172887)
|
||||
}
|
||||
|
||||
break
|
||||
case .topPeerCategoryGroups:
|
||||
if boxed {
|
||||
buffer.appendInt32(-1122524854)
|
||||
}
|
||||
|
||||
break
|
||||
case .topPeerCategoryPhoneCalls:
|
||||
if boxed {
|
||||
buffer.appendInt32(511092620)
|
||||
}
|
||||
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
public func descriptionFields() -> (String, [(String, Any)]) {
|
||||
switch self {
|
||||
case .topPeerCategoryBotsInline:
|
||||
return ("topPeerCategoryBotsInline", [])
|
||||
case .topPeerCategoryBotsPM:
|
||||
return ("topPeerCategoryBotsPM", [])
|
||||
case .topPeerCategoryChannels:
|
||||
return ("topPeerCategoryChannels", [])
|
||||
case .topPeerCategoryCorrespondents:
|
||||
return ("topPeerCategoryCorrespondents", [])
|
||||
case .topPeerCategoryForwardChats:
|
||||
return ("topPeerCategoryForwardChats", [])
|
||||
case .topPeerCategoryForwardUsers:
|
||||
return ("topPeerCategoryForwardUsers", [])
|
||||
case .topPeerCategoryGroups:
|
||||
return ("topPeerCategoryGroups", [])
|
||||
case .topPeerCategoryPhoneCalls:
|
||||
return ("topPeerCategoryPhoneCalls", [])
|
||||
}
|
||||
}
|
||||
|
||||
public static func parse_topPeerCategoryBotsInline(_ reader: BufferReader) -> TopPeerCategory? {
|
||||
return Api.TopPeerCategory.topPeerCategoryBotsInline
|
||||
}
|
||||
public static func parse_topPeerCategoryBotsPM(_ reader: BufferReader) -> TopPeerCategory? {
|
||||
return Api.TopPeerCategory.topPeerCategoryBotsPM
|
||||
}
|
||||
public static func parse_topPeerCategoryChannels(_ reader: BufferReader) -> TopPeerCategory? {
|
||||
return Api.TopPeerCategory.topPeerCategoryChannels
|
||||
}
|
||||
public static func parse_topPeerCategoryCorrespondents(_ reader: BufferReader) -> TopPeerCategory? {
|
||||
return Api.TopPeerCategory.topPeerCategoryCorrespondents
|
||||
}
|
||||
public static func parse_topPeerCategoryForwardChats(_ reader: BufferReader) -> TopPeerCategory? {
|
||||
return Api.TopPeerCategory.topPeerCategoryForwardChats
|
||||
}
|
||||
public static func parse_topPeerCategoryForwardUsers(_ reader: BufferReader) -> TopPeerCategory? {
|
||||
return Api.TopPeerCategory.topPeerCategoryForwardUsers
|
||||
}
|
||||
public static func parse_topPeerCategoryGroups(_ reader: BufferReader) -> TopPeerCategory? {
|
||||
return Api.TopPeerCategory.topPeerCategoryGroups
|
||||
}
|
||||
public static func parse_topPeerCategoryPhoneCalls(_ reader: BufferReader) -> TopPeerCategory? {
|
||||
return Api.TopPeerCategory.topPeerCategoryPhoneCalls
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -1,3 +1,115 @@
|
||||
public extension Api {
|
||||
enum TopPeerCategory: TypeConstructorDescription {
|
||||
case topPeerCategoryBotsInline
|
||||
case topPeerCategoryBotsPM
|
||||
case topPeerCategoryChannels
|
||||
case topPeerCategoryCorrespondents
|
||||
case topPeerCategoryForwardChats
|
||||
case topPeerCategoryForwardUsers
|
||||
case topPeerCategoryGroups
|
||||
case topPeerCategoryPhoneCalls
|
||||
|
||||
public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) {
|
||||
switch self {
|
||||
case .topPeerCategoryBotsInline:
|
||||
if boxed {
|
||||
buffer.appendInt32(344356834)
|
||||
}
|
||||
|
||||
break
|
||||
case .topPeerCategoryBotsPM:
|
||||
if boxed {
|
||||
buffer.appendInt32(-1419371685)
|
||||
}
|
||||
|
||||
break
|
||||
case .topPeerCategoryChannels:
|
||||
if boxed {
|
||||
buffer.appendInt32(371037736)
|
||||
}
|
||||
|
||||
break
|
||||
case .topPeerCategoryCorrespondents:
|
||||
if boxed {
|
||||
buffer.appendInt32(104314861)
|
||||
}
|
||||
|
||||
break
|
||||
case .topPeerCategoryForwardChats:
|
||||
if boxed {
|
||||
buffer.appendInt32(-68239120)
|
||||
}
|
||||
|
||||
break
|
||||
case .topPeerCategoryForwardUsers:
|
||||
if boxed {
|
||||
buffer.appendInt32(-1472172887)
|
||||
}
|
||||
|
||||
break
|
||||
case .topPeerCategoryGroups:
|
||||
if boxed {
|
||||
buffer.appendInt32(-1122524854)
|
||||
}
|
||||
|
||||
break
|
||||
case .topPeerCategoryPhoneCalls:
|
||||
if boxed {
|
||||
buffer.appendInt32(511092620)
|
||||
}
|
||||
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
public func descriptionFields() -> (String, [(String, Any)]) {
|
||||
switch self {
|
||||
case .topPeerCategoryBotsInline:
|
||||
return ("topPeerCategoryBotsInline", [])
|
||||
case .topPeerCategoryBotsPM:
|
||||
return ("topPeerCategoryBotsPM", [])
|
||||
case .topPeerCategoryChannels:
|
||||
return ("topPeerCategoryChannels", [])
|
||||
case .topPeerCategoryCorrespondents:
|
||||
return ("topPeerCategoryCorrespondents", [])
|
||||
case .topPeerCategoryForwardChats:
|
||||
return ("topPeerCategoryForwardChats", [])
|
||||
case .topPeerCategoryForwardUsers:
|
||||
return ("topPeerCategoryForwardUsers", [])
|
||||
case .topPeerCategoryGroups:
|
||||
return ("topPeerCategoryGroups", [])
|
||||
case .topPeerCategoryPhoneCalls:
|
||||
return ("topPeerCategoryPhoneCalls", [])
|
||||
}
|
||||
}
|
||||
|
||||
public static func parse_topPeerCategoryBotsInline(_ reader: BufferReader) -> TopPeerCategory? {
|
||||
return Api.TopPeerCategory.topPeerCategoryBotsInline
|
||||
}
|
||||
public static func parse_topPeerCategoryBotsPM(_ reader: BufferReader) -> TopPeerCategory? {
|
||||
return Api.TopPeerCategory.topPeerCategoryBotsPM
|
||||
}
|
||||
public static func parse_topPeerCategoryChannels(_ reader: BufferReader) -> TopPeerCategory? {
|
||||
return Api.TopPeerCategory.topPeerCategoryChannels
|
||||
}
|
||||
public static func parse_topPeerCategoryCorrespondents(_ reader: BufferReader) -> TopPeerCategory? {
|
||||
return Api.TopPeerCategory.topPeerCategoryCorrespondents
|
||||
}
|
||||
public static func parse_topPeerCategoryForwardChats(_ reader: BufferReader) -> TopPeerCategory? {
|
||||
return Api.TopPeerCategory.topPeerCategoryForwardChats
|
||||
}
|
||||
public static func parse_topPeerCategoryForwardUsers(_ reader: BufferReader) -> TopPeerCategory? {
|
||||
return Api.TopPeerCategory.topPeerCategoryForwardUsers
|
||||
}
|
||||
public static func parse_topPeerCategoryGroups(_ reader: BufferReader) -> TopPeerCategory? {
|
||||
return Api.TopPeerCategory.topPeerCategoryGroups
|
||||
}
|
||||
public static func parse_topPeerCategoryPhoneCalls(_ reader: BufferReader) -> TopPeerCategory? {
|
||||
return Api.TopPeerCategory.topPeerCategoryPhoneCalls
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
public extension Api {
|
||||
enum TopPeerCategoryPeers: TypeConstructorDescription {
|
||||
case topPeerCategoryPeers(category: Api.TopPeerCategory, count: Int32, peers: [Api.TopPeer])
|
||||
|
@ -595,6 +595,7 @@ public extension Api.payments {
|
||||
public extension Api.payments {
|
||||
enum PaymentForm: TypeConstructorDescription {
|
||||
case paymentForm(flags: Int32, formId: Int64, botId: Int64, title: String, description: String, photo: Api.WebDocument?, invoice: Api.Invoice, providerId: Int64, url: String, nativeProvider: String?, nativeParams: Api.DataJSON?, additionalMethods: [Api.PaymentFormMethod]?, savedInfo: Api.PaymentRequestedInfo?, savedCredentials: [Api.PaymentSavedCredentials]?, users: [Api.User])
|
||||
case paymentFormStars(flags: Int32, formId: Int64, botId: Int64, title: String, description: String, photo: Api.WebDocument?, invoice: Api.Invoice, users: [Api.User])
|
||||
|
||||
public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) {
|
||||
switch self {
|
||||
@ -630,6 +631,23 @@ public extension Api.payments {
|
||||
item.serialize(buffer, true)
|
||||
}
|
||||
break
|
||||
case .paymentFormStars(let flags, let formId, let botId, let title, let description, let photo, let invoice, let users):
|
||||
if boxed {
|
||||
buffer.appendInt32(2079764828)
|
||||
}
|
||||
serializeInt32(flags, buffer: buffer, boxed: false)
|
||||
serializeInt64(formId, buffer: buffer, boxed: false)
|
||||
serializeInt64(botId, buffer: buffer, boxed: false)
|
||||
serializeString(title, buffer: buffer, boxed: false)
|
||||
serializeString(description, buffer: buffer, boxed: false)
|
||||
if Int(flags) & Int(1 << 5) != 0 {photo!.serialize(buffer, true)}
|
||||
invoice.serialize(buffer, true)
|
||||
buffer.appendInt32(481674261)
|
||||
buffer.appendInt32(Int32(users.count))
|
||||
for item in users {
|
||||
item.serialize(buffer, true)
|
||||
}
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
@ -637,6 +655,8 @@ public extension Api.payments {
|
||||
switch self {
|
||||
case .paymentForm(let flags, let formId, let botId, let title, let description, let photo, let invoice, let providerId, let url, let nativeProvider, let nativeParams, let additionalMethods, let savedInfo, let savedCredentials, let users):
|
||||
return ("paymentForm", [("flags", flags as Any), ("formId", formId as Any), ("botId", botId as Any), ("title", title as Any), ("description", description as Any), ("photo", photo as Any), ("invoice", invoice as Any), ("providerId", providerId as Any), ("url", url as Any), ("nativeProvider", nativeProvider as Any), ("nativeParams", nativeParams as Any), ("additionalMethods", additionalMethods as Any), ("savedInfo", savedInfo as Any), ("savedCredentials", savedCredentials as Any), ("users", users as Any)])
|
||||
case .paymentFormStars(let flags, let formId, let botId, let title, let description, let photo, let invoice, let users):
|
||||
return ("paymentFormStars", [("flags", flags as Any), ("formId", formId as Any), ("botId", botId as Any), ("title", title as Any), ("description", description as Any), ("photo", photo as Any), ("invoice", invoice as Any), ("users", users as Any)])
|
||||
}
|
||||
}
|
||||
|
||||
@ -707,6 +727,44 @@ public extension Api.payments {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
public static func parse_paymentFormStars(_ reader: BufferReader) -> PaymentForm? {
|
||||
var _1: Int32?
|
||||
_1 = reader.readInt32()
|
||||
var _2: Int64?
|
||||
_2 = reader.readInt64()
|
||||
var _3: Int64?
|
||||
_3 = reader.readInt64()
|
||||
var _4: String?
|
||||
_4 = parseString(reader)
|
||||
var _5: String?
|
||||
_5 = parseString(reader)
|
||||
var _6: Api.WebDocument?
|
||||
if Int(_1!) & Int(1 << 5) != 0 {if let signature = reader.readInt32() {
|
||||
_6 = Api.parse(reader, signature: signature) as? Api.WebDocument
|
||||
} }
|
||||
var _7: Api.Invoice?
|
||||
if let signature = reader.readInt32() {
|
||||
_7 = Api.parse(reader, signature: signature) as? Api.Invoice
|
||||
}
|
||||
var _8: [Api.User]?
|
||||
if let _ = reader.readInt32() {
|
||||
_8 = Api.parseVector(reader, elementSignature: 0, elementType: Api.User.self)
|
||||
}
|
||||
let _c1 = _1 != nil
|
||||
let _c2 = _2 != nil
|
||||
let _c3 = _3 != nil
|
||||
let _c4 = _4 != nil
|
||||
let _c5 = _5 != nil
|
||||
let _c6 = (Int(_1!) & Int(1 << 5) == 0) || _6 != nil
|
||||
let _c7 = _7 != nil
|
||||
let _c8 = _8 != nil
|
||||
if _c1 && _c2 && _c3 && _c4 && _c5 && _c6 && _c7 && _c8 {
|
||||
return Api.payments.PaymentForm.paymentFormStars(flags: _1!, formId: _2!, botId: _3!, title: _4!, description: _5!, photo: _6, invoice: _7!, users: _8!)
|
||||
}
|
||||
else {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@ -1618,89 +1676,3 @@ public extension Api.premium {
|
||||
|
||||
}
|
||||
}
|
||||
public extension Api.premium {
|
||||
enum BoostsStatus: TypeConstructorDescription {
|
||||
case boostsStatus(flags: Int32, level: Int32, currentLevelBoosts: Int32, boosts: Int32, giftBoosts: Int32?, nextLevelBoosts: Int32?, premiumAudience: Api.StatsPercentValue?, boostUrl: String, prepaidGiveaways: [Api.PrepaidGiveaway]?, myBoostSlots: [Int32]?)
|
||||
|
||||
public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) {
|
||||
switch self {
|
||||
case .boostsStatus(let flags, let level, let currentLevelBoosts, let boosts, let giftBoosts, let nextLevelBoosts, let premiumAudience, let boostUrl, let prepaidGiveaways, let myBoostSlots):
|
||||
if boxed {
|
||||
buffer.appendInt32(1230586490)
|
||||
}
|
||||
serializeInt32(flags, buffer: buffer, boxed: false)
|
||||
serializeInt32(level, buffer: buffer, boxed: false)
|
||||
serializeInt32(currentLevelBoosts, buffer: buffer, boxed: false)
|
||||
serializeInt32(boosts, buffer: buffer, boxed: false)
|
||||
if Int(flags) & Int(1 << 4) != 0 {serializeInt32(giftBoosts!, buffer: buffer, boxed: false)}
|
||||
if Int(flags) & Int(1 << 0) != 0 {serializeInt32(nextLevelBoosts!, buffer: buffer, boxed: false)}
|
||||
if Int(flags) & Int(1 << 1) != 0 {premiumAudience!.serialize(buffer, true)}
|
||||
serializeString(boostUrl, buffer: buffer, boxed: false)
|
||||
if Int(flags) & Int(1 << 3) != 0 {buffer.appendInt32(481674261)
|
||||
buffer.appendInt32(Int32(prepaidGiveaways!.count))
|
||||
for item in prepaidGiveaways! {
|
||||
item.serialize(buffer, true)
|
||||
}}
|
||||
if Int(flags) & Int(1 << 2) != 0 {buffer.appendInt32(481674261)
|
||||
buffer.appendInt32(Int32(myBoostSlots!.count))
|
||||
for item in myBoostSlots! {
|
||||
serializeInt32(item, buffer: buffer, boxed: false)
|
||||
}}
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
public func descriptionFields() -> (String, [(String, Any)]) {
|
||||
switch self {
|
||||
case .boostsStatus(let flags, let level, let currentLevelBoosts, let boosts, let giftBoosts, let nextLevelBoosts, let premiumAudience, let boostUrl, let prepaidGiveaways, let myBoostSlots):
|
||||
return ("boostsStatus", [("flags", flags as Any), ("level", level as Any), ("currentLevelBoosts", currentLevelBoosts as Any), ("boosts", boosts as Any), ("giftBoosts", giftBoosts as Any), ("nextLevelBoosts", nextLevelBoosts as Any), ("premiumAudience", premiumAudience as Any), ("boostUrl", boostUrl as Any), ("prepaidGiveaways", prepaidGiveaways as Any), ("myBoostSlots", myBoostSlots as Any)])
|
||||
}
|
||||
}
|
||||
|
||||
public static func parse_boostsStatus(_ reader: BufferReader) -> BoostsStatus? {
|
||||
var _1: Int32?
|
||||
_1 = reader.readInt32()
|
||||
var _2: Int32?
|
||||
_2 = reader.readInt32()
|
||||
var _3: Int32?
|
||||
_3 = reader.readInt32()
|
||||
var _4: Int32?
|
||||
_4 = reader.readInt32()
|
||||
var _5: Int32?
|
||||
if Int(_1!) & Int(1 << 4) != 0 {_5 = reader.readInt32() }
|
||||
var _6: Int32?
|
||||
if Int(_1!) & Int(1 << 0) != 0 {_6 = reader.readInt32() }
|
||||
var _7: Api.StatsPercentValue?
|
||||
if Int(_1!) & Int(1 << 1) != 0 {if let signature = reader.readInt32() {
|
||||
_7 = Api.parse(reader, signature: signature) as? Api.StatsPercentValue
|
||||
} }
|
||||
var _8: String?
|
||||
_8 = parseString(reader)
|
||||
var _9: [Api.PrepaidGiveaway]?
|
||||
if Int(_1!) & Int(1 << 3) != 0 {if let _ = reader.readInt32() {
|
||||
_9 = Api.parseVector(reader, elementSignature: 0, elementType: Api.PrepaidGiveaway.self)
|
||||
} }
|
||||
var _10: [Int32]?
|
||||
if Int(_1!) & Int(1 << 2) != 0 {if let _ = reader.readInt32() {
|
||||
_10 = Api.parseVector(reader, elementSignature: -1471112230, elementType: Int32.self)
|
||||
} }
|
||||
let _c1 = _1 != nil
|
||||
let _c2 = _2 != nil
|
||||
let _c3 = _3 != nil
|
||||
let _c4 = _4 != nil
|
||||
let _c5 = (Int(_1!) & Int(1 << 4) == 0) || _5 != nil
|
||||
let _c6 = (Int(_1!) & Int(1 << 0) == 0) || _6 != nil
|
||||
let _c7 = (Int(_1!) & Int(1 << 1) == 0) || _7 != nil
|
||||
let _c8 = _8 != nil
|
||||
let _c9 = (Int(_1!) & Int(1 << 3) == 0) || _9 != nil
|
||||
let _c10 = (Int(_1!) & Int(1 << 2) == 0) || _10 != nil
|
||||
if _c1 && _c2 && _c3 && _c4 && _c5 && _c6 && _c7 && _c8 && _c9 && _c10 {
|
||||
return Api.premium.BoostsStatus.boostsStatus(flags: _1!, level: _2!, currentLevelBoosts: _3!, boosts: _4!, giftBoosts: _5, nextLevelBoosts: _6, premiumAudience: _7, boostUrl: _8!, prepaidGiveaways: _9, myBoostSlots: _10)
|
||||
}
|
||||
else {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -1,3 +1,89 @@
|
||||
public extension Api.premium {
|
||||
enum BoostsStatus: TypeConstructorDescription {
|
||||
case boostsStatus(flags: Int32, level: Int32, currentLevelBoosts: Int32, boosts: Int32, giftBoosts: Int32?, nextLevelBoosts: Int32?, premiumAudience: Api.StatsPercentValue?, boostUrl: String, prepaidGiveaways: [Api.PrepaidGiveaway]?, myBoostSlots: [Int32]?)
|
||||
|
||||
public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) {
|
||||
switch self {
|
||||
case .boostsStatus(let flags, let level, let currentLevelBoosts, let boosts, let giftBoosts, let nextLevelBoosts, let premiumAudience, let boostUrl, let prepaidGiveaways, let myBoostSlots):
|
||||
if boxed {
|
||||
buffer.appendInt32(1230586490)
|
||||
}
|
||||
serializeInt32(flags, buffer: buffer, boxed: false)
|
||||
serializeInt32(level, buffer: buffer, boxed: false)
|
||||
serializeInt32(currentLevelBoosts, buffer: buffer, boxed: false)
|
||||
serializeInt32(boosts, buffer: buffer, boxed: false)
|
||||
if Int(flags) & Int(1 << 4) != 0 {serializeInt32(giftBoosts!, buffer: buffer, boxed: false)}
|
||||
if Int(flags) & Int(1 << 0) != 0 {serializeInt32(nextLevelBoosts!, buffer: buffer, boxed: false)}
|
||||
if Int(flags) & Int(1 << 1) != 0 {premiumAudience!.serialize(buffer, true)}
|
||||
serializeString(boostUrl, buffer: buffer, boxed: false)
|
||||
if Int(flags) & Int(1 << 3) != 0 {buffer.appendInt32(481674261)
|
||||
buffer.appendInt32(Int32(prepaidGiveaways!.count))
|
||||
for item in prepaidGiveaways! {
|
||||
item.serialize(buffer, true)
|
||||
}}
|
||||
if Int(flags) & Int(1 << 2) != 0 {buffer.appendInt32(481674261)
|
||||
buffer.appendInt32(Int32(myBoostSlots!.count))
|
||||
for item in myBoostSlots! {
|
||||
serializeInt32(item, buffer: buffer, boxed: false)
|
||||
}}
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
public func descriptionFields() -> (String, [(String, Any)]) {
|
||||
switch self {
|
||||
case .boostsStatus(let flags, let level, let currentLevelBoosts, let boosts, let giftBoosts, let nextLevelBoosts, let premiumAudience, let boostUrl, let prepaidGiveaways, let myBoostSlots):
|
||||
return ("boostsStatus", [("flags", flags as Any), ("level", level as Any), ("currentLevelBoosts", currentLevelBoosts as Any), ("boosts", boosts as Any), ("giftBoosts", giftBoosts as Any), ("nextLevelBoosts", nextLevelBoosts as Any), ("premiumAudience", premiumAudience as Any), ("boostUrl", boostUrl as Any), ("prepaidGiveaways", prepaidGiveaways as Any), ("myBoostSlots", myBoostSlots as Any)])
|
||||
}
|
||||
}
|
||||
|
||||
public static func parse_boostsStatus(_ reader: BufferReader) -> BoostsStatus? {
|
||||
var _1: Int32?
|
||||
_1 = reader.readInt32()
|
||||
var _2: Int32?
|
||||
_2 = reader.readInt32()
|
||||
var _3: Int32?
|
||||
_3 = reader.readInt32()
|
||||
var _4: Int32?
|
||||
_4 = reader.readInt32()
|
||||
var _5: Int32?
|
||||
if Int(_1!) & Int(1 << 4) != 0 {_5 = reader.readInt32() }
|
||||
var _6: Int32?
|
||||
if Int(_1!) & Int(1 << 0) != 0 {_6 = reader.readInt32() }
|
||||
var _7: Api.StatsPercentValue?
|
||||
if Int(_1!) & Int(1 << 1) != 0 {if let signature = reader.readInt32() {
|
||||
_7 = Api.parse(reader, signature: signature) as? Api.StatsPercentValue
|
||||
} }
|
||||
var _8: String?
|
||||
_8 = parseString(reader)
|
||||
var _9: [Api.PrepaidGiveaway]?
|
||||
if Int(_1!) & Int(1 << 3) != 0 {if let _ = reader.readInt32() {
|
||||
_9 = Api.parseVector(reader, elementSignature: 0, elementType: Api.PrepaidGiveaway.self)
|
||||
} }
|
||||
var _10: [Int32]?
|
||||
if Int(_1!) & Int(1 << 2) != 0 {if let _ = reader.readInt32() {
|
||||
_10 = Api.parseVector(reader, elementSignature: -1471112230, elementType: Int32.self)
|
||||
} }
|
||||
let _c1 = _1 != nil
|
||||
let _c2 = _2 != nil
|
||||
let _c3 = _3 != nil
|
||||
let _c4 = _4 != nil
|
||||
let _c5 = (Int(_1!) & Int(1 << 4) == 0) || _5 != nil
|
||||
let _c6 = (Int(_1!) & Int(1 << 0) == 0) || _6 != nil
|
||||
let _c7 = (Int(_1!) & Int(1 << 1) == 0) || _7 != nil
|
||||
let _c8 = _8 != nil
|
||||
let _c9 = (Int(_1!) & Int(1 << 3) == 0) || _9 != nil
|
||||
let _c10 = (Int(_1!) & Int(1 << 2) == 0) || _10 != nil
|
||||
if _c1 && _c2 && _c3 && _c4 && _c5 && _c6 && _c7 && _c8 && _c9 && _c10 {
|
||||
return Api.premium.BoostsStatus.boostsStatus(flags: _1!, level: _2!, currentLevelBoosts: _3!, boosts: _4!, giftBoosts: _5, nextLevelBoosts: _6, premiumAudience: _7, boostUrl: _8!, prepaidGiveaways: _9, myBoostSlots: _10)
|
||||
}
|
||||
else {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
public extension Api.premium {
|
||||
enum MyBoosts: TypeConstructorDescription {
|
||||
case myBoosts(myBoosts: [Api.MyBoost], chats: [Api.Chat], users: [Api.User])
|
||||
|
@ -8762,6 +8762,23 @@ public extension Api.functions.payments {
|
||||
})
|
||||
}
|
||||
}
|
||||
public extension Api.functions.payments {
|
||||
static func sendStarsForm(flags: Int32, formId: Int64, invoice: Api.InputInvoice) -> (FunctionDescription, Buffer, DeserializeFunctionResponse<Api.payments.PaymentResult>) {
|
||||
let buffer = Buffer()
|
||||
buffer.appendInt32(45839133)
|
||||
serializeInt32(flags, buffer: buffer, boxed: false)
|
||||
serializeInt64(formId, buffer: buffer, boxed: false)
|
||||
invoice.serialize(buffer, true)
|
||||
return (FunctionDescription(name: "payments.sendStarsForm", parameters: [("flags", String(describing: flags)), ("formId", String(describing: formId)), ("invoice", String(describing: invoice))]), buffer, DeserializeFunctionResponse { (buffer: Buffer) -> Api.payments.PaymentResult? in
|
||||
let reader = BufferReader(buffer)
|
||||
var result: Api.payments.PaymentResult?
|
||||
if let signature = reader.readInt32() {
|
||||
result = Api.parse(reader, signature: signature) as? Api.payments.PaymentResult
|
||||
}
|
||||
return result
|
||||
})
|
||||
}
|
||||
}
|
||||
public extension Api.functions.payments {
|
||||
static func validateRequestedInfo(flags: Int32, invoice: Api.InputInvoice, info: Api.PaymentRequestedInfo) -> (FunctionDescription, Buffer, DeserializeFunctionResponse<Api.payments.ValidatedRequestedInfo>) {
|
||||
let buffer = Buffer()
|
||||
|
@ -129,6 +129,7 @@ enum AccountStateMutationOperation {
|
||||
case UpdateNewAuthorization(isUnconfirmed: Bool, hash: Int64, date: Int32, device: String, location: String)
|
||||
case UpdateWallpaper(peerId: PeerId, wallpaper: TelegramWallpaper?)
|
||||
case UpdateRevenueBalances(peerId: PeerId, balances: RevenueStats.Balances)
|
||||
case UpdateStarsBalance(peerId: PeerId, balance: Int64)
|
||||
}
|
||||
|
||||
struct HoleFromPreviousState {
|
||||
@ -678,9 +679,13 @@ struct AccountMutableState {
|
||||
self.addOperation(.UpdateRevenueBalances(peerId: peerId, balances: balances))
|
||||
}
|
||||
|
||||
mutating func updateStarsBalance(peerId: PeerId, balance: Int64) {
|
||||
self.addOperation(.UpdateStarsBalance(peerId: peerId, balance: balance))
|
||||
}
|
||||
|
||||
mutating func addOperation(_ operation: AccountStateMutationOperation) {
|
||||
switch operation {
|
||||
case .DeleteMessages, .DeleteMessagesWithGlobalIds, .EditMessage, .UpdateMessagePoll, .UpdateMessageReactions, .UpdateMedia, .ReadOutbox, .ReadGroupFeedInbox, .MergePeerPresences, .UpdateSecretChat, .AddSecretMessages, .ReadSecretOutbox, .AddPeerInputActivity, .UpdateCachedPeerData, .UpdatePinnedItemIds, .UpdatePinnedSavedItemIds, .UpdatePinnedTopic, .UpdatePinnedTopicOrder, .ReadMessageContents, .UpdateMessageImpressionCount, .UpdateMessageForwardsCount, .UpdateInstalledStickerPacks, .UpdateRecentGifs, .UpdateChatInputState, .UpdateCall, .AddCallSignalingData, .UpdateLangPack, .UpdateMinAvailableMessage, .UpdatePeerChatUnreadMark, .UpdateIsContact, .UpdatePeerChatInclusion, .UpdatePeersNearby, .UpdateTheme, .UpdateWallpaper, .SyncChatListFilters, .UpdateChatListFilterOrder, .UpdateChatListFilter, .UpdateReadThread, .UpdateGroupCallParticipants, .UpdateGroupCall, .UpdateMessagesPinned, .UpdateAutoremoveTimeout, .UpdateAttachMenuBots, .UpdateAudioTranscription, .UpdateConfig, .UpdateExtendedMedia, .ResetForumTopic, .UpdateStory, .UpdateReadStories, .UpdateStoryStealthMode, .UpdateStorySentReaction, .UpdateNewAuthorization, .UpdateRevenueBalances:
|
||||
case .DeleteMessages, .DeleteMessagesWithGlobalIds, .EditMessage, .UpdateMessagePoll, .UpdateMessageReactions, .UpdateMedia, .ReadOutbox, .ReadGroupFeedInbox, .MergePeerPresences, .UpdateSecretChat, .AddSecretMessages, .ReadSecretOutbox, .AddPeerInputActivity, .UpdateCachedPeerData, .UpdatePinnedItemIds, .UpdatePinnedSavedItemIds, .UpdatePinnedTopic, .UpdatePinnedTopicOrder, .ReadMessageContents, .UpdateMessageImpressionCount, .UpdateMessageForwardsCount, .UpdateInstalledStickerPacks, .UpdateRecentGifs, .UpdateChatInputState, .UpdateCall, .AddCallSignalingData, .UpdateLangPack, .UpdateMinAvailableMessage, .UpdatePeerChatUnreadMark, .UpdateIsContact, .UpdatePeerChatInclusion, .UpdatePeersNearby, .UpdateTheme, .UpdateWallpaper, .SyncChatListFilters, .UpdateChatListFilterOrder, .UpdateChatListFilter, .UpdateReadThread, .UpdateGroupCallParticipants, .UpdateGroupCall, .UpdateMessagesPinned, .UpdateAutoremoveTimeout, .UpdateAttachMenuBots, .UpdateAudioTranscription, .UpdateConfig, .UpdateExtendedMedia, .ResetForumTopic, .UpdateStory, .UpdateReadStories, .UpdateStoryStealthMode, .UpdateStorySentReaction, .UpdateNewAuthorization, .UpdateRevenueBalances, .UpdateStarsBalance:
|
||||
break
|
||||
case let .AddMessages(messages, location):
|
||||
for message in messages {
|
||||
@ -825,6 +830,7 @@ struct AccountReplayedFinalState {
|
||||
let updateConfig: Bool
|
||||
let isPremiumUpdated: Bool
|
||||
let updatedRevenueBalances: [PeerId: RevenueStats.Balances]
|
||||
let updatedStarsBalance: [PeerId: Int64]
|
||||
}
|
||||
|
||||
struct AccountFinalStateEvents {
|
||||
@ -852,12 +858,13 @@ struct AccountFinalStateEvents {
|
||||
let updateConfig: Bool
|
||||
let isPremiumUpdated: Bool
|
||||
let updatedRevenueBalances: [PeerId: RevenueStats.Balances]
|
||||
let updatedStarsBalance: [PeerId: Int64]
|
||||
|
||||
var isEmpty: Bool {
|
||||
return self.addedIncomingMessageIds.isEmpty && self.addedReactionEvents.isEmpty && self.wasScheduledMessageIds.isEmpty && self.deletedMessageIds.isEmpty && self.updatedTypingActivities.isEmpty && self.updatedWebpages.isEmpty && self.updatedCalls.isEmpty && self.addedCallSignalingData.isEmpty && self.updatedGroupCallParticipants.isEmpty && self.storyUpdates.isEmpty && self.updatedPeersNearby?.isEmpty ?? true && self.isContactUpdates.isEmpty && self.displayAlerts.isEmpty && self.dismissBotWebViews.isEmpty && self.delayNotificatonsUntil == nil && self.updatedMaxMessageId == nil && self.updatedQts == nil && self.externallyUpdatedPeerId.isEmpty && !authorizationListUpdated && self.updatedIncomingThreadReadStates.isEmpty && self.updatedOutgoingThreadReadStates.isEmpty && !self.updateConfig && !self.isPremiumUpdated && self.updatedRevenueBalances.isEmpty
|
||||
return self.addedIncomingMessageIds.isEmpty && self.addedReactionEvents.isEmpty && self.wasScheduledMessageIds.isEmpty && self.deletedMessageIds.isEmpty && self.updatedTypingActivities.isEmpty && self.updatedWebpages.isEmpty && self.updatedCalls.isEmpty && self.addedCallSignalingData.isEmpty && self.updatedGroupCallParticipants.isEmpty && self.storyUpdates.isEmpty && self.updatedPeersNearby?.isEmpty ?? true && self.isContactUpdates.isEmpty && self.displayAlerts.isEmpty && self.dismissBotWebViews.isEmpty && self.delayNotificatonsUntil == nil && self.updatedMaxMessageId == nil && self.updatedQts == nil && self.externallyUpdatedPeerId.isEmpty && !authorizationListUpdated && self.updatedIncomingThreadReadStates.isEmpty && self.updatedOutgoingThreadReadStates.isEmpty && !self.updateConfig && !self.isPremiumUpdated && self.updatedRevenueBalances.isEmpty && self.updatedStarsBalance.isEmpty
|
||||
}
|
||||
|
||||
init(addedIncomingMessageIds: [MessageId] = [], addedReactionEvents: [(reactionAuthor: Peer, reaction: MessageReaction.Reaction, message: Message, timestamp: Int32)] = [], wasScheduledMessageIds: [MessageId] = [], deletedMessageIds: [DeletedMessageId] = [], updatedTypingActivities: [PeerActivitySpace: [PeerId: PeerInputActivity?]] = [:], updatedWebpages: [MediaId: TelegramMediaWebpage] = [:], updatedCalls: [Api.PhoneCall] = [], addedCallSignalingData: [(Int64, Data)] = [], updatedGroupCallParticipants: [(Int64, GroupCallParticipantsContext.Update)] = [], storyUpdates: [InternalStoryUpdate] = [], updatedPeersNearby: [PeerNearby]? = nil, isContactUpdates: [(PeerId, Bool)] = [], displayAlerts: [(text: String, isDropAuth: Bool)] = [], dismissBotWebViews: [Int64] = [], delayNotificatonsUntil: Int32? = nil, updatedMaxMessageId: Int32? = nil, updatedQts: Int32? = nil, externallyUpdatedPeerId: Set<PeerId> = Set(), authorizationListUpdated: Bool = false, updatedIncomingThreadReadStates: [MessageId: MessageId.Id] = [:], updatedOutgoingThreadReadStates: [MessageId: MessageId.Id] = [:], updateConfig: Bool = false, isPremiumUpdated: Bool = false, updatedRevenueBalances: [PeerId: RevenueStats.Balances] = [:]) {
|
||||
init(addedIncomingMessageIds: [MessageId] = [], addedReactionEvents: [(reactionAuthor: Peer, reaction: MessageReaction.Reaction, message: Message, timestamp: Int32)] = [], wasScheduledMessageIds: [MessageId] = [], deletedMessageIds: [DeletedMessageId] = [], updatedTypingActivities: [PeerActivitySpace: [PeerId: PeerInputActivity?]] = [:], updatedWebpages: [MediaId: TelegramMediaWebpage] = [:], updatedCalls: [Api.PhoneCall] = [], addedCallSignalingData: [(Int64, Data)] = [], updatedGroupCallParticipants: [(Int64, GroupCallParticipantsContext.Update)] = [], storyUpdates: [InternalStoryUpdate] = [], updatedPeersNearby: [PeerNearby]? = nil, isContactUpdates: [(PeerId, Bool)] = [], displayAlerts: [(text: String, isDropAuth: Bool)] = [], dismissBotWebViews: [Int64] = [], delayNotificatonsUntil: Int32? = nil, updatedMaxMessageId: Int32? = nil, updatedQts: Int32? = nil, externallyUpdatedPeerId: Set<PeerId> = Set(), authorizationListUpdated: Bool = false, updatedIncomingThreadReadStates: [MessageId: MessageId.Id] = [:], updatedOutgoingThreadReadStates: [MessageId: MessageId.Id] = [:], updateConfig: Bool = false, isPremiumUpdated: Bool = false, updatedRevenueBalances: [PeerId: RevenueStats.Balances] = [:], updatedStarsBalance: [PeerId: Int64] = [:]) {
|
||||
self.addedIncomingMessageIds = addedIncomingMessageIds
|
||||
self.addedReactionEvents = addedReactionEvents
|
||||
self.wasScheduledMessageIds = wasScheduledMessageIds
|
||||
@ -882,6 +889,7 @@ struct AccountFinalStateEvents {
|
||||
self.updateConfig = updateConfig
|
||||
self.isPremiumUpdated = isPremiumUpdated
|
||||
self.updatedRevenueBalances = updatedRevenueBalances
|
||||
self.updatedStarsBalance = updatedStarsBalance
|
||||
}
|
||||
|
||||
init(state: AccountReplayedFinalState) {
|
||||
@ -909,6 +917,7 @@ struct AccountFinalStateEvents {
|
||||
self.updateConfig = state.updateConfig
|
||||
self.isPremiumUpdated = state.isPremiumUpdated
|
||||
self.updatedRevenueBalances = state.updatedRevenueBalances
|
||||
self.updatedStarsBalance = state.updatedStarsBalance
|
||||
}
|
||||
|
||||
func union(with other: AccountFinalStateEvents) -> AccountFinalStateEvents {
|
||||
@ -938,6 +947,6 @@ struct AccountFinalStateEvents {
|
||||
|
||||
let isPremiumUpdated = self.isPremiumUpdated || other.isPremiumUpdated
|
||||
|
||||
return AccountFinalStateEvents(addedIncomingMessageIds: self.addedIncomingMessageIds + other.addedIncomingMessageIds, addedReactionEvents: self.addedReactionEvents + other.addedReactionEvents, wasScheduledMessageIds: self.wasScheduledMessageIds + other.wasScheduledMessageIds, deletedMessageIds: self.deletedMessageIds + other.deletedMessageIds, updatedTypingActivities: self.updatedTypingActivities, updatedWebpages: self.updatedWebpages, updatedCalls: self.updatedCalls + other.updatedCalls, addedCallSignalingData: self.addedCallSignalingData + other.addedCallSignalingData, updatedGroupCallParticipants: self.updatedGroupCallParticipants + other.updatedGroupCallParticipants, storyUpdates: self.storyUpdates + other.storyUpdates, isContactUpdates: self.isContactUpdates + other.isContactUpdates, displayAlerts: self.displayAlerts + other.displayAlerts, dismissBotWebViews: self.dismissBotWebViews + other.dismissBotWebViews, delayNotificatonsUntil: delayNotificatonsUntil, updatedMaxMessageId: updatedMaxMessageId, updatedQts: updatedQts, externallyUpdatedPeerId: externallyUpdatedPeerId, authorizationListUpdated: authorizationListUpdated, updatedIncomingThreadReadStates: self.updatedIncomingThreadReadStates.merging(other.updatedIncomingThreadReadStates, uniquingKeysWith: { lhs, _ in lhs }), updateConfig: updateConfig, isPremiumUpdated: isPremiumUpdated, updatedRevenueBalances: self.updatedRevenueBalances.merging(other.updatedRevenueBalances, uniquingKeysWith: { lhs, _ in lhs }))
|
||||
return AccountFinalStateEvents(addedIncomingMessageIds: self.addedIncomingMessageIds + other.addedIncomingMessageIds, addedReactionEvents: self.addedReactionEvents + other.addedReactionEvents, wasScheduledMessageIds: self.wasScheduledMessageIds + other.wasScheduledMessageIds, deletedMessageIds: self.deletedMessageIds + other.deletedMessageIds, updatedTypingActivities: self.updatedTypingActivities, updatedWebpages: self.updatedWebpages, updatedCalls: self.updatedCalls + other.updatedCalls, addedCallSignalingData: self.addedCallSignalingData + other.addedCallSignalingData, updatedGroupCallParticipants: self.updatedGroupCallParticipants + other.updatedGroupCallParticipants, storyUpdates: self.storyUpdates + other.storyUpdates, isContactUpdates: self.isContactUpdates + other.isContactUpdates, displayAlerts: self.displayAlerts + other.displayAlerts, dismissBotWebViews: self.dismissBotWebViews + other.dismissBotWebViews, delayNotificatonsUntil: delayNotificatonsUntil, updatedMaxMessageId: updatedMaxMessageId, updatedQts: updatedQts, externallyUpdatedPeerId: externallyUpdatedPeerId, authorizationListUpdated: authorizationListUpdated, updatedIncomingThreadReadStates: self.updatedIncomingThreadReadStates.merging(other.updatedIncomingThreadReadStates, uniquingKeysWith: { lhs, _ in lhs }), updateConfig: updateConfig, isPremiumUpdated: isPremiumUpdated, updatedRevenueBalances: self.updatedRevenueBalances.merging(other.updatedRevenueBalances, uniquingKeysWith: { lhs, _ in lhs }), updatedStarsBalance: self.updatedStarsBalance.merging(other.updatedStarsBalance, uniquingKeysWith: { lhs, _ in lhs }))
|
||||
}
|
||||
}
|
||||
|
@ -1778,6 +1778,8 @@ private func finalStateWithUpdatesAndServerTime(accountPeerId: PeerId, postbox:
|
||||
updatedState.updateWallpaper(peerId: peer.peerId, wallpaper: wallpaper.flatMap { TelegramWallpaper(apiWallpaper: $0) })
|
||||
case let .updateBroadcastRevenueTransactions(peer, balances):
|
||||
updatedState.updateRevenueBalances(peerId: peer.peerId, balances: RevenueStats.Balances(apiRevenueBalances: balances))
|
||||
case let .updateStarsBalance(balance):
|
||||
updatedState.updateStarsBalance(peerId: accountPeerId, balance: balance)
|
||||
default:
|
||||
break
|
||||
}
|
||||
@ -3269,7 +3271,7 @@ private func optimizedOperations(_ operations: [AccountStateMutationOperation])
|
||||
var currentAddQuickReplyMessages: OptimizeAddMessagesState?
|
||||
for operation in operations {
|
||||
switch operation {
|
||||
case .DeleteMessages, .DeleteMessagesWithGlobalIds, .EditMessage, .UpdateMessagePoll, .UpdateMessageReactions, .UpdateMedia, .MergeApiChats, .MergeApiUsers, .MergePeerPresences, .UpdatePeer, .ReadInbox, .ReadOutbox, .ReadGroupFeedInbox, .ResetReadState, .ResetIncomingReadState, .UpdatePeerChatUnreadMark, .ResetMessageTagSummary, .UpdateNotificationSettings, .UpdateGlobalNotificationSettings, .UpdateSecretChat, .AddSecretMessages, .ReadSecretOutbox, .AddPeerInputActivity, .UpdateCachedPeerData, .UpdatePinnedItemIds, .UpdatePinnedSavedItemIds, .UpdatePinnedTopic, .UpdatePinnedTopicOrder, .ReadMessageContents, .UpdateMessageImpressionCount, .UpdateMessageForwardsCount, .UpdateInstalledStickerPacks, .UpdateRecentGifs, .UpdateChatInputState, .UpdateCall, .AddCallSignalingData, .UpdateLangPack, .UpdateMinAvailableMessage, .UpdateIsContact, .UpdatePeerChatInclusion, .UpdatePeersNearby, .UpdateTheme, .SyncChatListFilters, .UpdateChatListFilter, .UpdateChatListFilterOrder, .UpdateReadThread, .UpdateMessagesPinned, .UpdateGroupCallParticipants, .UpdateGroupCall, .UpdateAutoremoveTimeout, .UpdateAttachMenuBots, .UpdateAudioTranscription, .UpdateConfig, .UpdateExtendedMedia, .ResetForumTopic, .UpdateStory, .UpdateReadStories, .UpdateStoryStealthMode, .UpdateStorySentReaction, .UpdateNewAuthorization, .UpdateWallpaper, .UpdateRevenueBalances:
|
||||
case .DeleteMessages, .DeleteMessagesWithGlobalIds, .EditMessage, .UpdateMessagePoll, .UpdateMessageReactions, .UpdateMedia, .MergeApiChats, .MergeApiUsers, .MergePeerPresences, .UpdatePeer, .ReadInbox, .ReadOutbox, .ReadGroupFeedInbox, .ResetReadState, .ResetIncomingReadState, .UpdatePeerChatUnreadMark, .ResetMessageTagSummary, .UpdateNotificationSettings, .UpdateGlobalNotificationSettings, .UpdateSecretChat, .AddSecretMessages, .ReadSecretOutbox, .AddPeerInputActivity, .UpdateCachedPeerData, .UpdatePinnedItemIds, .UpdatePinnedSavedItemIds, .UpdatePinnedTopic, .UpdatePinnedTopicOrder, .ReadMessageContents, .UpdateMessageImpressionCount, .UpdateMessageForwardsCount, .UpdateInstalledStickerPacks, .UpdateRecentGifs, .UpdateChatInputState, .UpdateCall, .AddCallSignalingData, .UpdateLangPack, .UpdateMinAvailableMessage, .UpdateIsContact, .UpdatePeerChatInclusion, .UpdatePeersNearby, .UpdateTheme, .SyncChatListFilters, .UpdateChatListFilter, .UpdateChatListFilterOrder, .UpdateReadThread, .UpdateMessagesPinned, .UpdateGroupCallParticipants, .UpdateGroupCall, .UpdateAutoremoveTimeout, .UpdateAttachMenuBots, .UpdateAudioTranscription, .UpdateConfig, .UpdateExtendedMedia, .ResetForumTopic, .UpdateStory, .UpdateReadStories, .UpdateStoryStealthMode, .UpdateStorySentReaction, .UpdateNewAuthorization, .UpdateWallpaper, .UpdateRevenueBalances, .UpdateStarsBalance:
|
||||
if let currentAddMessages = currentAddMessages, !currentAddMessages.messages.isEmpty {
|
||||
result.append(.AddMessages(currentAddMessages.messages, currentAddMessages.location))
|
||||
}
|
||||
@ -3403,6 +3405,7 @@ func replayFinalState(
|
||||
var syncAttachMenuBots = false
|
||||
var updateConfig = false
|
||||
var updatedRevenueBalances: [PeerId: RevenueStats.Balances] = [:]
|
||||
var updatedStarsBalance: [PeerId: Int64] = [:]
|
||||
|
||||
var holesFromPreviousStateMessageIds: [MessageId] = []
|
||||
var clearHolesFromPreviousStateForChannelMessagesWithPts: [PeerIdAndMessageNamespace: Int32] = [:]
|
||||
@ -4830,6 +4833,8 @@ func replayFinalState(
|
||||
}
|
||||
case let .UpdateRevenueBalances(peerId, balances):
|
||||
updatedRevenueBalances[peerId] = balances
|
||||
case let .UpdateStarsBalance(peerId, balance):
|
||||
updatedStarsBalance[peerId] = balance
|
||||
}
|
||||
}
|
||||
|
||||
@ -5324,5 +5329,5 @@ func replayFinalState(
|
||||
}
|
||||
}
|
||||
|
||||
return AccountReplayedFinalState(state: finalState, addedIncomingMessageIds: addedIncomingMessageIds, addedReactionEvents: addedReactionEvents, wasScheduledMessageIds: wasScheduledMessageIds, addedSecretMessageIds: addedSecretMessageIds, deletedMessageIds: deletedMessageIds, updatedTypingActivities: updatedTypingActivities, updatedWebpages: updatedWebpages, updatedCalls: updatedCalls, addedCallSignalingData: addedCallSignalingData, updatedGroupCallParticipants: updatedGroupCallParticipants, storyUpdates: storyUpdates, updatedPeersNearby: updatedPeersNearby, isContactUpdates: isContactUpdates, delayNotificatonsUntil: delayNotificatonsUntil, updatedIncomingThreadReadStates: updatedIncomingThreadReadStates, updatedOutgoingThreadReadStates: updatedOutgoingThreadReadStates, updateConfig: updateConfig, isPremiumUpdated: isPremiumUpdated, updatedRevenueBalances: updatedRevenueBalances)
|
||||
return AccountReplayedFinalState(state: finalState, addedIncomingMessageIds: addedIncomingMessageIds, addedReactionEvents: addedReactionEvents, wasScheduledMessageIds: wasScheduledMessageIds, addedSecretMessageIds: addedSecretMessageIds, deletedMessageIds: deletedMessageIds, updatedTypingActivities: updatedTypingActivities, updatedWebpages: updatedWebpages, updatedCalls: updatedCalls, addedCallSignalingData: addedCallSignalingData, updatedGroupCallParticipants: updatedGroupCallParticipants, storyUpdates: storyUpdates, updatedPeersNearby: updatedPeersNearby, isContactUpdates: isContactUpdates, delayNotificatonsUntil: delayNotificatonsUntil, updatedIncomingThreadReadStates: updatedIncomingThreadReadStates, updatedOutgoingThreadReadStates: updatedOutgoingThreadReadStates, updateConfig: updateConfig, isPremiumUpdated: isPremiumUpdated, updatedRevenueBalances: updatedRevenueBalances, updatedStarsBalance: updatedStarsBalance)
|
||||
}
|
||||
|
@ -48,6 +48,10 @@ private final class UpdatedRevenueBalancesSubscriberContext {
|
||||
let subscribers = Bag<([PeerId: RevenueStats.Balances]) -> Void>()
|
||||
}
|
||||
|
||||
private final class UpdatedStarsBalanceSubscriberContext {
|
||||
let subscribers = Bag<([PeerId: Int64]) -> Void>()
|
||||
}
|
||||
|
||||
public enum DeletedMessageId: Hashable {
|
||||
case global(Int32)
|
||||
case messageId(MessageId)
|
||||
@ -282,6 +286,7 @@ public final class AccountStateManager {
|
||||
private var updatedWebpageContexts: [MediaId: UpdatedWebpageSubscriberContext] = [:]
|
||||
private var updatedPeersNearbyContext = UpdatedPeersNearbySubscriberContext()
|
||||
private var updatedRevenueBalancesContext = UpdatedRevenueBalancesSubscriberContext()
|
||||
private var updatedStarsBalanceContext = UpdatedStarsBalanceSubscriberContext()
|
||||
|
||||
private let delayNotificatonsUntil = Atomic<Int32?>(value: nil)
|
||||
private let appliedMaxMessageIdPromise = Promise<Int32?>(nil)
|
||||
@ -1030,6 +1035,9 @@ public final class AccountStateManager {
|
||||
if !events.updatedRevenueBalances.isEmpty {
|
||||
strongSelf.notifyUpdatedRevenueBalances(events.updatedRevenueBalances)
|
||||
}
|
||||
if !events.updatedStarsBalance.isEmpty {
|
||||
strongSelf.notifyUpdatedStarsBalance(events.updatedStarsBalance)
|
||||
}
|
||||
if !events.updatedCalls.isEmpty {
|
||||
for call in events.updatedCalls {
|
||||
strongSelf.callSessionManager?.updateSession(call, completion: { _ in })
|
||||
@ -1629,6 +1637,33 @@ public final class AccountStateManager {
|
||||
}
|
||||
}
|
||||
|
||||
public func updatedStarsBalance() -> Signal<[PeerId: Int64], NoError> {
|
||||
let queue = self.queue
|
||||
return Signal { [weak self] subscriber in
|
||||
let disposable = MetaDisposable()
|
||||
queue.async {
|
||||
if let strongSelf = self {
|
||||
let index = strongSelf.updatedStarsBalanceContext.subscribers.add({ starsBalance in
|
||||
subscriber.putNext(starsBalance)
|
||||
})
|
||||
|
||||
disposable.set(ActionDisposable {
|
||||
if let strongSelf = self {
|
||||
strongSelf.updatedStarsBalanceContext.subscribers.remove(index)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
return disposable
|
||||
}
|
||||
}
|
||||
|
||||
private func notifyUpdatedStarsBalance(_ updatedStarsBalance: [PeerId: Int64]) {
|
||||
for subscriber in self.updatedStarsBalanceContext.subscribers.copyItems() {
|
||||
subscriber(updatedStarsBalance)
|
||||
}
|
||||
}
|
||||
|
||||
func notifyDeletedMessages(messageIds: [MessageId]) {
|
||||
self.deletedMessagesPipe.putNext(messageIds.map { .messageId($0) })
|
||||
}
|
||||
@ -1922,6 +1957,12 @@ public final class AccountStateManager {
|
||||
}
|
||||
}
|
||||
|
||||
public func updatedStarsBalance() -> Signal<[PeerId: Int64], NoError> {
|
||||
return self.impl.signalWith { impl, subscriber in
|
||||
return impl.updatedStarsBalance().start(next: subscriber.putNext, error: subscriber.putError, completed: subscriber.putCompletion)
|
||||
}
|
||||
}
|
||||
|
||||
func addCustomOperation<T, E>(_ f: Signal<T, E>) -> Signal<T, E> {
|
||||
return self.impl.signalWith { impl, subscriber in
|
||||
return impl.addCustomOperation(f).start(next: subscriber.putNext, error: subscriber.putError, completed: subscriber.putCompletion)
|
||||
|
@ -119,8 +119,8 @@ public struct BotPaymentForm : Equatable {
|
||||
public let passwordMissing: Bool
|
||||
public let invoice: BotPaymentInvoice
|
||||
public let paymentBotId: PeerId
|
||||
public let providerId: PeerId
|
||||
public let url: String
|
||||
public let providerId: PeerId?
|
||||
public let url: String?
|
||||
public let nativeProvider: BotPaymentNativeProvider?
|
||||
public let savedInfo: BotPaymentRequestedInfo?
|
||||
public let savedCredentials: [BotPaymentSavedCredentials]
|
||||
@ -206,7 +206,7 @@ extension BotPaymentRequestedInfo {
|
||||
}
|
||||
}
|
||||
|
||||
private func _internal_parseInputInvoice(transaction: Transaction, source: BotPaymentInvoiceSource) -> Api.InputInvoice? {
|
||||
func _internal_parseInputInvoice(transaction: Transaction, source: BotPaymentInvoiceSource) -> Api.InputInvoice? {
|
||||
switch source {
|
||||
case let .message(messageId):
|
||||
guard let inputPeer = transaction.getPeer(messageId.peerId).flatMap(apiInputPeer) else {
|
||||
@ -321,6 +321,9 @@ func _internal_fetchBotPaymentInvoice(postbox: Postbox, network: Network, source
|
||||
}
|
||||
|
||||
return TelegramMediaInvoice(title: title, description: description, photo: photo.flatMap(TelegramMediaWebFile.init), receiptMessageId: nil, currency: parsedInvoice.currency, totalAmount: 0, startParam: "", extendedMedia: nil, flags: parsedFlags, version: TelegramMediaInvoice.lastVersion)
|
||||
case let .paymentFormStars(_, _, _, title, description, photo, invoice, _):
|
||||
let parsedInvoice = BotPaymentInvoice(apiInvoice: invoice)
|
||||
return TelegramMediaInvoice(title: title, description: description, photo: photo.flatMap(TelegramMediaWebFile.init), receiptMessageId: nil, currency: parsedInvoice.currency, totalAmount: 0, startParam: "", extendedMedia: nil, flags: [], version: TelegramMediaInvoice.lastVersion)
|
||||
}
|
||||
}
|
||||
|> mapError { _ -> BotPaymentFormRequestError in }
|
||||
@ -354,32 +357,43 @@ func _internal_fetchBotPaymentForm(accountPeerId: PeerId, postbox: Postbox, netw
|
||||
|> mapToSignal { result -> Signal<BotPaymentForm, BotPaymentFormRequestError> in
|
||||
return postbox.transaction { transaction -> BotPaymentForm in
|
||||
switch result {
|
||||
case let .paymentForm(flags, id, botId, title, description, photo, invoice, providerId, url, nativeProvider, nativeParams, additionalMethods, savedInfo, savedCredentials, apiUsers):
|
||||
let _ = title
|
||||
let _ = description
|
||||
let _ = photo
|
||||
case let .paymentForm(flags, id, botId, title, description, photo, invoice, providerId, url, nativeProvider, nativeParams, additionalMethods, savedInfo, savedCredentials, apiUsers):
|
||||
let _ = title
|
||||
let _ = description
|
||||
let _ = photo
|
||||
|
||||
let parsedPeers = AccumulatedPeers(users: apiUsers)
|
||||
updatePeers(transaction: transaction, accountPeerId: accountPeerId, peers: parsedPeers)
|
||||
let parsedPeers = AccumulatedPeers(users: apiUsers)
|
||||
updatePeers(transaction: transaction, accountPeerId: accountPeerId, peers: parsedPeers)
|
||||
|
||||
let parsedInvoice = BotPaymentInvoice(apiInvoice: invoice)
|
||||
var parsedNativeProvider: BotPaymentNativeProvider?
|
||||
if let nativeProvider = nativeProvider, let nativeParams = nativeParams {
|
||||
switch nativeParams {
|
||||
case let .dataJSON(data):
|
||||
parsedNativeProvider = BotPaymentNativeProvider(name: nativeProvider, params: data)
|
||||
}
|
||||
let parsedInvoice = BotPaymentInvoice(apiInvoice: invoice)
|
||||
var parsedNativeProvider: BotPaymentNativeProvider?
|
||||
if let nativeProvider = nativeProvider, let nativeParams = nativeParams {
|
||||
switch nativeParams {
|
||||
case let .dataJSON(data):
|
||||
parsedNativeProvider = BotPaymentNativeProvider(name: nativeProvider, params: data)
|
||||
}
|
||||
let parsedSavedInfo = savedInfo.flatMap(BotPaymentRequestedInfo.init)
|
||||
let parsedSavedCredentials = savedCredentials?.map({ savedCredentials -> BotPaymentSavedCredentials in
|
||||
switch savedCredentials {
|
||||
case let .paymentSavedCredentialsCard(id, title):
|
||||
return .card(id: id, title: title)
|
||||
}
|
||||
}) ?? []
|
||||
}
|
||||
let parsedSavedInfo = savedInfo.flatMap(BotPaymentRequestedInfo.init)
|
||||
let parsedSavedCredentials = savedCredentials?.map({ savedCredentials -> BotPaymentSavedCredentials in
|
||||
switch savedCredentials {
|
||||
case let .paymentSavedCredentialsCard(id, title):
|
||||
return .card(id: id, title: title)
|
||||
}
|
||||
}) ?? []
|
||||
|
||||
let additionalPaymentMethods = additionalMethods?.map({ BotPaymentMethod(apiPaymentFormMethod: $0) }) ?? []
|
||||
return BotPaymentForm(id: id, canSaveCredentials: (flags & (1 << 2)) != 0, passwordMissing: (flags & (1 << 3)) != 0, invoice: parsedInvoice, paymentBotId: PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt64Value(botId)), providerId: PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt64Value(providerId)), url: url, nativeProvider: parsedNativeProvider, savedInfo: parsedSavedInfo, savedCredentials: parsedSavedCredentials, additionalPaymentMethods: additionalPaymentMethods)
|
||||
let additionalPaymentMethods = additionalMethods?.map({ BotPaymentMethod(apiPaymentFormMethod: $0) }) ?? []
|
||||
return BotPaymentForm(id: id, canSaveCredentials: (flags & (1 << 2)) != 0, passwordMissing: (flags & (1 << 3)) != 0, invoice: parsedInvoice, paymentBotId: PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt64Value(botId)), providerId: PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt64Value(providerId)), url: url, nativeProvider: parsedNativeProvider, savedInfo: parsedSavedInfo, savedCredentials: parsedSavedCredentials, additionalPaymentMethods: additionalPaymentMethods)
|
||||
case let .paymentFormStars(flags, id, botId, title, description, photo, invoice, apiUsers):
|
||||
let _ = flags
|
||||
let _ = title
|
||||
let _ = description
|
||||
let _ = photo
|
||||
|
||||
let parsedPeers = AccumulatedPeers(users: apiUsers)
|
||||
updatePeers(transaction: transaction, accountPeerId: accountPeerId, peers: parsedPeers)
|
||||
|
||||
let parsedInvoice = BotPaymentInvoice(apiInvoice: invoice)
|
||||
return BotPaymentForm(id: id, canSaveCredentials: false, passwordMissing: false, invoice: parsedInvoice, paymentBotId: PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt64Value(botId)), providerId: nil, url: nil, nativeProvider: nil, savedInfo: nil, savedCredentials: [], additionalPaymentMethods: [])
|
||||
}
|
||||
}
|
||||
|> mapError { _ -> BotPaymentFormRequestError in }
|
||||
|
@ -104,11 +104,8 @@ private func requestStarsState(account: Account, peerId: EnginePeer.Id, offset:
|
||||
|
||||
var parsedTransactions: [StarsContext.State.Transaction] = []
|
||||
for entry in history {
|
||||
switch entry {
|
||||
case let .starsTransaction(id, stars, date, peer):
|
||||
if let peer = transaction.getPeer(peer.peerId) {
|
||||
parsedTransactions.append(StarsContext.State.Transaction(id: id, count: stars, date: date, peer: EnginePeer(peer)))
|
||||
}
|
||||
if let parsedTransaction = StarsContext.State.Transaction(apiTransaction: entry, transaction: transaction) {
|
||||
parsedTransactions.append(parsedTransaction)
|
||||
}
|
||||
}
|
||||
return InternalStarsStatus(balance: balance, transactions: parsedTransactions, nextOffset: nextOffset)
|
||||
@ -136,6 +133,7 @@ private final class StarsContextImpl {
|
||||
private var nextOffset: String?
|
||||
|
||||
private let disposable = MetaDisposable()
|
||||
private var updateDisposable: Disposable?
|
||||
|
||||
init(account: Account, peerId: EnginePeer.Id) {
|
||||
assert(Queue.mainQueue().isCurrent())
|
||||
@ -147,11 +145,20 @@ private final class StarsContextImpl {
|
||||
self._statePromise.set(.single(nil))
|
||||
|
||||
self.load()
|
||||
|
||||
self.updateDisposable = (account.stateManager.updatedStarsBalance()
|
||||
|> deliverOnMainQueue).startStrict(next: { [weak self] balances in
|
||||
guard let self, let state = self._state, let balance = balances[peerId] else {
|
||||
return
|
||||
}
|
||||
self._state = StarsContext.State(balance: balance, transactions: state.transactions)
|
||||
})
|
||||
}
|
||||
|
||||
deinit {
|
||||
assert(Queue.mainQueue().isCurrent())
|
||||
self.disposable.dispose()
|
||||
self.updateDisposable?.dispose()
|
||||
}
|
||||
|
||||
func load() {
|
||||
@ -190,15 +197,45 @@ private final class StarsContextImpl {
|
||||
}
|
||||
}
|
||||
|
||||
private extension StarsContext.State.Transaction {
|
||||
init?(apiTransaction: Api.StarsTransaction, transaction: Transaction) {
|
||||
switch apiTransaction {
|
||||
case let .starsTransaction(id, stars, date, transactionPeer):
|
||||
let parsedPeer: StarsContext.State.Transaction.Peer
|
||||
switch transactionPeer {
|
||||
case .starsTransactionPeerAppStore:
|
||||
parsedPeer = .appStore
|
||||
case .starsTransactionPeerPlayMarket:
|
||||
parsedPeer = .playMarket
|
||||
case .starsTransactionPeerFragment:
|
||||
parsedPeer = .fragment
|
||||
case let .starsTransactionPeer(apiPeer):
|
||||
guard let peer = transaction.getPeer(apiPeer.peerId) else {
|
||||
return nil
|
||||
}
|
||||
parsedPeer = .peer(EnginePeer(peer))
|
||||
}
|
||||
self.init(id: id, count: stars, date: date, peer: parsedPeer)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public final class StarsContext {
|
||||
public struct State: Equatable {
|
||||
public struct Transaction: Equatable {
|
||||
public enum Peer: Equatable {
|
||||
case appStore
|
||||
case playMarket
|
||||
case fragment
|
||||
case peer(EnginePeer)
|
||||
}
|
||||
|
||||
public let id: String
|
||||
public let count: Int64
|
||||
public let date: Int32
|
||||
public let peer: EnginePeer
|
||||
public let peer: Peer
|
||||
|
||||
init(id: String, count: Int64, date: Int32, peer: EnginePeer) {
|
||||
init(id: String, count: Int64, date: Int32, peer: Peer) {
|
||||
self.id = id
|
||||
self.count = count
|
||||
self.date = date
|
||||
@ -245,3 +282,79 @@ public final class StarsContext {
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func _internal_sendStarsPaymentForm(account: Account, formId: Int64, source: BotPaymentInvoiceSource) -> Signal<SendBotPaymentResult, SendBotPaymentFormError> {
|
||||
return account.postbox.transaction { transaction -> Api.InputInvoice? in
|
||||
return _internal_parseInputInvoice(transaction: transaction, source: source)
|
||||
}
|
||||
|> castError(SendBotPaymentFormError.self)
|
||||
|> mapToSignal { invoice -> Signal<SendBotPaymentResult, SendBotPaymentFormError> in
|
||||
guard let invoice = invoice else {
|
||||
return .fail(.generic)
|
||||
}
|
||||
|
||||
let flags: Int32 = 0
|
||||
|
||||
return account.network.request(Api.functions.payments.sendStarsForm(flags: flags, formId: formId, invoice: invoice))
|
||||
|> map { result -> SendBotPaymentResult in
|
||||
switch result {
|
||||
case let .paymentResult(updates):
|
||||
account.stateManager.addUpdates(updates)
|
||||
var receiptMessageId: MessageId?
|
||||
for apiMessage in updates.messages {
|
||||
if let message = StoreMessage(apiMessage: apiMessage, accountPeerId: account.peerId, peerIsForum: false) {
|
||||
for media in message.media {
|
||||
if let action = media as? TelegramMediaAction {
|
||||
if case .paymentSent = action.action {
|
||||
switch source {
|
||||
case let .slug(slug):
|
||||
for media in message.media {
|
||||
if let action = media as? TelegramMediaAction, case let .paymentSent(_, _, invoiceSlug?, _, _) = action.action, invoiceSlug == slug {
|
||||
if case let .Id(id) = message.id {
|
||||
receiptMessageId = id
|
||||
}
|
||||
}
|
||||
}
|
||||
case let .message(messageId):
|
||||
for attribute in message.attributes {
|
||||
if let reply = attribute as? ReplyMessageAttribute {
|
||||
if reply.messageId == messageId {
|
||||
if case let .Id(id) = message.id {
|
||||
receiptMessageId = id
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
case let .premiumGiveaway(_, _, _, _, _, _, randomId, _, _, _, _):
|
||||
if message.globallyUniqueId == randomId {
|
||||
if case let .Id(id) = message.id {
|
||||
receiptMessageId = id
|
||||
}
|
||||
}
|
||||
case .giftCode:
|
||||
receiptMessageId = nil
|
||||
case .stars:
|
||||
receiptMessageId = nil
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return .done(receiptMessageId: receiptMessageId)
|
||||
case let .paymentVerificationNeeded(url):
|
||||
return .externalVerificationRequired(url: url)
|
||||
}
|
||||
}
|
||||
|> `catch` { error -> Signal<SendBotPaymentResult, SendBotPaymentFormError> in
|
||||
if error.errorDescription == "BOT_PRECHECKOUT_FAILED" {
|
||||
return .fail(.precheckoutFailed)
|
||||
} else if error.errorDescription == "PAYMENT_FAILED" {
|
||||
return .fail(.paymentFailed)
|
||||
} else if error.errorDescription == "INVOICE_ALREADY_PAID" {
|
||||
return .fail(.alreadyPaid)
|
||||
}
|
||||
return .fail(.generic)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -73,5 +73,9 @@ public extension TelegramEngine {
|
||||
public func peerStarsContext(peerId: EnginePeer.Id) -> StarsContext {
|
||||
return StarsContext(account: self.account, peerId: peerId)
|
||||
}
|
||||
}
|
||||
|
||||
public func sendStarsPaymentForm(formId: Int64, source: BotPaymentInvoiceSource) -> Signal<SendBotPaymentResult, SendBotPaymentFormError> {
|
||||
return _internal_sendStarsPaymentForm(account: self.account, formId: formId, source: source)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user