mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-08-08 08:31:13 +00:00
- direct-bot giveaway payment
This commit is contained in:
parent
d203ef3764
commit
559e02a7e2
@ -12,6 +12,7 @@ public enum BotPaymentInvoiceSource {
|
|||||||
case stars(option: StarsTopUpOption)
|
case stars(option: StarsTopUpOption)
|
||||||
case starsGift(peerId: EnginePeer.Id, count: Int64, currency: String, amount: Int64)
|
case starsGift(peerId: EnginePeer.Id, count: Int64, currency: String, amount: Int64)
|
||||||
case starsChatSubscription(hash: String)
|
case starsChatSubscription(hash: String)
|
||||||
|
case starsGiveaway(stars: Int64, boostPeer: EnginePeer.Id, additionalPeerIds: [EnginePeer.Id], countries: [String], onlyNewSubscribers: Bool, showWinners: Bool, prizeDescription: String?, randomId: Int64, untilDate: Int32, currency: String, amount: Int64, users: Int32)
|
||||||
}
|
}
|
||||||
|
|
||||||
public struct BotPaymentInvoiceFields: OptionSet {
|
public struct BotPaymentInvoiceFields: OptionSet {
|
||||||
@ -317,6 +318,33 @@ func _internal_parseInputInvoice(transaction: Transaction, source: BotPaymentInv
|
|||||||
return .inputInvoiceStars(purpose: .inputStorePaymentStarsGift(userId: inputUser, stars: count, currency: currency, amount: amount))
|
return .inputInvoiceStars(purpose: .inputStorePaymentStarsGift(userId: inputUser, stars: count, currency: currency, amount: amount))
|
||||||
case let .starsChatSubscription(hash):
|
case let .starsChatSubscription(hash):
|
||||||
return .inputInvoiceChatInviteSubscription(hash: hash)
|
return .inputInvoiceChatInviteSubscription(hash: hash)
|
||||||
|
case let .starsGiveaway(stars, boostPeerId, additionalPeerIds, countries, onlyNewSubscribers, showWinners, prizeDescription, randomId, untilDate, currency, amount, users):
|
||||||
|
guard let peer = transaction.getPeer(boostPeerId), let apiBoostPeer = apiInputPeer(peer) else {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
var flags: Int32 = 0
|
||||||
|
if onlyNewSubscribers {
|
||||||
|
flags |= (1 << 0)
|
||||||
|
}
|
||||||
|
if showWinners {
|
||||||
|
flags |= (1 << 3)
|
||||||
|
}
|
||||||
|
var additionalPeers: [Api.InputPeer] = []
|
||||||
|
if !additionalPeerIds.isEmpty {
|
||||||
|
flags |= (1 << 1)
|
||||||
|
for peerId in additionalPeerIds {
|
||||||
|
if let peer = transaction.getPeer(peerId), let inputPeer = apiInputPeer(peer) {
|
||||||
|
additionalPeers.append(inputPeer)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if !countries.isEmpty {
|
||||||
|
flags |= (1 << 2)
|
||||||
|
}
|
||||||
|
if let _ = prizeDescription {
|
||||||
|
flags |= (1 << 4)
|
||||||
|
}
|
||||||
|
return .inputInvoiceStars(purpose: .inputStorePaymentStarsGiveaway(flags: flags, stars: stars, boostPeer: apiBoostPeer, additionalPeers: additionalPeers, countriesIso2: countries, prizeDescription: prizeDescription, randomId: randomId, untilDate: untilDate, currency: currency, amount: amount, users: users))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -626,6 +654,12 @@ func _internal_sendBotPaymentForm(account: Account, formId: Int64, source: BotPa
|
|||||||
receiptMessageId = id
|
receiptMessageId = id
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
case let .starsGiveaway(_, _, _, _, _, _, _, randomId, _, _, _, _):
|
||||||
|
if message.globallyUniqueId == randomId {
|
||||||
|
if case let .Id(id) = message.id {
|
||||||
|
receiptMessageId = id
|
||||||
|
}
|
||||||
|
}
|
||||||
case .giftCode, .stars, .starsGift, .starsChatSubscription:
|
case .giftCode, .stars, .starsGift, .starsChatSubscription:
|
||||||
receiptMessageId = nil
|
receiptMessageId = nil
|
||||||
}
|
}
|
||||||
|
@ -205,7 +205,7 @@ public struct StarsGiveawayOption: Equatable, Codable {
|
|||||||
self.yearlyBoosts = yearlyBoosts
|
self.yearlyBoosts = yearlyBoosts
|
||||||
self.currency = currency
|
self.currency = currency
|
||||||
self.amount = amount
|
self.amount = amount
|
||||||
self.storeProductId = storeProductId
|
self.storeProductId = storeProductId?.replacingOccurrences(of: "telegram_stars.topup", with: "org.telegram.telegramStars.topup")
|
||||||
self.winners = winners
|
self.winners = winners
|
||||||
self.isExtended = isExtended
|
self.isExtended = isExtended
|
||||||
self.isDefault = isDefault
|
self.isDefault = isDefault
|
||||||
@ -1278,6 +1278,12 @@ func _internal_sendStarsPaymentForm(account: Account, formId: Int64, source: Bot
|
|||||||
receiptMessageId = id
|
receiptMessageId = id
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
case let .starsGiveaway(_, _, _, _, _, _, _, randomId, _, _, _, _):
|
||||||
|
if message.globallyUniqueId == randomId {
|
||||||
|
if case let .Id(id) = message.id {
|
||||||
|
receiptMessageId = id
|
||||||
|
}
|
||||||
|
}
|
||||||
case .giftCode, .stars, .starsGift:
|
case .giftCode, .stars, .starsGift:
|
||||||
receiptMessageId = nil
|
receiptMessageId = nil
|
||||||
case .starsChatSubscription:
|
case .starsChatSubscription:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user