Update API

This commit is contained in:
Ilya Laktyushin 2023-12-06 00:23:48 +04:00
parent b0a52973cd
commit ee8b068355
15 changed files with 270 additions and 81 deletions

View File

@ -10614,3 +10614,7 @@ Sorry for the inconvenience.";
"MediaEditor.Shortcut.Location" = "Location"; "MediaEditor.Shortcut.Location" = "Location";
"MediaEditor.Shortcut.Reaction" = "Reaction"; "MediaEditor.Shortcut.Reaction" = "Reaction";
"MediaEditor.Shortcut.Audio" = "Audio"; "MediaEditor.Shortcut.Audio" = "Audio";
"BoostGift.WinnersTitle" = "WINNERS";
"BoostGift.Winners" = "Show Winners";
"BoostGift.WinnersInfo" = "Choose whether to make the list of winners public when the giveaway ends.";

View File

@ -575,6 +575,8 @@ private final class PendingInAppPurchaseState: Codable {
case additionalPeerIds case additionalPeerIds
case countries case countries
case onlyNewSubscribers case onlyNewSubscribers
case showWinners
case prizeDescription
case randomId case randomId
case untilDate case untilDate
} }
@ -593,7 +595,7 @@ private final class PendingInAppPurchaseState: Codable {
case restore case restore
case gift(peerId: EnginePeer.Id) case gift(peerId: EnginePeer.Id)
case giftCode(peerIds: [EnginePeer.Id], boostPeer: EnginePeer.Id?) case giftCode(peerIds: [EnginePeer.Id], boostPeer: EnginePeer.Id?)
case giveaway(boostPeer: EnginePeer.Id, additionalPeerIds: [EnginePeer.Id], countries: [String], onlyNewSubscribers: Bool, randomId: Int64, untilDate: Int32) case giveaway(boostPeer: EnginePeer.Id, additionalPeerIds: [EnginePeer.Id], countries: [String], onlyNewSubscribers: Bool, showWinners: Bool, prizeDescription: String?, randomId: Int64, untilDate: Int32)
public init(from decoder: Decoder) throws { public init(from decoder: Decoder) throws {
let container = try decoder.container(keyedBy: CodingKeys.self) let container = try decoder.container(keyedBy: CodingKeys.self)
@ -621,6 +623,8 @@ private final class PendingInAppPurchaseState: Codable {
additionalPeerIds: try container.decode([Int64].self, forKey: .randomId).map { EnginePeer.Id($0) }, additionalPeerIds: try container.decode([Int64].self, forKey: .randomId).map { EnginePeer.Id($0) },
countries: try container.decodeIfPresent([String].self, forKey: .countries) ?? [], countries: try container.decodeIfPresent([String].self, forKey: .countries) ?? [],
onlyNewSubscribers: try container.decode(Bool.self, forKey: .onlyNewSubscribers), onlyNewSubscribers: try container.decode(Bool.self, forKey: .onlyNewSubscribers),
showWinners: try container.decodeIfPresent(Bool.self, forKey: .showWinners) ?? false,
prizeDescription: try container.decodeIfPresent(String.self, forKey: .prizeDescription),
randomId: try container.decode(Int64.self, forKey: .randomId), randomId: try container.decode(Int64.self, forKey: .randomId),
untilDate: try container.decode(Int32.self, forKey: .untilDate) untilDate: try container.decode(Int32.self, forKey: .untilDate)
) )
@ -646,12 +650,14 @@ private final class PendingInAppPurchaseState: Codable {
try container.encode(PurposeType.giftCode.rawValue, forKey: .type) try container.encode(PurposeType.giftCode.rawValue, forKey: .type)
try container.encode(peerIds.map { $0.toInt64() }, forKey: .peers) try container.encode(peerIds.map { $0.toInt64() }, forKey: .peers)
try container.encodeIfPresent(boostPeer?.toInt64(), forKey: .boostPeer) try container.encodeIfPresent(boostPeer?.toInt64(), forKey: .boostPeer)
case let .giveaway(boostPeer, additionalPeerIds, countries, onlyNewSubscribers, randomId, untilDate): case let .giveaway(boostPeer, additionalPeerIds, countries, onlyNewSubscribers, showWinners, prizeDescription, randomId, untilDate):
try container.encode(PurposeType.giveaway.rawValue, forKey: .type) try container.encode(PurposeType.giveaway.rawValue, forKey: .type)
try container.encode(boostPeer.toInt64(), forKey: .boostPeer) try container.encode(boostPeer.toInt64(), forKey: .boostPeer)
try container.encode(additionalPeerIds.map { $0.toInt64() }, forKey: .additionalPeerIds) try container.encode(additionalPeerIds.map { $0.toInt64() }, forKey: .additionalPeerIds)
try container.encode(countries, forKey: .countries) try container.encode(countries, forKey: .countries)
try container.encode(onlyNewSubscribers, forKey: .onlyNewSubscribers) try container.encode(onlyNewSubscribers, forKey: .onlyNewSubscribers)
try container.encode(showWinners, forKey: .showWinners)
try container.encode(prizeDescription, forKey: .prizeDescription)
try container.encode(randomId, forKey: .randomId) try container.encode(randomId, forKey: .randomId)
try container.encode(untilDate, forKey: .untilDate) try container.encode(untilDate, forKey: .untilDate)
} }
@ -669,8 +675,8 @@ private final class PendingInAppPurchaseState: Codable {
self = .gift(peerId: peerId) self = .gift(peerId: peerId)
case let .giftCode(peerIds, boostPeer, _, _): case let .giftCode(peerIds, boostPeer, _, _):
self = .giftCode(peerIds: peerIds, boostPeer: boostPeer) self = .giftCode(peerIds: peerIds, boostPeer: boostPeer)
case let .giveaway(boostPeer, additionalPeerIds, countries, onlyNewSubscribers, randomId, untilDate, _, _): case let .giveaway(boostPeer, additionalPeerIds, countries, onlyNewSubscribers, showWinners, prizeDescription, randomId, untilDate, _, _):
self = .giveaway(boostPeer: boostPeer, additionalPeerIds: additionalPeerIds, countries: countries, onlyNewSubscribers: onlyNewSubscribers, randomId: randomId, untilDate: untilDate) self = .giveaway(boostPeer: boostPeer, additionalPeerIds: additionalPeerIds, countries: countries, onlyNewSubscribers: onlyNewSubscribers, showWinners: showWinners, prizeDescription: prizeDescription, randomId: randomId, untilDate: untilDate)
} }
} }
@ -687,8 +693,8 @@ private final class PendingInAppPurchaseState: Codable {
return .gift(peerId: peerId, currency: currency, amount: amount) return .gift(peerId: peerId, currency: currency, amount: amount)
case let .giftCode(peerIds, boostPeer): case let .giftCode(peerIds, boostPeer):
return .giftCode(peerIds: peerIds, boostPeer: boostPeer, currency: currency, amount: amount) return .giftCode(peerIds: peerIds, boostPeer: boostPeer, currency: currency, amount: amount)
case let .giveaway(boostPeer, additionalPeerIds, countries, onlyNewSubscribers, randomId, untilDate): case let .giveaway(boostPeer, additionalPeerIds, countries, onlyNewSubscribers, showWinners, prizeDescription, randomId, untilDate):
return .giveaway(boostPeer: boostPeer, additionalPeerIds: additionalPeerIds, countries: countries, onlyNewSubscribers: onlyNewSubscribers, randomId: randomId, untilDate: untilDate, currency: currency, amount: amount) return .giveaway(boostPeer: boostPeer, additionalPeerIds: additionalPeerIds, countries: countries, onlyNewSubscribers: onlyNewSubscribers, showWinners: showWinners, prizeDescription: prizeDescription, randomId: randomId, untilDate: untilDate, currency: currency, amount: amount)
} }
} }
} }

View File

@ -53,6 +53,8 @@ private enum CreateGiveawaySection: Int32 {
case subscriptions case subscriptions
case channels case channels
case users case users
case winners
case prizeDescription
case time case time
case duration case duration
} }
@ -92,6 +94,14 @@ private enum CreateGiveawayEntry: ItemListNodeEntry {
case usersNew(PresentationTheme, String, String, Bool) case usersNew(PresentationTheme, String, String, Bool)
case usersInfo(PresentationTheme, String) case usersInfo(PresentationTheme, String)
case winnersHeader(PresentationTheme, String)
case winners(PresentationTheme, String, Bool)
case winnersInfo(PresentationTheme, String)
case prizeDescriptionHeader(PresentationTheme, String)
case prizeDescription(PresentationTheme, String, String)
case prizeDescriptionInfo(PresentationTheme, String)
case timeHeader(PresentationTheme, String) case timeHeader(PresentationTheme, String)
case timeExpiryDate(PresentationTheme, PresentationDateTimeFormat, Int32?, Bool) case timeExpiryDate(PresentationTheme, PresentationDateTimeFormat, Int32?, Bool)
case timeCustomPicker(PresentationTheme, PresentationDateTimeFormat, Int32?, Int32?, Int32?, Bool, Bool) case timeCustomPicker(PresentationTheme, PresentationDateTimeFormat, Int32?, Int32?, Int32?, Bool, Bool)
@ -113,6 +123,10 @@ private enum CreateGiveawayEntry: ItemListNodeEntry {
return CreateGiveawaySection.channels.rawValue return CreateGiveawaySection.channels.rawValue
case .usersHeader, .usersAll, .usersNew, .usersInfo: case .usersHeader, .usersAll, .usersNew, .usersInfo:
return CreateGiveawaySection.users.rawValue return CreateGiveawaySection.users.rawValue
case .winnersHeader, .winners, .winnersInfo:
return CreateGiveawaySection.winners.rawValue
case .prizeDescriptionHeader, .prizeDescription, .prizeDescriptionInfo:
return CreateGiveawaySection.prizeDescription.rawValue
case .timeHeader, .timeExpiryDate, .timeCustomPicker, .timeInfo: case .timeHeader, .timeExpiryDate, .timeCustomPicker, .timeInfo:
return CreateGiveawaySection.time.rawValue return CreateGiveawaySection.time.rawValue
case .durationHeader, .duration, .durationInfo: case .durationHeader, .duration, .durationInfo:
@ -154,20 +168,32 @@ private enum CreateGiveawayEntry: ItemListNodeEntry {
return 104 return 104
case .usersInfo: case .usersInfo:
return 105 return 105
case .timeHeader: case .winnersHeader:
return 106 return 106
case .timeExpiryDate: case .winners:
return 107 return 107
case .timeCustomPicker: case .winnersInfo:
return 108 return 108
case .timeInfo: case .prizeDescriptionHeader:
return 109 return 109
case .durationHeader: case .prizeDescription:
return 110 return 110
case .prizeDescriptionInfo:
return 111
case .timeHeader:
return 112
case .timeExpiryDate:
return 113
case .timeCustomPicker:
return 114
case .timeInfo:
return 115
case .durationHeader:
return 116
case let .duration(index, _, _, _, _, _, _, _): case let .duration(index, _, _, _, _, _, _, _):
return 111 + index return 117 + index
case .durationInfo: case .durationInfo:
return 120 return 130
} }
} }
@ -269,7 +295,42 @@ private enum CreateGiveawayEntry: ItemListNodeEntry {
} else { } else {
return false return false
} }
case let .winnersHeader(lhsTheme, lhsText):
if case let .winnersHeader(rhsTheme, rhsText) = rhs, lhsTheme === rhsTheme, lhsText == rhsText {
return true
} else {
return false
}
case let .winners(lhsTheme, lhsText, lhsValue):
if case let .winners(rhsTheme, rhsText, rhsValue) = rhs, lhsTheme === rhsTheme, lhsText == rhsText, lhsValue == rhsValue {
return true
} else {
return false
}
case let .winnersInfo(lhsTheme, lhsText):
if case let .winnersInfo(rhsTheme, rhsText) = rhs, lhsTheme === rhsTheme, lhsText == rhsText {
return true
} else {
return false
}
case let .prizeDescriptionHeader(lhsTheme, lhsText):
if case let .prizeDescriptionHeader(rhsTheme, rhsText) = rhs, lhsTheme === rhsTheme, lhsText == rhsText {
return true
} else {
return false
}
case let .prizeDescription(lhsTheme, lhsPlaceholder, lhsValue):
if case let .prizeDescription(rhsTheme, rhsPlaceholder, rhsValue) = rhs, lhsTheme === rhsTheme, lhsPlaceholder == rhsPlaceholder, lhsValue == rhsValue {
return true
} else {
return false
}
case let .prizeDescriptionInfo(lhsTheme, lhsText):
if case let .prizeDescriptionInfo(rhsTheme, rhsText) = rhs, lhsTheme === rhsTheme, lhsText == rhsText {
return true
} else {
return false
}
case let .timeHeader(lhsTheme, lhsText): case let .timeHeader(lhsTheme, lhsText):
if case let .timeHeader(rhsTheme, rhsText) = rhs, lhsTheme === rhsTheme, lhsText == rhsText { if case let .timeHeader(rhsTheme, rhsText) = rhs, lhsTheme === rhsTheme, lhsText == rhsText {
return true return true
@ -423,6 +484,30 @@ private enum CreateGiveawayEntry: ItemListNodeEntry {
}) })
case let .usersInfo(_, text): case let .usersInfo(_, text):
return ItemListTextItem(presentationData: presentationData, text: .plain(text), sectionId: self.section) return ItemListTextItem(presentationData: presentationData, text: .plain(text), sectionId: self.section)
case let .winnersHeader(_, text):
return ItemListSectionHeaderItem(presentationData: presentationData, text: text, sectionId: self.section)
case let .winners(_, text, value):
return ItemListSwitchItem(presentationData: presentationData, title: text, value: value, sectionId: self.section, style: .blocks, updated: { value in
arguments.updateState { state in
var updatedState = state
updatedState.showWinners = value
return updatedState
}
})
case let .winnersInfo(_, text):
return ItemListTextItem(presentationData: presentationData, text: .plain(text), sectionId: self.section)
case let .prizeDescriptionHeader(_, text):
return ItemListSectionHeaderItem(presentationData: presentationData, text: text, sectionId: self.section)
case let .prizeDescription(_, placeholder, value):
return ItemListSingleLineInputItem(presentationData: presentationData, title: NSAttributedString(), text: value, placeholder: placeholder, sectionId: self.section, textUpdated: { value in
arguments.updateState { state in
var updatedState = state
updatedState.prizeDescription = value
return updatedState
}
}, action: {})
case let .prizeDescriptionInfo(_, text):
return ItemListTextItem(presentationData: presentationData, text: .plain(text), sectionId: self.section)
case let .timeHeader(_, text): case let .timeHeader(_, text):
return ItemListSectionHeaderItem(presentationData: presentationData, text: text, sectionId: self.section) return ItemListSectionHeaderItem(presentationData: presentationData, text: text, sectionId: self.section)
case let .timeExpiryDate(theme, dateTimeFormat, value, active): case let .timeExpiryDate(theme, dateTimeFormat, value, active):
@ -617,6 +702,14 @@ private func createGiveawayControllerEntries(
entries.append(.usersNew(presentationData.theme, presentationData.strings.BoostGift_OnlyNewSubscribers, countriesText, state.onlyNewEligible)) entries.append(.usersNew(presentationData.theme, presentationData.strings.BoostGift_OnlyNewSubscribers, countriesText, state.onlyNewEligible))
entries.append(.usersInfo(presentationData.theme, presentationData.strings.BoostGift_LimitSubscribersInfo)) entries.append(.usersInfo(presentationData.theme, presentationData.strings.BoostGift_LimitSubscribersInfo))
entries.append(.winnersHeader(presentationData.theme, presentationData.strings.BoostGift_WinnersTitle.uppercased()))
entries.append(.winners(presentationData.theme, presentationData.strings.BoostGift_Winners, state.showWinners))
entries.append(.winnersInfo(presentationData.theme, presentationData.strings.BoostGift_WinnersInfo))
entries.append(.prizeDescriptionHeader(presentationData.theme, "Additional Prizes".uppercased()))
entries.append(.prizeDescription(presentationData.theme, "Prize Description (Optional)", state.prizeDescription))
entries.append(.prizeDescriptionInfo(presentationData.theme, "Provide description of any additional prizes you plan to award to the winners, in addition to Telegram Premium."))
entries.append(.timeHeader(presentationData.theme, presentationData.strings.BoostGift_DateTitle.uppercased())) entries.append(.timeHeader(presentationData.theme, presentationData.strings.BoostGift_DateTitle.uppercased()))
entries.append(.timeCustomPicker(presentationData.theme, presentationData.dateTimeFormat, state.time, minDate, maxDate, state.pickingExpiryDate, state.pickingExpiryTime)) entries.append(.timeCustomPicker(presentationData.theme, presentationData.dateTimeFormat, state.time, minDate, maxDate, state.pickingExpiryDate, state.pickingExpiryTime))
entries.append(.timeInfo(presentationData.theme, presentationData.strings.BoostGift_DateInfo(presentationData.strings.BoostGift_DateInfoSubscribers(Int32(state.subscriptions))).string)) entries.append(.timeInfo(presentationData.theme, presentationData.strings.BoostGift_DateInfo(presentationData.strings.BoostGift_DateInfoSubscribers(Int32(state.subscriptions))).string))
@ -680,11 +773,13 @@ private struct CreateGiveawayControllerState: Equatable {
var mode: Mode var mode: Mode
var subscriptions: Int32 var subscriptions: Int32
var channels: [EnginePeer.Id] var channels: [EnginePeer.Id] = []
var peers: [EnginePeer.Id] var peers: [EnginePeer.Id] = []
var selectedMonths: Int32? var selectedMonths: Int32?
var countries: [String] var countries: [String] = []
var onlyNewEligible: Bool var onlyNewEligible: Bool = false
var showWinners: Bool = false
var prizeDescription: String = ""
var time: Int32 var time: Int32
var pickingExpiryTime = false var pickingExpiryTime = false
var pickingExpiryDate = false var pickingExpiryDate = false
@ -722,7 +817,7 @@ public func createGiveawayController(context: AccountContext, updatedPresentatio
let minDate = currentTime + 60 * 30 let minDate = currentTime + 60 * 30
let maxDate = currentTime + context.userLimits.maxGiveawayPeriodSeconds let maxDate = currentTime + context.userLimits.maxGiveawayPeriodSeconds
let initialState: CreateGiveawayControllerState = CreateGiveawayControllerState(mode: .giveaway, subscriptions: initialSubscriptions, channels: [], peers: [], countries: [], onlyNewEligible: false, time: expiryTime) let initialState: CreateGiveawayControllerState = CreateGiveawayControllerState(mode: .giveaway, subscriptions: initialSubscriptions, time: expiryTime)
let statePromise = ValuePromise(initialState, ignoreRepeated: true) let statePromise = ValuePromise(initialState, ignoreRepeated: true)
let stateValue = Atomic(value: initialState) let stateValue = Atomic(value: initialState)
@ -948,7 +1043,7 @@ public func createGiveawayController(context: AccountContext, updatedPresentatio
let quantity: Int32 let quantity: Int32
switch state.mode { switch state.mode {
case .giveaway: case .giveaway:
purpose = .giveaway(boostPeer: peerId, additionalPeerIds: state.channels.filter { $0 != peerId }, countries: state.countries, onlyNewSubscribers: state.onlyNewEligible, randomId: Int64.random(in: .min ..< .max), untilDate: state.time, currency: currency, amount: amount) purpose = .giveaway(boostPeer: peerId, additionalPeerIds: state.channels.filter { $0 != peerId }, countries: state.countries, onlyNewSubscribers: state.onlyNewEligible, showWinners: state.showWinners, prizeDescription: state.prizeDescription.isEmpty ? nil : state.prizeDescription, randomId: Int64.random(in: .min ..< .max), untilDate: state.time, currency: currency, amount: amount)
quantity = selectedProduct.giftOption.storeQuantity quantity = selectedProduct.giftOption.storeQuantity
case .gift: case .gift:
purpose = .giftCode(peerIds: state.peers, boostPeer: peerId, currency: currency, amount: amount) purpose = .giftCode(peerIds: state.peers, boostPeer: peerId, currency: currency, amount: amount)
@ -1040,7 +1135,7 @@ public func createGiveawayController(context: AccountContext, updatedPresentatio
return updatedState return updatedState
} }
let _ = (context.engine.payments.launchPrepaidGiveaway(peerId: peerId, id: prepaidGiveaway.id, additionalPeerIds: state.channels.filter { $0 != peerId }, countries: state.countries, onlyNewSubscribers: state.onlyNewEligible, randomId: Int64.random(in: .min ..< .max), untilDate: state.time) let _ = (context.engine.payments.launchPrepaidGiveaway(peerId: peerId, id: prepaidGiveaway.id, additionalPeerIds: state.channels.filter { $0 != peerId }, countries: state.countries, onlyNewSubscribers: state.onlyNewEligible, showWinners: state.showWinners, prizeDescription: state.prizeDescription.isEmpty ? nil : state.prizeDescription, randomId: Int64.random(in: .min ..< .max), untilDate: state.time)
|> deliverOnMainQueue).startStandalone(completed: { |> deliverOnMainQueue).startStandalone(completed: {
if let controller, let navigationController = controller.navigationController as? NavigationController { if let controller, let navigationController = controller.navigationController as? NavigationController {
var controllers = navigationController.viewControllers var controllers = navigationController.viewControllers

View File

@ -414,7 +414,7 @@ fileprivate let parsers: [Int32 : (BufferReader) -> Any?] = {
dict[1251549527] = { return Api.InputStickeredMedia.parse_inputStickeredMediaPhoto($0) } dict[1251549527] = { return Api.InputStickeredMedia.parse_inputStickeredMediaPhoto($0) }
dict[1634697192] = { return Api.InputStorePaymentPurpose.parse_inputStorePaymentGiftPremium($0) } dict[1634697192] = { return Api.InputStorePaymentPurpose.parse_inputStorePaymentGiftPremium($0) }
dict[-1551868097] = { return Api.InputStorePaymentPurpose.parse_inputStorePaymentPremiumGiftCode($0) } dict[-1551868097] = { return Api.InputStorePaymentPurpose.parse_inputStorePaymentPremiumGiftCode($0) }
dict[2090038758] = { return Api.InputStorePaymentPurpose.parse_inputStorePaymentPremiumGiveaway($0) } dict[369444042] = { return Api.InputStorePaymentPurpose.parse_inputStorePaymentPremiumGiveaway($0) }
dict[-1502273946] = { return Api.InputStorePaymentPurpose.parse_inputStorePaymentPremiumSubscription($0) } dict[-1502273946] = { return Api.InputStorePaymentPurpose.parse_inputStorePaymentPremiumSubscription($0) }
dict[1012306921] = { return Api.InputTheme.parse_inputTheme($0) } dict[1012306921] = { return Api.InputTheme.parse_inputTheme($0) }
dict[-175567375] = { return Api.InputTheme.parse_inputThemeSlug($0) } dict[-175567375] = { return Api.InputTheme.parse_inputThemeSlug($0) }
@ -542,7 +542,7 @@ fileprivate let parsers: [Int32 : (BufferReader) -> Any?] = {
dict[-38694904] = { return Api.MessageMedia.parse_messageMediaGame($0) } dict[-38694904] = { return Api.MessageMedia.parse_messageMediaGame($0) }
dict[1457575028] = { return Api.MessageMedia.parse_messageMediaGeo($0) } dict[1457575028] = { return Api.MessageMedia.parse_messageMediaGeo($0) }
dict[-1186937242] = { return Api.MessageMedia.parse_messageMediaGeoLive($0) } dict[-1186937242] = { return Api.MessageMedia.parse_messageMediaGeoLive($0) }
dict[1478887012] = { return Api.MessageMedia.parse_messageMediaGiveaway($0) } dict[-626162256] = { return Api.MessageMedia.parse_messageMediaGiveaway($0) }
dict[-156940077] = { return Api.MessageMedia.parse_messageMediaInvoice($0) } dict[-156940077] = { return Api.MessageMedia.parse_messageMediaInvoice($0) }
dict[1766936791] = { return Api.MessageMedia.parse_messageMediaPhoto($0) } dict[1766936791] = { return Api.MessageMedia.parse_messageMediaPhoto($0) }
dict[1272375192] = { return Api.MessageMedia.parse_messageMediaPoll($0) } dict[1272375192] = { return Api.MessageMedia.parse_messageMediaPoll($0) }
@ -1176,7 +1176,7 @@ fileprivate let parsers: [Int32 : (BufferReader) -> Any?] = {
dict[-1222446760] = { return Api.payments.CheckedGiftCode.parse_checkedGiftCode($0) } dict[-1222446760] = { return Api.payments.CheckedGiftCode.parse_checkedGiftCode($0) }
dict[-1362048039] = { return Api.payments.ExportedInvoice.parse_exportedInvoice($0) } dict[-1362048039] = { return Api.payments.ExportedInvoice.parse_exportedInvoice($0) }
dict[1130879648] = { return Api.payments.GiveawayInfo.parse_giveawayInfo($0) } dict[1130879648] = { return Api.payments.GiveawayInfo.parse_giveawayInfo($0) }
dict[13456752] = { return Api.payments.GiveawayInfo.parse_giveawayInfoResults($0) } dict[-1966612121] = { return Api.payments.GiveawayInfo.parse_giveawayInfoResults($0) }
dict[-1610250415] = { return Api.payments.PaymentForm.parse_paymentForm($0) } dict[-1610250415] = { return Api.payments.PaymentForm.parse_paymentForm($0) }
dict[1891958275] = { return Api.payments.PaymentReceipt.parse_paymentReceipt($0) } dict[1891958275] = { return Api.payments.PaymentReceipt.parse_paymentReceipt($0) }
dict[1314881805] = { return Api.payments.PaymentResult.parse_paymentResult($0) } dict[1314881805] = { return Api.payments.PaymentResult.parse_paymentResult($0) }

View File

@ -604,7 +604,7 @@ public extension Api {
indirect enum InputStorePaymentPurpose: TypeConstructorDescription { indirect enum InputStorePaymentPurpose: TypeConstructorDescription {
case inputStorePaymentGiftPremium(userId: Api.InputUser, currency: String, amount: Int64) case inputStorePaymentGiftPremium(userId: Api.InputUser, currency: String, amount: Int64)
case inputStorePaymentPremiumGiftCode(flags: Int32, users: [Api.InputUser], boostPeer: Api.InputPeer?, currency: String, amount: Int64) case inputStorePaymentPremiumGiftCode(flags: Int32, users: [Api.InputUser], boostPeer: Api.InputPeer?, currency: String, amount: Int64)
case inputStorePaymentPremiumGiveaway(flags: Int32, boostPeer: Api.InputPeer, additionalPeers: [Api.InputPeer]?, countriesIso2: [String]?, randomId: Int64, untilDate: Int32, currency: String, amount: Int64) case inputStorePaymentPremiumGiveaway(flags: Int32, boostPeer: Api.InputPeer, additionalPeers: [Api.InputPeer]?, countriesIso2: [String]?, prizeDescription: String?, randomId: Int64, untilDate: Int32, currency: String, amount: Int64)
case inputStorePaymentPremiumSubscription(flags: Int32) case inputStorePaymentPremiumSubscription(flags: Int32)
public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) { public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) {
@ -631,9 +631,9 @@ public extension Api {
serializeString(currency, buffer: buffer, boxed: false) serializeString(currency, buffer: buffer, boxed: false)
serializeInt64(amount, buffer: buffer, boxed: false) serializeInt64(amount, buffer: buffer, boxed: false)
break break
case .inputStorePaymentPremiumGiveaway(let flags, let boostPeer, let additionalPeers, let countriesIso2, let randomId, let untilDate, let currency, let amount): case .inputStorePaymentPremiumGiveaway(let flags, let boostPeer, let additionalPeers, let countriesIso2, let prizeDescription, let randomId, let untilDate, let currency, let amount):
if boxed { if boxed {
buffer.appendInt32(2090038758) buffer.appendInt32(369444042)
} }
serializeInt32(flags, buffer: buffer, boxed: false) serializeInt32(flags, buffer: buffer, boxed: false)
boostPeer.serialize(buffer, true) boostPeer.serialize(buffer, true)
@ -647,6 +647,7 @@ public extension Api {
for item in countriesIso2! { for item in countriesIso2! {
serializeString(item, buffer: buffer, boxed: false) serializeString(item, buffer: buffer, boxed: false)
}} }}
if Int(flags) & Int(1 << 4) != 0 {serializeString(prizeDescription!, buffer: buffer, boxed: false)}
serializeInt64(randomId, buffer: buffer, boxed: false) serializeInt64(randomId, buffer: buffer, boxed: false)
serializeInt32(untilDate, buffer: buffer, boxed: false) serializeInt32(untilDate, buffer: buffer, boxed: false)
serializeString(currency, buffer: buffer, boxed: false) serializeString(currency, buffer: buffer, boxed: false)
@ -667,8 +668,8 @@ public extension Api {
return ("inputStorePaymentGiftPremium", [("userId", userId as Any), ("currency", currency as Any), ("amount", amount as Any)]) return ("inputStorePaymentGiftPremium", [("userId", userId as Any), ("currency", currency as Any), ("amount", amount as Any)])
case .inputStorePaymentPremiumGiftCode(let flags, let users, let boostPeer, let currency, let amount): case .inputStorePaymentPremiumGiftCode(let flags, let users, let boostPeer, let currency, let amount):
return ("inputStorePaymentPremiumGiftCode", [("flags", flags as Any), ("users", users as Any), ("boostPeer", boostPeer as Any), ("currency", currency as Any), ("amount", amount as Any)]) return ("inputStorePaymentPremiumGiftCode", [("flags", flags as Any), ("users", users as Any), ("boostPeer", boostPeer as Any), ("currency", currency as Any), ("amount", amount as Any)])
case .inputStorePaymentPremiumGiveaway(let flags, let boostPeer, let additionalPeers, let countriesIso2, let randomId, let untilDate, let currency, let amount): case .inputStorePaymentPremiumGiveaway(let flags, let boostPeer, let additionalPeers, let countriesIso2, let prizeDescription, let randomId, let untilDate, let currency, let amount):
return ("inputStorePaymentPremiumGiveaway", [("flags", flags as Any), ("boostPeer", boostPeer as Any), ("additionalPeers", additionalPeers as Any), ("countriesIso2", countriesIso2 as Any), ("randomId", randomId as Any), ("untilDate", untilDate as Any), ("currency", currency as Any), ("amount", amount as Any)]) return ("inputStorePaymentPremiumGiveaway", [("flags", flags as Any), ("boostPeer", boostPeer as Any), ("additionalPeers", additionalPeers as Any), ("countriesIso2", countriesIso2 as Any), ("prizeDescription", prizeDescription as Any), ("randomId", randomId as Any), ("untilDate", untilDate as Any), ("currency", currency as Any), ("amount", amount as Any)])
case .inputStorePaymentPremiumSubscription(let flags): case .inputStorePaymentPremiumSubscription(let flags):
return ("inputStorePaymentPremiumSubscription", [("flags", flags as Any)]) return ("inputStorePaymentPremiumSubscription", [("flags", flags as Any)])
} }
@ -735,24 +736,27 @@ public extension Api {
if Int(_1!) & Int(1 << 2) != 0 {if let _ = reader.readInt32() { if Int(_1!) & Int(1 << 2) != 0 {if let _ = reader.readInt32() {
_4 = Api.parseVector(reader, elementSignature: -1255641564, elementType: String.self) _4 = Api.parseVector(reader, elementSignature: -1255641564, elementType: String.self)
} } } }
var _5: Int64? var _5: String?
_5 = reader.readInt64() if Int(_1!) & Int(1 << 4) != 0 {_5 = parseString(reader) }
var _6: Int32? var _6: Int64?
_6 = reader.readInt32() _6 = reader.readInt64()
var _7: String? var _7: Int32?
_7 = parseString(reader) _7 = reader.readInt32()
var _8: Int64? var _8: String?
_8 = reader.readInt64() _8 = parseString(reader)
var _9: Int64?
_9 = reader.readInt64()
let _c1 = _1 != nil let _c1 = _1 != nil
let _c2 = _2 != nil let _c2 = _2 != nil
let _c3 = (Int(_1!) & Int(1 << 1) == 0) || _3 != nil let _c3 = (Int(_1!) & Int(1 << 1) == 0) || _3 != nil
let _c4 = (Int(_1!) & Int(1 << 2) == 0) || _4 != nil let _c4 = (Int(_1!) & Int(1 << 2) == 0) || _4 != nil
let _c5 = _5 != nil let _c5 = (Int(_1!) & Int(1 << 4) == 0) || _5 != nil
let _c6 = _6 != nil let _c6 = _6 != nil
let _c7 = _7 != nil let _c7 = _7 != nil
let _c8 = _8 != nil let _c8 = _8 != nil
if _c1 && _c2 && _c3 && _c4 && _c5 && _c6 && _c7 && _c8 { let _c9 = _9 != nil
return Api.InputStorePaymentPurpose.inputStorePaymentPremiumGiveaway(flags: _1!, boostPeer: _2!, additionalPeers: _3, countriesIso2: _4, randomId: _5!, untilDate: _6!, currency: _7!, amount: _8!) if _c1 && _c2 && _c3 && _c4 && _c5 && _c6 && _c7 && _c8 && _c9 {
return Api.InputStorePaymentPurpose.inputStorePaymentPremiumGiveaway(flags: _1!, boostPeer: _2!, additionalPeers: _3, countriesIso2: _4, prizeDescription: _5, randomId: _6!, untilDate: _7!, currency: _8!, amount: _9!)
} }
else { else {
return nil return nil

View File

@ -697,7 +697,7 @@ public extension Api {
case messageMediaGame(game: Api.Game) case messageMediaGame(game: Api.Game)
case messageMediaGeo(geo: Api.GeoPoint) case messageMediaGeo(geo: Api.GeoPoint)
case messageMediaGeoLive(flags: Int32, geo: Api.GeoPoint, heading: Int32?, period: Int32, proximityNotificationRadius: Int32?) case messageMediaGeoLive(flags: Int32, geo: Api.GeoPoint, heading: Int32?, period: Int32, proximityNotificationRadius: Int32?)
case messageMediaGiveaway(flags: Int32, channels: [Int64], countriesIso2: [String]?, quantity: Int32, months: Int32, untilDate: Int32) case messageMediaGiveaway(flags: Int32, channels: [Int64], countriesIso2: [String]?, prizeDescription: String?, quantity: Int32, months: Int32, untilDate: Int32)
case messageMediaInvoice(flags: Int32, title: String, description: String, photo: Api.WebDocument?, receiptMsgId: Int32?, currency: String, totalAmount: Int64, startParam: String, extendedMedia: Api.MessageExtendedMedia?) case messageMediaInvoice(flags: Int32, title: String, description: String, photo: Api.WebDocument?, receiptMsgId: Int32?, currency: String, totalAmount: Int64, startParam: String, extendedMedia: Api.MessageExtendedMedia?)
case messageMediaPhoto(flags: Int32, photo: Api.Photo?, ttlSeconds: Int32?) case messageMediaPhoto(flags: Int32, photo: Api.Photo?, ttlSeconds: Int32?)
case messageMediaPoll(poll: Api.Poll, results: Api.PollResults) case messageMediaPoll(poll: Api.Poll, results: Api.PollResults)
@ -762,9 +762,9 @@ public extension Api {
serializeInt32(period, buffer: buffer, boxed: false) serializeInt32(period, buffer: buffer, boxed: false)
if Int(flags) & Int(1 << 1) != 0 {serializeInt32(proximityNotificationRadius!, buffer: buffer, boxed: false)} if Int(flags) & Int(1 << 1) != 0 {serializeInt32(proximityNotificationRadius!, buffer: buffer, boxed: false)}
break break
case .messageMediaGiveaway(let flags, let channels, let countriesIso2, let quantity, let months, let untilDate): case .messageMediaGiveaway(let flags, let channels, let countriesIso2, let prizeDescription, let quantity, let months, let untilDate):
if boxed { if boxed {
buffer.appendInt32(1478887012) buffer.appendInt32(-626162256)
} }
serializeInt32(flags, buffer: buffer, boxed: false) serializeInt32(flags, buffer: buffer, boxed: false)
buffer.appendInt32(481674261) buffer.appendInt32(481674261)
@ -777,6 +777,7 @@ public extension Api {
for item in countriesIso2! { for item in countriesIso2! {
serializeString(item, buffer: buffer, boxed: false) serializeString(item, buffer: buffer, boxed: false)
}} }}
if Int(flags) & Int(1 << 3) != 0 {serializeString(prizeDescription!, buffer: buffer, boxed: false)}
serializeInt32(quantity, buffer: buffer, boxed: false) serializeInt32(quantity, buffer: buffer, boxed: false)
serializeInt32(months, buffer: buffer, boxed: false) serializeInt32(months, buffer: buffer, boxed: false)
serializeInt32(untilDate, buffer: buffer, boxed: false) serializeInt32(untilDate, buffer: buffer, boxed: false)
@ -862,8 +863,8 @@ public extension Api {
return ("messageMediaGeo", [("geo", geo as Any)]) return ("messageMediaGeo", [("geo", geo as Any)])
case .messageMediaGeoLive(let flags, let geo, let heading, let period, let proximityNotificationRadius): case .messageMediaGeoLive(let flags, let geo, let heading, let period, let proximityNotificationRadius):
return ("messageMediaGeoLive", [("flags", flags as Any), ("geo", geo as Any), ("heading", heading as Any), ("period", period as Any), ("proximityNotificationRadius", proximityNotificationRadius as Any)]) return ("messageMediaGeoLive", [("flags", flags as Any), ("geo", geo as Any), ("heading", heading as Any), ("period", period as Any), ("proximityNotificationRadius", proximityNotificationRadius as Any)])
case .messageMediaGiveaway(let flags, let channels, let countriesIso2, let quantity, let months, let untilDate): case .messageMediaGiveaway(let flags, let channels, let countriesIso2, let prizeDescription, let quantity, let months, let untilDate):
return ("messageMediaGiveaway", [("flags", flags as Any), ("channels", channels as Any), ("countriesIso2", countriesIso2 as Any), ("quantity", quantity as Any), ("months", months as Any), ("untilDate", untilDate as Any)]) return ("messageMediaGiveaway", [("flags", flags as Any), ("channels", channels as Any), ("countriesIso2", countriesIso2 as Any), ("prizeDescription", prizeDescription as Any), ("quantity", quantity as Any), ("months", months as Any), ("untilDate", untilDate as Any)])
case .messageMediaInvoice(let flags, let title, let description, let photo, let receiptMsgId, let currency, let totalAmount, let startParam, let extendedMedia): case .messageMediaInvoice(let flags, let title, let description, let photo, let receiptMsgId, let currency, let totalAmount, let startParam, let extendedMedia):
return ("messageMediaInvoice", [("flags", flags as Any), ("title", title as Any), ("description", description as Any), ("photo", photo as Any), ("receiptMsgId", receiptMsgId as Any), ("currency", currency as Any), ("totalAmount", totalAmount as Any), ("startParam", startParam as Any), ("extendedMedia", extendedMedia as Any)]) return ("messageMediaInvoice", [("flags", flags as Any), ("title", title as Any), ("description", description as Any), ("photo", photo as Any), ("receiptMsgId", receiptMsgId as Any), ("currency", currency as Any), ("totalAmount", totalAmount as Any), ("startParam", startParam as Any), ("extendedMedia", extendedMedia as Any)])
case .messageMediaPhoto(let flags, let photo, let ttlSeconds): case .messageMediaPhoto(let flags, let photo, let ttlSeconds):
@ -1007,20 +1008,23 @@ public extension Api {
if Int(_1!) & Int(1 << 1) != 0 {if let _ = reader.readInt32() { if Int(_1!) & Int(1 << 1) != 0 {if let _ = reader.readInt32() {
_3 = Api.parseVector(reader, elementSignature: -1255641564, elementType: String.self) _3 = Api.parseVector(reader, elementSignature: -1255641564, elementType: String.self)
} } } }
var _4: Int32? var _4: String?
_4 = reader.readInt32() if Int(_1!) & Int(1 << 3) != 0 {_4 = parseString(reader) }
var _5: Int32? var _5: Int32?
_5 = reader.readInt32() _5 = reader.readInt32()
var _6: Int32? var _6: Int32?
_6 = reader.readInt32() _6 = reader.readInt32()
var _7: Int32?
_7 = reader.readInt32()
let _c1 = _1 != nil let _c1 = _1 != nil
let _c2 = _2 != nil let _c2 = _2 != nil
let _c3 = (Int(_1!) & Int(1 << 1) == 0) || _3 != nil let _c3 = (Int(_1!) & Int(1 << 1) == 0) || _3 != nil
let _c4 = _4 != nil let _c4 = (Int(_1!) & Int(1 << 3) == 0) || _4 != nil
let _c5 = _5 != nil let _c5 = _5 != nil
let _c6 = _6 != nil let _c6 = _6 != nil
if _c1 && _c2 && _c3 && _c4 && _c5 && _c6 { let _c7 = _7 != nil
return Api.MessageMedia.messageMediaGiveaway(flags: _1!, channels: _2!, countriesIso2: _3, quantity: _4!, months: _5!, untilDate: _6!) if _c1 && _c2 && _c3 && _c4 && _c5 && _c6 && _c7 {
return Api.MessageMedia.messageMediaGiveaway(flags: _1!, channels: _2!, countriesIso2: _3, prizeDescription: _4, quantity: _5!, months: _6!, untilDate: _7!)
} }
else { else {
return nil return nil

View File

@ -911,7 +911,7 @@ public extension Api.payments {
public extension Api.payments { public extension Api.payments {
enum GiveawayInfo: TypeConstructorDescription { enum GiveawayInfo: TypeConstructorDescription {
case giveawayInfo(flags: Int32, startDate: Int32, joinedTooEarlyDate: Int32?, adminDisallowedChatId: Int64?, disallowedCountry: String?) case giveawayInfo(flags: Int32, startDate: Int32, joinedTooEarlyDate: Int32?, adminDisallowedChatId: Int64?, disallowedCountry: String?)
case giveawayInfoResults(flags: Int32, startDate: Int32, giftCodeSlug: String?, finishDate: Int32, winnersCount: Int32, activatedCount: Int32) case giveawayInfoResults(flags: Int32, startDate: Int32, giftCodeSlug: String?, finishDate: Int32, winnersCount: Int32, activatedCount: Int32, winners: [Api.User]?)
public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) { public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) {
switch self { switch self {
@ -925,9 +925,9 @@ public extension Api.payments {
if Int(flags) & Int(1 << 2) != 0 {serializeInt64(adminDisallowedChatId!, buffer: buffer, boxed: false)} if Int(flags) & Int(1 << 2) != 0 {serializeInt64(adminDisallowedChatId!, buffer: buffer, boxed: false)}
if Int(flags) & Int(1 << 4) != 0 {serializeString(disallowedCountry!, buffer: buffer, boxed: false)} if Int(flags) & Int(1 << 4) != 0 {serializeString(disallowedCountry!, buffer: buffer, boxed: false)}
break break
case .giveawayInfoResults(let flags, let startDate, let giftCodeSlug, let finishDate, let winnersCount, let activatedCount): case .giveawayInfoResults(let flags, let startDate, let giftCodeSlug, let finishDate, let winnersCount, let activatedCount, let winners):
if boxed { if boxed {
buffer.appendInt32(13456752) buffer.appendInt32(-1966612121)
} }
serializeInt32(flags, buffer: buffer, boxed: false) serializeInt32(flags, buffer: buffer, boxed: false)
serializeInt32(startDate, buffer: buffer, boxed: false) serializeInt32(startDate, buffer: buffer, boxed: false)
@ -935,6 +935,11 @@ public extension Api.payments {
serializeInt32(finishDate, buffer: buffer, boxed: false) serializeInt32(finishDate, buffer: buffer, boxed: false)
serializeInt32(winnersCount, buffer: buffer, boxed: false) serializeInt32(winnersCount, buffer: buffer, boxed: false)
serializeInt32(activatedCount, buffer: buffer, boxed: false) serializeInt32(activatedCount, buffer: buffer, boxed: false)
if Int(flags) & Int(1 << 2) != 0 {buffer.appendInt32(481674261)
buffer.appendInt32(Int32(winners!.count))
for item in winners! {
item.serialize(buffer, true)
}}
break break
} }
} }
@ -943,8 +948,8 @@ public extension Api.payments {
switch self { switch self {
case .giveawayInfo(let flags, let startDate, let joinedTooEarlyDate, let adminDisallowedChatId, let disallowedCountry): case .giveawayInfo(let flags, let startDate, let joinedTooEarlyDate, let adminDisallowedChatId, let disallowedCountry):
return ("giveawayInfo", [("flags", flags as Any), ("startDate", startDate as Any), ("joinedTooEarlyDate", joinedTooEarlyDate as Any), ("adminDisallowedChatId", adminDisallowedChatId as Any), ("disallowedCountry", disallowedCountry as Any)]) return ("giveawayInfo", [("flags", flags as Any), ("startDate", startDate as Any), ("joinedTooEarlyDate", joinedTooEarlyDate as Any), ("adminDisallowedChatId", adminDisallowedChatId as Any), ("disallowedCountry", disallowedCountry as Any)])
case .giveawayInfoResults(let flags, let startDate, let giftCodeSlug, let finishDate, let winnersCount, let activatedCount): case .giveawayInfoResults(let flags, let startDate, let giftCodeSlug, let finishDate, let winnersCount, let activatedCount, let winners):
return ("giveawayInfoResults", [("flags", flags as Any), ("startDate", startDate as Any), ("giftCodeSlug", giftCodeSlug as Any), ("finishDate", finishDate as Any), ("winnersCount", winnersCount as Any), ("activatedCount", activatedCount as Any)]) return ("giveawayInfoResults", [("flags", flags as Any), ("startDate", startDate as Any), ("giftCodeSlug", giftCodeSlug as Any), ("finishDate", finishDate as Any), ("winnersCount", winnersCount as Any), ("activatedCount", activatedCount as Any), ("winners", winners as Any)])
} }
} }
@ -984,14 +989,19 @@ public extension Api.payments {
_5 = reader.readInt32() _5 = reader.readInt32()
var _6: Int32? var _6: Int32?
_6 = reader.readInt32() _6 = reader.readInt32()
var _7: [Api.User]?
if Int(_1!) & Int(1 << 2) != 0 {if let _ = reader.readInt32() {
_7 = Api.parseVector(reader, elementSignature: 0, elementType: Api.User.self)
} }
let _c1 = _1 != nil let _c1 = _1 != nil
let _c2 = _2 != nil let _c2 = _2 != nil
let _c3 = (Int(_1!) & Int(1 << 0) == 0) || _3 != nil let _c3 = (Int(_1!) & Int(1 << 0) == 0) || _3 != nil
let _c4 = _4 != nil let _c4 = _4 != nil
let _c5 = _5 != nil let _c5 = _5 != nil
let _c6 = _6 != nil let _c6 = _6 != nil
if _c1 && _c2 && _c3 && _c4 && _c5 && _c6 { let _c7 = (Int(_1!) & Int(1 << 2) == 0) || _7 != nil
return Api.payments.GiveawayInfo.giveawayInfoResults(flags: _1!, startDate: _2!, giftCodeSlug: _3, finishDate: _4!, winnersCount: _5!, activatedCount: _6!) if _c1 && _c2 && _c3 && _c4 && _c5 && _c6 && _c7 {
return Api.payments.GiveawayInfo.giveawayInfoResults(flags: _1!, startDate: _2!, giftCodeSlug: _3, finishDate: _4!, winnersCount: _5!, activatedCount: _6!, winners: _7)
} }
else { else {
return nil return nil

View File

@ -422,12 +422,15 @@ func textMediaAndExpirationTimerFromApiMedia(_ media: Api.MessageMedia?, _ peerI
case let .messageMediaStory(flags, peerId, id, _): case let .messageMediaStory(flags, peerId, id, _):
let isMention = (flags & (1 << 1)) != 0 let isMention = (flags & (1 << 1)) != 0
return (TelegramMediaStory(storyId: StoryId(peerId: peerId.peerId, id: id), isMention: isMention), nil, nil, nil, nil) return (TelegramMediaStory(storyId: StoryId(peerId: peerId.peerId, id: id), isMention: isMention), nil, nil, nil, nil)
case let .messageMediaGiveaway(apiFlags, channels, countries, quantity, months, untilDate): case let .messageMediaGiveaway(apiFlags, channels, countries, prizeDescription, quantity, months, untilDate):
var flags: TelegramMediaGiveaway.Flags = [] var flags: TelegramMediaGiveaway.Flags = []
if (apiFlags & (1 << 0)) != 0 { if (apiFlags & (1 << 0)) != 0 {
flags.insert(.onlyNewSubscribers) flags.insert(.onlyNewSubscribers)
} }
return (TelegramMediaGiveaway(flags: flags, channelPeerIds: channels.map { PeerId(namespace: Namespaces.Peer.CloudChannel, id: PeerId.Id._internalFromInt64Value($0)) }, countries: countries ?? [], quantity: quantity, months: months, untilDate: untilDate), nil, nil, nil, nil) if (apiFlags & (1 << 2)) != 0 {
flags.insert(.showWinners)
}
return (TelegramMediaGiveaway(flags: flags, channelPeerIds: channels.map { PeerId(namespace: Namespaces.Peer.CloudChannel, id: PeerId.Id._internalFromInt64Value($0)) }, countries: countries ?? [], quantity: quantity, months: months, untilDate: untilDate, prizeDescription: prizeDescription), nil, nil, nil, nil)
} }
} }

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 167 return 168
} }
public func parseMessage(_ data: Data!) -> Any! { public func parseMessage(_ data: Data!) -> Any! {

View File

@ -9,6 +9,7 @@ public final class TelegramMediaGiveaway: Media, Equatable {
} }
public static let onlyNewSubscribers = Flags(rawValue: 1 << 0) public static let onlyNewSubscribers = Flags(rawValue: 1 << 0)
public static let showWinners = Flags(rawValue: 1 << 1)
} }
public var id: MediaId? { public var id: MediaId? {
@ -24,14 +25,16 @@ public final class TelegramMediaGiveaway: Media, Equatable {
public let quantity: Int32 public let quantity: Int32
public let months: Int32 public let months: Int32
public let untilDate: Int32 public let untilDate: Int32
public let prizeDescription: String?
public init(flags: Flags, channelPeerIds: [PeerId], countries: [String], quantity: Int32, months: Int32, untilDate: Int32) { public init(flags: Flags, channelPeerIds: [PeerId], countries: [String], quantity: Int32, months: Int32, untilDate: Int32, prizeDescription: String?) {
self.flags = flags self.flags = flags
self.channelPeerIds = channelPeerIds self.channelPeerIds = channelPeerIds
self.countries = countries self.countries = countries
self.quantity = quantity self.quantity = quantity
self.months = months self.months = months
self.untilDate = untilDate self.untilDate = untilDate
self.prizeDescription = prizeDescription
} }
public init(decoder: PostboxDecoder) { public init(decoder: PostboxDecoder) {
@ -41,6 +44,7 @@ public final class TelegramMediaGiveaway: Media, Equatable {
self.quantity = decoder.decodeInt32ForKey("qty", orElse: 0) self.quantity = decoder.decodeInt32ForKey("qty", orElse: 0)
self.months = decoder.decodeInt32ForKey("mts", orElse: 0) self.months = decoder.decodeInt32ForKey("mts", orElse: 0)
self.untilDate = decoder.decodeInt32ForKey("unt", orElse: 0) self.untilDate = decoder.decodeInt32ForKey("unt", orElse: 0)
self.prizeDescription = decoder.decodeOptionalStringForKey("des")
} }
public func encode(_ encoder: PostboxEncoder) { public func encode(_ encoder: PostboxEncoder) {
@ -50,6 +54,11 @@ public final class TelegramMediaGiveaway: Media, Equatable {
encoder.encodeInt32(self.quantity, forKey: "qty") encoder.encodeInt32(self.quantity, forKey: "qty")
encoder.encodeInt32(self.months, forKey: "mts") encoder.encodeInt32(self.months, forKey: "mts")
encoder.encodeInt32(self.untilDate, forKey: "unt") encoder.encodeInt32(self.untilDate, forKey: "unt")
if let prizeDescription = self.prizeDescription {
encoder.encodeString(prizeDescription, forKey: "des")
} else {
encoder.encodeNil(forKey: "des")
}
} }
public func isLikelyToBeUpdated() -> Bool { public func isLikelyToBeUpdated() -> Bool {
@ -78,6 +87,9 @@ public final class TelegramMediaGiveaway: Media, Equatable {
if self.untilDate != other.untilDate { if self.untilDate != other.untilDate {
return false return false
} }
if self.prizeDescription != other.prizeDescription {
return false
}
return true return true
} }

View File

@ -16,7 +16,7 @@ public enum AppStoreTransactionPurpose {
case restore case restore
case gift(peerId: EnginePeer.Id, currency: String, amount: Int64) case gift(peerId: EnginePeer.Id, currency: String, amount: Int64)
case giftCode(peerIds: [EnginePeer.Id], boostPeer: EnginePeer.Id?, currency: String, amount: Int64) case giftCode(peerIds: [EnginePeer.Id], boostPeer: EnginePeer.Id?, currency: String, amount: Int64)
case giveaway(boostPeer: EnginePeer.Id, additionalPeerIds: [EnginePeer.Id], countries: [String], onlyNewSubscribers: Bool, randomId: Int64, untilDate: Int32, currency: String, amount: Int64) case giveaway(boostPeer: EnginePeer.Id, additionalPeerIds: [EnginePeer.Id], countries: [String], onlyNewSubscribers: Bool, showWinners: Bool, prizeDescription: String?, randomId: Int64, untilDate: Int32, currency: String, amount: Int64)
} }
private func apiInputStorePaymentPurpose(account: Account, purpose: AppStoreTransactionPurpose) -> Signal<Api.InputStorePaymentPurpose, NoError> { private func apiInputStorePaymentPurpose(account: Account, purpose: AppStoreTransactionPurpose) -> Signal<Api.InputStorePaymentPurpose, NoError> {
@ -59,7 +59,7 @@ private func apiInputStorePaymentPurpose(account: Account, purpose: AppStoreTran
return .inputStorePaymentPremiumGiftCode(flags: flags, users: apiInputUsers, boostPeer: apiBoostPeer, currency: currency, amount: amount) return .inputStorePaymentPremiumGiftCode(flags: flags, users: apiInputUsers, boostPeer: apiBoostPeer, currency: currency, amount: amount)
} }
case let .giveaway(boostPeerId, additionalPeerIds, countries, onlyNewSubscribers, randomId, untilDate, currency, amount): case let .giveaway(boostPeerId, additionalPeerIds, countries, onlyNewSubscribers, showWinners, prizeDescription, randomId, untilDate, currency, amount):
return account.postbox.transaction { transaction -> Signal<Api.InputStorePaymentPurpose, NoError> in return account.postbox.transaction { transaction -> Signal<Api.InputStorePaymentPurpose, NoError> in
guard let peer = transaction.getPeer(boostPeerId), let apiBoostPeer = apiInputPeer(peer) else { guard let peer = transaction.getPeer(boostPeerId), let apiBoostPeer = apiInputPeer(peer) else {
return .complete() return .complete()
@ -68,6 +68,9 @@ private func apiInputStorePaymentPurpose(account: Account, purpose: AppStoreTran
if onlyNewSubscribers { if onlyNewSubscribers {
flags |= (1 << 0) flags |= (1 << 0)
} }
if showWinners {
flags |= (1 << 0)
}
var additionalPeers: [Api.InputPeer] = [] var additionalPeers: [Api.InputPeer] = []
if !additionalPeerIds.isEmpty { if !additionalPeerIds.isEmpty {
flags |= (1 << 1) flags |= (1 << 1)
@ -80,7 +83,10 @@ private func apiInputStorePaymentPurpose(account: Account, purpose: AppStoreTran
if !countries.isEmpty { if !countries.isEmpty {
flags |= (1 << 2) flags |= (1 << 2)
} }
return .single(.inputStorePaymentPremiumGiveaway(flags: flags, boostPeer: apiBoostPeer, additionalPeers: additionalPeers, countriesIso2: countries, randomId: randomId, untilDate: untilDate, currency: currency, amount: amount)) if let _ = prizeDescription {
flags |= (1 << 4)
}
return .single(.inputStorePaymentPremiumGiveaway(flags: flags, boostPeer: apiBoostPeer, additionalPeers: additionalPeers, countriesIso2: countries, prizeDescription: prizeDescription, randomId: randomId, untilDate: untilDate, currency: currency, amount: amount))
} }
|> switchToLatest |> switchToLatest
} }

View File

@ -7,7 +7,7 @@ import TelegramApi
public enum BotPaymentInvoiceSource { 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, 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)
} }
@ -214,7 +214,7 @@ private func _internal_parseInputInvoice(transaction: Transaction, source: BotPa
return .inputInvoiceMessage(peer: inputPeer, msgId: messageId.id) return .inputInvoiceMessage(peer: inputPeer, msgId: messageId.id)
case let .slug(slug): case let .slug(slug):
return .inputInvoiceSlug(slug: slug) return .inputInvoiceSlug(slug: slug)
case let .premiumGiveaway(boostPeerId, additionalPeerIds, countries, onlyNewSubscribers, randomId, untilDate, currency, amount, option): case let .premiumGiveaway(boostPeerId, additionalPeerIds, countries, onlyNewSubscribers, showWinners, prizeDescription, randomId, untilDate, currency, amount, option):
guard let peer = transaction.getPeer(boostPeerId), let apiBoostPeer = apiInputPeer(peer) else { guard let peer = transaction.getPeer(boostPeerId), let apiBoostPeer = apiInputPeer(peer) else {
return nil return nil
} }
@ -222,6 +222,9 @@ private func _internal_parseInputInvoice(transaction: Transaction, source: BotPa
if onlyNewSubscribers { if onlyNewSubscribers {
flags |= (1 << 0) flags |= (1 << 0)
} }
if showWinners {
flags |= (1 << 3)
}
var additionalPeers: [Api.InputPeer] = [] var additionalPeers: [Api.InputPeer] = []
if !additionalPeerIds.isEmpty { if !additionalPeerIds.isEmpty {
flags |= (1 << 1) flags |= (1 << 1)
@ -234,7 +237,11 @@ private func _internal_parseInputInvoice(transaction: Transaction, source: BotPa
if !countries.isEmpty { if !countries.isEmpty {
flags |= (1 << 2) flags |= (1 << 2)
} }
let input: Api.InputStorePaymentPurpose = .inputStorePaymentPremiumGiveaway(flags: flags, boostPeer: apiBoostPeer, additionalPeers: additionalPeers, countriesIso2: countries, randomId: randomId, untilDate: untilDate, currency: currency, amount: amount) if let _ = prizeDescription {
flags |= (1 << 4)
}
let inputPurpose: Api.InputStorePaymentPurpose = .inputStorePaymentPremiumGiveaway(flags: flags, boostPeer: apiBoostPeer, additionalPeers: additionalPeers, countriesIso2: countries, prizeDescription: prizeDescription, randomId: randomId, untilDate: untilDate, currency: currency, amount: amount)
flags = 0 flags = 0
@ -247,7 +254,7 @@ 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: input, option: option) return .inputInvoicePremiumGiftCode(purpose: inputPurpose, option: option)
} }
} }
@ -526,7 +533,7 @@ func _internal_sendBotPaymentForm(account: Account, formId: Int64, source: BotPa
} }
} }
} }
case let .premiumGiveaway(_, _, _, _, randomId, _, _, _, _): case let .premiumGiveaway(_, _, _, _, _, _, randomId, _, _, _, _):
if message.globallyUniqueId == randomId { if message.globallyUniqueId == randomId {
if case let .Id(id) = message.id { if case let .Id(id) = message.id {
receiptMessageId = id receiptMessageId = id

View File

@ -120,7 +120,7 @@ func _internal_getPremiumGiveawayInfo(account: Account, peerId: EnginePeer.Id, m
} else { } else {
return .ongoing(startDate: startDate, status: .notQualified) return .ongoing(startDate: startDate, status: .notQualified)
} }
case let .giveawayInfoResults(flags, startDate, giftCodeSlug, finishDate, winnersCount, activatedCount): case let .giveawayInfoResults(flags, startDate, giftCodeSlug, finishDate, winnersCount, activatedCount, _):
let status: PremiumGiveawayInfo.ResultStatus let status: PremiumGiveawayInfo.ResultStatus
if (flags & (1 << 1)) != 0 { if (flags & (1 << 1)) != 0 {
status = .refunded status = .refunded
@ -201,18 +201,19 @@ public enum LaunchPrepaidGiveawayError {
case generic case generic
} }
func _internal_launchPrepaidGiveaway(account: Account, peerId: EnginePeer.Id, id: Int64, additionalPeerIds: [EnginePeer.Id], countries: [String], onlyNewSubscribers: Bool, randomId: Int64, untilDate: Int32) -> Signal<Never, LaunchPrepaidGiveawayError> { func _internal_launchPrepaidGiveaway(account: Account, peerId: EnginePeer.Id, id: Int64, additionalPeerIds: [EnginePeer.Id], countries: [String], onlyNewSubscribers: Bool, showWinners: Bool, prizeDescription: String?, randomId: Int64, untilDate: Int32) -> Signal<Never, LaunchPrepaidGiveawayError> {
return account.postbox.transaction { transaction -> Signal<Never, LaunchPrepaidGiveawayError> in return account.postbox.transaction { transaction -> Signal<Never, LaunchPrepaidGiveawayError> in
var flags: Int32 = 0 var flags: Int32 = 0
if onlyNewSubscribers { if onlyNewSubscribers {
flags |= (1 << 0) flags |= (1 << 0)
} }
if showWinners {
flags |= (1 << 3)
}
var inputPeer: Api.InputPeer? var inputPeer: Api.InputPeer?
if let peer = transaction.getPeer(peerId), let apiPeer = apiInputPeer(peer) { if let peer = transaction.getPeer(peerId), let apiPeer = apiInputPeer(peer) {
inputPeer = apiPeer inputPeer = apiPeer
} }
var additionalPeers: [Api.InputPeer] = [] var additionalPeers: [Api.InputPeer] = []
if !additionalPeerIds.isEmpty { if !additionalPeerIds.isEmpty {
flags |= (1 << 1) flags |= (1 << 1)
@ -222,15 +223,16 @@ func _internal_launchPrepaidGiveaway(account: Account, peerId: EnginePeer.Id, id
} }
} }
} }
if !countries.isEmpty { if !countries.isEmpty {
flags |= (1 << 2) flags |= (1 << 2)
} }
if let _ = prizeDescription {
flags |= (1 << 4)
}
guard let inputPeer = inputPeer else { guard let inputPeer = inputPeer else {
return .complete() return .complete()
} }
return account.network.request(Api.functions.payments.launchPrepaidGiveaway(peer: inputPeer, giveawayId: id, purpose: .inputStorePaymentPremiumGiveaway(flags: flags, boostPeer: inputPeer, additionalPeers: additionalPeers, countriesIso2: countries, randomId: randomId, untilDate: untilDate, currency: "", amount: 0))) return account.network.request(Api.functions.payments.launchPrepaidGiveaway(peer: inputPeer, giveawayId: id, purpose: .inputStorePaymentPremiumGiveaway(flags: flags, boostPeer: inputPeer, additionalPeers: additionalPeers, countriesIso2: countries, prizeDescription: prizeDescription, randomId: randomId, untilDate: untilDate, currency: "", amount: 0)))
|> mapError { _ -> LaunchPrepaidGiveawayError in |> mapError { _ -> LaunchPrepaidGiveawayError in
return .generic return .generic
} }

View File

@ -62,8 +62,8 @@ public extension TelegramEngine {
return _internal_getPremiumGiveawayInfo(account: self.account, peerId: peerId, messageId: messageId) return _internal_getPremiumGiveawayInfo(account: self.account, peerId: peerId, messageId: messageId)
} }
public func launchPrepaidGiveaway(peerId: EnginePeer.Id, id: Int64, additionalPeerIds: [EnginePeer.Id], countries: [String], onlyNewSubscribers: Bool, randomId: Int64, untilDate: Int32) -> Signal<Never, LaunchPrepaidGiveawayError> { public func launchPrepaidGiveaway(peerId: EnginePeer.Id, id: Int64, additionalPeerIds: [EnginePeer.Id], countries: [String], onlyNewSubscribers: Bool, showWinners: Bool, prizeDescription: String?, randomId: Int64, untilDate: Int32) -> Signal<Never, LaunchPrepaidGiveawayError> {
return _internal_launchPrepaidGiveaway(account: self.account, peerId: peerId, id: id, additionalPeerIds: additionalPeerIds, countries: countries, onlyNewSubscribers: onlyNewSubscribers, randomId: randomId, untilDate: untilDate) return _internal_launchPrepaidGiveaway(account: self.account, peerId: peerId, id: id, additionalPeerIds: additionalPeerIds, countries: countries, onlyNewSubscribers: onlyNewSubscribers, showWinners: showWinners, prizeDescription: prizeDescription, randomId: randomId, untilDate: untilDate)
} }
} }
} }

View File

@ -33,6 +33,9 @@ public class ChatMessageGiveawayBubbleContentNode: ChatMessageBubbleContentNode
private let prizeTitleNode: TextNode private let prizeTitleNode: TextNode
private let prizeTextNode: TextNode private let prizeTextNode: TextNode
private let additionalPrizeTitleNode: TextNode
private let additionalPrizeTextNode: TextNode
private let participantsTitleNode: TextNode private let participantsTitleNode: TextNode
private let participantsTextNode: TextNode private let participantsTextNode: TextNode
@ -81,6 +84,9 @@ public class ChatMessageGiveawayBubbleContentNode: ChatMessageBubbleContentNode
self.prizeTitleNode = TextNode() self.prizeTitleNode = TextNode()
self.prizeTextNode = TextNode() self.prizeTextNode = TextNode()
self.additionalPrizeTitleNode = TextNode()
self.additionalPrizeTextNode = TextNode()
self.participantsTitleNode = TextNode() self.participantsTitleNode = TextNode()
self.participantsTextNode = TextNode() self.participantsTextNode = TextNode()
@ -101,6 +107,8 @@ public class ChatMessageGiveawayBubbleContentNode: ChatMessageBubbleContentNode
self.addSubnode(self.prizeTitleNode) self.addSubnode(self.prizeTitleNode)
self.addSubnode(self.prizeTextNode) self.addSubnode(self.prizeTextNode)
self.addSubnode(self.additionalPrizeTitleNode)
self.addSubnode(self.additionalPrizeTextNode)
self.addSubnode(self.participantsTitleNode) self.addSubnode(self.participantsTitleNode)
self.addSubnode(self.participantsTextNode) self.addSubnode(self.participantsTextNode)
self.addSubnode(self.countriesTextNode) self.addSubnode(self.countriesTextNode)
@ -181,6 +189,9 @@ public class ChatMessageGiveawayBubbleContentNode: ChatMessageBubbleContentNode
let makePrizeTitleLayout = TextNode.asyncLayout(self.prizeTitleNode) let makePrizeTitleLayout = TextNode.asyncLayout(self.prizeTitleNode)
let makePrizeTextLayout = TextNode.asyncLayout(self.prizeTextNode) let makePrizeTextLayout = TextNode.asyncLayout(self.prizeTextNode)
let makeAdditionalPrizeTitleLayout = TextNode.asyncLayout(self.additionalPrizeTitleNode)
let makeAdditionalPrizeTextLayout = TextNode.asyncLayout(self.additionalPrizeTextNode)
let makeParticipantsTitleLayout = TextNode.asyncLayout(self.participantsTitleNode) let makeParticipantsTitleLayout = TextNode.asyncLayout(self.participantsTitleNode)
let makeParticipantsTextLayout = TextNode.asyncLayout(self.participantsTextNode) let makeParticipantsTextLayout = TextNode.asyncLayout(self.participantsTextNode)
@ -232,6 +243,8 @@ public class ChatMessageGiveawayBubbleContentNode: ChatMessageBubbleContentNode
let prizeTitleString = NSAttributedString(string: item.presentationData.strings.Chat_Giveaway_Message_PrizeTitle, font: titleFont, textColor: textColor) let prizeTitleString = NSAttributedString(string: item.presentationData.strings.Chat_Giveaway_Message_PrizeTitle, font: titleFont, textColor: textColor)
var prizeTextString: NSAttributedString? var prizeTextString: NSAttributedString?
var additionalPrizeTitleString: NSAttributedString?
var additionalPrizeTextString: NSAttributedString?
if let giveaway { if let giveaway {
prizeTextString = parseMarkdownIntoAttributedString(item.presentationData.strings.Chat_Giveaway_Message_PrizeText( prizeTextString = parseMarkdownIntoAttributedString(item.presentationData.strings.Chat_Giveaway_Message_PrizeText(
item.presentationData.strings.Chat_Giveaway_Message_Subscriptions(giveaway.quantity), item.presentationData.strings.Chat_Giveaway_Message_Subscriptions(giveaway.quantity),
@ -244,6 +257,11 @@ public class ChatMessageGiveawayBubbleContentNode: ChatMessageBubbleContentNode
return ("URL", url) return ("URL", url)
} }
), textAlignment: .center) ), textAlignment: .center)
if let prizeDescription = giveaway.prizeDescription {
additionalPrizeTitleString = NSAttributedString(string: "Additional Prize", font: titleFont, textColor: textColor)
additionalPrizeTextString = NSAttributedString(string: prizeDescription, font: textFont, textColor: textColor)
}
} }
let participantsTitleString = NSAttributedString(string: item.presentationData.strings.Chat_Giveaway_Message_ParticipantsTitle, font: titleFont, textColor: textColor) let participantsTitleString = NSAttributedString(string: item.presentationData.strings.Chat_Giveaway_Message_ParticipantsTitle, font: titleFont, textColor: textColor)
@ -316,6 +334,10 @@ public class ChatMessageGiveawayBubbleContentNode: ChatMessageBubbleContentNode
let (prizeTextLayout, prizeTextApply) = makePrizeTextLayout(TextNodeLayoutArguments(attributedString: prizeTextString, backgroundColor: nil, maximumNumberOfLines: 5, truncationType: .end, constrainedSize: CGSize(width: maxTextWidth, height: CGFloat.greatestFiniteMagnitude), alignment: .center, cutout: nil, insets: UIEdgeInsets())) let (prizeTextLayout, prizeTextApply) = makePrizeTextLayout(TextNodeLayoutArguments(attributedString: prizeTextString, backgroundColor: nil, maximumNumberOfLines: 5, truncationType: .end, constrainedSize: CGSize(width: maxTextWidth, height: CGFloat.greatestFiniteMagnitude), alignment: .center, cutout: nil, insets: UIEdgeInsets()))
let (additionalPrizeTitleLayout, additionalPrizeTitleApply) = makeAdditionalPrizeTitleLayout(TextNodeLayoutArguments(attributedString: additionalPrizeTitleString, backgroundColor: nil, maximumNumberOfLines: 1, truncationType: .end, constrainedSize: CGSize(width: maxTextWidth, height: CGFloat.greatestFiniteMagnitude), alignment: .center, cutout: nil, insets: UIEdgeInsets()))
let (additionalPrizeTextLayout, additionalPrizeTextApply) = makeAdditionalPrizeTextLayout(TextNodeLayoutArguments(attributedString: additionalPrizeTextString, backgroundColor: nil, maximumNumberOfLines: 6, truncationType: .end, constrainedSize: CGSize(width: maxTextWidth, height: CGFloat.greatestFiniteMagnitude), alignment: .center, cutout: nil, insets: UIEdgeInsets()))
let (participantsTitleLayout, participantsTitleApply) = makeParticipantsTitleLayout(TextNodeLayoutArguments(attributedString: participantsTitleString, backgroundColor: nil, maximumNumberOfLines: 1, truncationType: .end, constrainedSize: CGSize(width: maxTextWidth, height: CGFloat.greatestFiniteMagnitude), alignment: .center, cutout: nil, insets: UIEdgeInsets())) let (participantsTitleLayout, participantsTitleApply) = makeParticipantsTitleLayout(TextNodeLayoutArguments(attributedString: participantsTitleString, backgroundColor: nil, maximumNumberOfLines: 1, truncationType: .end, constrainedSize: CGSize(width: maxTextWidth, height: CGFloat.greatestFiniteMagnitude), alignment: .center, cutout: nil, insets: UIEdgeInsets()))
let (participantsTextLayout, participantsTextApply) = makeParticipantsTextLayout(TextNodeLayoutArguments(attributedString: participantsTextString, backgroundColor: nil, maximumNumberOfLines: 5, truncationType: .end, constrainedSize: CGSize(width: maxTextWidth, height: CGFloat.greatestFiniteMagnitude), alignment: .center, cutout: nil, insets: UIEdgeInsets())) let (participantsTextLayout, participantsTextApply) = makeParticipantsTextLayout(TextNodeLayoutArguments(attributedString: participantsTextString, backgroundColor: nil, maximumNumberOfLines: 5, truncationType: .end, constrainedSize: CGSize(width: maxTextWidth, height: CGFloat.greatestFiniteMagnitude), alignment: .center, cutout: nil, insets: UIEdgeInsets()))
@ -423,6 +445,8 @@ public class ChatMessageGiveawayBubbleContentNode: ChatMessageBubbleContentNode
} }
maxContentWidth = max(maxContentWidth, prizeTitleLayout.size.width) maxContentWidth = max(maxContentWidth, prizeTitleLayout.size.width)
maxContentWidth = max(maxContentWidth, prizeTextLayout.size.width) maxContentWidth = max(maxContentWidth, prizeTextLayout.size.width)
maxContentWidth = max(maxContentWidth, additionalPrizeTitleLayout.size.width)
maxContentWidth = max(maxContentWidth, additionalPrizeTextLayout.size.width)
maxContentWidth = max(maxContentWidth, participantsTitleLayout.size.width) maxContentWidth = max(maxContentWidth, participantsTitleLayout.size.width)
maxContentWidth = max(maxContentWidth, participantsTextLayout.size.width) maxContentWidth = max(maxContentWidth, participantsTextLayout.size.width)
maxContentWidth = max(maxContentWidth, dateTitleLayout.size.width) maxContentWidth = max(maxContentWidth, dateTitleLayout.size.width)
@ -453,6 +477,9 @@ public class ChatMessageGiveawayBubbleContentNode: ChatMessageBubbleContentNode
var layoutSize = CGSize(width: boundingWidth, height: 49.0 + prizeTitleLayout.size.height + prizeTextLayout.size.height + participantsTitleLayout.size.height + participantsTextLayout.size.height + dateTitleLayout.size.height + dateTextLayout.size.height + buttonSize.height + buttonSpacing + 120.0) var layoutSize = CGSize(width: boundingWidth, height: 49.0 + prizeTitleLayout.size.height + prizeTextLayout.size.height + participantsTitleLayout.size.height + participantsTextLayout.size.height + dateTitleLayout.size.height + dateTextLayout.size.height + buttonSize.height + buttonSpacing + 120.0)
if additionalPrizeTextLayout.size.height > 0.0 {
layoutSize.height += additionalPrizeTitleLayout.size.height + additionalPrizeTextLayout.size.height + 7.0
}
if countriesTextLayout.size.height > 0.0 { if countriesTextLayout.size.height > 0.0 {
layoutSize.height += countriesTextLayout.size.height + 7.0 layoutSize.height += countriesTextLayout.size.height + 7.0
} }
@ -477,6 +504,8 @@ public class ChatMessageGiveawayBubbleContentNode: ChatMessageBubbleContentNode
let _ = badgeTextApply() let _ = badgeTextApply()
let _ = prizeTitleApply() let _ = prizeTitleApply()
let _ = prizeTextApply() let _ = prizeTextApply()
let _ = additionalPrizeTitleApply()
let _ = additionalPrizeTextApply()
let _ = participantsTitleApply() let _ = participantsTitleApply()
let _ = participantsTextApply() let _ = participantsTextApply()
let _ = countriesTextApply() let _ = countriesTextApply()
@ -508,6 +537,13 @@ public class ChatMessageGiveawayBubbleContentNode: ChatMessageBubbleContentNode
strongSelf.prizeTextNode.frame = CGRect(origin: CGPoint(x: floorToScreenPixels((layoutSize.width - prizeTextLayout.size.width) / 2.0), y: originY), size: prizeTextLayout.size) strongSelf.prizeTextNode.frame = CGRect(origin: CGPoint(x: floorToScreenPixels((layoutSize.width - prizeTextLayout.size.width) / 2.0), y: originY), size: prizeTextLayout.size)
originY += prizeTextLayout.size.height + largeSpacing originY += prizeTextLayout.size.height + largeSpacing
if additionalPrizeTextLayout.size.height > 0.0 {
strongSelf.additionalPrizeTitleNode.frame = CGRect(origin: CGPoint(x: floorToScreenPixels((layoutSize.width - additionalPrizeTitleLayout.size.width) / 2.0), y: originY), size: additionalPrizeTitleLayout.size)
originY += additionalPrizeTitleLayout.size.height + smallSpacing
strongSelf.additionalPrizeTextNode.frame = CGRect(origin: CGPoint(x: floorToScreenPixels((layoutSize.width - additionalPrizeTextLayout.size.width) / 2.0), y: originY), size: additionalPrizeTextLayout.size)
originY += additionalPrizeTextLayout.size.height + largeSpacing
}
strongSelf.participantsTitleNode.frame = CGRect(origin: CGPoint(x: floorToScreenPixels((layoutSize.width - participantsTitleLayout.size.width) / 2.0), y: originY), size: participantsTitleLayout.size) strongSelf.participantsTitleNode.frame = CGRect(origin: CGPoint(x: floorToScreenPixels((layoutSize.width - participantsTitleLayout.size.width) / 2.0), y: originY), size: participantsTitleLayout.size)
originY += participantsTitleLayout.size.height + smallSpacing originY += participantsTitleLayout.size.height + smallSpacing
strongSelf.participantsTextNode.frame = CGRect(origin: CGPoint(x: floorToScreenPixels((layoutSize.width - participantsTextLayout.size.width) / 2.0), y: originY), size: participantsTextLayout.size) strongSelf.participantsTextNode.frame = CGRect(origin: CGPoint(x: floorToScreenPixels((layoutSize.width - participantsTextLayout.size.width) / 2.0), y: originY), size: participantsTextLayout.size)