diff --git a/submodules/TelegramApi/Sources/Api0.swift b/submodules/TelegramApi/Sources/Api0.swift index e3cafd3663..7080823c5f 100644 --- a/submodules/TelegramApi/Sources/Api0.swift +++ b/submodules/TelegramApi/Sources/Api0.swift @@ -617,6 +617,7 @@ fileprivate let parsers: [Int32 : (BufferReader) -> Any?] = { dict[1348510708] = { return Api.MessageAction.parse_messageActionSetChatWallPaper($0) } dict[1007897979] = { return Api.MessageAction.parse_messageActionSetMessagesTTL($0) } dict[-229775366] = { return Api.MessageAction.parse_messageActionStarGift($0) } + dict[965651149] = { return Api.MessageAction.parse_messageActionStarGiftAuctionBid($0) } dict[-1787656893] = { return Api.MessageAction.parse_messageActionStarGiftUnique($0) } dict[747579941] = { return Api.MessageAction.parse_messageActionSuggestBirthday($0) } dict[1474192222] = { return Api.MessageAction.parse_messageActionSuggestProfilePhoto($0) } @@ -973,7 +974,7 @@ fileprivate let parsers: [Int32 : (BufferReader) -> Any?] = { dict[2109703795] = { return Api.SponsoredMessage.parse_sponsoredMessage($0) } dict[1124938064] = { return Api.SponsoredMessageReportOption.parse_sponsoredMessageReportOption($0) } dict[-963180333] = { return Api.SponsoredPeer.parse_sponsoredPeer($0) } - dict[-2136190013] = { return Api.StarGift.parse_starGift($0) } + dict[761666756] = { return Api.StarGift.parse_starGift($0) } dict[-1329630181] = { return Api.StarGift.parse_starGiftUnique($0) } dict[-650279524] = { return Api.StarGiftAttribute.parse_starGiftAttributeBackdrop($0) } dict[970559507] = { return Api.StarGiftAttribute.parse_starGiftAttributeModel($0) } @@ -983,7 +984,8 @@ fileprivate let parsers: [Int32 : (BufferReader) -> Any?] = { dict[520210263] = { return Api.StarGiftAttributeId.parse_starGiftAttributeIdBackdrop($0) } dict[1219145276] = { return Api.StarGiftAttributeId.parse_starGiftAttributeIdModel($0) } dict[1242965043] = { return Api.StarGiftAttributeId.parse_starGiftAttributeIdPattern($0) } - dict[-483580782] = { return Api.StarGiftAuctionState.parse_starGiftAuctionState($0) } + dict[1219300270] = { return Api.StarGiftAuctionAcquiredGift.parse_starGiftAuctionAcquiredGift($0) } + dict[-1707438777] = { return Api.StarGiftAuctionState.parse_starGiftAuctionState($0) } dict[676935593] = { return Api.StarGiftAuctionState.parse_starGiftAuctionStateFinished($0) } dict[-30197422] = { return Api.StarGiftAuctionState.parse_starGiftAuctionStateNotModified($0) } dict[-165829476] = { return Api.StarGiftAuctionUserState.parse_starGiftAuctionUserState($0) } @@ -1480,6 +1482,7 @@ fileprivate let parsers: [Int32 : (BufferReader) -> Any?] = { dict[-1803939105] = { return Api.payments.ResaleStarGifts.parse_resaleStarGifts($0) } dict[-74456004] = { return Api.payments.SavedInfo.parse_savedInfo($0) } dict[-1779201615] = { return Api.payments.SavedStarGifts.parse_savedStarGifts($0) } + dict[2103169520] = { return Api.payments.StarGiftAuctionAcquiredGifts.parse_starGiftAuctionAcquiredGifts($0) } dict[-2061303084] = { return Api.payments.StarGiftAuctionState.parse_starGiftAuctionState($0) } dict[-1977011469] = { return Api.payments.StarGiftCollections.parse_starGiftCollections($0) } dict[-1598402793] = { return Api.payments.StarGiftCollections.parse_starGiftCollectionsNotModified($0) } @@ -2215,6 +2218,8 @@ public extension Api { _1.serialize(buffer, boxed) case let _1 as Api.StarGiftAttributeId: _1.serialize(buffer, boxed) + case let _1 as Api.StarGiftAuctionAcquiredGift: + _1.serialize(buffer, boxed) case let _1 as Api.StarGiftAuctionState: _1.serialize(buffer, boxed) case let _1 as Api.StarGiftAuctionUserState: @@ -2635,6 +2640,8 @@ public extension Api { _1.serialize(buffer, boxed) case let _1 as Api.payments.SavedStarGifts: _1.serialize(buffer, boxed) + case let _1 as Api.payments.StarGiftAuctionAcquiredGifts: + _1.serialize(buffer, boxed) case let _1 as Api.payments.StarGiftAuctionState: _1.serialize(buffer, boxed) case let _1 as Api.payments.StarGiftCollections: diff --git a/submodules/TelegramApi/Sources/Api15.swift b/submodules/TelegramApi/Sources/Api15.swift index 4a45cedc4c..6e85f4ca69 100644 --- a/submodules/TelegramApi/Sources/Api15.swift +++ b/submodules/TelegramApi/Sources/Api15.swift @@ -1070,6 +1070,7 @@ public extension Api { case messageActionSetChatWallPaper(flags: Int32, wallpaper: Api.WallPaper) case messageActionSetMessagesTTL(flags: Int32, period: Int32, autoSettingFrom: Int64?) case messageActionStarGift(flags: Int32, gift: Api.StarGift, message: Api.TextWithEntities?, convertStars: Int64?, upgradeMsgId: Int32?, upgradeStars: Int64?, fromId: Api.Peer?, peer: Api.Peer?, savedId: Int64?, prepaidUpgradeHash: String?, giftMsgId: Int32?) + case messageActionStarGiftAuctionBid(flags: Int32, gift: Api.StarGift, bidAmount: Int64, message: Api.TextWithEntities?, peer: Api.Peer?, nextDropAt: Int32?) case messageActionStarGiftUnique(flags: Int32, gift: Api.StarGift, canExportAt: Int32?, transferStars: Int64?, fromId: Api.Peer?, peer: Api.Peer?, savedId: Int64?, resaleAmount: Api.StarsAmount?, canTransferAt: Int32?, canResellAt: Int32?, dropOriginalDetailsStars: Int64?) case messageActionSuggestBirthday(birthday: Api.Birthday) case messageActionSuggestProfilePhoto(photo: Api.Photo) @@ -1476,6 +1477,17 @@ public extension Api { if Int(flags) & Int(1 << 14) != 0 {serializeString(prepaidUpgradeHash!, buffer: buffer, boxed: false)} if Int(flags) & Int(1 << 15) != 0 {serializeInt32(giftMsgId!, buffer: buffer, boxed: false)} break + case .messageActionStarGiftAuctionBid(let flags, let gift, let bidAmount, let message, let peer, let nextDropAt): + if boxed { + buffer.appendInt32(965651149) + } + serializeInt32(flags, buffer: buffer, boxed: false) + gift.serialize(buffer, true) + serializeInt64(bidAmount, buffer: buffer, boxed: false) + if Int(flags) & Int(1 << 1) != 0 {message!.serialize(buffer, true)} + if Int(flags) & Int(1 << 2) != 0 {peer!.serialize(buffer, true)} + if Int(flags) & Int(1 << 3) != 0 {serializeInt32(nextDropAt!, buffer: buffer, boxed: false)} + break case .messageActionStarGiftUnique(let flags, let gift, let canExportAt, let transferStars, let fromId, let peer, let savedId, let resaleAmount, let canTransferAt, let canResellAt, let dropOriginalDetailsStars): if boxed { buffer.appendInt32(-1787656893) @@ -1679,6 +1691,8 @@ public extension Api { return ("messageActionSetMessagesTTL", [("flags", flags as Any), ("period", period as Any), ("autoSettingFrom", autoSettingFrom as Any)]) case .messageActionStarGift(let flags, let gift, let message, let convertStars, let upgradeMsgId, let upgradeStars, let fromId, let peer, let savedId, let prepaidUpgradeHash, let giftMsgId): return ("messageActionStarGift", [("flags", flags as Any), ("gift", gift as Any), ("message", message as Any), ("convertStars", convertStars as Any), ("upgradeMsgId", upgradeMsgId as Any), ("upgradeStars", upgradeStars as Any), ("fromId", fromId as Any), ("peer", peer as Any), ("savedId", savedId as Any), ("prepaidUpgradeHash", prepaidUpgradeHash as Any), ("giftMsgId", giftMsgId as Any)]) + case .messageActionStarGiftAuctionBid(let flags, let gift, let bidAmount, let message, let peer, let nextDropAt): + return ("messageActionStarGiftAuctionBid", [("flags", flags as Any), ("gift", gift as Any), ("bidAmount", bidAmount as Any), ("message", message as Any), ("peer", peer as Any), ("nextDropAt", nextDropAt as Any)]) case .messageActionStarGiftUnique(let flags, let gift, let canExportAt, let transferStars, let fromId, let peer, let savedId, let resaleAmount, let canTransferAt, let canResellAt, let dropOriginalDetailsStars): return ("messageActionStarGiftUnique", [("flags", flags as Any), ("gift", gift as Any), ("canExportAt", canExportAt as Any), ("transferStars", transferStars as Any), ("fromId", fromId as Any), ("peer", peer as Any), ("savedId", savedId as Any), ("resaleAmount", resaleAmount as Any), ("canTransferAt", canTransferAt as Any), ("canResellAt", canResellAt as Any), ("dropOriginalDetailsStars", dropOriginalDetailsStars as Any)]) case .messageActionSuggestBirthday(let birthday): @@ -2467,6 +2481,38 @@ public extension Api { return nil } } + public static func parse_messageActionStarGiftAuctionBid(_ reader: BufferReader) -> MessageAction? { + var _1: Int32? + _1 = reader.readInt32() + var _2: Api.StarGift? + if let signature = reader.readInt32() { + _2 = Api.parse(reader, signature: signature) as? Api.StarGift + } + var _3: Int64? + _3 = reader.readInt64() + var _4: Api.TextWithEntities? + if Int(_1!) & Int(1 << 1) != 0 {if let signature = reader.readInt32() { + _4 = Api.parse(reader, signature: signature) as? Api.TextWithEntities + } } + var _5: Api.Peer? + if Int(_1!) & Int(1 << 2) != 0 {if let signature = reader.readInt32() { + _5 = Api.parse(reader, signature: signature) as? Api.Peer + } } + var _6: Int32? + if Int(_1!) & Int(1 << 3) != 0 {_6 = reader.readInt32() } + let _c1 = _1 != nil + let _c2 = _2 != nil + let _c3 = _3 != nil + let _c4 = (Int(_1!) & Int(1 << 1) == 0) || _4 != nil + let _c5 = (Int(_1!) & Int(1 << 2) == 0) || _5 != nil + let _c6 = (Int(_1!) & Int(1 << 3) == 0) || _6 != nil + if _c1 && _c2 && _c3 && _c4 && _c5 && _c6 { + return Api.MessageAction.messageActionStarGiftAuctionBid(flags: _1!, gift: _2!, bidAmount: _3!, message: _4, peer: _5, nextDropAt: _6) + } + else { + return nil + } + } public static func parse_messageActionStarGiftUnique(_ reader: BufferReader) -> MessageAction? { var _1: Int32? _1 = reader.readInt32() diff --git a/submodules/TelegramApi/Sources/Api25.swift b/submodules/TelegramApi/Sources/Api25.swift index c7c6da55ad..d8d0bb3744 100644 --- a/submodules/TelegramApi/Sources/Api25.swift +++ b/submodules/TelegramApi/Sources/Api25.swift @@ -288,14 +288,14 @@ public extension Api { } public extension Api { enum StarGift: TypeConstructorDescription { - 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?, releasedBy: Api.Peer?, perUserTotal: Int32?, perUserRemains: Int32?, lockedUntilDate: Int32?) + 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?, releasedBy: Api.Peer?, perUserTotal: Int32?, perUserRemains: Int32?, lockedUntilDate: Int32?, dropSize: Int32?) case starGiftUnique(flags: Int32, id: Int64, giftId: Int64, title: String, slug: String, num: Int32, ownerId: Api.Peer?, ownerName: String?, ownerAddress: String?, attributes: [Api.StarGiftAttribute], availabilityIssued: Int32, availabilityTotal: Int32, giftAddress: String?, resellAmount: [Api.StarsAmount]?, releasedBy: Api.Peer?, valueAmount: Int64?, valueCurrency: String?, themePeer: Api.Peer?, peerColor: Api.PeerColor?, hostId: Api.Peer?) public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) { switch self { - 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, let releasedBy, let perUserTotal, let perUserRemains, let lockedUntilDate): + 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, let releasedBy, let perUserTotal, let perUserRemains, let lockedUntilDate, let dropSize): if boxed { - buffer.appendInt32(-2136190013) + buffer.appendInt32(761666756) } serializeInt32(flags, buffer: buffer, boxed: false) serializeInt64(id, buffer: buffer, boxed: false) @@ -314,6 +314,7 @@ public extension Api { if Int(flags) & Int(1 << 8) != 0 {serializeInt32(perUserTotal!, buffer: buffer, boxed: false)} if Int(flags) & Int(1 << 8) != 0 {serializeInt32(perUserRemains!, buffer: buffer, boxed: false)} if Int(flags) & Int(1 << 9) != 0 {serializeInt32(lockedUntilDate!, buffer: buffer, boxed: false)} + if Int(flags) & Int(1 << 11) != 0 {serializeInt32(dropSize!, buffer: buffer, boxed: false)} break case .starGiftUnique(let flags, let id, let giftId, let title, let slug, let num, let ownerId, let ownerName, let ownerAddress, let attributes, let availabilityIssued, let availabilityTotal, let giftAddress, let resellAmount, let releasedBy, let valueAmount, let valueCurrency, let themePeer, let peerColor, let hostId): if boxed { @@ -353,8 +354,8 @@ public extension Api { public func descriptionFields() -> (String, [(String, Any)]) { switch self { - 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, let releasedBy, let perUserTotal, let perUserRemains, let lockedUntilDate): - 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), ("releasedBy", releasedBy as Any), ("perUserTotal", perUserTotal as Any), ("perUserRemains", perUserRemains as Any), ("lockedUntilDate", lockedUntilDate as Any)]) + 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, let releasedBy, let perUserTotal, let perUserRemains, let lockedUntilDate, let dropSize): + 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), ("releasedBy", releasedBy as Any), ("perUserTotal", perUserTotal as Any), ("perUserRemains", perUserRemains as Any), ("lockedUntilDate", lockedUntilDate as Any), ("dropSize", dropSize as Any)]) case .starGiftUnique(let flags, let id, let giftId, let title, let slug, let num, let ownerId, let ownerName, let ownerAddress, let attributes, let availabilityIssued, let availabilityTotal, let giftAddress, let resellAmount, let releasedBy, let valueAmount, let valueCurrency, let themePeer, let peerColor, let hostId): return ("starGiftUnique", [("flags", flags as Any), ("id", id as Any), ("giftId", giftId 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), ("resellAmount", resellAmount as Any), ("releasedBy", releasedBy as Any), ("valueAmount", valueAmount as Any), ("valueCurrency", valueCurrency as Any), ("themePeer", themePeer as Any), ("peerColor", peerColor as Any), ("hostId", hostId as Any)]) } @@ -399,6 +400,8 @@ public extension Api { if Int(_1!) & Int(1 << 8) != 0 {_16 = reader.readInt32() } var _17: Int32? if Int(_1!) & Int(1 << 9) != 0 {_17 = reader.readInt32() } + var _18: Int32? + if Int(_1!) & Int(1 << 11) != 0 {_18 = reader.readInt32() } let _c1 = _1 != nil let _c2 = _2 != nil let _c3 = _3 != nil @@ -416,8 +419,9 @@ public extension Api { let _c15 = (Int(_1!) & Int(1 << 8) == 0) || _15 != nil let _c16 = (Int(_1!) & Int(1 << 8) == 0) || _16 != nil let _c17 = (Int(_1!) & Int(1 << 9) == 0) || _17 != nil - if _c1 && _c2 && _c3 && _c4 && _c5 && _c6 && _c7 && _c8 && _c9 && _c10 && _c11 && _c12 && _c13 && _c14 && _c15 && _c16 && _c17 { - 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, releasedBy: _14, perUserTotal: _15, perUserRemains: _16, lockedUntilDate: _17) + let _c18 = (Int(_1!) & Int(1 << 11) == 0) || _18 != nil + if _c1 && _c2 && _c3 && _c4 && _c5 && _c6 && _c7 && _c8 && _c9 && _c10 && _c11 && _c12 && _c13 && _c14 && _c15 && _c16 && _c17 && _c18 { + 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, releasedBy: _14, perUserTotal: _15, perUserRemains: _16, lockedUntilDate: _17, dropSize: _18) } else { return nil @@ -788,17 +792,77 @@ public extension Api { } } +public extension Api { + enum StarGiftAuctionAcquiredGift: TypeConstructorDescription { + case starGiftAuctionAcquiredGift(flags: Int32, peer: Api.Peer, date: Int32, bidAmount: Int64, pos: Int32, message: Api.TextWithEntities?) + + public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) { + switch self { + case .starGiftAuctionAcquiredGift(let flags, let peer, let date, let bidAmount, let pos, let message): + if boxed { + buffer.appendInt32(1219300270) + } + serializeInt32(flags, buffer: buffer, boxed: false) + peer.serialize(buffer, true) + serializeInt32(date, buffer: buffer, boxed: false) + serializeInt64(bidAmount, buffer: buffer, boxed: false) + serializeInt32(pos, buffer: buffer, boxed: false) + if Int(flags) & Int(1 << 1) != 0 {message!.serialize(buffer, true)} + break + } + } + + public func descriptionFields() -> (String, [(String, Any)]) { + switch self { + case .starGiftAuctionAcquiredGift(let flags, let peer, let date, let bidAmount, let pos, let message): + return ("starGiftAuctionAcquiredGift", [("flags", flags as Any), ("peer", peer as Any), ("date", date as Any), ("bidAmount", bidAmount as Any), ("pos", pos as Any), ("message", message as Any)]) + } + } + + public static func parse_starGiftAuctionAcquiredGift(_ reader: BufferReader) -> StarGiftAuctionAcquiredGift? { + var _1: Int32? + _1 = reader.readInt32() + var _2: Api.Peer? + if let signature = reader.readInt32() { + _2 = Api.parse(reader, signature: signature) as? Api.Peer + } + var _3: Int32? + _3 = reader.readInt32() + var _4: Int64? + _4 = reader.readInt64() + var _5: Int32? + _5 = reader.readInt32() + var _6: Api.TextWithEntities? + if Int(_1!) & Int(1 << 1) != 0 {if let signature = reader.readInt32() { + _6 = Api.parse(reader, signature: signature) as? Api.TextWithEntities + } } + let _c1 = _1 != nil + let _c2 = _2 != nil + let _c3 = _3 != nil + let _c4 = _4 != nil + let _c5 = _5 != nil + let _c6 = (Int(_1!) & Int(1 << 1) == 0) || _6 != nil + if _c1 && _c2 && _c3 && _c4 && _c5 && _c6 { + return Api.StarGiftAuctionAcquiredGift.starGiftAuctionAcquiredGift(flags: _1!, peer: _2!, date: _3!, bidAmount: _4!, pos: _5!, message: _6) + } + else { + return nil + } + } + + } +} public extension Api { enum StarGiftAuctionState: TypeConstructorDescription { - case starGiftAuctionState(version: Int32, minBidAmount: Int64, bidLevels: [Api.AuctionBidLevel], topBidders: [Int64], dropSize: Int32, nextDropAt: Int32, dropsLeft: Int32, dropsTotal: Int32) + case starGiftAuctionState(version: Int32, minBidAmount: Int64, bidLevels: [Api.AuctionBidLevel], topBidders: [Int64], nextDropAt: Int32, giftsLeft: Int32, dropsLeft: Int32, dropsTotal: Int32) case starGiftAuctionStateFinished case starGiftAuctionStateNotModified public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) { switch self { - case .starGiftAuctionState(let version, let minBidAmount, let bidLevels, let topBidders, let dropSize, let nextDropAt, let dropsLeft, let dropsTotal): + case .starGiftAuctionState(let version, let minBidAmount, let bidLevels, let topBidders, let nextDropAt, let giftsLeft, let dropsLeft, let dropsTotal): if boxed { - buffer.appendInt32(-483580782) + buffer.appendInt32(-1707438777) } serializeInt32(version, buffer: buffer, boxed: false) serializeInt64(minBidAmount, buffer: buffer, boxed: false) @@ -812,8 +876,8 @@ public extension Api { for item in topBidders { serializeInt64(item, buffer: buffer, boxed: false) } - serializeInt32(dropSize, buffer: buffer, boxed: false) serializeInt32(nextDropAt, buffer: buffer, boxed: false) + serializeInt32(giftsLeft, buffer: buffer, boxed: false) serializeInt32(dropsLeft, buffer: buffer, boxed: false) serializeInt32(dropsTotal, buffer: buffer, boxed: false) break @@ -834,8 +898,8 @@ public extension Api { public func descriptionFields() -> (String, [(String, Any)]) { switch self { - case .starGiftAuctionState(let version, let minBidAmount, let bidLevels, let topBidders, let dropSize, let nextDropAt, let dropsLeft, let dropsTotal): - return ("starGiftAuctionState", [("version", version as Any), ("minBidAmount", minBidAmount as Any), ("bidLevels", bidLevels as Any), ("topBidders", topBidders as Any), ("dropSize", dropSize as Any), ("nextDropAt", nextDropAt as Any), ("dropsLeft", dropsLeft as Any), ("dropsTotal", dropsTotal as Any)]) + case .starGiftAuctionState(let version, let minBidAmount, let bidLevels, let topBidders, let nextDropAt, let giftsLeft, let dropsLeft, let dropsTotal): + return ("starGiftAuctionState", [("version", version as Any), ("minBidAmount", minBidAmount as Any), ("bidLevels", bidLevels as Any), ("topBidders", topBidders as Any), ("nextDropAt", nextDropAt as Any), ("giftsLeft", giftsLeft as Any), ("dropsLeft", dropsLeft as Any), ("dropsTotal", dropsTotal as Any)]) case .starGiftAuctionStateFinished: return ("starGiftAuctionStateFinished", []) case .starGiftAuctionStateNotModified: @@ -873,7 +937,7 @@ public extension Api { let _c7 = _7 != nil let _c8 = _8 != nil if _c1 && _c2 && _c3 && _c4 && _c5 && _c6 && _c7 && _c8 { - return Api.StarGiftAuctionState.starGiftAuctionState(version: _1!, minBidAmount: _2!, bidLevels: _3!, topBidders: _4!, dropSize: _5!, nextDropAt: _6!, dropsLeft: _7!, dropsTotal: _8!) + return Api.StarGiftAuctionState.starGiftAuctionState(version: _1!, minBidAmount: _2!, bidLevels: _3!, topBidders: _4!, nextDropAt: _5!, giftsLeft: _6!, dropsLeft: _7!, dropsTotal: _8!) } else { return nil @@ -1542,55 +1606,3 @@ public extension Api { } } -public extension Api { - enum StarsTopupOption: TypeConstructorDescription { - case starsTopupOption(flags: Int32, stars: Int64, storeProduct: String?, currency: String, amount: Int64) - - public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) { - switch self { - case .starsTopupOption(let flags, let stars, let storeProduct, let currency, let amount): - if boxed { - buffer.appendInt32(198776256) - } - serializeInt32(flags, buffer: buffer, boxed: false) - serializeInt64(stars, buffer: buffer, boxed: false) - if Int(flags) & Int(1 << 0) != 0 {serializeString(storeProduct!, buffer: buffer, boxed: false)} - serializeString(currency, buffer: buffer, boxed: false) - serializeInt64(amount, buffer: buffer, boxed: false) - break - } - } - - public func descriptionFields() -> (String, [(String, Any)]) { - switch self { - case .starsTopupOption(let flags, let stars, let storeProduct, let currency, let amount): - return ("starsTopupOption", [("flags", flags as Any), ("stars", stars as Any), ("storeProduct", storeProduct as Any), ("currency", currency as Any), ("amount", amount as Any)]) - } - } - - public static func parse_starsTopupOption(_ reader: BufferReader) -> StarsTopupOption? { - var _1: Int32? - _1 = reader.readInt32() - var _2: Int64? - _2 = reader.readInt64() - var _3: String? - if Int(_1!) & Int(1 << 0) != 0 {_3 = parseString(reader) } - var _4: String? - _4 = parseString(reader) - var _5: Int64? - _5 = reader.readInt64() - let _c1 = _1 != nil - let _c2 = _2 != nil - let _c3 = (Int(_1!) & Int(1 << 0) == 0) || _3 != nil - let _c4 = _4 != nil - let _c5 = _5 != nil - if _c1 && _c2 && _c3 && _c4 && _c5 { - return Api.StarsTopupOption.starsTopupOption(flags: _1!, stars: _2!, storeProduct: _3, currency: _4!, amount: _5!) - } - else { - return nil - } - } - - } -} diff --git a/submodules/TelegramApi/Sources/Api26.swift b/submodules/TelegramApi/Sources/Api26.swift index 20bf032043..96d4ba0d0a 100644 --- a/submodules/TelegramApi/Sources/Api26.swift +++ b/submodules/TelegramApi/Sources/Api26.swift @@ -1,3 +1,55 @@ +public extension Api { + enum StarsTopupOption: TypeConstructorDescription { + case starsTopupOption(flags: Int32, stars: Int64, storeProduct: String?, currency: String, amount: Int64) + + public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) { + switch self { + case .starsTopupOption(let flags, let stars, let storeProduct, let currency, let amount): + if boxed { + buffer.appendInt32(198776256) + } + serializeInt32(flags, buffer: buffer, boxed: false) + serializeInt64(stars, buffer: buffer, boxed: false) + if Int(flags) & Int(1 << 0) != 0 {serializeString(storeProduct!, buffer: buffer, boxed: false)} + serializeString(currency, buffer: buffer, boxed: false) + serializeInt64(amount, buffer: buffer, boxed: false) + break + } + } + + public func descriptionFields() -> (String, [(String, Any)]) { + switch self { + case .starsTopupOption(let flags, let stars, let storeProduct, let currency, let amount): + return ("starsTopupOption", [("flags", flags as Any), ("stars", stars as Any), ("storeProduct", storeProduct as Any), ("currency", currency as Any), ("amount", amount as Any)]) + } + } + + public static func parse_starsTopupOption(_ reader: BufferReader) -> StarsTopupOption? { + var _1: Int32? + _1 = reader.readInt32() + var _2: Int64? + _2 = reader.readInt64() + var _3: String? + if Int(_1!) & Int(1 << 0) != 0 {_3 = parseString(reader) } + var _4: String? + _4 = parseString(reader) + var _5: Int64? + _5 = reader.readInt64() + let _c1 = _1 != nil + let _c2 = _2 != nil + let _c3 = (Int(_1!) & Int(1 << 0) == 0) || _3 != nil + let _c4 = _4 != nil + let _c5 = _5 != nil + if _c1 && _c2 && _c3 && _c4 && _c5 { + return Api.StarsTopupOption.starsTopupOption(flags: _1!, stars: _2!, storeProduct: _3, currency: _4!, amount: _5!) + } + else { + return nil + } + } + + } +} public extension Api { enum StarsTransaction: TypeConstructorDescription { case starsTransaction(flags: Int32, id: String, amount: Api.StarsAmount, date: Int32, peer: Api.StarsTransactionPeer, title: String?, description: String?, photo: Api.WebDocument?, transactionDate: Int32?, transactionUrl: String?, botPayload: Buffer?, msgId: Int32?, extendedMedia: [Api.MessageMedia]?, subscriptionPeriod: Int32?, giveawayPostId: Int32?, stargift: Api.StarGift?, floodskipNumber: Int32?, starrefCommissionPermille: Int32?, starrefPeer: Api.Peer?, starrefAmount: Api.StarsAmount?, paidMessages: Int32?, premiumGiftMonths: Int32?, adsProceedsFromDate: Int32?, adsProceedsToDate: Int32?) diff --git a/submodules/TelegramApi/Sources/Api36.swift b/submodules/TelegramApi/Sources/Api36.swift index 9a73b7be16..ad96419d87 100644 --- a/submodules/TelegramApi/Sources/Api36.swift +++ b/submodules/TelegramApi/Sources/Api36.swift @@ -276,6 +276,68 @@ public extension Api.payments { } } +public extension Api.payments { + enum StarGiftAuctionAcquiredGifts: TypeConstructorDescription { + case starGiftAuctionAcquiredGifts(gifts: [Api.StarGiftAuctionAcquiredGift], users: [Api.User], chats: [Api.Chat]) + + public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) { + switch self { + case .starGiftAuctionAcquiredGifts(let gifts, let users, let chats): + if boxed { + buffer.appendInt32(2103169520) + } + buffer.appendInt32(481674261) + buffer.appendInt32(Int32(gifts.count)) + for item in gifts { + item.serialize(buffer, true) + } + buffer.appendInt32(481674261) + buffer.appendInt32(Int32(users.count)) + for item in users { + item.serialize(buffer, true) + } + buffer.appendInt32(481674261) + buffer.appendInt32(Int32(chats.count)) + for item in chats { + item.serialize(buffer, true) + } + break + } + } + + public func descriptionFields() -> (String, [(String, Any)]) { + switch self { + case .starGiftAuctionAcquiredGifts(let gifts, let users, let chats): + return ("starGiftAuctionAcquiredGifts", [("gifts", gifts as Any), ("users", users as Any), ("chats", chats as Any)]) + } + } + + public static func parse_starGiftAuctionAcquiredGifts(_ reader: BufferReader) -> StarGiftAuctionAcquiredGifts? { + var _1: [Api.StarGiftAuctionAcquiredGift]? + if let _ = reader.readInt32() { + _1 = Api.parseVector(reader, elementSignature: 0, elementType: Api.StarGiftAuctionAcquiredGift.self) + } + var _2: [Api.User]? + if let _ = reader.readInt32() { + _2 = Api.parseVector(reader, elementSignature: 0, elementType: Api.User.self) + } + var _3: [Api.Chat]? + if let _ = reader.readInt32() { + _3 = Api.parseVector(reader, elementSignature: 0, elementType: Api.Chat.self) + } + let _c1 = _1 != nil + let _c2 = _2 != nil + let _c3 = _3 != nil + if _c1 && _c2 && _c3 { + return Api.payments.StarGiftAuctionAcquiredGifts.starGiftAuctionAcquiredGifts(gifts: _1!, users: _2!, chats: _3!) + } + else { + return nil + } + } + + } +} public extension Api.payments { enum StarGiftAuctionState: TypeConstructorDescription { case starGiftAuctionState(state: Api.StarGiftAuctionState, userState: Api.StarGiftAuctionUserState, timeout: Int32, users: [Api.User]) @@ -1624,67 +1686,3 @@ public extension Api.photos { } } -public extension Api.premium { - enum BoostsList: TypeConstructorDescription { - case boostsList(flags: Int32, count: Int32, boosts: [Api.Boost], nextOffset: String?, users: [Api.User]) - - public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) { - switch self { - case .boostsList(let flags, let count, let boosts, let nextOffset, let users): - if boxed { - buffer.appendInt32(-2030542532) - } - serializeInt32(flags, buffer: buffer, boxed: false) - serializeInt32(count, buffer: buffer, boxed: false) - buffer.appendInt32(481674261) - buffer.appendInt32(Int32(boosts.count)) - for item in boosts { - item.serialize(buffer, true) - } - if Int(flags) & Int(1 << 0) != 0 {serializeString(nextOffset!, buffer: buffer, boxed: false)} - buffer.appendInt32(481674261) - buffer.appendInt32(Int32(users.count)) - for item in users { - item.serialize(buffer, true) - } - break - } - } - - public func descriptionFields() -> (String, [(String, Any)]) { - switch self { - case .boostsList(let flags, let count, let boosts, let nextOffset, let users): - return ("boostsList", [("flags", flags as Any), ("count", count as Any), ("boosts", boosts as Any), ("nextOffset", nextOffset as Any), ("users", users as Any)]) - } - } - - public static func parse_boostsList(_ reader: BufferReader) -> BoostsList? { - var _1: Int32? - _1 = reader.readInt32() - var _2: Int32? - _2 = reader.readInt32() - var _3: [Api.Boost]? - if let _ = reader.readInt32() { - _3 = Api.parseVector(reader, elementSignature: 0, elementType: Api.Boost.self) - } - var _4: String? - if Int(_1!) & Int(1 << 0) != 0 {_4 = parseString(reader) } - var _5: [Api.User]? - if let _ = reader.readInt32() { - _5 = Api.parseVector(reader, elementSignature: 0, elementType: Api.User.self) - } - let _c1 = _1 != nil - let _c2 = _2 != nil - let _c3 = _3 != nil - let _c4 = (Int(_1!) & Int(1 << 0) == 0) || _4 != nil - let _c5 = _5 != nil - if _c1 && _c2 && _c3 && _c4 && _c5 { - return Api.premium.BoostsList.boostsList(flags: _1!, count: _2!, boosts: _3!, nextOffset: _4, users: _5!) - } - else { - return nil - } - } - - } -} diff --git a/submodules/TelegramApi/Sources/Api37.swift b/submodules/TelegramApi/Sources/Api37.swift index 273c78fed3..a76ef6a6a9 100644 --- a/submodules/TelegramApi/Sources/Api37.swift +++ b/submodules/TelegramApi/Sources/Api37.swift @@ -1,3 +1,67 @@ +public extension Api.premium { + enum BoostsList: TypeConstructorDescription { + case boostsList(flags: Int32, count: Int32, boosts: [Api.Boost], nextOffset: String?, users: [Api.User]) + + public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) { + switch self { + case .boostsList(let flags, let count, let boosts, let nextOffset, let users): + if boxed { + buffer.appendInt32(-2030542532) + } + serializeInt32(flags, buffer: buffer, boxed: false) + serializeInt32(count, buffer: buffer, boxed: false) + buffer.appendInt32(481674261) + buffer.appendInt32(Int32(boosts.count)) + for item in boosts { + item.serialize(buffer, true) + } + if Int(flags) & Int(1 << 0) != 0 {serializeString(nextOffset!, buffer: buffer, boxed: false)} + buffer.appendInt32(481674261) + buffer.appendInt32(Int32(users.count)) + for item in users { + item.serialize(buffer, true) + } + break + } + } + + public func descriptionFields() -> (String, [(String, Any)]) { + switch self { + case .boostsList(let flags, let count, let boosts, let nextOffset, let users): + return ("boostsList", [("flags", flags as Any), ("count", count as Any), ("boosts", boosts as Any), ("nextOffset", nextOffset as Any), ("users", users as Any)]) + } + } + + public static func parse_boostsList(_ reader: BufferReader) -> BoostsList? { + var _1: Int32? + _1 = reader.readInt32() + var _2: Int32? + _2 = reader.readInt32() + var _3: [Api.Boost]? + if let _ = reader.readInt32() { + _3 = Api.parseVector(reader, elementSignature: 0, elementType: Api.Boost.self) + } + var _4: String? + if Int(_1!) & Int(1 << 0) != 0 {_4 = parseString(reader) } + var _5: [Api.User]? + if let _ = reader.readInt32() { + _5 = Api.parseVector(reader, elementSignature: 0, elementType: Api.User.self) + } + let _c1 = _1 != nil + let _c2 = _2 != nil + let _c3 = _3 != nil + let _c4 = (Int(_1!) & Int(1 << 0) == 0) || _4 != nil + let _c5 = _5 != nil + if _c1 && _c2 && _c3 && _c4 && _c5 { + return Api.premium.BoostsList.boostsList(flags: _1!, count: _2!, boosts: _3!, nextOffset: _4, users: _5!) + } + else { + return nil + } + } + + } +} public extension Api.premium { enum BoostsStatus: TypeConstructorDescription { case boostsStatus(flags: Int32, level: Int32, currentLevelBoosts: Int32, boosts: Int32, giftBoosts: Int32?, nextLevelBoosts: Int32?, premiumAudience: Api.StatsPercentValue?, boostUrl: String, prepaidGiveaways: [Api.PrepaidGiveaway]?, myBoostSlots: [Int32]?) @@ -1530,175 +1594,3 @@ public extension Api.stories { } } -public extension Api.updates { - indirect enum ChannelDifference: TypeConstructorDescription { - case channelDifference(flags: Int32, pts: Int32, timeout: Int32?, newMessages: [Api.Message], otherUpdates: [Api.Update], chats: [Api.Chat], users: [Api.User]) - case channelDifferenceEmpty(flags: Int32, pts: Int32, timeout: Int32?) - case channelDifferenceTooLong(flags: Int32, timeout: Int32?, dialog: Api.Dialog, messages: [Api.Message], chats: [Api.Chat], users: [Api.User]) - - public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) { - switch self { - case .channelDifference(let flags, let pts, let timeout, let newMessages, let otherUpdates, let chats, let users): - if boxed { - buffer.appendInt32(543450958) - } - serializeInt32(flags, buffer: buffer, boxed: false) - serializeInt32(pts, buffer: buffer, boxed: false) - if Int(flags) & Int(1 << 1) != 0 {serializeInt32(timeout!, buffer: buffer, boxed: false)} - buffer.appendInt32(481674261) - buffer.appendInt32(Int32(newMessages.count)) - for item in newMessages { - item.serialize(buffer, true) - } - buffer.appendInt32(481674261) - buffer.appendInt32(Int32(otherUpdates.count)) - for item in otherUpdates { - item.serialize(buffer, true) - } - buffer.appendInt32(481674261) - buffer.appendInt32(Int32(chats.count)) - for item in chats { - item.serialize(buffer, true) - } - buffer.appendInt32(481674261) - buffer.appendInt32(Int32(users.count)) - for item in users { - item.serialize(buffer, true) - } - break - case .channelDifferenceEmpty(let flags, let pts, let timeout): - if boxed { - buffer.appendInt32(1041346555) - } - serializeInt32(flags, buffer: buffer, boxed: false) - serializeInt32(pts, buffer: buffer, boxed: false) - if Int(flags) & Int(1 << 1) != 0 {serializeInt32(timeout!, buffer: buffer, boxed: false)} - break - case .channelDifferenceTooLong(let flags, let timeout, let dialog, let messages, let chats, let users): - if boxed { - buffer.appendInt32(-1531132162) - } - serializeInt32(flags, buffer: buffer, boxed: false) - if Int(flags) & Int(1 << 1) != 0 {serializeInt32(timeout!, buffer: buffer, boxed: false)} - dialog.serialize(buffer, true) - buffer.appendInt32(481674261) - buffer.appendInt32(Int32(messages.count)) - for item in messages { - item.serialize(buffer, true) - } - buffer.appendInt32(481674261) - buffer.appendInt32(Int32(chats.count)) - for item in chats { - item.serialize(buffer, true) - } - buffer.appendInt32(481674261) - buffer.appendInt32(Int32(users.count)) - for item in users { - item.serialize(buffer, true) - } - break - } - } - - public func descriptionFields() -> (String, [(String, Any)]) { - switch self { - case .channelDifference(let flags, let pts, let timeout, let newMessages, let otherUpdates, let chats, let users): - return ("channelDifference", [("flags", flags as Any), ("pts", pts as Any), ("timeout", timeout as Any), ("newMessages", newMessages as Any), ("otherUpdates", otherUpdates as Any), ("chats", chats as Any), ("users", users as Any)]) - case .channelDifferenceEmpty(let flags, let pts, let timeout): - return ("channelDifferenceEmpty", [("flags", flags as Any), ("pts", pts as Any), ("timeout", timeout as Any)]) - case .channelDifferenceTooLong(let flags, let timeout, let dialog, let messages, let chats, let users): - return ("channelDifferenceTooLong", [("flags", flags as Any), ("timeout", timeout as Any), ("dialog", dialog as Any), ("messages", messages as Any), ("chats", chats as Any), ("users", users as Any)]) - } - } - - public static func parse_channelDifference(_ reader: BufferReader) -> ChannelDifference? { - var _1: Int32? - _1 = reader.readInt32() - var _2: Int32? - _2 = reader.readInt32() - var _3: Int32? - if Int(_1!) & Int(1 << 1) != 0 {_3 = reader.readInt32() } - var _4: [Api.Message]? - if let _ = reader.readInt32() { - _4 = Api.parseVector(reader, elementSignature: 0, elementType: Api.Message.self) - } - var _5: [Api.Update]? - if let _ = reader.readInt32() { - _5 = Api.parseVector(reader, elementSignature: 0, elementType: Api.Update.self) - } - var _6: [Api.Chat]? - if let _ = reader.readInt32() { - _6 = Api.parseVector(reader, elementSignature: 0, elementType: Api.Chat.self) - } - var _7: [Api.User]? - if let _ = reader.readInt32() { - _7 = Api.parseVector(reader, elementSignature: 0, elementType: Api.User.self) - } - let _c1 = _1 != nil - let _c2 = _2 != nil - let _c3 = (Int(_1!) & Int(1 << 1) == 0) || _3 != nil - let _c4 = _4 != nil - let _c5 = _5 != nil - let _c6 = _6 != nil - let _c7 = _7 != nil - if _c1 && _c2 && _c3 && _c4 && _c5 && _c6 && _c7 { - return Api.updates.ChannelDifference.channelDifference(flags: _1!, pts: _2!, timeout: _3, newMessages: _4!, otherUpdates: _5!, chats: _6!, users: _7!) - } - else { - return nil - } - } - public static func parse_channelDifferenceEmpty(_ reader: BufferReader) -> ChannelDifference? { - var _1: Int32? - _1 = reader.readInt32() - var _2: Int32? - _2 = reader.readInt32() - var _3: Int32? - if Int(_1!) & Int(1 << 1) != 0 {_3 = reader.readInt32() } - let _c1 = _1 != nil - let _c2 = _2 != nil - let _c3 = (Int(_1!) & Int(1 << 1) == 0) || _3 != nil - if _c1 && _c2 && _c3 { - return Api.updates.ChannelDifference.channelDifferenceEmpty(flags: _1!, pts: _2!, timeout: _3) - } - else { - return nil - } - } - public static func parse_channelDifferenceTooLong(_ reader: BufferReader) -> ChannelDifference? { - var _1: Int32? - _1 = reader.readInt32() - var _2: Int32? - if Int(_1!) & Int(1 << 1) != 0 {_2 = reader.readInt32() } - var _3: Api.Dialog? - if let signature = reader.readInt32() { - _3 = Api.parse(reader, signature: signature) as? Api.Dialog - } - var _4: [Api.Message]? - if let _ = reader.readInt32() { - _4 = Api.parseVector(reader, elementSignature: 0, elementType: Api.Message.self) - } - var _5: [Api.Chat]? - if let _ = reader.readInt32() { - _5 = Api.parseVector(reader, elementSignature: 0, elementType: Api.Chat.self) - } - var _6: [Api.User]? - if let _ = reader.readInt32() { - _6 = Api.parseVector(reader, elementSignature: 0, elementType: Api.User.self) - } - let _c1 = _1 != nil - let _c2 = (Int(_1!) & Int(1 << 1) == 0) || _2 != nil - let _c3 = _3 != nil - let _c4 = _4 != nil - let _c5 = _5 != nil - let _c6 = _6 != nil - if _c1 && _c2 && _c3 && _c4 && _c5 && _c6 { - return Api.updates.ChannelDifference.channelDifferenceTooLong(flags: _1!, timeout: _2, dialog: _3!, messages: _4!, chats: _5!, users: _6!) - } - else { - return nil - } - } - - } -} diff --git a/submodules/TelegramApi/Sources/Api38.swift b/submodules/TelegramApi/Sources/Api38.swift index 0b6b16c01e..8634876ecf 100644 --- a/submodules/TelegramApi/Sources/Api38.swift +++ b/submodules/TelegramApi/Sources/Api38.swift @@ -1,3 +1,175 @@ +public extension Api.updates { + indirect enum ChannelDifference: TypeConstructorDescription { + case channelDifference(flags: Int32, pts: Int32, timeout: Int32?, newMessages: [Api.Message], otherUpdates: [Api.Update], chats: [Api.Chat], users: [Api.User]) + case channelDifferenceEmpty(flags: Int32, pts: Int32, timeout: Int32?) + case channelDifferenceTooLong(flags: Int32, timeout: Int32?, dialog: Api.Dialog, messages: [Api.Message], chats: [Api.Chat], users: [Api.User]) + + public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) { + switch self { + case .channelDifference(let flags, let pts, let timeout, let newMessages, let otherUpdates, let chats, let users): + if boxed { + buffer.appendInt32(543450958) + } + serializeInt32(flags, buffer: buffer, boxed: false) + serializeInt32(pts, buffer: buffer, boxed: false) + if Int(flags) & Int(1 << 1) != 0 {serializeInt32(timeout!, buffer: buffer, boxed: false)} + buffer.appendInt32(481674261) + buffer.appendInt32(Int32(newMessages.count)) + for item in newMessages { + item.serialize(buffer, true) + } + buffer.appendInt32(481674261) + buffer.appendInt32(Int32(otherUpdates.count)) + for item in otherUpdates { + item.serialize(buffer, true) + } + buffer.appendInt32(481674261) + buffer.appendInt32(Int32(chats.count)) + for item in chats { + item.serialize(buffer, true) + } + buffer.appendInt32(481674261) + buffer.appendInt32(Int32(users.count)) + for item in users { + item.serialize(buffer, true) + } + break + case .channelDifferenceEmpty(let flags, let pts, let timeout): + if boxed { + buffer.appendInt32(1041346555) + } + serializeInt32(flags, buffer: buffer, boxed: false) + serializeInt32(pts, buffer: buffer, boxed: false) + if Int(flags) & Int(1 << 1) != 0 {serializeInt32(timeout!, buffer: buffer, boxed: false)} + break + case .channelDifferenceTooLong(let flags, let timeout, let dialog, let messages, let chats, let users): + if boxed { + buffer.appendInt32(-1531132162) + } + serializeInt32(flags, buffer: buffer, boxed: false) + if Int(flags) & Int(1 << 1) != 0 {serializeInt32(timeout!, buffer: buffer, boxed: false)} + dialog.serialize(buffer, true) + buffer.appendInt32(481674261) + buffer.appendInt32(Int32(messages.count)) + for item in messages { + item.serialize(buffer, true) + } + buffer.appendInt32(481674261) + buffer.appendInt32(Int32(chats.count)) + for item in chats { + item.serialize(buffer, true) + } + buffer.appendInt32(481674261) + buffer.appendInt32(Int32(users.count)) + for item in users { + item.serialize(buffer, true) + } + break + } + } + + public func descriptionFields() -> (String, [(String, Any)]) { + switch self { + case .channelDifference(let flags, let pts, let timeout, let newMessages, let otherUpdates, let chats, let users): + return ("channelDifference", [("flags", flags as Any), ("pts", pts as Any), ("timeout", timeout as Any), ("newMessages", newMessages as Any), ("otherUpdates", otherUpdates as Any), ("chats", chats as Any), ("users", users as Any)]) + case .channelDifferenceEmpty(let flags, let pts, let timeout): + return ("channelDifferenceEmpty", [("flags", flags as Any), ("pts", pts as Any), ("timeout", timeout as Any)]) + case .channelDifferenceTooLong(let flags, let timeout, let dialog, let messages, let chats, let users): + return ("channelDifferenceTooLong", [("flags", flags as Any), ("timeout", timeout as Any), ("dialog", dialog as Any), ("messages", messages as Any), ("chats", chats as Any), ("users", users as Any)]) + } + } + + public static func parse_channelDifference(_ reader: BufferReader) -> ChannelDifference? { + var _1: Int32? + _1 = reader.readInt32() + var _2: Int32? + _2 = reader.readInt32() + var _3: Int32? + if Int(_1!) & Int(1 << 1) != 0 {_3 = reader.readInt32() } + var _4: [Api.Message]? + if let _ = reader.readInt32() { + _4 = Api.parseVector(reader, elementSignature: 0, elementType: Api.Message.self) + } + var _5: [Api.Update]? + if let _ = reader.readInt32() { + _5 = Api.parseVector(reader, elementSignature: 0, elementType: Api.Update.self) + } + var _6: [Api.Chat]? + if let _ = reader.readInt32() { + _6 = Api.parseVector(reader, elementSignature: 0, elementType: Api.Chat.self) + } + var _7: [Api.User]? + if let _ = reader.readInt32() { + _7 = Api.parseVector(reader, elementSignature: 0, elementType: Api.User.self) + } + let _c1 = _1 != nil + let _c2 = _2 != nil + let _c3 = (Int(_1!) & Int(1 << 1) == 0) || _3 != nil + let _c4 = _4 != nil + let _c5 = _5 != nil + let _c6 = _6 != nil + let _c7 = _7 != nil + if _c1 && _c2 && _c3 && _c4 && _c5 && _c6 && _c7 { + return Api.updates.ChannelDifference.channelDifference(flags: _1!, pts: _2!, timeout: _3, newMessages: _4!, otherUpdates: _5!, chats: _6!, users: _7!) + } + else { + return nil + } + } + public static func parse_channelDifferenceEmpty(_ reader: BufferReader) -> ChannelDifference? { + var _1: Int32? + _1 = reader.readInt32() + var _2: Int32? + _2 = reader.readInt32() + var _3: Int32? + if Int(_1!) & Int(1 << 1) != 0 {_3 = reader.readInt32() } + let _c1 = _1 != nil + let _c2 = _2 != nil + let _c3 = (Int(_1!) & Int(1 << 1) == 0) || _3 != nil + if _c1 && _c2 && _c3 { + return Api.updates.ChannelDifference.channelDifferenceEmpty(flags: _1!, pts: _2!, timeout: _3) + } + else { + return nil + } + } + public static func parse_channelDifferenceTooLong(_ reader: BufferReader) -> ChannelDifference? { + var _1: Int32? + _1 = reader.readInt32() + var _2: Int32? + if Int(_1!) & Int(1 << 1) != 0 {_2 = reader.readInt32() } + var _3: Api.Dialog? + if let signature = reader.readInt32() { + _3 = Api.parse(reader, signature: signature) as? Api.Dialog + } + var _4: [Api.Message]? + if let _ = reader.readInt32() { + _4 = Api.parseVector(reader, elementSignature: 0, elementType: Api.Message.self) + } + var _5: [Api.Chat]? + if let _ = reader.readInt32() { + _5 = Api.parseVector(reader, elementSignature: 0, elementType: Api.Chat.self) + } + var _6: [Api.User]? + if let _ = reader.readInt32() { + _6 = Api.parseVector(reader, elementSignature: 0, elementType: Api.User.self) + } + let _c1 = _1 != nil + let _c2 = (Int(_1!) & Int(1 << 1) == 0) || _2 != nil + let _c3 = _3 != nil + let _c4 = _4 != nil + let _c5 = _5 != nil + let _c6 = _6 != nil + if _c1 && _c2 && _c3 && _c4 && _c5 && _c6 { + return Api.updates.ChannelDifference.channelDifferenceTooLong(flags: _1!, timeout: _2, dialog: _3!, messages: _4!, chats: _5!, users: _6!) + } + else { + return nil + } + } + + } +} public extension Api.updates { enum Difference: TypeConstructorDescription { case difference(newMessages: [Api.Message], newEncryptedMessages: [Api.EncryptedMessage], otherUpdates: [Api.Update], chats: [Api.Chat], users: [Api.User], state: Api.updates.State) diff --git a/submodules/TelegramApi/Sources/Api39.swift b/submodules/TelegramApi/Sources/Api39.swift index 4f235a40c8..54c173245b 100644 --- a/submodules/TelegramApi/Sources/Api39.swift +++ b/submodules/TelegramApi/Sources/Api39.swift @@ -9754,6 +9754,21 @@ public extension Api.functions.payments { }) } } +public extension Api.functions.payments { + static func getStarGiftAuctionAcquiredGifts(giftId: Int64) -> (FunctionDescription, Buffer, DeserializeFunctionResponse) { + let buffer = Buffer() + buffer.appendInt32(1805831148) + serializeInt64(giftId, buffer: buffer, boxed: false) + return (FunctionDescription(name: "payments.getStarGiftAuctionAcquiredGifts", parameters: [("giftId", String(describing: giftId))]), buffer, DeserializeFunctionResponse { (buffer: Buffer) -> Api.payments.StarGiftAuctionAcquiredGifts? in + let reader = BufferReader(buffer) + var result: Api.payments.StarGiftAuctionAcquiredGifts? + if let signature = reader.readInt32() { + result = Api.parse(reader, signature: signature) as? Api.payments.StarGiftAuctionAcquiredGifts + } + return result + }) + } +} public extension Api.functions.payments { static func getStarGiftAuctionState(giftId: Int64, version: Int32) -> (FunctionDescription, Buffer, DeserializeFunctionResponse) { let buffer = Buffer() diff --git a/submodules/TelegramCore/Sources/ApiUtils/StoreMessage_Telegram.swift b/submodules/TelegramCore/Sources/ApiUtils/StoreMessage_Telegram.swift index 73d733be1a..bcc31f0bf9 100644 --- a/submodules/TelegramCore/Sources/ApiUtils/StoreMessage_Telegram.swift +++ b/submodules/TelegramCore/Sources/ApiUtils/StoreMessage_Telegram.swift @@ -232,7 +232,7 @@ func apiMessagePeerIds(_ message: Api.Message) -> [PeerId] { } switch action { - case .messageActionChannelCreate, .messageActionChatDeletePhoto, .messageActionChatEditPhoto, .messageActionChatEditTitle, .messageActionEmpty, .messageActionPinMessage, .messageActionHistoryClear, .messageActionGameScore, .messageActionPaymentSent, .messageActionPaymentSentMe, .messageActionPhoneCall, .messageActionScreenshotTaken, .messageActionCustomAction, .messageActionBotAllowed, .messageActionSecureValuesSent, .messageActionSecureValuesSentMe, .messageActionContactSignUp, .messageActionGroupCall, .messageActionSetMessagesTTL, .messageActionGroupCallScheduled, .messageActionSetChatTheme, .messageActionChatJoinedByRequest, .messageActionWebViewDataSent, .messageActionWebViewDataSentMe, .messageActionGiftPremium, .messageActionGiftStars, .messageActionTopicCreate, .messageActionTopicEdit, .messageActionSuggestProfilePhoto, .messageActionSetChatWallPaper, .messageActionGiveawayLaunch, .messageActionGiveawayResults, .messageActionBoostApply, .messageActionRequestedPeerSentMe, .messageActionStarGift, .messageActionStarGiftUnique, .messageActionPaidMessagesRefunded, .messageActionPaidMessagesPrice, .messageActionTodoCompletions, .messageActionTodoAppendTasks, .messageActionSuggestedPostApproval, .messageActionGiftTon, .messageActionSuggestedPostSuccess, .messageActionSuggestedPostRefund, .messageActionSuggestBirthday: + case .messageActionChannelCreate, .messageActionChatDeletePhoto, .messageActionChatEditPhoto, .messageActionChatEditTitle, .messageActionEmpty, .messageActionPinMessage, .messageActionHistoryClear, .messageActionGameScore, .messageActionPaymentSent, .messageActionPaymentSentMe, .messageActionPhoneCall, .messageActionScreenshotTaken, .messageActionCustomAction, .messageActionBotAllowed, .messageActionSecureValuesSent, .messageActionSecureValuesSentMe, .messageActionContactSignUp, .messageActionGroupCall, .messageActionSetMessagesTTL, .messageActionGroupCallScheduled, .messageActionSetChatTheme, .messageActionChatJoinedByRequest, .messageActionWebViewDataSent, .messageActionWebViewDataSentMe, .messageActionGiftPremium, .messageActionGiftStars, .messageActionTopicCreate, .messageActionTopicEdit, .messageActionSuggestProfilePhoto, .messageActionSetChatWallPaper, .messageActionGiveawayLaunch, .messageActionGiveawayResults, .messageActionBoostApply, .messageActionRequestedPeerSentMe, .messageActionStarGift, .messageActionStarGiftUnique, .messageActionPaidMessagesRefunded, .messageActionPaidMessagesPrice, .messageActionTodoCompletions, .messageActionTodoAppendTasks, .messageActionSuggestedPostApproval, .messageActionGiftTon, .messageActionSuggestedPostSuccess, .messageActionSuggestedPostRefund, .messageActionSuggestBirthday, .messageActionStarGiftAuctionBid: break case let .messageActionChannelMigrateFrom(_, chatId): result.append(PeerId(namespace: Namespaces.Peer.CloudGroup, id: PeerId.Id._internalFromInt64Value(chatId))) diff --git a/submodules/TelegramCore/Sources/ApiUtils/TelegramMediaAction.swift b/submodules/TelegramCore/Sources/ApiUtils/TelegramMediaAction.swift index 6a5c365629..f2e90bad8f 100644 --- a/submodules/TelegramCore/Sources/ApiUtils/TelegramMediaAction.swift +++ b/submodules/TelegramCore/Sources/ApiUtils/TelegramMediaAction.swift @@ -274,6 +274,34 @@ func telegramMediaActionFromApiAction(_ action: Api.MessageAction) -> TelegramMe return TelegramMediaAction(action: .suggestedPostRefund(TelegramMediaActionType.SuggestedPostRefund(isUserInitiated: (flags & (1 << 0)) != 0))) case let .messageActionSuggestBirthday(birthday): return TelegramMediaAction(action: .suggestedBirthday(TelegramBirthday(apiBirthday: birthday))) + case let .messageActionStarGiftAuctionBid(flags, apiGift, bidAmount, message, peer, nextDropAt): + guard let gift = StarGift(apiStarGift: apiGift) else { + return nil + } + let text: String? + let entities: [MessageTextEntity]? + switch message { + case let .textWithEntities(textValue, entitiesValue): + text = textValue + entities = messageTextEntitiesFromApiEntities(entitiesValue) + default: + text = nil + entities = nil + } + var mappedFlags: TelegramMediaActionType.StarGiftAuctionBidFlags = [] + if (flags & (1 << 0)) != 0 { + mappedFlags.insert(.isAcquired) + } + if (flags & (1 << 3)) != 0 { + mappedFlags.insert(.ioOutbid) + } + if (flags & (1 << 4)) != 0 { + mappedFlags.insert(.isReturned) + } + if (flags & (1 << 5)) != 0 { + mappedFlags.insert(.isFinal) + } + return TelegramMediaAction(action: .starGiftAuctionBid(gift: gift, bidAmount: bidAmount, text: text, entities: entities, peerId: peer?.peerId, nextDropAt: nextDropAt, flags: mappedFlags)) } } diff --git a/submodules/TelegramCore/Sources/SyncCore/SyncCore_TelegramMediaAction.swift b/submodules/TelegramCore/Sources/SyncCore/SyncCore_TelegramMediaAction.swift index 662fbc6cdd..75ed083ff7 100644 --- a/submodules/TelegramCore/Sources/SyncCore/SyncCore_TelegramMediaAction.swift +++ b/submodules/TelegramCore/Sources/SyncCore/SyncCore_TelegramMediaAction.swift @@ -199,6 +199,18 @@ public enum TelegramMediaActionType: PostboxCoding, Equatable { } } + public struct StarGiftAuctionBidFlags: OptionSet { + public var rawValue: Int32 + public init(rawValue: Int32) { + self.rawValue = rawValue + } + + public static let isAcquired = StarGiftAuctionBidFlags(rawValue: 1 << 0) + public static let ioOutbid = StarGiftAuctionBidFlags(rawValue: 1 << 1) + public static let isReturned = StarGiftAuctionBidFlags(rawValue: 1 << 2) + public static let isFinal = StarGiftAuctionBidFlags(rawValue: 1 << 3) + } + case unknown case groupCreated(title: String) case addedMembers(peerIds: [PeerId]) @@ -255,6 +267,7 @@ public enum TelegramMediaActionType: PostboxCoding, Equatable { case suggestedPostSuccess(amount: CurrencyAmount) case suggestedPostRefund(SuggestedPostRefund) case suggestedBirthday(TelegramBirthday) + case starGiftAuctionBid(gift: StarGift, bidAmount: Int64, text: String?, entities: [MessageTextEntity]?, peerId: EnginePeer.Id?, nextDropAt: Int32?, flags: StarGiftAuctionBidFlags) public init(decoder: PostboxDecoder) { let rawValue: Int32 = decoder.decodeInt32ForKey("_rawValue", orElse: 0) @@ -422,6 +435,8 @@ public enum TelegramMediaActionType: PostboxCoding, Equatable { self = .suggestedPostRefund(decoder.decodeCodable(SuggestedPostRefund.self, forKey: "s") ?? SuggestedPostRefund(isUserInitiated: true)) case 55: self = .suggestedBirthday(decoder.decodeCodable(TelegramBirthday.self, forKey: "birthday") ?? TelegramBirthday(day: 1, month: 1, year: nil)) + case 56: + self = .starGiftAuctionBid(gift: decoder.decodeObjectForKey("gift", decoder: { StarGift(decoder: $0) }) as! StarGift, bidAmount: decoder.decodeInt64ForKey("bidAmount", orElse: 0), text: decoder.decodeOptionalStringForKey("text"), entities: decoder.decodeOptionalObjectArrayWithDecoderForKey("entities"), peerId: decoder.decodeOptionalInt64ForKey("peerId").flatMap { EnginePeer.Id($0) }, nextDropAt: decoder.decodeOptionalInt32ForKey("nextDropAt"), flags: StarGiftAuctionBidFlags(rawValue: decoder.decodeInt32ForKey("flags", orElse: 0))) default: self = .unknown } @@ -881,6 +896,28 @@ public enum TelegramMediaActionType: PostboxCoding, Equatable { case let .suggestedBirthday(birthday): encoder.encodeInt32(55, forKey: "_rawValue") encoder.encodeCodable(birthday, forKey: "birthday") + case let .starGiftAuctionBid(gift, bidAmount, text, entities, peerId, nextDropAt, flags): + encoder.encodeInt32(56, forKey: "_rawValue") + encoder.encodeObject(gift, forKey: "gift") + encoder.encodeInt64(bidAmount, forKey: "bidAmount") + if let text, let entities { + encoder.encodeString(text, forKey: "text") + encoder.encodeObjectArray(entities, forKey: "entities") + } else { + encoder.encodeNil(forKey: "text") + encoder.encodeNil(forKey: "entities") + } + if let peerId { + encoder.encodeInt64(peerId.toInt64(), forKey: "peerId") + } else { + encoder.encodeNil(forKey: "peerId") + } + if let nextDropAt { + encoder.encodeInt32(nextDropAt, forKey: "nextDropAt") + } else { + encoder.encodeNil(forKey: "nextDropAt") + } + encoder.encodeInt32(flags.rawValue, forKey: "flags") } } @@ -934,6 +971,12 @@ public enum TelegramMediaActionType: PostboxCoding, Equatable { return peerIds case let .conferenceCall(conferenceCall): return conferenceCall.otherParticipants + case let .starGiftAuctionBid(_, _, _, _, peerId, _, _): + var peerIds: [PeerId] = [] + if let peerId { + peerIds.append(peerId) + } + return peerIds default: return [] } diff --git a/submodules/TelegramCore/Sources/TelegramEngine/Payments/StarGifts.swift b/submodules/TelegramCore/Sources/TelegramEngine/Payments/StarGifts.swift index e4f55d6495..22f0d22da1 100644 --- a/submodules/TelegramCore/Sources/TelegramEngine/Payments/StarGifts.swift +++ b/submodules/TelegramCore/Sources/TelegramEngine/Payments/StarGifts.swift @@ -60,6 +60,7 @@ public enum StarGift: Equatable, Codable, PostboxCoding { case releasedBy case perUserLimit case lockedUntilDate + case auctionDropSize } public struct Availability: Equatable, Codable, PostboxCoding { @@ -183,8 +184,9 @@ public enum StarGift: Equatable, Codable, PostboxCoding { public let releasedBy: EnginePeer.Id? public let perUserLimit: PerUserLimit? public let lockedUntilDate: Int32? + public let auctionDropSize: Int32? - public init(id: Int64, title: String?, file: TelegramMediaFile, price: Int64, convertStars: Int64, availability: Availability?, soldOut: SoldOut?, flags: Flags, upgradeStars: Int64?, releasedBy: EnginePeer.Id?, perUserLimit: PerUserLimit?, lockedUntilDate: Int32?) { + public init(id: Int64, title: String?, file: TelegramMediaFile, price: Int64, convertStars: Int64, availability: Availability?, soldOut: SoldOut?, flags: Flags, upgradeStars: Int64?, releasedBy: EnginePeer.Id?, perUserLimit: PerUserLimit?, lockedUntilDate: Int32?, auctionDropSize: Int32?) { self.id = id self.title = title self.file = file @@ -197,6 +199,7 @@ public enum StarGift: Equatable, Codable, PostboxCoding { self.releasedBy = releasedBy self.perUserLimit = perUserLimit self.lockedUntilDate = lockedUntilDate + self.auctionDropSize = auctionDropSize } public init(from decoder: Decoder) throws { @@ -219,6 +222,7 @@ public enum StarGift: Equatable, Codable, PostboxCoding { self.releasedBy = try container.decodeIfPresent(EnginePeer.Id.self, forKey: .releasedBy) self.perUserLimit = try container.decodeIfPresent(PerUserLimit.self, forKey: .perUserLimit) self.lockedUntilDate = try container.decodeIfPresent(Int32.self, forKey: .lockedUntilDate) + self.auctionDropSize = try container.decodeIfPresent(Int32.self, forKey: .auctionDropSize) } public init(decoder: PostboxDecoder) { @@ -234,6 +238,7 @@ public enum StarGift: Equatable, Codable, PostboxCoding { self.releasedBy = decoder.decodeOptionalInt64ForKey(CodingKeys.releasedBy.rawValue).flatMap { EnginePeer.Id($0) } self.perUserLimit = decoder.decodeObjectForKey(CodingKeys.perUserLimit.rawValue, decoder: { StarGift.Gift.PerUserLimit(decoder: $0) }) as? StarGift.Gift.PerUserLimit self.lockedUntilDate = decoder.decodeOptionalInt32ForKey(CodingKeys.lockedUntilDate.rawValue) + self.auctionDropSize = decoder.decodeOptionalInt32ForKey(CodingKeys.auctionDropSize.rawValue) } public func encode(to encoder: Encoder) throws { @@ -255,6 +260,7 @@ public enum StarGift: Equatable, Codable, PostboxCoding { try container.encodeIfPresent(self.releasedBy, forKey: .releasedBy) try container.encodeIfPresent(self.perUserLimit, forKey: .perUserLimit) try container.encodeIfPresent(self.lockedUntilDate, forKey: .lockedUntilDate) + try container.encodeIfPresent(self.auctionDropSize, forKey: .auctionDropSize) } public func encode(_ encoder: PostboxEncoder) { @@ -298,6 +304,11 @@ public enum StarGift: Equatable, Codable, PostboxCoding { } else { encoder.encodeNil(forKey: CodingKeys.lockedUntilDate.rawValue) } + if let auctionDropSize = self.auctionDropSize { + encoder.encodeInt32(auctionDropSize, forKey: CodingKeys.auctionDropSize.rawValue) + } else { + encoder.encodeNil(forKey: CodingKeys.auctionDropSize.rawValue) + } } } @@ -960,7 +971,7 @@ public extension StarGift { extension StarGift { init?(apiStarGift: Api.StarGift) { switch apiStarGift { - case let .starGift(apiFlags, id, sticker, stars, availabilityRemains, availabilityTotal, availabilityResale, convertStars, firstSale, lastSale, upgradeStars, minResaleStars, title, releasedBy, perUserTotal, perUserRemains, lockedUntilDate): + case let .starGift(apiFlags, id, sticker, stars, availabilityRemains, availabilityTotal, availabilityResale, convertStars, firstSale, lastSale, upgradeStars, minResaleStars, title, releasedBy, perUserTotal, perUserRemains, lockedUntilDate, dropSize): var flags = StarGift.Gift.Flags() if (apiFlags & (1 << 2)) != 0 { flags.insert(.isBirthdayGift) @@ -995,7 +1006,7 @@ extension StarGift { guard let file = telegramMediaFileFromApiDocument(sticker, altDocuments: nil) else { return nil } - self = .generic(StarGift.Gift(id: id, title: title, file: file, price: stars, convertStars: convertStars, availability: availability, soldOut: soldOut, flags: flags, upgradeStars: upgradeStars, releasedBy: releasedBy?.peerId, perUserLimit: perUserLimit, lockedUntilDate: lockedUntilDate)) + self = .generic(StarGift.Gift(id: id, title: title, file: file, price: stars, convertStars: convertStars, availability: availability, soldOut: soldOut, flags: flags, upgradeStars: upgradeStars, releasedBy: releasedBy?.peerId, perUserLimit: perUserLimit, lockedUntilDate: lockedUntilDate, auctionDropSize: dropSize)) case let .starGiftUnique(apiFlags, id, giftId, title, slug, num, ownerPeerId, ownerName, ownerAddress, attributes, availabilityIssued, availabilityTotal, giftAddress, resellAmounts, releasedBy, valueAmount, valueCurrency, themePeer, peerColor, hostPeerId): let owner: StarGift.UniqueGift.Owner if let ownerAddress { diff --git a/submodules/TelegramCore/Sources/TelegramEngine/Payments/StarGiftsAuctions.swift b/submodules/TelegramCore/Sources/TelegramEngine/Payments/StarGiftsAuctions.swift index d26a45ebd2..fdb923c700 100644 --- a/submodules/TelegramCore/Sources/TelegramEngine/Payments/StarGiftsAuctions.swift +++ b/submodules/TelegramCore/Sources/TelegramEngine/Payments/StarGiftsAuctions.swift @@ -38,11 +38,12 @@ public final class GiftAuctionContext { } public enum AuctionState: Equatable { - case ongoing(version: Int32, minBidAmount: Int64, bidLevels: [BidLevel], topBidders: [EnginePeer.Id], dropSize: Int32, nextDropDate: Int32, dropsLeft: Int32, dropsTotal: Int32) + case ongoing(version: Int32, minBidAmount: Int64, bidLevels: [BidLevel], topBidders: [EnginePeer.Id], nextDropDate: Int32, giftsLeft: Int32, dropsLeft: Int32, dropsTotal: Int32) case finished } public struct MyState: Equatable { + public var isOutbid: Bool public var bidAmount: Int64? public var bidDate: Int32? public var minBidAmount: Int64? @@ -184,8 +185,8 @@ extension GiftAuctionContext.State.BidLevel { extension GiftAuctionContext.State.AuctionState { init?(apiAuctionState: Api.StarGiftAuctionState) { switch apiAuctionState { - case let .starGiftAuctionState(version, minBidAmount, bidLevels, topBidders, dropSize, nextDropAt, dropsLeft, dropsTotal): - self = .ongoing(version: version, minBidAmount: minBidAmount, bidLevels: bidLevels.map(GiftAuctionContext.State.BidLevel.init(apiBidLevel:)), topBidders: topBidders.map { EnginePeer.Id(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt64Value($0)) }, dropSize: dropSize, nextDropDate: nextDropAt, dropsLeft: dropsLeft, dropsTotal: dropsTotal) + case let .starGiftAuctionState(version, minBidAmount, bidLevels, topBidders, nextDropAt, giftsLeft, dropsLeft, dropsTotal): + self = .ongoing(version: version, minBidAmount: minBidAmount, bidLevels: bidLevels.map(GiftAuctionContext.State.BidLevel.init(apiBidLevel:)), topBidders: topBidders.map { EnginePeer.Id(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt64Value($0)) }, nextDropDate: nextDropAt, giftsLeft: giftsLeft, dropsLeft: dropsLeft, dropsTotal: dropsTotal) case .starGiftAuctionStateFinished: self = .finished case .starGiftAuctionStateNotModified: @@ -197,7 +198,8 @@ extension GiftAuctionContext.State.AuctionState { extension GiftAuctionContext.State.MyState { init(apiAuctionUserState: Api.StarGiftAuctionUserState) { switch apiAuctionUserState { - case let .starGiftAuctionUserState(_, bidAmount, bidDate, minBidAmount, acquiredCount): + case let .starGiftAuctionUserState(flags, bidAmount, bidDate, minBidAmount, acquiredCount): + self.isOutbid = (flags & (1 << 1)) != 0 self.bidAmount = bidAmount self.bidDate = bidDate self.minBidAmount = minBidAmount @@ -205,3 +207,61 @@ extension GiftAuctionContext.State.MyState { } } } + +public struct GiftAuctionAcquiredGift { + public var nameHidden: Bool + public let peer: EnginePeer + public let date: Int32 + public let bidAmount: Int64 + public let position: Int32 + public let text: String? + public let entities: [MessageTextEntity]? +} + +func _internal_getGiftAuctionAcquiredGifts(account: Account, giftId: Int64) -> Signal<[GiftAuctionAcquiredGift], NoError> { + return account.network.request(Api.functions.payments.getStarGiftAuctionAcquiredGifts(giftId: giftId)) + |> map(Optional.init) + |> `catch` { _ in + return .single(nil) + } + |> mapToSignal { result in + guard let result else { + return .single([]) + } + return account.postbox.transaction { transaction -> [GiftAuctionAcquiredGift] in + switch result { + case let .starGiftAuctionAcquiredGifts(gifts, users, chats): + let parsedPeers = AccumulatedPeers(transaction: transaction, chats: chats, users: users) + updatePeers(transaction: transaction, accountPeerId: account.peerId, peers: parsedPeers) + + var mappedGifts: [GiftAuctionAcquiredGift] = [] + for gift in gifts { + switch gift { + case let .starGiftAuctionAcquiredGift(flags, peerId, date, bidAmount, pos, message): + if let peer = transaction.getPeer(peerId.peerId) { + var text: String? + var entities: [MessageTextEntity]? + switch message { + case let .textWithEntities(textValue, entitiesValue): + text = textValue + entities = messageTextEntitiesFromApiEntities(entitiesValue) + default: + break + } + mappedGifts.append(GiftAuctionAcquiredGift( + nameHidden: (flags & (1 << 0)) != 0, + peer: EnginePeer(peer), + date: date, + bidAmount: bidAmount, + position: pos, + text: text, + entities: entities + )) + } + } + } + return mappedGifts + } + } + } +} diff --git a/submodules/TelegramCore/Sources/TelegramEngine/Payments/TelegramEnginePayments.swift b/submodules/TelegramCore/Sources/TelegramEngine/Payments/TelegramEnginePayments.swift index 4454f56559..f92f22385b 100644 --- a/submodules/TelegramCore/Sources/TelegramEngine/Payments/TelegramEnginePayments.swift +++ b/submodules/TelegramCore/Sources/TelegramEngine/Payments/TelegramEnginePayments.swift @@ -173,6 +173,10 @@ public extension TelegramEngine { return _internal_updateStarGiftResalePrice(account: self.account, reference: reference, price: price) } + public func getGiftAuctionAcquiredGifts(giftId: Int64) -> Signal<[GiftAuctionAcquiredGift], NoError> { + return _internal_getGiftAuctionAcquiredGifts(account: self.account, giftId: giftId) + } + public func getStarsTransaction(reference: StarsTransactionReference) -> Signal { return _internal_getStarsTransaction(accountPeerId: self.account.peerId, postbox: self.account.postbox, network: self.account.network, transactionReference: reference) } diff --git a/submodules/TelegramStringFormatting/Sources/ServiceMessageStrings.swift b/submodules/TelegramStringFormatting/Sources/ServiceMessageStrings.swift index f936684cf8..4204a0b342 100644 --- a/submodules/TelegramStringFormatting/Sources/ServiceMessageStrings.swift +++ b/submodules/TelegramStringFormatting/Sources/ServiceMessageStrings.swift @@ -1614,6 +1614,15 @@ public func universalServiceMessageString(presentationData: (PresentationTheme, attributedString = addAttributesToStringWithRanges(strings.Notification_StarsGift_Sent(authorName, price)._tuple, body: bodyAttributes, argumentAttributes: attributes) } } + case let .starGiftAuctionBid(gift, bidAmount, text, entities, peerId, nextDropAt, flags): + let _ = gift + let _ = bidAmount + let _ = text + let _ = entities + let _ = peerId + let _ = nextDropAt + let _ = flags + attributedString = nil case .unknown: attributedString = nil } diff --git a/submodules/TelegramUI/Components/Gifts/GiftSetupScreen/Sources/GiftSetupScreen.swift b/submodules/TelegramUI/Components/Gifts/GiftSetupScreen/Sources/GiftSetupScreen.swift index f3a1f7436d..58a2cbf639 100644 --- a/submodules/TelegramUI/Components/Gifts/GiftSetupScreen/Sources/GiftSetupScreen.swift +++ b/submodules/TelegramUI/Components/Gifts/GiftSetupScreen/Sources/GiftSetupScreen.swift @@ -1873,7 +1873,7 @@ private final class GiftSetupScreenComponent: Component { ))) if let giftAuctionState = self.giftAuctionState { switch giftAuctionState.auctionState { - case let .ongoing(_, _, _, _, _, nextDropDate, _, _): + case let .ongoing(_, _, _, _, nextDropDate, _, _, _): let currentTime = Int32(CFAbsoluteTimeGetCurrent() + kCFAbsoluteTimeIntervalSince1970) let dropTimeout = nextDropDate - currentTime diff --git a/submodules/TelegramUI/Components/Gifts/GiftViewScreen/Sources/GiftAuctionBoughtScreen.swift b/submodules/TelegramUI/Components/Gifts/GiftViewScreen/Sources/GiftAuctionBoughtScreen.swift index 0cb4fc05cd..2203f920ef 100644 --- a/submodules/TelegramUI/Components/Gifts/GiftViewScreen/Sources/GiftAuctionBoughtScreen.swift +++ b/submodules/TelegramUI/Components/Gifts/GiftViewScreen/Sources/GiftAuctionBoughtScreen.swift @@ -25,13 +25,16 @@ private final class GiftAuctionBoughtScreenComponent: Component { let context: AccountContext let gift: StarGift + let acquiredGifts: [GiftAuctionAcquiredGift] init( context: AccountContext, - gift: StarGift + gift: StarGift, + acquiredGifts: [GiftAuctionAcquiredGift] ) { self.context = context self.gift = gift + self.acquiredGifts = acquiredGifts } static func ==(lhs: GiftAuctionBoughtScreenComponent, rhs: GiftAuctionBoughtScreenComponent) -> Bool { @@ -76,7 +79,7 @@ private final class GiftAuctionBoughtScreenComponent: Component { private let closeButton = ComponentView() private let title = ComponentView() - private var itemsViews: [Int64: ComponentView] = [:] + private var itemsViews: [Int32: ComponentView] = [:] private let actionButton = ComponentView() private var ignoreScrolling: Bool = false @@ -285,10 +288,8 @@ private final class GiftAuctionBoughtScreenComponent: Component { let tableTextColor = environment.theme.list.itemPrimaryTextColor - let mockDate = Int32(Date().timeIntervalSince1970) - - for i in 0 ..< 3 { - let id = Int64(i) + for gift in component.acquiredGifts { + let id = gift.date let itemView: ComponentView if let current = self.itemsViews[id] { itemView = current @@ -324,7 +325,7 @@ private final class GiftAuctionBoughtScreenComponent: Component { AnyComponentWithIdentity( id: "title", component: AnyComponent( - MultilineTextComponent(text: .plain(NSAttributedString(string: "Round #\(3 + i * 2)", font: tableBoldFont, textColor: tableTextColor))) + MultilineTextComponent(text: .plain(NSAttributedString(string: "Round #1", font: tableBoldFont, textColor: tableTextColor))) ) ) ], spacing: 1.0)) @@ -340,7 +341,7 @@ private final class GiftAuctionBoughtScreenComponent: Component { context: component.context, theme: environment.theme, strings: environment.strings, - peer: nil + peer: gift.peer ) ), action: { @@ -352,10 +353,10 @@ private final class GiftAuctionBoughtScreenComponent: Component { items.append(.init( id: "date", title: "Date", - component: AnyComponent(MultilineTextComponent(text: .plain(NSAttributedString(string: stringForMediumDate(timestamp: mockDate, strings: environment.strings, dateTimeFormat: environment.dateTimeFormat), font: tableFont, textColor: tableTextColor)))) + component: AnyComponent(MultilineTextComponent(text: .plain(NSAttributedString(string: stringForMediumDate(timestamp: gift.date, strings: environment.strings, dateTimeFormat: environment.dateTimeFormat), font: tableFont, textColor: tableTextColor)))) )) - let valueString = "⭐️\(formatStarsAmountText(StarsAmount(value: Int64(3531 + 1000 * i + 13 * i), nanos: 0), dateTimeFormat: environment.dateTimeFormat))" + let valueString = "⭐️\(formatStarsAmountText(StarsAmount(value: gift.bidAmount, nanos: 0), dateTimeFormat: environment.dateTimeFormat))" let valueAttributedString = NSMutableAttributedString(string: valueString, font: tableFont, textColor: tableTextColor) let range = (valueAttributedString.string as NSString).range(of: "⭐️") if range.location != NSNotFound { @@ -380,7 +381,7 @@ private final class GiftAuctionBoughtScreenComponent: Component { component: AnyComponent(Button( content: AnyComponent(ButtonContentComponent( context: component.context, - text: "TOP \(10 + i)", + text: "TOP \(gift.position)", color: environment.theme.list.itemAccentColor )), action: { @@ -462,7 +463,13 @@ private final class GiftAuctionBoughtScreenComponent: Component { let title = self.title let actionButton = self.actionButton - let titleText = "3 Items Bought" + let titleText: String + if component.acquiredGifts.count == 1 { + titleText = "1 Item Bought" + } else { + titleText = "\(component.acquiredGifts.count) Items Bought" + } + let titleSize = title.update( transition: .immediate, component: AnyComponent(MultilineTextComponent( @@ -623,12 +630,13 @@ public class GiftAuctionBoughtScreen: ViewControllerComponentContainer { private var didPlayAppearAnimation: Bool = false private var isDismissed: Bool = false - public init(context: AccountContext, gift: StarGift) { + public init(context: AccountContext, gift: StarGift, acquiredGifts: [GiftAuctionAcquiredGift]) { self.context = context super.init(context: context, component: GiftAuctionBoughtScreenComponent( context: context, - gift: gift + gift: gift, + acquiredGifts: acquiredGifts ), navigationBarAppearance: .none, theme: .default) self.statusBar.statusBarStyle = .Ignore diff --git a/submodules/TelegramUI/Components/Gifts/GiftViewScreen/Sources/GiftAuctionScreen.swift b/submodules/TelegramUI/Components/Gifts/GiftViewScreen/Sources/GiftAuctionScreen.swift index 094b494ac2..1404e06044 100644 --- a/submodules/TelegramUI/Components/Gifts/GiftViewScreen/Sources/GiftAuctionScreen.swift +++ b/submodules/TelegramUI/Components/Gifts/GiftViewScreen/Sources/GiftAuctionScreen.swift @@ -27,6 +27,7 @@ import GlassBarButtonComponent import AnimatedTextComponent import BotPaymentsUI import UndoUI +import GiftItemComponent private final class BadgeComponent: Component { let theme: PresentationTheme @@ -977,6 +978,8 @@ private final class GiftAuctionScreenComponent: Component { private var liveStreamPerks: [ComponentView] = [] private var liveStreamMessagePreview: ComponentView? + private let myGifts = ComponentView() + private var myPeerTitle: ComponentView? private var myPeerItem: ComponentView? @@ -988,6 +991,9 @@ private final class GiftAuctionScreenComponent: Component { private var giftAuctionTimer: SwiftSignalKit.Timer? private var peersMap: [EnginePeer.Id: EnginePeer] = [:] + private var giftAuctionAcquiredGifts: [GiftAuctionAcquiredGift] = [] + private var giftAuctionAcquiredGiftsDisposable: Disposable? + private let actionButton = ComponentView() private var ignoreScrolling: Bool = false @@ -1097,6 +1103,9 @@ private final class GiftAuctionScreenComponent: Component { deinit { self.balanceDisposable?.dispose() + self.giftAuctionDisposable?.dispose() + self.giftAuctionAcquiredGiftsDisposable?.dispose() + self.giftAuctionTimer?.invalidate() } func scrollViewDidScroll(_ scrollView: UIScrollView) { @@ -1503,6 +1512,17 @@ private final class GiftAuctionScreenComponent: Component { self?.state?.updated() }, queue: Queue.mainQueue()) self.giftAuctionTimer?.start() + + if case let .generic(gift) = component.gift { + self.giftAuctionAcquiredGiftsDisposable = (component.context.engine.payments.getGiftAuctionAcquiredGifts(giftId: gift.id) + |> deliverOnMainQueue).startStrict(next: { [weak self] acquiredGifts in + guard let self else { + return + } + self.giftAuctionAcquiredGifts = acquiredGifts + self.state?.updated(transition: .easeInOut(duration: 0.25)) + }) + } } self.component = component @@ -1690,7 +1710,7 @@ private final class GiftAuctionScreenComponent: Component { var dropsLeftAnimatedItems: [AnimatedTextComponent.Item] = [] if let auctionState = self.giftAuctionState?.auctionState { - if case let .ongoing(_, minBidAmount, _, _, _, nextDropDate, dropsLeft, _) = auctionState { + if case let .ongoing(_, minBidAmount, _, _, nextDropDate, _, dropsLeft, _) = auctionState { var minBidAmount = minBidAmount if let myMinBidAmmount = self.giftAuctionState?.myState.minBidAmount { minBidAmount = myMinBidAmmount @@ -1825,6 +1845,67 @@ private final class GiftAuctionScreenComponent: Component { contentHeight += perkHeight contentHeight += 24.0 + if self.giftAuctionAcquiredGifts.count > 0, case let .generic(gift) = component.gift { + var text = "\(self.giftAuctionAcquiredGifts.count)" + if self.giftAuctionAcquiredGifts.count == 1 { + text += " item bought" + } else { + text += " items bought" + } + + var myGiftsTransition = transition + let myGiftsSize = self.myGifts.update( + transition: .immediate, + component: AnyComponent( + PlainButtonComponent(content: AnyComponent( + HStack([ + AnyComponentWithIdentity(id: "icon", component: AnyComponent( + GiftItemComponent( + context: component.context, + theme: environment.theme, + strings: environment.strings, + peer: nil, + subject: .starGift(gift: gift, price: ""), + mode: .tableIcon + ) + )), + AnyComponentWithIdentity(id: "text", component: AnyComponent( + MultilineTextComponent(text: .plain(NSAttributedString(string: text, font: Font.regular(15.0), textColor: environment.theme.actionSheet.controlAccentColor))) + )), + AnyComponentWithIdentity(id: "chevron", component: AnyComponent( + BundleIconComponent(name: "Settings/TextArrowRight", tintColor: environment.theme.actionSheet.controlAccentColor) + )) + ], spacing: 6.0) + ), action: { [weak self] in + guard let self, let component = self.component else { + return + } + let giftController = GiftAuctionBoughtScreen(context: component.context, gift: component.gift, acquiredGifts: self.giftAuctionAcquiredGifts) + self.environment?.controller()?.push(giftController) + }, animateScale: false) + ), + environment: {}, + containerSize: availableSize + ) + let myGiftsFrame = CGRect(origin: CGPoint(x: floorToScreenPixels((availableSize.width - myGiftsSize.width) / 2.0), y: contentHeight), size: myGiftsSize) + if let myGiftsView = self.myGifts.view { + if myGiftsView.superview == nil { + myGiftsTransition = .immediate + + self.scrollContentView.addSubview(myGiftsView) + + if !transition.animation.isImmediate { + transition.animateAlpha(view: myGiftsView, from: 0.0, to: 1.0) + } + } + myGiftsTransition.setFrame(view: myGiftsView, frame: myGiftsFrame) + } + contentHeight += myGiftsSize.height + contentHeight += 15.0 + } else { + + } + if self.backgroundHandleView.image == nil { self.backgroundHandleView.image = generateStretchableFilledCircleImage(diameter: 5.0, color: .white)?.withRenderingMode(.alwaysTemplate) } @@ -1883,8 +1964,7 @@ private final class GiftAuctionScreenComponent: Component { guard let self, let component = self.component else { return } - //let giftController = component.context.sharedContext.makeGiftAuctionInfoScreen(context: component.context, gift: component.gift, completion: {}) - let giftController = GiftAuctionBoughtScreen(context: component.context, gift: component.gift) + let giftController = component.context.sharedContext.makeGiftAuctionInfoScreen(context: component.context, gift: component.gift, completion: {}) self.environment?.controller()?.push(giftController) } )),