mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-06-15 21:45:19 +00:00
Update API
This commit is contained in:
parent
d92ac9275f
commit
829ccedc80
@ -391,6 +391,7 @@ fileprivate let parsers: [Int32 : (BufferReader) -> Any?] = {
|
||||
dict[-625298705] = { return Api.InputInvoice.parse_inputInvoicePremiumGiftStars($0) }
|
||||
dict[-1020867857] = { return Api.InputInvoice.parse_inputInvoiceSlug($0) }
|
||||
dict[-396206446] = { return Api.InputInvoice.parse_inputInvoiceStarGift($0) }
|
||||
dict[1674298252] = { return Api.InputInvoice.parse_inputInvoiceStarGiftResale($0) }
|
||||
dict[1247763417] = { return Api.InputInvoice.parse_inputInvoiceStarGiftTransfer($0) }
|
||||
dict[1300335965] = { return Api.InputInvoice.parse_inputInvoiceStarGiftUpgrade($0) }
|
||||
dict[1710230755] = { return Api.InputInvoice.parse_inputInvoiceStars($0) }
|
||||
@ -933,7 +934,7 @@ fileprivate let parsers: [Int32 : (BufferReader) -> Any?] = {
|
||||
dict[1124938064] = { return Api.SponsoredMessageReportOption.parse_sponsoredMessageReportOption($0) }
|
||||
dict[-963180333] = { return Api.SponsoredPeer.parse_sponsoredPeer($0) }
|
||||
dict[46953416] = { return Api.StarGift.parse_starGift($0) }
|
||||
dict[1549979985] = { return Api.StarGift.parse_starGiftUnique($0) }
|
||||
dict[1678891913] = { return Api.StarGift.parse_starGiftUnique($0) }
|
||||
dict[-1809377438] = { return Api.StarGiftAttribute.parse_starGiftAttributeBackdrop($0) }
|
||||
dict[970559507] = { return Api.StarGiftAttribute.parse_starGiftAttributeModel($0) }
|
||||
dict[-524291476] = { return Api.StarGiftAttribute.parse_starGiftAttributeOriginalDetails($0) }
|
||||
|
@ -255,6 +255,7 @@ public extension Api {
|
||||
case inputInvoicePremiumGiftStars(flags: Int32, userId: Api.InputUser, months: Int32, message: Api.TextWithEntities?)
|
||||
case inputInvoiceSlug(slug: String)
|
||||
case inputInvoiceStarGift(flags: Int32, peer: Api.InputPeer, giftId: Int64, message: Api.TextWithEntities?)
|
||||
case inputInvoiceStarGiftResale(slug: String, toId: Api.InputPeer)
|
||||
case inputInvoiceStarGiftTransfer(stargift: Api.InputSavedStarGift, toId: Api.InputPeer)
|
||||
case inputInvoiceStarGiftUpgrade(flags: Int32, stargift: Api.InputSavedStarGift)
|
||||
case inputInvoiceStars(purpose: Api.InputStorePaymentPurpose)
|
||||
@ -312,6 +313,13 @@ public extension Api {
|
||||
serializeInt64(giftId, buffer: buffer, boxed: false)
|
||||
if Int(flags) & Int(1 << 1) != 0 {message!.serialize(buffer, true)}
|
||||
break
|
||||
case .inputInvoiceStarGiftResale(let slug, let toId):
|
||||
if boxed {
|
||||
buffer.appendInt32(1674298252)
|
||||
}
|
||||
serializeString(slug, buffer: buffer, boxed: false)
|
||||
toId.serialize(buffer, true)
|
||||
break
|
||||
case .inputInvoiceStarGiftTransfer(let stargift, let toId):
|
||||
if boxed {
|
||||
buffer.appendInt32(1247763417)
|
||||
@ -351,6 +359,8 @@ public extension Api {
|
||||
return ("inputInvoiceSlug", [("slug", slug as Any)])
|
||||
case .inputInvoiceStarGift(let flags, let peer, let giftId, let message):
|
||||
return ("inputInvoiceStarGift", [("flags", flags as Any), ("peer", peer as Any), ("giftId", giftId as Any), ("message", message as Any)])
|
||||
case .inputInvoiceStarGiftResale(let slug, let toId):
|
||||
return ("inputInvoiceStarGiftResale", [("slug", slug as Any), ("toId", toId as Any)])
|
||||
case .inputInvoiceStarGiftTransfer(let stargift, let toId):
|
||||
return ("inputInvoiceStarGiftTransfer", [("stargift", stargift as Any), ("toId", toId as Any)])
|
||||
case .inputInvoiceStarGiftUpgrade(let flags, let stargift):
|
||||
@ -480,6 +490,22 @@ public extension Api {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
public static func parse_inputInvoiceStarGiftResale(_ reader: BufferReader) -> InputInvoice? {
|
||||
var _1: String?
|
||||
_1 = parseString(reader)
|
||||
var _2: Api.InputPeer?
|
||||
if let signature = reader.readInt32() {
|
||||
_2 = Api.parse(reader, signature: signature) as? Api.InputPeer
|
||||
}
|
||||
let _c1 = _1 != nil
|
||||
let _c2 = _2 != nil
|
||||
if _c1 && _c2 {
|
||||
return Api.InputInvoice.inputInvoiceStarGiftResale(slug: _1!, toId: _2!)
|
||||
}
|
||||
else {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
public static func parse_inputInvoiceStarGiftTransfer(_ reader: BufferReader) -> InputInvoice? {
|
||||
var _1: Api.InputSavedStarGift?
|
||||
if let signature = reader.readInt32() {
|
||||
|
@ -629,7 +629,7 @@ public extension Api {
|
||||
public extension Api {
|
||||
enum StarGift: TypeConstructorDescription {
|
||||
case starGift(flags: Int32, id: Int64, sticker: Api.Document, stars: Int64, availabilityRemains: Int32?, availabilityTotal: Int32?, convertStars: Int64, firstSaleDate: Int32?, lastSaleDate: Int32?, upgradeStars: Int64?)
|
||||
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?)
|
||||
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?)
|
||||
|
||||
public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) {
|
||||
switch self {
|
||||
@ -648,9 +648,9 @@ public extension Api {
|
||||
if Int(flags) & Int(1 << 1) != 0 {serializeInt32(lastSaleDate!, buffer: buffer, boxed: false)}
|
||||
if Int(flags) & Int(1 << 3) != 0 {serializeInt64(upgradeStars!, buffer: buffer, boxed: false)}
|
||||
break
|
||||
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):
|
||||
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):
|
||||
if boxed {
|
||||
buffer.appendInt32(1549979985)
|
||||
buffer.appendInt32(1678891913)
|
||||
}
|
||||
serializeInt32(flags, buffer: buffer, boxed: false)
|
||||
serializeInt64(id, buffer: buffer, boxed: false)
|
||||
@ -668,6 +668,7 @@ public extension Api {
|
||||
serializeInt32(availabilityIssued, buffer: buffer, boxed: false)
|
||||
serializeInt32(availabilityTotal, buffer: buffer, boxed: false)
|
||||
if Int(flags) & Int(1 << 3) != 0 {serializeString(giftAddress!, buffer: buffer, boxed: false)}
|
||||
if Int(flags) & Int(1 << 4) != 0 {serializeInt64(resellStars!, buffer: buffer, boxed: false)}
|
||||
break
|
||||
}
|
||||
}
|
||||
@ -676,8 +677,8 @@ public extension Api {
|
||||
switch self {
|
||||
case .starGift(let flags, let id, let sticker, let stars, let availabilityRemains, let availabilityTotal, let convertStars, let firstSaleDate, let lastSaleDate, let upgradeStars):
|
||||
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), ("convertStars", convertStars as Any), ("firstSaleDate", firstSaleDate as Any), ("lastSaleDate", lastSaleDate as Any), ("upgradeStars", upgradeStars as Any)])
|
||||
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):
|
||||
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)])
|
||||
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):
|
||||
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)])
|
||||
}
|
||||
}
|
||||
|
||||
@ -750,6 +751,8 @@ public extension Api {
|
||||
_11 = reader.readInt32()
|
||||
var _12: String?
|
||||
if Int(_1!) & Int(1 << 3) != 0 {_12 = parseString(reader) }
|
||||
var _13: Int64?
|
||||
if Int(_1!) & Int(1 << 4) != 0 {_13 = reader.readInt64() }
|
||||
let _c1 = _1 != nil
|
||||
let _c2 = _2 != nil
|
||||
let _c3 = _3 != nil
|
||||
@ -762,8 +765,9 @@ public extension Api {
|
||||
let _c10 = _10 != nil
|
||||
let _c11 = _11 != nil
|
||||
let _c12 = (Int(_1!) & Int(1 << 3) == 0) || _12 != nil
|
||||
if _c1 && _c2 && _c3 && _c4 && _c5 && _c6 && _c7 && _c8 && _c9 && _c10 && _c11 && _c12 {
|
||||
return Api.StarGift.starGiftUnique(flags: _1!, id: _2!, title: _3!, slug: _4!, num: _5!, ownerId: _6, ownerName: _7, ownerAddress: _8, attributes: _9!, availabilityIssued: _10!, availabilityTotal: _11!, giftAddress: _12)
|
||||
let _c13 = (Int(_1!) & Int(1 << 4) == 0) || _13 != nil
|
||||
if _c1 && _c2 && _c3 && _c4 && _c5 && _c6 && _c7 && _c8 && _c9 && _c10 && _c11 && _c12 && _c13 {
|
||||
return Api.StarGift.starGiftUnique(flags: _1!, id: _2!, title: _3!, slug: _4!, num: _5!, ownerId: _6, ownerName: _7, ownerAddress: _8, attributes: _9!, availabilityIssued: _10!, availabilityTotal: _11!, giftAddress: _12, resellStars: _13)
|
||||
}
|
||||
else {
|
||||
return nil
|
||||
|
@ -9766,6 +9766,22 @@ public extension Api.functions.payments {
|
||||
})
|
||||
}
|
||||
}
|
||||
public extension Api.functions.payments {
|
||||
static func updateStarGiftPrice(slug: String, resellStars: Int64) -> (FunctionDescription, Buffer, DeserializeFunctionResponse<Api.Updates>) {
|
||||
let buffer = Buffer()
|
||||
buffer.appendInt32(-489360582)
|
||||
serializeString(slug, buffer: buffer, boxed: false)
|
||||
serializeInt64(resellStars, buffer: buffer, boxed: false)
|
||||
return (FunctionDescription(name: "payments.updateStarGiftPrice", parameters: [("slug", String(describing: slug)), ("resellStars", String(describing: resellStars))]), buffer, DeserializeFunctionResponse { (buffer: Buffer) -> Api.Updates? in
|
||||
let reader = BufferReader(buffer)
|
||||
var result: Api.Updates?
|
||||
if let signature = reader.readInt32() {
|
||||
result = Api.parse(reader, signature: signature) as? Api.Updates
|
||||
}
|
||||
return result
|
||||
})
|
||||
}
|
||||
}
|
||||
public extension Api.functions.payments {
|
||||
static func upgradeStarGift(flags: Int32, stargift: Api.InputSavedStarGift) -> (FunctionDescription, Buffer, DeserializeFunctionResponse<Api.Updates>) {
|
||||
let buffer = Buffer()
|
||||
|
@ -109,6 +109,10 @@ func messageFilterForTagMask(_ tagMask: MessageTags) -> Api.MessagesFilter? {
|
||||
return Api.MessagesFilter.inputMessagesFilterGif
|
||||
} else if tagMask == .pinned {
|
||||
return Api.MessagesFilter.inputMessagesFilterPinned
|
||||
} else if tagMask == .voice {
|
||||
return Api.MessagesFilter.inputMessagesFilterVoice
|
||||
} else if tagMask == .roundVideo {
|
||||
return Api.MessagesFilter.inputMessagesFilterRoundVideo
|
||||
} else {
|
||||
return nil
|
||||
}
|
||||
|
@ -353,7 +353,8 @@ func managedUniqueStarGifts(accountPeerId: PeerId, postbox: Postbox, network: Ne
|
||||
.backdrop(name: "", innerColor: innerColor, outerColor: outerColor, patternColor: patternColor, textColor: textColor, rarity: 0)
|
||||
],
|
||||
availability: StarGift.UniqueGift.Availability(issued: 0, total: 0),
|
||||
giftAddress: nil
|
||||
giftAddress: nil,
|
||||
resellStars: nil
|
||||
)
|
||||
if let entry = CodableEntry(RecentStarGiftItem(gift)) {
|
||||
items.append(OrderedItemListEntry(id: RecentStarGiftItemId(id).rawValue, contents: entry))
|
||||
|
@ -210,7 +210,7 @@ public class BoxedMessage: NSObject {
|
||||
|
||||
public class Serialization: NSObject, MTSerialization {
|
||||
public func currentLayer() -> UInt {
|
||||
return 202
|
||||
return 203
|
||||
}
|
||||
|
||||
public func parseMessage(_ data: Data!) -> Any! {
|
||||
|
@ -170,8 +170,10 @@ public extension MessageTags {
|
||||
static let video = MessageTags(rawValue: 1 << 9)
|
||||
static let pinned = MessageTags(rawValue: 1 << 10)
|
||||
static let unseenReaction = MessageTags(rawValue: 1 << 11)
|
||||
static let voice = MessageTags(rawValue: 1 << 12)
|
||||
static let roundVideo = MessageTags(rawValue: 1 << 13)
|
||||
|
||||
static let all: MessageTags = [.photoOrVideo, .file, .music, .webPage, .voiceOrInstantVideo, .unseenPersonalMessage, .liveLocation, .gif, .photo, .video, .pinned, .unseenReaction]
|
||||
static let all: MessageTags = [.photoOrVideo, .file, .music, .webPage, .voiceOrInstantVideo, .unseenPersonalMessage, .liveLocation, .gif, .photo, .video, .pinned, .unseenReaction, .voice, .roundVideo]
|
||||
}
|
||||
|
||||
public extension GlobalMessageTags {
|
||||
|
@ -17,6 +17,7 @@ public enum BotPaymentInvoiceSource {
|
||||
case starGiftUpgrade(keepOriginalInfo: Bool, reference: StarGiftReference)
|
||||
case starGiftTransfer(reference: StarGiftReference, toPeerId: EnginePeer.Id)
|
||||
case premiumGift(peerId: EnginePeer.Id, option: CachedPremiumGiftOption, text: String?, entities: [MessageTextEntity]?)
|
||||
case starGiftResale(slug: String, toPeerId: EnginePeer.Id)
|
||||
}
|
||||
|
||||
public struct BotPaymentInvoiceFields: OptionSet {
|
||||
@ -400,6 +401,11 @@ func _internal_parseInputInvoice(transaction: Transaction, source: BotPaymentInv
|
||||
message = .textWithEntities(text: text, entities: entities.flatMap { apiEntitiesFromMessageTextEntities($0, associatedPeers: SimpleDictionary()) } ?? [])
|
||||
}
|
||||
return .inputInvoicePremiumGiftStars(flags: flags, userId: inputUser, months: option.months, message: message)
|
||||
case let .starGiftResale(slug, toPeerId):
|
||||
guard let peer = transaction.getPeer(toPeerId), let inputPeer = apiInputPeer(peer) else {
|
||||
return nil
|
||||
}
|
||||
return .inputInvoiceStarGiftResale(slug: slug, toId: inputPeer)
|
||||
}
|
||||
}
|
||||
|
||||
@ -733,7 +739,7 @@ func _internal_sendBotPaymentForm(account: Account, formId: Int64, source: BotPa
|
||||
receiptMessageId = id
|
||||
}
|
||||
}
|
||||
case .giftCode, .stars, .starsGift, .starsChatSubscription, .starGift, .starGiftUpgrade, .starGiftTransfer, .premiumGift:
|
||||
case .giftCode, .stars, .starsGift, .starsChatSubscription, .starGift, .starGiftUpgrade, .starGiftTransfer, .premiumGift, .starGiftResale:
|
||||
receiptMessageId = nil
|
||||
}
|
||||
}
|
||||
|
@ -211,6 +211,7 @@ public enum StarGift: Equatable, Codable, PostboxCoding {
|
||||
case attributes
|
||||
case availability
|
||||
case giftAddress
|
||||
case resellStars
|
||||
}
|
||||
|
||||
public enum Attribute: Equatable, Codable, PostboxCoding {
|
||||
@ -451,8 +452,9 @@ public enum StarGift: Equatable, Codable, PostboxCoding {
|
||||
public let attributes: [Attribute]
|
||||
public let availability: Availability
|
||||
public let giftAddress: String?
|
||||
public let resellStars: Int64?
|
||||
|
||||
public init(id: Int64, title: String, number: Int32, slug: String, owner: Owner, attributes: [Attribute], availability: Availability, giftAddress: String?) {
|
||||
public init(id: Int64, title: String, number: Int32, slug: String, owner: Owner, attributes: [Attribute], availability: Availability, giftAddress: String?, resellStars: Int64?) {
|
||||
self.id = id
|
||||
self.title = title
|
||||
self.number = number
|
||||
@ -461,6 +463,7 @@ public enum StarGift: Equatable, Codable, PostboxCoding {
|
||||
self.attributes = attributes
|
||||
self.availability = availability
|
||||
self.giftAddress = giftAddress
|
||||
self.resellStars = resellStars
|
||||
}
|
||||
|
||||
public init(from decoder: Decoder) throws {
|
||||
@ -481,6 +484,7 @@ public enum StarGift: Equatable, Codable, PostboxCoding {
|
||||
self.attributes = try container.decode([UniqueGift.Attribute].self, forKey: .attributes)
|
||||
self.availability = try container.decode(UniqueGift.Availability.self, forKey: .availability)
|
||||
self.giftAddress = try container.decodeIfPresent(String.self, forKey: .giftAddress)
|
||||
self.resellStars = try container.decodeIfPresent(Int64.self, forKey: .resellStars)
|
||||
}
|
||||
|
||||
public init(decoder: PostboxDecoder) {
|
||||
@ -500,6 +504,7 @@ public enum StarGift: Equatable, Codable, PostboxCoding {
|
||||
self.attributes = (try? decoder.decodeObjectArrayWithCustomDecoderForKey(CodingKeys.attributes.rawValue, decoder: { UniqueGift.Attribute(decoder: $0) })) ?? []
|
||||
self.availability = decoder.decodeObjectForKey(CodingKeys.availability.rawValue, decoder: { UniqueGift.Availability(decoder: $0) }) as! UniqueGift.Availability
|
||||
self.giftAddress = decoder.decodeOptionalStringForKey(CodingKeys.giftAddress.rawValue)
|
||||
self.resellStars = decoder.decodeOptionalInt64ForKey(CodingKeys.resellStars.rawValue)
|
||||
}
|
||||
|
||||
public func encode(to encoder: Encoder) throws {
|
||||
@ -519,6 +524,7 @@ public enum StarGift: Equatable, Codable, PostboxCoding {
|
||||
try container.encode(self.attributes, forKey: .attributes)
|
||||
try container.encode(self.availability, forKey: .availability)
|
||||
try container.encodeIfPresent(self.giftAddress, forKey: .giftAddress)
|
||||
try container.encodeIfPresent(self.resellStars, forKey: .resellStars)
|
||||
}
|
||||
|
||||
public func encode(_ encoder: PostboxEncoder) {
|
||||
@ -541,6 +547,25 @@ public enum StarGift: Equatable, Codable, PostboxCoding {
|
||||
} else {
|
||||
encoder.encodeNil(forKey: CodingKeys.giftAddress.rawValue)
|
||||
}
|
||||
if let resellStars = self.resellStars {
|
||||
encoder.encodeInt64(resellStars, forKey: CodingKeys.resellStars.rawValue)
|
||||
} else {
|
||||
encoder.encodeNil(forKey: CodingKeys.resellStars.rawValue)
|
||||
}
|
||||
}
|
||||
|
||||
public func withResellStars(_ resellStars: Int64?) -> UniqueGift {
|
||||
return UniqueGift(
|
||||
id: self.id,
|
||||
title: self.title,
|
||||
number: self.number,
|
||||
slug: self.slug,
|
||||
owner: self.owner,
|
||||
attributes: self.attributes,
|
||||
availability: self.availability,
|
||||
giftAddress: self.giftAddress,
|
||||
resellStars: resellStars
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@ -626,7 +651,7 @@ extension StarGift {
|
||||
return nil
|
||||
}
|
||||
self = .generic(StarGift.Gift(id: id, file: file, price: stars, convertStars: convertStars, availability: availability, soldOut: soldOut, flags: flags, upgradeStars: upgradeStars))
|
||||
case let .starGiftUnique(_, id, title, slug, num, ownerPeerId, ownerName, ownerAddress, attributes, availabilityIssued, availabilityTotal, giftAddress):
|
||||
case let .starGiftUnique(_, id, title, slug, num, ownerPeerId, ownerName, ownerAddress, attributes, availabilityIssued, availabilityTotal, giftAddress, reselltars):
|
||||
let owner: StarGift.UniqueGift.Owner
|
||||
if let ownerAddress {
|
||||
owner = .address(ownerAddress)
|
||||
@ -637,7 +662,7 @@ extension StarGift {
|
||||
} else {
|
||||
return nil
|
||||
}
|
||||
self = .unique(StarGift.UniqueGift(id: id, title: title, number: num, slug: slug, owner: owner, attributes: attributes.compactMap { UniqueGift.Attribute(apiAttribute: $0) }, availability: UniqueGift.Availability(issued: availabilityIssued, total: availabilityTotal), giftAddress: giftAddress))
|
||||
self = .unique(StarGift.UniqueGift(id: id, title: title, number: num, slug: slug, owner: owner, attributes: attributes.compactMap { UniqueGift.Attribute(apiAttribute: $0) }, availability: UniqueGift.Availability(issued: availabilityIssued, total: availabilityTotal), giftAddress: giftAddress, resellStars: reselltars))
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1388,6 +1413,41 @@ private final class ProfileGiftsContextImpl {
|
||||
}
|
||||
}
|
||||
|
||||
func updateStarGiftResellPrice(slug: String, price: Int64?) {
|
||||
self.actionDisposable.set(
|
||||
_internal_updateStarGiftResalePrice(account: self.account, slug: slug, price: price).startStrict()
|
||||
)
|
||||
|
||||
|
||||
if let index = self.gifts.firstIndex(where: { gift in
|
||||
if case let .unique(uniqueGift) = gift.gift, uniqueGift.slug == slug {
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}) {
|
||||
if case let .unique(uniqueGift) = self.gifts[index].gift {
|
||||
let updatedUniqueGift = uniqueGift.withResellStars(price)
|
||||
let updatedGift = self.gifts[index].withGift(.unique(updatedUniqueGift))
|
||||
self.gifts[index] = updatedGift
|
||||
}
|
||||
}
|
||||
|
||||
if let index = self.filteredGifts.firstIndex(where: { gift in
|
||||
if case let .unique(uniqueGift) = gift.gift, uniqueGift.slug == slug {
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}) {
|
||||
if case let .unique(uniqueGift) = self.filteredGifts[index].gift {
|
||||
let updatedUniqueGift = uniqueGift.withResellStars(price)
|
||||
let updatedGift = self.filteredGifts[index].withGift(.unique(updatedUniqueGift))
|
||||
self.filteredGifts[index] = updatedGift
|
||||
}
|
||||
}
|
||||
|
||||
self.pushState()
|
||||
}
|
||||
|
||||
func toggleStarGiftsNotifications(enabled: Bool) {
|
||||
self.actionDisposable.set(
|
||||
_internal_toggleStarGiftsNotifications(account: self.account, peerId: self.peerId, enabled: enabled).startStrict()
|
||||
@ -1583,6 +1643,25 @@ public final class ProfileGiftsContext {
|
||||
try container.encodeIfPresent(self.transferStars, forKey: .transferStars)
|
||||
}
|
||||
|
||||
public func withGift(_ gift: TelegramCore.StarGift) -> StarGift {
|
||||
return StarGift(
|
||||
gift: gift,
|
||||
reference: self.reference,
|
||||
fromPeer: self.fromPeer,
|
||||
date: self.date,
|
||||
text: self.text,
|
||||
entities: self.entities,
|
||||
nameHidden: self.nameHidden,
|
||||
savedToProfile: self.savedToProfile,
|
||||
pinnedToTop: self.pinnedToTop,
|
||||
convertStars: self.convertStars,
|
||||
canUpgrade: self.canUpgrade,
|
||||
canExportDate: self.canExportDate,
|
||||
upgradeStars: self.upgradeStars,
|
||||
transferStars: self.transferStars
|
||||
)
|
||||
}
|
||||
|
||||
public func withSavedToProfile(_ savedToProfile: Bool) -> StarGift {
|
||||
return StarGift(
|
||||
gift: self.gift,
|
||||
@ -1750,6 +1829,12 @@ public final class ProfileGiftsContext {
|
||||
}
|
||||
}
|
||||
|
||||
public func updateStarGiftResellPrice(slug: String, price: Int64?) {
|
||||
self.impl.with { impl in
|
||||
impl.updateStarGiftResellPrice(slug: slug, price: price)
|
||||
}
|
||||
}
|
||||
|
||||
public func toggleStarGiftsNotifications(enabled: Bool) {
|
||||
self.impl.with { impl in
|
||||
impl.toggleStarGiftsNotifications(enabled: enabled)
|
||||
@ -2070,6 +2155,21 @@ func _internal_toggleStarGiftsNotifications(account: Account, peerId: EnginePeer
|
||||
}
|
||||
}
|
||||
|
||||
func _internal_updateStarGiftResalePrice(account: Account, slug: String, price: Int64?) -> Signal<Never, NoError> {
|
||||
return account.network.request(Api.functions.payments.updateStarGiftPrice(slug: slug, resellStars: price ?? 0))
|
||||
|> map(Optional.init)
|
||||
|> `catch` { _ -> Signal<Api.Updates?, NoError> in
|
||||
return .single(nil)
|
||||
}
|
||||
|> mapToSignal { updates -> Signal<Void, NoError> in
|
||||
if let updates {
|
||||
account.stateManager.addUpdates(updates)
|
||||
}
|
||||
return .complete()
|
||||
}
|
||||
|> ignoreValues
|
||||
}
|
||||
|
||||
public extension StarGift.UniqueGift {
|
||||
var itemFile: TelegramMediaFile? {
|
||||
for attribute in self.attributes {
|
||||
|
@ -1524,7 +1524,7 @@ func _internal_sendStarsPaymentForm(account: Account, formId: Int64, source: Bot
|
||||
receiptMessageId = id
|
||||
}
|
||||
}
|
||||
case .giftCode, .stars, .starsGift, .starsChatSubscription, .starGift, .starGiftUpgrade, .starGiftTransfer, .premiumGift:
|
||||
case .giftCode, .stars, .starsGift, .starsChatSubscription, .starGift, .starGiftUpgrade, .starGiftTransfer, .premiumGift, .starGiftResale:
|
||||
receiptMessageId = nil
|
||||
}
|
||||
} else if case let .starGiftUnique(gift, _, _, savedToProfile, canExportDate, transferStars, _, peerId, _, savedId) = action.action, case let .Id(messageId) = message.id {
|
||||
|
@ -148,6 +148,10 @@ public extension TelegramEngine {
|
||||
public func toggleStarGiftsNotifications(peerId: EnginePeer.Id, enabled: Bool) -> Signal<Never, NoError> {
|
||||
return _internal_toggleStarGiftsNotifications(account: self.account, peerId: peerId, enabled: enabled)
|
||||
}
|
||||
|
||||
public func updateStarGiftResalePrice(slug: String, price: Int64?) -> Signal<Never, NoError> {
|
||||
return _internal_updateStarGiftResalePrice(account: self.account, slug: slug, price: price)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user