Skip to content

Commit c3051cb

Browse files
committed
Update API
1 parent 73b8c2d commit c3051cb

File tree

3 files changed

+26
-11
lines changed

3 files changed

+26
-11
lines changed

submodules/TelegramApi/Sources/Api0.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -933,7 +933,7 @@ fileprivate let parsers: [Int32 : (BufferReader) -> Any?] = {
933933
dict[1301522832] = { return Api.SponsoredMessage.parse_sponsoredMessage($0) }
934934
dict[1124938064] = { return Api.SponsoredMessageReportOption.parse_sponsoredMessageReportOption($0) }
935935
dict[-963180333] = { return Api.SponsoredPeer.parse_sponsoredPeer($0) }
936-
dict[-1615652352] = { return Api.StarGift.parse_starGift($0) }
936+
dict[-970274264] = { return Api.StarGift.parse_starGift($0) }
937937
dict[1678891913] = { return Api.StarGift.parse_starGiftUnique($0) }
938938
dict[-650279524] = { return Api.StarGiftAttribute.parse_starGiftAttributeBackdrop($0) }
939939
dict[970559507] = { return Api.StarGiftAttribute.parse_starGiftAttributeModel($0) }

submodules/TelegramApi/Sources/Api24.swift

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -628,14 +628,14 @@ public extension Api {
628628
}
629629
public extension Api {
630630
enum StarGift: TypeConstructorDescription {
631-
case starGift(flags: Int32, id: Int64, sticker: Api.Document, stars: Int64, availabilityRemains: Int32?, availabilityTotal: Int32?, availabilityResale: Int64?, convertStars: Int64, firstSaleDate: Int32?, lastSaleDate: Int32?, upgradeStars: Int64?, resellMinStars: Int64?)
631+
case starGift(flags: Int32, id: Int64, sticker: Api.Document, stars: Int64, availabilityRemains: Int32?, availabilityTotal: Int32?, availabilityResale: Int64?, convertStars: Int64, firstSaleDate: Int32?, lastSaleDate: Int32?, upgradeStars: Int64?, resellMinStars: Int64?, title: String?)
632632
case starGiftUnique(flags: Int32, id: Int64, title: String, slug: String, num: Int32, ownerId: Api.Peer?, ownerName: String?, ownerAddress: String?, attributes: [Api.StarGiftAttribute], availabilityIssued: Int32, availabilityTotal: Int32, giftAddress: String?, resellStars: Int64?)
633633

634634
public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) {
635635
switch self {
636-
case .starGift(let flags, let id, let sticker, let stars, let availabilityRemains, let availabilityTotal, let availabilityResale, let convertStars, let firstSaleDate, let lastSaleDate, let upgradeStars, let resellMinStars):
636+
case .starGift(let flags, let id, let sticker, let stars, let availabilityRemains, let availabilityTotal, let availabilityResale, let convertStars, let firstSaleDate, let lastSaleDate, let upgradeStars, let resellMinStars, let title):
637637
if boxed {
638-
buffer.appendInt32(-1615652352)
638+
buffer.appendInt32(-970274264)
639639
}
640640
serializeInt32(flags, buffer: buffer, boxed: false)
641641
serializeInt64(id, buffer: buffer, boxed: false)
@@ -649,6 +649,7 @@ public extension Api {
649649
if Int(flags) & Int(1 << 1) != 0 {serializeInt32(lastSaleDate!, buffer: buffer, boxed: false)}
650650
if Int(flags) & Int(1 << 3) != 0 {serializeInt64(upgradeStars!, buffer: buffer, boxed: false)}
651651
if Int(flags) & Int(1 << 4) != 0 {serializeInt64(resellMinStars!, buffer: buffer, boxed: false)}
652+
if Int(flags) & Int(1 << 5) != 0 {serializeString(title!, buffer: buffer, boxed: false)}
652653
break
653654
case .starGiftUnique(let flags, let id, let title, let slug, let num, let ownerId, let ownerName, let ownerAddress, let attributes, let availabilityIssued, let availabilityTotal, let giftAddress, let resellStars):
654655
if boxed {
@@ -677,8 +678,8 @@ public extension Api {
677678

678679
public func descriptionFields() -> (String, [(String, Any)]) {
679680
switch self {
680-
case .starGift(let flags, let id, let sticker, let stars, let availabilityRemains, let availabilityTotal, let availabilityResale, let convertStars, let firstSaleDate, let lastSaleDate, let upgradeStars, let resellMinStars):
681-
return ("starGift", [("flags", flags as Any), ("id", id as Any), ("sticker", sticker as Any), ("stars", stars as Any), ("availabilityRemains", availabilityRemains as Any), ("availabilityTotal", availabilityTotal as Any), ("availabilityResale", availabilityResale as Any), ("convertStars", convertStars as Any), ("firstSaleDate", firstSaleDate as Any), ("lastSaleDate", lastSaleDate as Any), ("upgradeStars", upgradeStars as Any), ("resellMinStars", resellMinStars as Any)])
681+
case .starGift(let flags, let id, let sticker, let stars, let availabilityRemains, let availabilityTotal, let availabilityResale, let convertStars, let firstSaleDate, let lastSaleDate, let upgradeStars, let resellMinStars, let title):
682+
return ("starGift", [("flags", flags as Any), ("id", id as Any), ("sticker", sticker as Any), ("stars", stars as Any), ("availabilityRemains", availabilityRemains as Any), ("availabilityTotal", availabilityTotal as Any), ("availabilityResale", availabilityResale as Any), ("convertStars", convertStars as Any), ("firstSaleDate", firstSaleDate as Any), ("lastSaleDate", lastSaleDate as Any), ("upgradeStars", upgradeStars as Any), ("resellMinStars", resellMinStars as Any), ("title", title as Any)])
682683
case .starGiftUnique(let flags, let id, let title, let slug, let num, let ownerId, let ownerName, let ownerAddress, let attributes, let availabilityIssued, let availabilityTotal, let giftAddress, let resellStars):
683684
return ("starGiftUnique", [("flags", flags as Any), ("id", id as Any), ("title", title as Any), ("slug", slug as Any), ("num", num as Any), ("ownerId", ownerId as Any), ("ownerName", ownerName as Any), ("ownerAddress", ownerAddress as Any), ("attributes", attributes as Any), ("availabilityIssued", availabilityIssued as Any), ("availabilityTotal", availabilityTotal as Any), ("giftAddress", giftAddress as Any), ("resellStars", resellStars as Any)])
684685
}
@@ -711,6 +712,8 @@ public extension Api {
711712
if Int(_1!) & Int(1 << 3) != 0 {_11 = reader.readInt64() }
712713
var _12: Int64?
713714
if Int(_1!) & Int(1 << 4) != 0 {_12 = reader.readInt64() }
715+
var _13: String?
716+
if Int(_1!) & Int(1 << 5) != 0 {_13 = parseString(reader) }
714717
let _c1 = _1 != nil
715718
let _c2 = _2 != nil
716719
let _c3 = _3 != nil
@@ -723,8 +726,9 @@ public extension Api {
723726
let _c10 = (Int(_1!) & Int(1 << 1) == 0) || _10 != nil
724727
let _c11 = (Int(_1!) & Int(1 << 3) == 0) || _11 != nil
725728
let _c12 = (Int(_1!) & Int(1 << 4) == 0) || _12 != nil
726-
if _c1 && _c2 && _c3 && _c4 && _c5 && _c6 && _c7 && _c8 && _c9 && _c10 && _c11 && _c12 {
727-
return Api.StarGift.starGift(flags: _1!, id: _2!, sticker: _3!, stars: _4!, availabilityRemains: _5, availabilityTotal: _6, availabilityResale: _7, convertStars: _8!, firstSaleDate: _9, lastSaleDate: _10, upgradeStars: _11, resellMinStars: _12)
729+
let _c13 = (Int(_1!) & Int(1 << 5) == 0) || _13 != nil
730+
if _c1 && _c2 && _c3 && _c4 && _c5 && _c6 && _c7 && _c8 && _c9 && _c10 && _c11 && _c12 && _c13 {
731+
return Api.StarGift.starGift(flags: _1!, id: _2!, sticker: _3!, stars: _4!, availabilityRemains: _5, availabilityTotal: _6, availabilityResale: _7, convertStars: _8!, firstSaleDate: _9, lastSaleDate: _10, upgradeStars: _11, resellMinStars: _12, title: _13)
728732
}
729733
else {
730734
return nil

submodules/TelegramCore/Sources/TelegramEngine/Payments/StarGifts.swift

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ public enum StarGift: Equatable, Codable, PostboxCoding {
4646

4747
enum CodingKeys: String, CodingKey {
4848
case id
49+
case title
4950
case file
5051
case price
5152
case convertStars
@@ -140,6 +141,7 @@ public enum StarGift: Equatable, Codable, PostboxCoding {
140141
}
141142

142143
public let id: Int64
144+
public let title: String?
143145
public let file: TelegramMediaFile
144146
public let price: Int64
145147
public let convertStars: Int64
@@ -148,8 +150,9 @@ public enum StarGift: Equatable, Codable, PostboxCoding {
148150
public let flags: Flags
149151
public let upgradeStars: Int64?
150152

151-
public init(id: Int64, file: TelegramMediaFile, price: Int64, convertStars: Int64, availability: Availability?, soldOut: SoldOut?, flags: Flags, upgradeStars: Int64?) {
153+
public init(id: Int64, title: String?, file: TelegramMediaFile, price: Int64, convertStars: Int64, availability: Availability?, soldOut: SoldOut?, flags: Flags, upgradeStars: Int64?) {
152154
self.id = id
155+
self.title = title
153156
self.file = file
154157
self.price = price
155158
self.convertStars = convertStars
@@ -162,6 +165,7 @@ public enum StarGift: Equatable, Codable, PostboxCoding {
162165
public init(from decoder: Decoder) throws {
163166
let container = try decoder.container(keyedBy: CodingKeys.self)
164167
self.id = try container.decode(Int64.self, forKey: .id)
168+
self.title = try container.decodeIfPresent(String.self, forKey: .title)
165169

166170
if let fileData = try container.decodeIfPresent(Data.self, forKey: .file), let file = PostboxDecoder(buffer: MemoryBuffer(data: fileData)).decodeRootObject() as? TelegramMediaFile {
167171
self.file = file
@@ -179,6 +183,7 @@ public enum StarGift: Equatable, Codable, PostboxCoding {
179183

180184
public init(decoder: PostboxDecoder) {
181185
self.id = decoder.decodeInt64ForKey(CodingKeys.id.rawValue, orElse: 0)
186+
self.title = decoder.decodeOptionalStringForKey(CodingKeys.title.rawValue)
182187
self.file = decoder.decodeObjectForKey(CodingKeys.file.rawValue) as! TelegramMediaFile
183188
self.price = decoder.decodeInt64ForKey(CodingKeys.price.rawValue, orElse: 0)
184189
self.convertStars = decoder.decodeInt64ForKey(CodingKeys.convertStars.rawValue, orElse: 0)
@@ -191,6 +196,7 @@ public enum StarGift: Equatable, Codable, PostboxCoding {
191196
public func encode(to encoder: Encoder) throws {
192197
var container = encoder.container(keyedBy: CodingKeys.self)
193198
try container.encode(self.id, forKey: .id)
199+
try container.encodeIfPresent(self.title, forKey: .title)
194200

195201
let encoder = PostboxEncoder()
196202
encoder.encodeRootObject(self.file)
@@ -207,6 +213,11 @@ public enum StarGift: Equatable, Codable, PostboxCoding {
207213

208214
public func encode(_ encoder: PostboxEncoder) {
209215
encoder.encodeInt64(self.id, forKey: CodingKeys.id.rawValue)
216+
if let title = self.title {
217+
encoder.encodeString(title, forKey: CodingKeys.title.rawValue)
218+
} else {
219+
encoder.encodeNil(forKey: CodingKeys.title.rawValue)
220+
}
210221
encoder.encodeObject(self.file, forKey: CodingKeys.file.rawValue)
211222
encoder.encodeInt64(self.price, forKey: CodingKeys.price.rawValue)
212223
encoder.encodeInt64(self.convertStars, forKey: CodingKeys.convertStars.rawValue)
@@ -668,7 +679,7 @@ public enum StarGift: Equatable, Codable, PostboxCoding {
668679
extension StarGift {
669680
init?(apiStarGift: Api.StarGift) {
670681
switch apiStarGift {
671-
case let .starGift(apiFlags, id, sticker, stars, availabilityRemains, availabilityTotal, availabilityResale, convertStars, firstSale, lastSale, upgradeStars, minResaleStars):
682+
case let .starGift(apiFlags, id, sticker, stars, availabilityRemains, availabilityTotal, availabilityResale, convertStars, firstSale, lastSale, upgradeStars, minResaleStars, title):
672683
var flags = StarGift.Gift.Flags()
673684
if (apiFlags & (1 << 2)) != 0 {
674685
flags.insert(.isBirthdayGift)
@@ -690,7 +701,7 @@ extension StarGift {
690701
guard let file = telegramMediaFileFromApiDocument(sticker, altDocuments: nil) else {
691702
return nil
692703
}
693-
self = .generic(StarGift.Gift(id: id, file: file, price: stars, convertStars: convertStars, availability: availability, soldOut: soldOut, flags: flags, upgradeStars: upgradeStars))
704+
self = .generic(StarGift.Gift(id: id, title: title, file: file, price: stars, convertStars: convertStars, availability: availability, soldOut: soldOut, flags: flags, upgradeStars: upgradeStars))
694705
case let .starGiftUnique(_, id, title, slug, num, ownerPeerId, ownerName, ownerAddress, attributes, availabilityIssued, availabilityTotal, giftAddress, reselltars):
695706
let owner: StarGift.UniqueGift.Owner
696707
if let ownerAddress {

0 commit comments

Comments
 (0)