mirror of
https://github.com/TelegramMessenger/Telegram-iOS.git
synced 2026-07-06 03:33:41 +02:00
Update API
This commit is contained in:
parent
7a0c3503a9
commit
1d139d11bf
7 changed files with 62 additions and 35 deletions
|
|
@ -398,6 +398,7 @@ fileprivate let parsers: [Int32 : (BufferReader) -> Any?] = {
|
|||
dict[-1020867857] = { return Api.InputInvoice.parse_inputInvoiceSlug($0) }
|
||||
dict[-396206446] = { return Api.InputInvoice.parse_inputInvoiceStarGift($0) }
|
||||
dict[2010287526] = { return Api.InputInvoice.parse_inputInvoiceStarGiftAuctionBid($0) }
|
||||
dict[-2061017960] = { return Api.InputInvoice.parse_inputInvoiceStarGiftAuctionUpdateBid($0) }
|
||||
dict[153344209] = { return Api.InputInvoice.parse_inputInvoiceStarGiftDropOriginalDetails($0) }
|
||||
dict[-1710536520] = { return Api.InputInvoice.parse_inputInvoiceStarGiftPrepaidUpgrade($0) }
|
||||
dict[-1012968668] = { return Api.InputInvoice.parse_inputInvoiceStarGiftResale($0) }
|
||||
|
|
@ -589,7 +590,7 @@ fileprivate let parsers: [Int32 : (BufferReader) -> Any?] = {
|
|||
dict[-1230047312] = { return Api.MessageAction.parse_messageActionEmpty($0) }
|
||||
dict[-1834538890] = { return Api.MessageAction.parse_messageActionGameScore($0) }
|
||||
dict[-1730095465] = { return Api.MessageAction.parse_messageActionGeoProximityReached($0) }
|
||||
dict[1456486804] = { return Api.MessageAction.parse_messageActionGiftCode($0) }
|
||||
dict[834962247] = { return Api.MessageAction.parse_messageActionGiftCode($0) }
|
||||
dict[1223234306] = { return Api.MessageAction.parse_messageActionGiftPremium($0) }
|
||||
dict[1171632161] = { return Api.MessageAction.parse_messageActionGiftStars($0) }
|
||||
dict[-1465661799] = { return Api.MessageAction.parse_messageActionGiftTon($0) }
|
||||
|
|
@ -1464,7 +1465,7 @@ fileprivate let parsers: [Int32 : (BufferReader) -> Any?] = {
|
|||
dict[1042605427] = { return Api.payments.BankCardData.parse_bankCardData($0) }
|
||||
dict[-706379148] = { return Api.payments.CheckCanSendGiftResult.parse_checkCanSendGiftResultFail($0) }
|
||||
dict[927967149] = { return Api.payments.CheckCanSendGiftResult.parse_checkCanSendGiftResultOk($0) }
|
||||
dict[675942550] = { return Api.payments.CheckedGiftCode.parse_checkedGiftCode($0) }
|
||||
dict[-342343793] = { return Api.payments.CheckedGiftCode.parse_checkedGiftCode($0) }
|
||||
dict[-1730811363] = { return Api.payments.ConnectedStarRefBots.parse_connectedStarRefBots($0) }
|
||||
dict[-1362048039] = { return Api.payments.ExportedInvoice.parse_exportedInvoice($0) }
|
||||
dict[1130879648] = { return Api.payments.GiveawayInfo.parse_giveawayInfo($0) }
|
||||
|
|
|
|||
|
|
@ -567,6 +567,7 @@ public extension Api {
|
|||
case inputInvoiceSlug(slug: String)
|
||||
case inputInvoiceStarGift(flags: Int32, peer: Api.InputPeer, giftId: Int64, message: Api.TextWithEntities?)
|
||||
case inputInvoiceStarGiftAuctionBid(flags: Int32, peer: Api.InputPeer, giftId: Int64, bidAmount: Int64, message: Api.TextWithEntities?)
|
||||
case inputInvoiceStarGiftAuctionUpdateBid(giftId: Int64, bidAmount: Int64)
|
||||
case inputInvoiceStarGiftDropOriginalDetails(stargift: Api.InputSavedStarGift)
|
||||
case inputInvoiceStarGiftPrepaidUpgrade(peer: Api.InputPeer, hash: String)
|
||||
case inputInvoiceStarGiftResale(flags: Int32, slug: String, toId: Api.InputPeer)
|
||||
|
|
@ -643,6 +644,13 @@ public extension Api {
|
|||
serializeInt64(bidAmount, buffer: buffer, boxed: false)
|
||||
if Int(flags) & Int(1 << 1) != 0 {message!.serialize(buffer, true)}
|
||||
break
|
||||
case .inputInvoiceStarGiftAuctionUpdateBid(let giftId, let bidAmount):
|
||||
if boxed {
|
||||
buffer.appendInt32(-2061017960)
|
||||
}
|
||||
serializeInt64(giftId, buffer: buffer, boxed: false)
|
||||
serializeInt64(bidAmount, buffer: buffer, boxed: false)
|
||||
break
|
||||
case .inputInvoiceStarGiftDropOriginalDetails(let stargift):
|
||||
if boxed {
|
||||
buffer.appendInt32(153344209)
|
||||
|
|
@ -707,6 +715,8 @@ public extension Api {
|
|||
return ("inputInvoiceStarGift", [("flags", flags as Any), ("peer", peer as Any), ("giftId", giftId as Any), ("message", message as Any)])
|
||||
case .inputInvoiceStarGiftAuctionBid(let flags, let peer, let giftId, let bidAmount, let message):
|
||||
return ("inputInvoiceStarGiftAuctionBid", [("flags", flags as Any), ("peer", peer as Any), ("giftId", giftId as Any), ("bidAmount", bidAmount as Any), ("message", message as Any)])
|
||||
case .inputInvoiceStarGiftAuctionUpdateBid(let giftId, let bidAmount):
|
||||
return ("inputInvoiceStarGiftAuctionUpdateBid", [("giftId", giftId as Any), ("bidAmount", bidAmount as Any)])
|
||||
case .inputInvoiceStarGiftDropOriginalDetails(let stargift):
|
||||
return ("inputInvoiceStarGiftDropOriginalDetails", [("stargift", stargift as Any)])
|
||||
case .inputInvoiceStarGiftPrepaidUpgrade(let peer, let hash):
|
||||
|
|
@ -882,6 +892,20 @@ public extension Api {
|
|||
return nil
|
||||
}
|
||||
}
|
||||
public static func parse_inputInvoiceStarGiftAuctionUpdateBid(_ reader: BufferReader) -> InputInvoice? {
|
||||
var _1: Int64?
|
||||
_1 = reader.readInt64()
|
||||
var _2: Int64?
|
||||
_2 = reader.readInt64()
|
||||
let _c1 = _1 != nil
|
||||
let _c2 = _2 != nil
|
||||
if _c1 && _c2 {
|
||||
return Api.InputInvoice.inputInvoiceStarGiftAuctionUpdateBid(giftId: _1!, bidAmount: _2!)
|
||||
}
|
||||
else {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
public static func parse_inputInvoiceStarGiftDropOriginalDetails(_ reader: BufferReader) -> InputInvoice? {
|
||||
var _1: Api.InputSavedStarGift?
|
||||
if let signature = reader.readInt32() {
|
||||
|
|
|
|||
|
|
@ -1043,7 +1043,7 @@ public extension Api {
|
|||
case messageActionEmpty
|
||||
case messageActionGameScore(gameId: Int64, score: Int32)
|
||||
case messageActionGeoProximityReached(fromId: Api.Peer, toId: Api.Peer, distance: Int32)
|
||||
case messageActionGiftCode(flags: Int32, boostPeer: Api.Peer?, months: Int32, slug: String, currency: String?, amount: Int64?, cryptoCurrency: String?, cryptoAmount: Int64?, message: Api.TextWithEntities?)
|
||||
case messageActionGiftCode(flags: Int32, boostPeer: Api.Peer?, days: Int32, slug: String, currency: String?, amount: Int64?, cryptoCurrency: String?, cryptoAmount: Int64?, message: Api.TextWithEntities?)
|
||||
case messageActionGiftPremium(flags: Int32, currency: String, amount: Int64, days: Int32, cryptoCurrency: String?, cryptoAmount: Int64?, message: Api.TextWithEntities?)
|
||||
case messageActionGiftStars(flags: Int32, currency: String, amount: Int64, stars: Int64, cryptoCurrency: String?, cryptoAmount: Int64?, transactionId: String?)
|
||||
case messageActionGiftTon(flags: Int32, currency: String, amount: Int64, cryptoCurrency: String, cryptoAmount: Int64, transactionId: String?)
|
||||
|
|
@ -1221,13 +1221,13 @@ public extension Api {
|
|||
toId.serialize(buffer, true)
|
||||
serializeInt32(distance, buffer: buffer, boxed: false)
|
||||
break
|
||||
case .messageActionGiftCode(let flags, let boostPeer, let months, let slug, let currency, let amount, let cryptoCurrency, let cryptoAmount, let message):
|
||||
case .messageActionGiftCode(let flags, let boostPeer, let days, let slug, let currency, let amount, let cryptoCurrency, let cryptoAmount, let message):
|
||||
if boxed {
|
||||
buffer.appendInt32(1456486804)
|
||||
buffer.appendInt32(834962247)
|
||||
}
|
||||
serializeInt32(flags, buffer: buffer, boxed: false)
|
||||
if Int(flags) & Int(1 << 1) != 0 {boostPeer!.serialize(buffer, true)}
|
||||
serializeInt32(months, buffer: buffer, boxed: false)
|
||||
serializeInt32(days, buffer: buffer, boxed: false)
|
||||
serializeString(slug, buffer: buffer, boxed: false)
|
||||
if Int(flags) & Int(1 << 2) != 0 {serializeString(currency!, buffer: buffer, boxed: false)}
|
||||
if Int(flags) & Int(1 << 2) != 0 {serializeInt64(amount!, buffer: buffer, boxed: false)}
|
||||
|
|
@ -1625,8 +1625,8 @@ public extension Api {
|
|||
return ("messageActionGameScore", [("gameId", gameId as Any), ("score", score as Any)])
|
||||
case .messageActionGeoProximityReached(let fromId, let toId, let distance):
|
||||
return ("messageActionGeoProximityReached", [("fromId", fromId as Any), ("toId", toId as Any), ("distance", distance as Any)])
|
||||
case .messageActionGiftCode(let flags, let boostPeer, let months, let slug, let currency, let amount, let cryptoCurrency, let cryptoAmount, let message):
|
||||
return ("messageActionGiftCode", [("flags", flags as Any), ("boostPeer", boostPeer as Any), ("months", months as Any), ("slug", slug as Any), ("currency", currency as Any), ("amount", amount as Any), ("cryptoCurrency", cryptoCurrency as Any), ("cryptoAmount", cryptoAmount as Any), ("message", message as Any)])
|
||||
case .messageActionGiftCode(let flags, let boostPeer, let days, let slug, let currency, let amount, let cryptoCurrency, let cryptoAmount, let message):
|
||||
return ("messageActionGiftCode", [("flags", flags as Any), ("boostPeer", boostPeer as Any), ("days", days as Any), ("slug", slug as Any), ("currency", currency as Any), ("amount", amount as Any), ("cryptoCurrency", cryptoCurrency as Any), ("cryptoAmount", cryptoAmount as Any), ("message", message as Any)])
|
||||
case .messageActionGiftPremium(let flags, let currency, let amount, let days, let cryptoCurrency, let cryptoAmount, let message):
|
||||
return ("messageActionGiftPremium", [("flags", flags as Any), ("currency", currency as Any), ("amount", amount as Any), ("days", days as Any), ("cryptoCurrency", cryptoCurrency as Any), ("cryptoAmount", cryptoAmount as Any), ("message", message as Any)])
|
||||
case .messageActionGiftStars(let flags, let currency, let amount, let stars, let cryptoCurrency, let cryptoAmount, let transactionId):
|
||||
|
|
@ -1960,7 +1960,7 @@ public extension Api {
|
|||
let _c8 = (Int(_1!) & Int(1 << 3) == 0) || _8 != nil
|
||||
let _c9 = (Int(_1!) & Int(1 << 4) == 0) || _9 != nil
|
||||
if _c1 && _c2 && _c3 && _c4 && _c5 && _c6 && _c7 && _c8 && _c9 {
|
||||
return Api.MessageAction.messageActionGiftCode(flags: _1!, boostPeer: _2, months: _3!, slug: _4!, currency: _5, amount: _6, cryptoCurrency: _7, cryptoAmount: _8, message: _9)
|
||||
return Api.MessageAction.messageActionGiftCode(flags: _1!, boostPeer: _2, days: _3!, slug: _4!, currency: _5, amount: _6, cryptoCurrency: _7, cryptoAmount: _8, message: _9)
|
||||
}
|
||||
else {
|
||||
return nil
|
||||
|
|
|
|||
|
|
@ -966,20 +966,20 @@ public extension Api.payments {
|
|||
}
|
||||
public extension Api.payments {
|
||||
enum CheckedGiftCode: TypeConstructorDescription {
|
||||
case checkedGiftCode(flags: Int32, fromId: Api.Peer?, giveawayMsgId: Int32?, toId: Int64?, date: Int32, months: Int32, usedDate: Int32?, chats: [Api.Chat], users: [Api.User])
|
||||
case checkedGiftCode(flags: Int32, fromId: Api.Peer?, giveawayMsgId: Int32?, toId: Int64?, date: Int32, days: Int32, usedDate: Int32?, chats: [Api.Chat], users: [Api.User])
|
||||
|
||||
public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) {
|
||||
switch self {
|
||||
case .checkedGiftCode(let flags, let fromId, let giveawayMsgId, let toId, let date, let months, let usedDate, let chats, let users):
|
||||
case .checkedGiftCode(let flags, let fromId, let giveawayMsgId, let toId, let date, let days, let usedDate, let chats, let users):
|
||||
if boxed {
|
||||
buffer.appendInt32(675942550)
|
||||
buffer.appendInt32(-342343793)
|
||||
}
|
||||
serializeInt32(flags, buffer: buffer, boxed: false)
|
||||
if Int(flags) & Int(1 << 4) != 0 {fromId!.serialize(buffer, true)}
|
||||
if Int(flags) & Int(1 << 3) != 0 {serializeInt32(giveawayMsgId!, buffer: buffer, boxed: false)}
|
||||
if Int(flags) & Int(1 << 0) != 0 {serializeInt64(toId!, buffer: buffer, boxed: false)}
|
||||
serializeInt32(date, buffer: buffer, boxed: false)
|
||||
serializeInt32(months, buffer: buffer, boxed: false)
|
||||
serializeInt32(days, buffer: buffer, boxed: false)
|
||||
if Int(flags) & Int(1 << 1) != 0 {serializeInt32(usedDate!, buffer: buffer, boxed: false)}
|
||||
buffer.appendInt32(481674261)
|
||||
buffer.appendInt32(Int32(chats.count))
|
||||
|
|
@ -997,8 +997,8 @@ public extension Api.payments {
|
|||
|
||||
public func descriptionFields() -> (String, [(String, Any)]) {
|
||||
switch self {
|
||||
case .checkedGiftCode(let flags, let fromId, let giveawayMsgId, let toId, let date, let months, let usedDate, let chats, let users):
|
||||
return ("checkedGiftCode", [("flags", flags as Any), ("fromId", fromId as Any), ("giveawayMsgId", giveawayMsgId as Any), ("toId", toId as Any), ("date", date as Any), ("months", months as Any), ("usedDate", usedDate as Any), ("chats", chats as Any), ("users", users as Any)])
|
||||
case .checkedGiftCode(let flags, let fromId, let giveawayMsgId, let toId, let date, let days, let usedDate, let chats, let users):
|
||||
return ("checkedGiftCode", [("flags", flags as Any), ("fromId", fromId as Any), ("giveawayMsgId", giveawayMsgId as Any), ("toId", toId as Any), ("date", date as Any), ("days", days as Any), ("usedDate", usedDate as Any), ("chats", chats as Any), ("users", users as Any)])
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1037,7 +1037,7 @@ public extension Api.payments {
|
|||
let _c8 = _8 != nil
|
||||
let _c9 = _9 != nil
|
||||
if _c1 && _c2 && _c3 && _c4 && _c5 && _c6 && _c7 && _c8 && _c9 {
|
||||
return Api.payments.CheckedGiftCode.checkedGiftCode(flags: _1!, fromId: _2, giveawayMsgId: _3, toId: _4, date: _5!, months: _6!, usedDate: _7, chats: _8!, users: _9!)
|
||||
return Api.payments.CheckedGiftCode.checkedGiftCode(flags: _1!, fromId: _2, giveawayMsgId: _3, toId: _4, date: _5!, days: _6!, usedDate: _7, chats: _8!, users: _9!)
|
||||
}
|
||||
else {
|
||||
return nil
|
||||
|
|
|
|||
|
|
@ -20,7 +20,8 @@ public enum BotPaymentInvoiceSource {
|
|||
case starGiftResale(slug: String, toPeerId: EnginePeer.Id, ton: Bool)
|
||||
case starGiftPrepaidUpgrade(peerId: EnginePeer.Id, hash: String)
|
||||
case starGiftDropOriginalDetails(reference: StarGiftReference)
|
||||
case starGiftAuctionBid(hideName: Bool, updateBid: Bool, peerId: EnginePeer.Id, giftId: Int64, bidAmount: Int64, text: String?, entities: [MessageTextEntity]?)
|
||||
case starGiftAuctionBid(hideName: Bool, peerId: EnginePeer.Id, giftId: Int64, bidAmount: Int64, text: String?, entities: [MessageTextEntity]?)
|
||||
case starGiftAuctionUpdateBid(giftId: Int64, bidAmount: Int64)
|
||||
}
|
||||
|
||||
public struct BotPaymentInvoiceFields: OptionSet {
|
||||
|
|
@ -425,7 +426,7 @@ func _internal_parseInputInvoice(transaction: Transaction, source: BotPaymentInv
|
|||
case let .starGiftDropOriginalDetails(reference):
|
||||
return reference.apiStarGiftReference(transaction: transaction).flatMap { .inputInvoiceStarGiftDropOriginalDetails(stargift: $0) }
|
||||
|
||||
case let .starGiftAuctionBid(hideName, updateBid, peerId, giftId, bidAmount, text, entities):
|
||||
case let .starGiftAuctionBid(hideName, peerId, giftId, bidAmount, text, entities):
|
||||
guard let peer = transaction.getPeer(peerId), let inputPeer = apiInputPeer(peer) else {
|
||||
return nil
|
||||
}
|
||||
|
|
@ -433,15 +434,14 @@ func _internal_parseInputInvoice(transaction: Transaction, source: BotPaymentInv
|
|||
if hideName {
|
||||
flags |= (1 << 0)
|
||||
}
|
||||
if updateBid {
|
||||
flags |= (1 << 2)
|
||||
}
|
||||
var message: Api.TextWithEntities?
|
||||
if let text, !text.isEmpty {
|
||||
flags |= (1 << 1)
|
||||
message = .textWithEntities(text: text, entities: entities.flatMap { apiEntitiesFromMessageTextEntities($0, associatedPeers: SimpleDictionary()) } ?? [])
|
||||
}
|
||||
return .inputInvoiceStarGiftAuctionBid(flags: flags, peer: inputPeer, giftId: giftId, bidAmount: bidAmount, message: message)
|
||||
case let .starGiftAuctionUpdateBid(giftId, bidAmount):
|
||||
return .inputInvoiceStarGiftAuctionUpdateBid(giftId: giftId, bidAmount: bidAmount)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -784,7 +784,7 @@ func _internal_sendBotPaymentForm(account: Account, formId: Int64, source: BotPa
|
|||
receiptMessageId = id
|
||||
}
|
||||
}
|
||||
case .giftCode, .stars, .starsGift, .starsChatSubscription, .starGift, .starGiftUpgrade, .starGiftTransfer, .premiumGift, .starGiftResale, .starGiftPrepaidUpgrade, .starGiftDropOriginalDetails, .starGiftAuctionBid:
|
||||
case .giftCode, .stars, .starsGift, .starsChatSubscription, .starGift, .starGiftUpgrade, .starGiftTransfer, .premiumGift, .starGiftResale, .starGiftPrepaidUpgrade, .starGiftDropOriginalDetails, .starGiftAuctionBid, .starGiftAuctionUpdateBid:
|
||||
receiptMessageId = nil
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1630,7 +1630,7 @@ func _internal_sendStarsPaymentForm(account: Account, formId: Int64, source: Bot
|
|||
receiptMessageId = id
|
||||
}
|
||||
}
|
||||
case .giftCode, .stars, .starsGift, .starsChatSubscription, .starGift, .starGiftUpgrade, .starGiftTransfer, .premiumGift, .starGiftResale, .starGiftPrepaidUpgrade, .starGiftDropOriginalDetails, .starGiftAuctionBid:
|
||||
case .giftCode, .stars, .starsGift, .starsChatSubscription, .starGift, .starGiftUpgrade, .starGiftTransfer, .premiumGift, .starGiftResale, .starGiftPrepaidUpgrade, .starGiftDropOriginalDetails, .starGiftAuctionBid, .starGiftAuctionUpdateBid:
|
||||
receiptMessageId = nil
|
||||
}
|
||||
} else if case let .starGiftUnique(gift, _, _, savedToProfile, canExportDate, transferStars, _, _, peerId, _, savedId, _, canTransferDate, canResaleDate, dropOriginalDetailsStars, _) = action.action, case let .Id(messageId) = message.id {
|
||||
|
|
|
|||
|
|
@ -1325,21 +1325,23 @@ private final class GiftAuctionScreenComponent: Component {
|
|||
self.isLoading = true
|
||||
self.state?.updated()
|
||||
|
||||
var updateBid = false
|
||||
let source: BotPaymentInvoiceSource
|
||||
if let state = self.giftAuctionState, state.myState.bidAmount != nil {
|
||||
updateBid = true
|
||||
source = .starGiftAuctionUpdateBid(
|
||||
giftId: gift.id,
|
||||
bidAmount: value
|
||||
)
|
||||
} else {
|
||||
source = .starGiftAuctionBid(
|
||||
hideName: false,
|
||||
peerId: component.context.account.peerId,
|
||||
giftId: gift.id,
|
||||
bidAmount: value,
|
||||
text: nil,
|
||||
entities: nil
|
||||
)
|
||||
}
|
||||
|
||||
let source: BotPaymentInvoiceSource = .starGiftAuctionBid(
|
||||
hideName: false,
|
||||
updateBid: updateBid,
|
||||
peerId: component.context.account.peerId,
|
||||
giftId: gift.id,
|
||||
bidAmount: value,
|
||||
text: nil,
|
||||
entities: nil
|
||||
)
|
||||
|
||||
let signal = BotCheckoutController.InputData.fetch(context: component.context, source: source)
|
||||
|> `catch` { error -> Signal<BotCheckoutController.InputData, SendBotPaymentFormError> in
|
||||
switch error {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue