mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-06-16 05:55:20 +00:00
Merge branch 'master' of gitlab.com:peter-iakovlev/telegram-ios
This commit is contained in:
commit
3afcd89a39
@ -30,7 +30,7 @@ public func requestUpdatesXml(account: Account, source: String) -> Signal<Data,
|
|||||||
|> mapToSignal { result in
|
|> mapToSignal { result in
|
||||||
switch result {
|
switch result {
|
||||||
case let .channelMessages(_, _, _, _, apiMessages, _, apiChats, apiUsers):
|
case let .channelMessages(_, _, _, _, apiMessages, _, apiChats, apiUsers):
|
||||||
if let apiMessage = apiMessages.first, let storeMessage = StoreMessage(apiMessage: apiMessage, peerIsForum: peer.isForum) {
|
if let apiMessage = apiMessages.first, let storeMessage = StoreMessage(apiMessage: apiMessage, accountPeerId: account.peerId, peerIsForum: peer.isForum) {
|
||||||
|
|
||||||
var peers: [PeerId: Peer] = [:]
|
var peers: [PeerId: Peer] = [:]
|
||||||
for chat in apiChats {
|
for chat in apiChats {
|
||||||
@ -113,7 +113,7 @@ public func downloadAppUpdate(account: Account, source: String, messageId: Int32
|
|||||||
}
|
}
|
||||||
|
|
||||||
let messageAndFile:(Message, TelegramMediaFile)? = apiMessages.compactMap { value in
|
let messageAndFile:(Message, TelegramMediaFile)? = apiMessages.compactMap { value in
|
||||||
return StoreMessage(apiMessage: value, peerIsForum: peer.isForum)
|
return StoreMessage(apiMessage: value, accountPeerId: account.peerId, peerIsForum: peer.isForum)
|
||||||
}.compactMap { value in
|
}.compactMap { value in
|
||||||
return locallyRenderedMessage(message: value, peers: peers)
|
return locallyRenderedMessage(message: value, peers: peers)
|
||||||
}.sorted(by: {
|
}.sorted(by: {
|
||||||
|
@ -8,6 +8,7 @@ public enum BotPaymentInvoiceSource {
|
|||||||
case message(MessageId)
|
case message(MessageId)
|
||||||
case slug(String)
|
case slug(String)
|
||||||
case premiumGiveaway(boostPeer: EnginePeer.Id, additionalPeerIds: [EnginePeer.Id], countries: [String], onlyNewSubscribers: Bool, showWinners: Bool, prizeDescription: String?, randomId: Int64, untilDate: Int32, currency: String, amount: Int64, option: PremiumGiftCodeOption)
|
case premiumGiveaway(boostPeer: EnginePeer.Id, additionalPeerIds: [EnginePeer.Id], countries: [String], onlyNewSubscribers: Bool, showWinners: Bool, prizeDescription: String?, randomId: Int64, untilDate: Int32, currency: String, amount: Int64, option: PremiumGiftCodeOption)
|
||||||
|
case giftCode(users: [PeerId], currency: String, amount: Int64, option: PremiumGiftCodeOption)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -255,6 +256,33 @@ private func _internal_parseInputInvoice(transaction: Transaction, source: BotPa
|
|||||||
let option: Api.PremiumGiftCodeOption = .premiumGiftCodeOption(flags: flags, users: option.users, months: option.months, storeProduct: option.storeProductId, storeQuantity: option.storeQuantity, currency: option.currency, amount: option.amount)
|
let option: Api.PremiumGiftCodeOption = .premiumGiftCodeOption(flags: flags, users: option.users, months: option.months, storeProduct: option.storeProductId, storeQuantity: option.storeQuantity, currency: option.currency, amount: option.amount)
|
||||||
|
|
||||||
return .inputInvoicePremiumGiftCode(purpose: inputPurpose, option: option)
|
return .inputInvoicePremiumGiftCode(purpose: inputPurpose, option: option)
|
||||||
|
case let .giftCode(users, currency, amount, option):
|
||||||
|
|
||||||
|
|
||||||
|
var inputUsers: [Api.InputUser] = []
|
||||||
|
if !users.isEmpty {
|
||||||
|
for peerId in users {
|
||||||
|
if let peer = transaction.getPeer(peerId), let inputPeer = apiInputUser(peer) {
|
||||||
|
inputUsers.append(inputPeer)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
let inputPurpose: Api.InputStorePaymentPurpose = .inputStorePaymentPremiumGiftCode(flags: 0, users: inputUsers, boostPeer: nil, currency: currency, amount: amount)
|
||||||
|
|
||||||
|
|
||||||
|
var flags: Int32 = 0
|
||||||
|
if let _ = option.storeProductId {
|
||||||
|
flags |= (1 << 0)
|
||||||
|
}
|
||||||
|
if option.storeQuantity > 0 {
|
||||||
|
flags |= (1 << 1)
|
||||||
|
}
|
||||||
|
|
||||||
|
let option: Api.PremiumGiftCodeOption = .premiumGiftCodeOption(flags: flags, users: option.users, months: option.months, storeProduct: option.storeProductId, storeQuantity: option.storeQuantity, currency: option.currency, amount: option.amount)
|
||||||
|
|
||||||
|
return .inputInvoicePremiumGiftCode(purpose: inputPurpose, option: option)
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -539,6 +567,8 @@ func _internal_sendBotPaymentForm(account: Account, formId: Int64, source: BotPa
|
|||||||
receiptMessageId = id
|
receiptMessageId = id
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
case .giftCode:
|
||||||
|
receiptMessageId = nil
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user