Update API [skip ci]

This commit is contained in:
Ilya Laktyushin 2024-11-07 14:01:54 +01:00
parent 9a46522b43
commit 8ec6964dfe
9 changed files with 110 additions and 26 deletions

View File

@ -487,7 +487,7 @@ fileprivate let parsers: [Int32 : (BufferReader) -> Any?] = {
dict[-193992412] = { return Api.InputWebFileLocation.parse_inputWebFileAudioAlbumThumbLocation($0) } dict[-193992412] = { return Api.InputWebFileLocation.parse_inputWebFileAudioAlbumThumbLocation($0) }
dict[-1625153079] = { return Api.InputWebFileLocation.parse_inputWebFileGeoPointLocation($0) } dict[-1625153079] = { return Api.InputWebFileLocation.parse_inputWebFileGeoPointLocation($0) }
dict[-1036396922] = { return Api.InputWebFileLocation.parse_inputWebFileLocation($0) } dict[-1036396922] = { return Api.InputWebFileLocation.parse_inputWebFileLocation($0) }
dict[1572428309] = { return Api.Invoice.parse_invoice($0) } dict[77522308] = { return Api.Invoice.parse_invoice($0) }
dict[-1059185703] = { return Api.JSONObjectValue.parse_jsonObjectValue($0) } dict[-1059185703] = { return Api.JSONObjectValue.parse_jsonObjectValue($0) }
dict[-146520221] = { return Api.JSONValue.parse_jsonArray($0) } dict[-146520221] = { return Api.JSONValue.parse_jsonArray($0) }
dict[-952869270] = { return Api.JSONValue.parse_jsonBool($0) } dict[-952869270] = { return Api.JSONValue.parse_jsonBool($0) }
@ -899,7 +899,7 @@ fileprivate let parsers: [Int32 : (BufferReader) -> Any?] = {
dict[-1798404822] = { return Api.StarsGiveawayOption.parse_starsGiveawayOption($0) } dict[-1798404822] = { return Api.StarsGiveawayOption.parse_starsGiveawayOption($0) }
dict[1411605001] = { return Api.StarsGiveawayWinnersOption.parse_starsGiveawayWinnersOption($0) } dict[1411605001] = { return Api.StarsGiveawayWinnersOption.parse_starsGiveawayWinnersOption($0) }
dict[2033461574] = { return Api.StarsRevenueStatus.parse_starsRevenueStatus($0) } dict[2033461574] = { return Api.StarsRevenueStatus.parse_starsRevenueStatus($0) }
dict[1401868056] = { return Api.StarsSubscription.parse_starsSubscription($0) } dict[779004698] = { return Api.StarsSubscription.parse_starsSubscription($0) }
dict[88173912] = { return Api.StarsSubscriptionPricing.parse_starsSubscriptionPricing($0) } dict[88173912] = { return Api.StarsSubscriptionPricing.parse_starsSubscriptionPricing($0) }
dict[198776256] = { return Api.StarsTopupOption.parse_starsTopupOption($0) } dict[198776256] = { return Api.StarsTopupOption.parse_starsTopupOption($0) }
dict[903148150] = { return Api.StarsTransaction.parse_starsTransaction($0) } dict[903148150] = { return Api.StarsTransaction.parse_starsTransaction($0) }
@ -974,6 +974,7 @@ fileprivate let parsers: [Int32 : (BufferReader) -> Any?] = {
dict[675009298] = { return Api.Update.parse_updateBotPurchasedPaidMedia($0) } dict[675009298] = { return Api.Update.parse_updateBotPurchasedPaidMedia($0) }
dict[-1246823043] = { return Api.Update.parse_updateBotShippingQuery($0) } dict[-1246823043] = { return Api.Update.parse_updateBotShippingQuery($0) }
dict[-997782967] = { return Api.Update.parse_updateBotStopped($0) } dict[-997782967] = { return Api.Update.parse_updateBotStopped($0) }
dict[-1464975695] = { return Api.Update.parse_updateBotSubscriptionExpire($0) }
dict[-2095595325] = { return Api.Update.parse_updateBotWebhookJSON($0) } dict[-2095595325] = { return Api.Update.parse_updateBotWebhookJSON($0) }
dict[-1684914010] = { return Api.Update.parse_updateBotWebhookJSONQuery($0) } dict[-1684914010] = { return Api.Update.parse_updateBotWebhookJSONQuery($0) }
dict[-539401739] = { return Api.Update.parse_updateBroadcastRevenueTransactions($0) } dict[-539401739] = { return Api.Update.parse_updateBroadcastRevenueTransactions($0) }

View File

@ -416,13 +416,13 @@ public extension Api {
} }
public extension Api { public extension Api {
enum Invoice: TypeConstructorDescription { enum Invoice: TypeConstructorDescription {
case invoice(flags: Int32, currency: String, prices: [Api.LabeledPrice], maxTipAmount: Int64?, suggestedTipAmounts: [Int64]?, termsUrl: String?) case invoice(flags: Int32, currency: String, prices: [Api.LabeledPrice], maxTipAmount: Int64?, suggestedTipAmounts: [Int64]?, termsUrl: String?, subscriptionPeriod: Int32?)
public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) { public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) {
switch self { switch self {
case .invoice(let flags, let currency, let prices, let maxTipAmount, let suggestedTipAmounts, let termsUrl): case .invoice(let flags, let currency, let prices, let maxTipAmount, let suggestedTipAmounts, let termsUrl, let subscriptionPeriod):
if boxed { if boxed {
buffer.appendInt32(1572428309) buffer.appendInt32(77522308)
} }
serializeInt32(flags, buffer: buffer, boxed: false) serializeInt32(flags, buffer: buffer, boxed: false)
serializeString(currency, buffer: buffer, boxed: false) serializeString(currency, buffer: buffer, boxed: false)
@ -438,14 +438,15 @@ public extension Api {
serializeInt64(item, buffer: buffer, boxed: false) serializeInt64(item, buffer: buffer, boxed: false)
}} }}
if Int(flags) & Int(1 << 10) != 0 {serializeString(termsUrl!, buffer: buffer, boxed: false)} if Int(flags) & Int(1 << 10) != 0 {serializeString(termsUrl!, buffer: buffer, boxed: false)}
if Int(flags) & Int(1 << 11) != 0 {serializeInt32(subscriptionPeriod!, buffer: buffer, boxed: false)}
break break
} }
} }
public func descriptionFields() -> (String, [(String, Any)]) { public func descriptionFields() -> (String, [(String, Any)]) {
switch self { switch self {
case .invoice(let flags, let currency, let prices, let maxTipAmount, let suggestedTipAmounts, let termsUrl): case .invoice(let flags, let currency, let prices, let maxTipAmount, let suggestedTipAmounts, let termsUrl, let subscriptionPeriod):
return ("invoice", [("flags", flags as Any), ("currency", currency as Any), ("prices", prices as Any), ("maxTipAmount", maxTipAmount as Any), ("suggestedTipAmounts", suggestedTipAmounts as Any), ("termsUrl", termsUrl as Any)]) return ("invoice", [("flags", flags as Any), ("currency", currency as Any), ("prices", prices as Any), ("maxTipAmount", maxTipAmount as Any), ("suggestedTipAmounts", suggestedTipAmounts as Any), ("termsUrl", termsUrl as Any), ("subscriptionPeriod", subscriptionPeriod as Any)])
} }
} }
@ -466,14 +467,17 @@ public extension Api {
} } } }
var _6: String? var _6: String?
if Int(_1!) & Int(1 << 10) != 0 {_6 = parseString(reader) } if Int(_1!) & Int(1 << 10) != 0 {_6 = parseString(reader) }
var _7: Int32?
if Int(_1!) & Int(1 << 11) != 0 {_7 = reader.readInt32() }
let _c1 = _1 != nil let _c1 = _1 != nil
let _c2 = _2 != nil let _c2 = _2 != nil
let _c3 = _3 != nil let _c3 = _3 != nil
let _c4 = (Int(_1!) & Int(1 << 8) == 0) || _4 != nil let _c4 = (Int(_1!) & Int(1 << 8) == 0) || _4 != nil
let _c5 = (Int(_1!) & Int(1 << 8) == 0) || _5 != nil let _c5 = (Int(_1!) & Int(1 << 8) == 0) || _5 != nil
let _c6 = (Int(_1!) & Int(1 << 10) == 0) || _6 != nil let _c6 = (Int(_1!) & Int(1 << 10) == 0) || _6 != nil
if _c1 && _c2 && _c3 && _c4 && _c5 && _c6 { let _c7 = (Int(_1!) & Int(1 << 11) == 0) || _7 != nil
return Api.Invoice.invoice(flags: _1!, currency: _2!, prices: _3!, maxTipAmount: _4, suggestedTipAmounts: _5, termsUrl: _6) if _c1 && _c2 && _c3 && _c4 && _c5 && _c6 && _c7 {
return Api.Invoice.invoice(flags: _1!, currency: _2!, prices: _3!, maxTipAmount: _4, suggestedTipAmounts: _5, termsUrl: _6, subscriptionPeriod: _7)
} }
else { else {
return nil return nil

View File

@ -858,13 +858,13 @@ public extension Api {
} }
public extension Api { public extension Api {
enum StarsSubscription: TypeConstructorDescription { enum StarsSubscription: TypeConstructorDescription {
case starsSubscription(flags: Int32, id: String, peer: Api.Peer, untilDate: Int32, pricing: Api.StarsSubscriptionPricing, chatInviteHash: String?) case starsSubscription(flags: Int32, id: String, peer: Api.Peer, untilDate: Int32, pricing: Api.StarsSubscriptionPricing, chatInviteHash: String?, title: String?, photo: Api.WebDocument?, invoiceSlug: String?)
public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) { public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) {
switch self { switch self {
case .starsSubscription(let flags, let id, let peer, let untilDate, let pricing, let chatInviteHash): case .starsSubscription(let flags, let id, let peer, let untilDate, let pricing, let chatInviteHash, let title, let photo, let invoiceSlug):
if boxed { if boxed {
buffer.appendInt32(1401868056) buffer.appendInt32(779004698)
} }
serializeInt32(flags, buffer: buffer, boxed: false) serializeInt32(flags, buffer: buffer, boxed: false)
serializeString(id, buffer: buffer, boxed: false) serializeString(id, buffer: buffer, boxed: false)
@ -872,14 +872,17 @@ public extension Api {
serializeInt32(untilDate, buffer: buffer, boxed: false) serializeInt32(untilDate, buffer: buffer, boxed: false)
pricing.serialize(buffer, true) pricing.serialize(buffer, true)
if Int(flags) & Int(1 << 3) != 0 {serializeString(chatInviteHash!, buffer: buffer, boxed: false)} if Int(flags) & Int(1 << 3) != 0 {serializeString(chatInviteHash!, buffer: buffer, boxed: false)}
if Int(flags) & Int(1 << 4) != 0 {serializeString(title!, buffer: buffer, boxed: false)}
if Int(flags) & Int(1 << 5) != 0 {photo!.serialize(buffer, true)}
if Int(flags) & Int(1 << 6) != 0 {serializeString(invoiceSlug!, buffer: buffer, boxed: false)}
break break
} }
} }
public func descriptionFields() -> (String, [(String, Any)]) { public func descriptionFields() -> (String, [(String, Any)]) {
switch self { switch self {
case .starsSubscription(let flags, let id, let peer, let untilDate, let pricing, let chatInviteHash): case .starsSubscription(let flags, let id, let peer, let untilDate, let pricing, let chatInviteHash, let title, let photo, let invoiceSlug):
return ("starsSubscription", [("flags", flags as Any), ("id", id as Any), ("peer", peer as Any), ("untilDate", untilDate as Any), ("pricing", pricing as Any), ("chatInviteHash", chatInviteHash as Any)]) return ("starsSubscription", [("flags", flags as Any), ("id", id as Any), ("peer", peer as Any), ("untilDate", untilDate as Any), ("pricing", pricing as Any), ("chatInviteHash", chatInviteHash as Any), ("title", title as Any), ("photo", photo as Any), ("invoiceSlug", invoiceSlug as Any)])
} }
} }
@ -900,14 +903,25 @@ public extension Api {
} }
var _6: String? var _6: String?
if Int(_1!) & Int(1 << 3) != 0 {_6 = parseString(reader) } if Int(_1!) & Int(1 << 3) != 0 {_6 = parseString(reader) }
var _7: String?
if Int(_1!) & Int(1 << 4) != 0 {_7 = parseString(reader) }
var _8: Api.WebDocument?
if Int(_1!) & Int(1 << 5) != 0 {if let signature = reader.readInt32() {
_8 = Api.parse(reader, signature: signature) as? Api.WebDocument
} }
var _9: String?
if Int(_1!) & Int(1 << 6) != 0 {_9 = parseString(reader) }
let _c1 = _1 != nil let _c1 = _1 != nil
let _c2 = _2 != nil let _c2 = _2 != nil
let _c3 = _3 != nil let _c3 = _3 != nil
let _c4 = _4 != nil let _c4 = _4 != nil
let _c5 = _5 != nil let _c5 = _5 != nil
let _c6 = (Int(_1!) & Int(1 << 3) == 0) || _6 != nil let _c6 = (Int(_1!) & Int(1 << 3) == 0) || _6 != nil
if _c1 && _c2 && _c3 && _c4 && _c5 && _c6 { let _c7 = (Int(_1!) & Int(1 << 4) == 0) || _7 != nil
return Api.StarsSubscription.starsSubscription(flags: _1!, id: _2!, peer: _3!, untilDate: _4!, pricing: _5!, chatInviteHash: _6) let _c8 = (Int(_1!) & Int(1 << 5) == 0) || _8 != nil
let _c9 = (Int(_1!) & Int(1 << 6) == 0) || _9 != nil
if _c1 && _c2 && _c3 && _c4 && _c5 && _c6 && _c7 && _c8 && _c9 {
return Api.StarsSubscription.starsSubscription(flags: _1!, id: _2!, peer: _3!, untilDate: _4!, pricing: _5!, chatInviteHash: _6, title: _7, photo: _8, invoiceSlug: _9)
} }
else { else {
return nil return nil

View File

@ -645,6 +645,7 @@ public extension Api {
case updateBotPurchasedPaidMedia(userId: Int64, payload: String, qts: Int32) case updateBotPurchasedPaidMedia(userId: Int64, payload: String, qts: Int32)
case updateBotShippingQuery(queryId: Int64, userId: Int64, payload: Buffer, shippingAddress: Api.PostAddress) case updateBotShippingQuery(queryId: Int64, userId: Int64, payload: Buffer, shippingAddress: Api.PostAddress)
case updateBotStopped(userId: Int64, date: Int32, stopped: Api.Bool, qts: Int32) case updateBotStopped(userId: Int64, date: Int32, stopped: Api.Bool, qts: Int32)
case updateBotSubscriptionExpire(userId: Int64, payload: String, untilDate: Int32, qts: Int32)
case updateBotWebhookJSON(data: Api.DataJSON) case updateBotWebhookJSON(data: Api.DataJSON)
case updateBotWebhookJSONQuery(queryId: Int64, data: Api.DataJSON, timeout: Int32) case updateBotWebhookJSONQuery(queryId: Int64, data: Api.DataJSON, timeout: Int32)
case updateBroadcastRevenueTransactions(peer: Api.Peer, balances: Api.BroadcastRevenueBalances) case updateBroadcastRevenueTransactions(peer: Api.Peer, balances: Api.BroadcastRevenueBalances)
@ -969,6 +970,15 @@ public extension Api {
stopped.serialize(buffer, true) stopped.serialize(buffer, true)
serializeInt32(qts, buffer: buffer, boxed: false) serializeInt32(qts, buffer: buffer, boxed: false)
break break
case .updateBotSubscriptionExpire(let userId, let payload, let untilDate, let qts):
if boxed {
buffer.appendInt32(-1464975695)
}
serializeInt64(userId, buffer: buffer, boxed: false)
serializeString(payload, buffer: buffer, boxed: false)
serializeInt32(untilDate, buffer: buffer, boxed: false)
serializeInt32(qts, buffer: buffer, boxed: false)
break
case .updateBotWebhookJSON(let data): case .updateBotWebhookJSON(let data):
if boxed { if boxed {
buffer.appendInt32(-2095595325) buffer.appendInt32(-2095595325)
@ -2041,6 +2051,8 @@ public extension Api {
return ("updateBotShippingQuery", [("queryId", queryId as Any), ("userId", userId as Any), ("payload", payload as Any), ("shippingAddress", shippingAddress as Any)]) return ("updateBotShippingQuery", [("queryId", queryId as Any), ("userId", userId as Any), ("payload", payload as Any), ("shippingAddress", shippingAddress as Any)])
case .updateBotStopped(let userId, let date, let stopped, let qts): case .updateBotStopped(let userId, let date, let stopped, let qts):
return ("updateBotStopped", [("userId", userId as Any), ("date", date as Any), ("stopped", stopped as Any), ("qts", qts as Any)]) return ("updateBotStopped", [("userId", userId as Any), ("date", date as Any), ("stopped", stopped as Any), ("qts", qts as Any)])
case .updateBotSubscriptionExpire(let userId, let payload, let untilDate, let qts):
return ("updateBotSubscriptionExpire", [("userId", userId as Any), ("payload", payload as Any), ("untilDate", untilDate as Any), ("qts", qts as Any)])
case .updateBotWebhookJSON(let data): case .updateBotWebhookJSON(let data):
return ("updateBotWebhookJSON", [("data", data as Any)]) return ("updateBotWebhookJSON", [("data", data as Any)])
case .updateBotWebhookJSONQuery(let queryId, let data, let timeout): case .updateBotWebhookJSONQuery(let queryId, let data, let timeout):
@ -2732,6 +2744,26 @@ public extension Api {
return nil return nil
} }
} }
public static func parse_updateBotSubscriptionExpire(_ reader: BufferReader) -> Update? {
var _1: Int64?
_1 = reader.readInt64()
var _2: String?
_2 = parseString(reader)
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.Update.updateBotSubscriptionExpire(userId: _1!, payload: _2!, untilDate: _3!, qts: _4!)
}
else {
return nil
}
}
public static func parse_updateBotWebhookJSON(_ reader: BufferReader) -> Update? { public static func parse_updateBotWebhookJSON(_ reader: BufferReader) -> Update? {
var _1: Api.DataJSON? var _1: Api.DataJSON?
if let signature = reader.readInt32() { if let signature = reader.readInt32() {

View File

@ -210,7 +210,7 @@ public class BoxedMessage: NSObject {
public class Serialization: NSObject, MTSerialization { public class Serialization: NSObject, MTSerialization {
public func currentLayer() -> UInt { public func currentLayer() -> UInt {
return 192 return 194
} }
public func parseMessage(_ data: Data!) -> Any! { public func parseMessage(_ data: Data!) -> Any! {

View File

@ -114,8 +114,8 @@ public final class TelegramMediaInvoice: Media, Equatable {
self.currency = currency self.currency = currency
self.totalAmount = totalAmount self.totalAmount = totalAmount
self.startParam = startParam self.startParam = startParam
self.flags = flags
self.extendedMedia = extendedMedia self.extendedMedia = extendedMedia
self.flags = flags
self.version = version self.version = version
} }
@ -126,8 +126,8 @@ public final class TelegramMediaInvoice: Media, Equatable {
self.totalAmount = decoder.decodeInt64ForKey("ta", orElse: 0) self.totalAmount = decoder.decodeInt64ForKey("ta", orElse: 0)
self.startParam = decoder.decodeStringForKey("sp", orElse: "") self.startParam = decoder.decodeStringForKey("sp", orElse: "")
self.photo = decoder.decodeObjectForKey("p") as? TelegramMediaWebFile self.photo = decoder.decodeObjectForKey("p") as? TelegramMediaWebFile
self.flags = TelegramMediaInvoiceFlags(rawValue: decoder.decodeInt32ForKey("f", orElse: 0))
self.extendedMedia = decoder.decodeObjectForKey("m", decoder: { TelegramExtendedMedia(decoder: $0) }) as? TelegramExtendedMedia self.extendedMedia = decoder.decodeObjectForKey("m", decoder: { TelegramExtendedMedia(decoder: $0) }) as? TelegramExtendedMedia
self.flags = TelegramMediaInvoiceFlags(rawValue: decoder.decodeInt32ForKey("f", orElse: 0))
if let receiptMessageIdPeerId = decoder.decodeOptionalInt64ForKey("r.p") as Int64?, let receiptMessageIdNamespace = decoder.decodeOptionalInt32ForKey("r.n") as Int32?, let receiptMessageIdId = decoder.decodeOptionalInt32ForKey("r.i") as Int32? { if let receiptMessageIdPeerId = decoder.decodeOptionalInt64ForKey("r.p") as Int64?, let receiptMessageIdNamespace = decoder.decodeOptionalInt32ForKey("r.n") as Int32?, let receiptMessageIdId = decoder.decodeOptionalInt32ForKey("r.i") as Int32? {
self.receiptMessageId = MessageId(peerId: PeerId(receiptMessageIdPeerId), namespace: receiptMessageIdNamespace, id: receiptMessageIdId) self.receiptMessageId = MessageId(peerId: PeerId(receiptMessageIdPeerId), namespace: receiptMessageIdNamespace, id: receiptMessageIdId)

View File

@ -56,6 +56,9 @@ func _internal_requestSimpleWebView(postbox: Postbox, network: Network, botId: P
if (flags & (1 << 1)) != 0 { if (flags & (1 << 1)) != 0 {
resultFlags.insert(.fullSize) resultFlags.insert(.fullSize)
} }
if (flags & (1 << 2)) != 0 {
resultFlags.insert(.fullScreen)
}
return .single(RequestWebViewResult(flags: resultFlags, queryId: queryId, url: url, keepAliveSignal: nil)) return .single(RequestWebViewResult(flags: resultFlags, queryId: queryId, url: url, keepAliveSignal: nil))
} }
} }
@ -103,6 +106,9 @@ func _internal_requestMainWebView(postbox: Postbox, network: Network, botId: Pee
if (flags & (1 << 1)) != 0 { if (flags & (1 << 1)) != 0 {
resultFlags.insert(.fullSize) resultFlags.insert(.fullSize)
} }
if (flags & (1 << 2)) != 0 {
resultFlags.insert(.fullScreen)
}
return .single(RequestWebViewResult(flags: resultFlags, queryId: queryId, url: url, keepAliveSignal: nil)) return .single(RequestWebViewResult(flags: resultFlags, queryId: queryId, url: url, keepAliveSignal: nil))
} }
} }
@ -128,6 +134,7 @@ public struct RequestWebViewResult {
} }
public static let fullSize = Flags(rawValue: 1 << 0) public static let fullSize = Flags(rawValue: 1 << 0)
public static let fullScreen = Flags(rawValue: 1 << 1)
} }
public let flags: Flags public let flags: Flags
@ -237,6 +244,9 @@ func _internal_requestWebView(postbox: Postbox, network: Network, stateManager:
if (webViewFlags & (1 << 1)) != 0 { if (webViewFlags & (1 << 1)) != 0 {
resultFlags.insert(.fullSize) resultFlags.insert(.fullSize)
} }
if (flags & (1 << 2)) != 0 {
resultFlags.insert(.fullScreen)
}
let keepAlive: Signal<Never, KeepWebViewError>? let keepAlive: Signal<Never, KeepWebViewError>?
if let queryId { if let queryId {
keepAlive = keepWebViewSignal(network: network, stateManager: stateManager, flags: flags, peer: inputPeer, bot: inputBot, queryId: queryId, replyToMessageId: replyToMessageId, threadId: threadId, sendAs: nil) keepAlive = keepWebViewSignal(network: network, stateManager: stateManager, flags: flags, peer: inputPeer, bot: inputBot, queryId: queryId, replyToMessageId: replyToMessageId, threadId: threadId, sendAs: nil)
@ -323,6 +333,9 @@ func _internal_requestAppWebView(postbox: Postbox, network: Network, stateManage
if (flags & (1 << 1)) != 0 { if (flags & (1 << 1)) != 0 {
resultFlags.insert(.fullSize) resultFlags.insert(.fullSize)
} }
if (flags & (1 << 2)) != 0 {
resultFlags.insert(.fullScreen)
}
return .single(RequestWebViewResult(flags: resultFlags, queryId: queryId, url: url, keepAliveSignal: nil)) return .single(RequestWebViewResult(flags: resultFlags, queryId: queryId, url: url, keepAliveSignal: nil))
} }
} }

View File

@ -63,14 +63,16 @@ public struct BotPaymentInvoice : Equatable {
public let prices: [BotPaymentPrice] public let prices: [BotPaymentPrice]
public let tip: Tip? public let tip: Tip?
public let termsInfo: RecurrentInfo? public let termsInfo: RecurrentInfo?
public let subscriptionPeriod: Int32?
public init(isTest: Bool, requestedFields: BotPaymentInvoiceFields, currency: String, prices: [BotPaymentPrice], tip: Tip?, termsInfo: RecurrentInfo?) { public init(isTest: Bool, requestedFields: BotPaymentInvoiceFields, currency: String, prices: [BotPaymentPrice], tip: Tip?, termsInfo: RecurrentInfo?, subscriptionPeriod: Int32?) {
self.isTest = isTest self.isTest = isTest
self.requestedFields = requestedFields self.requestedFields = requestedFields
self.currency = currency self.currency = currency
self.prices = prices self.prices = prices
self.tip = tip self.tip = tip
self.termsInfo = termsInfo self.termsInfo = termsInfo
self.subscriptionPeriod = subscriptionPeriod
} }
} }
@ -175,7 +177,7 @@ public enum BotPaymentFormRequestError {
extension BotPaymentInvoice { extension BotPaymentInvoice {
init(apiInvoice: Api.Invoice) { init(apiInvoice: Api.Invoice) {
switch apiInvoice { switch apiInvoice {
case let .invoice(flags, currency, prices, maxTipAmount, suggestedTipAmounts, termsUrl): case let .invoice(flags, currency, prices, maxTipAmount, suggestedTipAmounts, termsUrl, subscriptionPeriod):
var fields = BotPaymentInvoiceFields() var fields = BotPaymentInvoiceFields()
if (flags & (1 << 1)) != 0 { if (flags & (1 << 1)) != 0 {
fields.insert(.name) fields.insert(.name)
@ -212,7 +214,7 @@ extension BotPaymentInvoice {
case let .labeledPrice(label, amount): case let .labeledPrice(label, amount):
return BotPaymentPrice(label: label, amount: amount) return BotPaymentPrice(label: label, amount: amount)
} }
}, tip: parsedTip, termsInfo: termsInfo) }, tip: parsedTip, termsInfo: termsInfo, subscriptionPeriod: subscriptionPeriod)
} }
} }
} }

View File

@ -554,7 +554,7 @@ private extension StarsContext.State.Transaction {
private extension StarsContext.State.Subscription { private extension StarsContext.State.Subscription {
init?(apiSubscription: Api.StarsSubscription, transaction: Transaction) { init?(apiSubscription: Api.StarsSubscription, transaction: Transaction) {
switch apiSubscription { switch apiSubscription {
case let .starsSubscription(apiFlags, id, apiPeer, untilDate, pricing, inviteHash): case let .starsSubscription(apiFlags, id, apiPeer, untilDate, pricing, inviteHash, title, photo, invoiceSlug):
guard let peer = transaction.getPeer(apiPeer.peerId) else { guard let peer = transaction.getPeer(apiPeer.peerId) else {
return nil return nil
} }
@ -568,7 +568,7 @@ private extension StarsContext.State.Subscription {
if (apiFlags & (1 << 2)) != 0 { if (apiFlags & (1 << 2)) != 0 {
flags.insert(.missingBalance) flags.insert(.missingBalance)
} }
self.init(flags: flags, id: id, peer: EnginePeer(peer), untilDate: untilDate, pricing: StarsSubscriptionPricing(apiStarsSubscriptionPricing: pricing), inviteHash: inviteHash) self.init(flags: flags, id: id, peer: EnginePeer(peer), untilDate: untilDate, pricing: StarsSubscriptionPricing(apiStarsSubscriptionPricing: pricing), inviteHash: inviteHash, title: title, photo: photo.flatMap(TelegramMediaWebFile.init), invoiceSlug: invoiceSlug)
} }
} }
} }
@ -727,6 +727,9 @@ public final class StarsContext {
public let untilDate: Int32 public let untilDate: Int32
public let pricing: StarsSubscriptionPricing public let pricing: StarsSubscriptionPricing
public let inviteHash: String? public let inviteHash: String?
public let title: String?
public let photo: TelegramMediaWebFile?
public let invoiceSlug: String?
public init( public init(
flags: Flags, flags: Flags,
@ -734,7 +737,10 @@ public final class StarsContext {
peer: EnginePeer, peer: EnginePeer,
untilDate: Int32, untilDate: Int32,
pricing: StarsSubscriptionPricing, pricing: StarsSubscriptionPricing,
inviteHash: String? inviteHash: String?,
title: String?,
photo: TelegramMediaWebFile?,
invoiceSlug: String?
) { ) {
self.flags = flags self.flags = flags
self.id = id self.id = id
@ -742,6 +748,9 @@ public final class StarsContext {
self.untilDate = untilDate self.untilDate = untilDate
self.pricing = pricing self.pricing = pricing
self.inviteHash = inviteHash self.inviteHash = inviteHash
self.title = title
self.photo = photo
self.invoiceSlug = invoiceSlug
} }
public static func == (lhs: Subscription, rhs: Subscription) -> Bool { public static func == (lhs: Subscription, rhs: Subscription) -> Bool {
@ -763,6 +772,15 @@ public final class StarsContext {
if lhs.inviteHash != rhs.inviteHash { if lhs.inviteHash != rhs.inviteHash {
return false return false
} }
if lhs.title != rhs.title {
return false
}
if lhs.photo != rhs.photo {
return false
}
if lhs.invoiceSlug != rhs.invoiceSlug {
return false
}
return true return true
} }
} }
@ -1192,7 +1210,7 @@ private final class StarsSubscriptionsContextImpl {
} else { } else {
updatedFlags.remove(.isCancelled) updatedFlags.remove(.isCancelled)
} }
let updatedSubscription = StarsContext.State.Subscription(flags: updatedFlags, id: subscription.id, peer: subscription.peer, untilDate: subscription.untilDate, pricing: subscription.pricing, inviteHash: subscription.inviteHash) let updatedSubscription = StarsContext.State.Subscription(flags: updatedFlags, id: subscription.id, peer: subscription.peer, untilDate: subscription.untilDate, pricing: subscription.pricing, inviteHash: subscription.inviteHash, title: subscription.title, photo: subscription.photo, invoiceSlug: subscription.invoiceSlug)
updatedState.subscriptions[index] = updatedSubscription updatedState.subscriptions[index] = updatedSubscription
} }
self.updateState(updatedState) self.updateState(updatedState)