mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-06-16 05:55:20 +00:00
Update API
This commit is contained in:
parent
2ce819bee1
commit
47cc4200c6
@ -68,18 +68,22 @@ public func presentGiveawayInfoController(
|
|||||||
var untilDateValue: Int32 = 0
|
var untilDateValue: Int32 = 0
|
||||||
if let giveaway {
|
if let giveaway {
|
||||||
untilDateValue = giveaway.untilDate
|
untilDateValue = giveaway.untilDate
|
||||||
} else if let _ = giveawayResults {
|
} else if let giveawayResults {
|
||||||
untilDateValue = message.timestamp
|
untilDateValue = giveawayResults.untilDate
|
||||||
}
|
}
|
||||||
|
|
||||||
var onlyNewSubscribers = false
|
var onlyNewSubscribers = false
|
||||||
if let giveaway, giveaway.flags.contains(.onlyNewSubscribers) {
|
if let giveaway, giveaway.flags.contains(.onlyNewSubscribers) {
|
||||||
onlyNewSubscribers = true
|
onlyNewSubscribers = true
|
||||||
|
} else if let giveawayResults, giveawayResults.flags.contains(.onlyNewSubscribers) {
|
||||||
|
onlyNewSubscribers = true
|
||||||
}
|
}
|
||||||
|
|
||||||
var channelsCount = 1
|
var channelsCount: Int32 = 1
|
||||||
if let giveaway {
|
if let giveaway {
|
||||||
channelsCount = giveaway.channelPeerIds.count
|
channelsCount = Int32(giveaway.channelPeerIds.count)
|
||||||
|
} else if let giveawayResults {
|
||||||
|
channelsCount = 1 + giveawayResults.additionalChannelsCount
|
||||||
}
|
}
|
||||||
|
|
||||||
let presentationData = context.sharedContext.currentPresentationData.with { $0 }
|
let presentationData = context.sharedContext.currentPresentationData.with { $0 }
|
||||||
|
@ -488,7 +488,7 @@ fileprivate let parsers: [Int32 : (BufferReader) -> Any?] = {
|
|||||||
dict[-1230047312] = { return Api.MessageAction.parse_messageActionEmpty($0) }
|
dict[-1230047312] = { return Api.MessageAction.parse_messageActionEmpty($0) }
|
||||||
dict[-1834538890] = { return Api.MessageAction.parse_messageActionGameScore($0) }
|
dict[-1834538890] = { return Api.MessageAction.parse_messageActionGameScore($0) }
|
||||||
dict[-1730095465] = { return Api.MessageAction.parse_messageActionGeoProximityReached($0) }
|
dict[-1730095465] = { return Api.MessageAction.parse_messageActionGeoProximityReached($0) }
|
||||||
dict[-758129906] = { return Api.MessageAction.parse_messageActionGiftCode($0) }
|
dict[1737240073] = { return Api.MessageAction.parse_messageActionGiftCode($0) }
|
||||||
dict[-935499028] = { return Api.MessageAction.parse_messageActionGiftPremium($0) }
|
dict[-935499028] = { return Api.MessageAction.parse_messageActionGiftPremium($0) }
|
||||||
dict[858499565] = { return Api.MessageAction.parse_messageActionGiveawayLaunch($0) }
|
dict[858499565] = { return Api.MessageAction.parse_messageActionGiveawayLaunch($0) }
|
||||||
dict[715107781] = { return Api.MessageAction.parse_messageActionGiveawayResults($0) }
|
dict[715107781] = { return Api.MessageAction.parse_messageActionGiveawayResults($0) }
|
||||||
@ -544,7 +544,7 @@ fileprivate let parsers: [Int32 : (BufferReader) -> Any?] = {
|
|||||||
dict[1457575028] = { return Api.MessageMedia.parse_messageMediaGeo($0) }
|
dict[1457575028] = { return Api.MessageMedia.parse_messageMediaGeo($0) }
|
||||||
dict[-1186937242] = { return Api.MessageMedia.parse_messageMediaGeoLive($0) }
|
dict[-1186937242] = { return Api.MessageMedia.parse_messageMediaGeoLive($0) }
|
||||||
dict[-626162256] = { return Api.MessageMedia.parse_messageMediaGiveaway($0) }
|
dict[-626162256] = { return Api.MessageMedia.parse_messageMediaGiveaway($0) }
|
||||||
dict[-1323305567] = { return Api.MessageMedia.parse_messageMediaGiveawayResults($0) }
|
dict[-963047320] = { return Api.MessageMedia.parse_messageMediaGiveawayResults($0) }
|
||||||
dict[-156940077] = { return Api.MessageMedia.parse_messageMediaInvoice($0) }
|
dict[-156940077] = { return Api.MessageMedia.parse_messageMediaInvoice($0) }
|
||||||
dict[1766936791] = { return Api.MessageMedia.parse_messageMediaPhoto($0) }
|
dict[1766936791] = { return Api.MessageMedia.parse_messageMediaPhoto($0) }
|
||||||
dict[1272375192] = { return Api.MessageMedia.parse_messageMediaPoll($0) }
|
dict[1272375192] = { return Api.MessageMedia.parse_messageMediaPoll($0) }
|
||||||
|
@ -609,7 +609,7 @@ public extension Api {
|
|||||||
case messageActionEmpty
|
case messageActionEmpty
|
||||||
case messageActionGameScore(gameId: Int64, score: Int32)
|
case messageActionGameScore(gameId: Int64, score: Int32)
|
||||||
case messageActionGeoProximityReached(fromId: Api.Peer, toId: Api.Peer, distance: Int32)
|
case messageActionGeoProximityReached(fromId: Api.Peer, toId: Api.Peer, distance: Int32)
|
||||||
case messageActionGiftCode(flags: Int32, boostPeer: Api.Peer?, months: Int32, slug: String)
|
case messageActionGiftCode(flags: Int32, boostPeer: Api.Peer?, months: Int32, slug: String, currency: String?, amount: Int64?, cryptoCurrency: String?, cryptoAmount: Int64?)
|
||||||
case messageActionGiftPremium(flags: Int32, currency: String, amount: Int64, months: Int32, cryptoCurrency: String?, cryptoAmount: Int64?)
|
case messageActionGiftPremium(flags: Int32, currency: String, amount: Int64, months: Int32, cryptoCurrency: String?, cryptoAmount: Int64?)
|
||||||
case messageActionGiveawayLaunch
|
case messageActionGiveawayLaunch
|
||||||
case messageActionGiveawayResults(winnersCount: Int32, unclaimedCount: Int32)
|
case messageActionGiveawayResults(winnersCount: Int32, unclaimedCount: Int32)
|
||||||
@ -753,14 +753,18 @@ public extension Api {
|
|||||||
toId.serialize(buffer, true)
|
toId.serialize(buffer, true)
|
||||||
serializeInt32(distance, buffer: buffer, boxed: false)
|
serializeInt32(distance, buffer: buffer, boxed: false)
|
||||||
break
|
break
|
||||||
case .messageActionGiftCode(let flags, let boostPeer, let months, let slug):
|
case .messageActionGiftCode(let flags, let boostPeer, let months, let slug, let currency, let amount, let cryptoCurrency, let cryptoAmount):
|
||||||
if boxed {
|
if boxed {
|
||||||
buffer.appendInt32(-758129906)
|
buffer.appendInt32(1737240073)
|
||||||
}
|
}
|
||||||
serializeInt32(flags, buffer: buffer, boxed: false)
|
serializeInt32(flags, buffer: buffer, boxed: false)
|
||||||
if Int(flags) & Int(1 << 1) != 0 {boostPeer!.serialize(buffer, true)}
|
if Int(flags) & Int(1 << 1) != 0 {boostPeer!.serialize(buffer, true)}
|
||||||
serializeInt32(months, buffer: buffer, boxed: false)
|
serializeInt32(months, buffer: buffer, boxed: false)
|
||||||
serializeString(slug, buffer: buffer, boxed: false)
|
serializeString(slug, buffer: buffer, boxed: false)
|
||||||
|
if Int(flags) & Int(1 << 2) != 0 {serializeString(currency!, buffer: buffer, boxed: false)}
|
||||||
|
if Int(flags) & Int(1 << 2) != 0 {serializeInt64(amount!, buffer: buffer, boxed: false)}
|
||||||
|
if Int(flags) & Int(1 << 3) != 0 {serializeString(cryptoCurrency!, buffer: buffer, boxed: false)}
|
||||||
|
if Int(flags) & Int(1 << 3) != 0 {serializeInt64(cryptoAmount!, buffer: buffer, boxed: false)}
|
||||||
break
|
break
|
||||||
case .messageActionGiftPremium(let flags, let currency, let amount, let months, let cryptoCurrency, let cryptoAmount):
|
case .messageActionGiftPremium(let flags, let currency, let amount, let months, let cryptoCurrency, let cryptoAmount):
|
||||||
if boxed {
|
if boxed {
|
||||||
@ -986,8 +990,8 @@ public extension Api {
|
|||||||
return ("messageActionGameScore", [("gameId", gameId as Any), ("score", score as Any)])
|
return ("messageActionGameScore", [("gameId", gameId as Any), ("score", score as Any)])
|
||||||
case .messageActionGeoProximityReached(let fromId, let toId, let distance):
|
case .messageActionGeoProximityReached(let fromId, let toId, let distance):
|
||||||
return ("messageActionGeoProximityReached", [("fromId", fromId as Any), ("toId", toId as Any), ("distance", distance as Any)])
|
return ("messageActionGeoProximityReached", [("fromId", fromId as Any), ("toId", toId as Any), ("distance", distance as Any)])
|
||||||
case .messageActionGiftCode(let flags, let boostPeer, let months, let slug):
|
case .messageActionGiftCode(let flags, let boostPeer, let months, let slug, let currency, let amount, let cryptoCurrency, let cryptoAmount):
|
||||||
return ("messageActionGiftCode", [("flags", flags as Any), ("boostPeer", boostPeer as Any), ("months", months as Any), ("slug", slug as Any)])
|
return ("messageActionGiftCode", [("flags", flags as Any), ("boostPeer", boostPeer as Any), ("months", months as Any), ("slug", slug as Any), ("currency", currency as Any), ("amount", amount as Any), ("cryptoCurrency", cryptoCurrency as Any), ("cryptoAmount", cryptoAmount as Any)])
|
||||||
case .messageActionGiftPremium(let flags, let currency, let amount, let months, let cryptoCurrency, let cryptoAmount):
|
case .messageActionGiftPremium(let flags, let currency, let amount, let months, let cryptoCurrency, let cryptoAmount):
|
||||||
return ("messageActionGiftPremium", [("flags", flags as Any), ("currency", currency as Any), ("amount", amount as Any), ("months", months as Any), ("cryptoCurrency", cryptoCurrency as Any), ("cryptoAmount", cryptoAmount as Any)])
|
return ("messageActionGiftPremium", [("flags", flags as Any), ("currency", currency as Any), ("amount", amount as Any), ("months", months as Any), ("cryptoCurrency", cryptoCurrency as Any), ("cryptoAmount", cryptoAmount as Any)])
|
||||||
case .messageActionGiveawayLaunch:
|
case .messageActionGiveawayLaunch:
|
||||||
@ -1236,12 +1240,24 @@ public extension Api {
|
|||||||
_3 = reader.readInt32()
|
_3 = reader.readInt32()
|
||||||
var _4: String?
|
var _4: String?
|
||||||
_4 = parseString(reader)
|
_4 = parseString(reader)
|
||||||
|
var _5: String?
|
||||||
|
if Int(_1!) & Int(1 << 2) != 0 {_5 = parseString(reader) }
|
||||||
|
var _6: Int64?
|
||||||
|
if Int(_1!) & Int(1 << 2) != 0 {_6 = reader.readInt64() }
|
||||||
|
var _7: String?
|
||||||
|
if Int(_1!) & Int(1 << 3) != 0 {_7 = parseString(reader) }
|
||||||
|
var _8: Int64?
|
||||||
|
if Int(_1!) & Int(1 << 3) != 0 {_8 = reader.readInt64() }
|
||||||
let _c1 = _1 != nil
|
let _c1 = _1 != nil
|
||||||
let _c2 = (Int(_1!) & Int(1 << 1) == 0) || _2 != nil
|
let _c2 = (Int(_1!) & Int(1 << 1) == 0) || _2 != nil
|
||||||
let _c3 = _3 != nil
|
let _c3 = _3 != nil
|
||||||
let _c4 = _4 != nil
|
let _c4 = _4 != nil
|
||||||
if _c1 && _c2 && _c3 && _c4 {
|
let _c5 = (Int(_1!) & Int(1 << 2) == 0) || _5 != nil
|
||||||
return Api.MessageAction.messageActionGiftCode(flags: _1!, boostPeer: _2, months: _3!, slug: _4!)
|
let _c6 = (Int(_1!) & Int(1 << 2) == 0) || _6 != nil
|
||||||
|
let _c7 = (Int(_1!) & Int(1 << 3) == 0) || _7 != nil
|
||||||
|
let _c8 = (Int(_1!) & Int(1 << 3) == 0) || _8 != nil
|
||||||
|
if _c1 && _c2 && _c3 && _c4 && _c5 && _c6 && _c7 && _c8 {
|
||||||
|
return Api.MessageAction.messageActionGiftCode(flags: _1!, boostPeer: _2, months: _3!, slug: _4!, currency: _5, amount: _6, cryptoCurrency: _7, cryptoAmount: _8)
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
return nil
|
return nil
|
||||||
|
@ -698,7 +698,7 @@ public extension Api {
|
|||||||
case messageMediaGeo(geo: Api.GeoPoint)
|
case messageMediaGeo(geo: Api.GeoPoint)
|
||||||
case messageMediaGeoLive(flags: Int32, geo: Api.GeoPoint, heading: Int32?, period: Int32, proximityNotificationRadius: Int32?)
|
case messageMediaGeoLive(flags: Int32, geo: Api.GeoPoint, heading: Int32?, period: Int32, proximityNotificationRadius: Int32?)
|
||||||
case messageMediaGiveaway(flags: Int32, channels: [Int64], countriesIso2: [String]?, prizeDescription: String?, quantity: Int32, months: Int32, untilDate: Int32)
|
case messageMediaGiveaway(flags: Int32, channels: [Int64], countriesIso2: [String]?, prizeDescription: String?, quantity: Int32, months: Int32, untilDate: Int32)
|
||||||
case messageMediaGiveawayResults(flags: Int32, channelId: Int64, launchMsgId: Int32, winnersCount: Int32, unclaimedCount: Int32, winners: [Int64], months: Int32, prizeDescription: String?)
|
case messageMediaGiveawayResults(flags: Int32, channelId: Int64, additionalPeersCount: Int32?, launchMsgId: Int32, winnersCount: Int32, unclaimedCount: Int32, winners: [Int64], months: Int32, prizeDescription: String?, untilDate: Int32)
|
||||||
case messageMediaInvoice(flags: Int32, title: String, description: String, photo: Api.WebDocument?, receiptMsgId: Int32?, currency: String, totalAmount: Int64, startParam: String, extendedMedia: Api.MessageExtendedMedia?)
|
case messageMediaInvoice(flags: Int32, title: String, description: String, photo: Api.WebDocument?, receiptMsgId: Int32?, currency: String, totalAmount: Int64, startParam: String, extendedMedia: Api.MessageExtendedMedia?)
|
||||||
case messageMediaPhoto(flags: Int32, photo: Api.Photo?, ttlSeconds: Int32?)
|
case messageMediaPhoto(flags: Int32, photo: Api.Photo?, ttlSeconds: Int32?)
|
||||||
case messageMediaPoll(poll: Api.Poll, results: Api.PollResults)
|
case messageMediaPoll(poll: Api.Poll, results: Api.PollResults)
|
||||||
@ -783,12 +783,13 @@ public extension Api {
|
|||||||
serializeInt32(months, buffer: buffer, boxed: false)
|
serializeInt32(months, buffer: buffer, boxed: false)
|
||||||
serializeInt32(untilDate, buffer: buffer, boxed: false)
|
serializeInt32(untilDate, buffer: buffer, boxed: false)
|
||||||
break
|
break
|
||||||
case .messageMediaGiveawayResults(let flags, let channelId, let launchMsgId, let winnersCount, let unclaimedCount, let winners, let months, let prizeDescription):
|
case .messageMediaGiveawayResults(let flags, let channelId, let additionalPeersCount, let launchMsgId, let winnersCount, let unclaimedCount, let winners, let months, let prizeDescription, let untilDate):
|
||||||
if boxed {
|
if boxed {
|
||||||
buffer.appendInt32(-1323305567)
|
buffer.appendInt32(-963047320)
|
||||||
}
|
}
|
||||||
serializeInt32(flags, buffer: buffer, boxed: false)
|
serializeInt32(flags, buffer: buffer, boxed: false)
|
||||||
serializeInt64(channelId, buffer: buffer, boxed: false)
|
serializeInt64(channelId, buffer: buffer, boxed: false)
|
||||||
|
if Int(flags) & Int(1 << 3) != 0 {serializeInt32(additionalPeersCount!, buffer: buffer, boxed: false)}
|
||||||
serializeInt32(launchMsgId, buffer: buffer, boxed: false)
|
serializeInt32(launchMsgId, buffer: buffer, boxed: false)
|
||||||
serializeInt32(winnersCount, buffer: buffer, boxed: false)
|
serializeInt32(winnersCount, buffer: buffer, boxed: false)
|
||||||
serializeInt32(unclaimedCount, buffer: buffer, boxed: false)
|
serializeInt32(unclaimedCount, buffer: buffer, boxed: false)
|
||||||
@ -799,6 +800,7 @@ public extension Api {
|
|||||||
}
|
}
|
||||||
serializeInt32(months, buffer: buffer, boxed: false)
|
serializeInt32(months, buffer: buffer, boxed: false)
|
||||||
if Int(flags) & Int(1 << 1) != 0 {serializeString(prizeDescription!, buffer: buffer, boxed: false)}
|
if Int(flags) & Int(1 << 1) != 0 {serializeString(prizeDescription!, buffer: buffer, boxed: false)}
|
||||||
|
serializeInt32(untilDate, buffer: buffer, boxed: false)
|
||||||
break
|
break
|
||||||
case .messageMediaInvoice(let flags, let title, let description, let photo, let receiptMsgId, let currency, let totalAmount, let startParam, let extendedMedia):
|
case .messageMediaInvoice(let flags, let title, let description, let photo, let receiptMsgId, let currency, let totalAmount, let startParam, let extendedMedia):
|
||||||
if boxed {
|
if boxed {
|
||||||
@ -883,8 +885,8 @@ public extension Api {
|
|||||||
return ("messageMediaGeoLive", [("flags", flags as Any), ("geo", geo as Any), ("heading", heading as Any), ("period", period as Any), ("proximityNotificationRadius", proximityNotificationRadius as Any)])
|
return ("messageMediaGeoLive", [("flags", flags as Any), ("geo", geo as Any), ("heading", heading as Any), ("period", period as Any), ("proximityNotificationRadius", proximityNotificationRadius as Any)])
|
||||||
case .messageMediaGiveaway(let flags, let channels, let countriesIso2, let prizeDescription, let quantity, let months, let untilDate):
|
case .messageMediaGiveaway(let flags, let channels, let countriesIso2, let prizeDescription, let quantity, let months, let untilDate):
|
||||||
return ("messageMediaGiveaway", [("flags", flags as Any), ("channels", channels as Any), ("countriesIso2", countriesIso2 as Any), ("prizeDescription", prizeDescription as Any), ("quantity", quantity as Any), ("months", months as Any), ("untilDate", untilDate as Any)])
|
return ("messageMediaGiveaway", [("flags", flags as Any), ("channels", channels as Any), ("countriesIso2", countriesIso2 as Any), ("prizeDescription", prizeDescription as Any), ("quantity", quantity as Any), ("months", months as Any), ("untilDate", untilDate as Any)])
|
||||||
case .messageMediaGiveawayResults(let flags, let channelId, let launchMsgId, let winnersCount, let unclaimedCount, let winners, let months, let prizeDescription):
|
case .messageMediaGiveawayResults(let flags, let channelId, let additionalPeersCount, let launchMsgId, let winnersCount, let unclaimedCount, let winners, let months, let prizeDescription, let untilDate):
|
||||||
return ("messageMediaGiveawayResults", [("flags", flags as Any), ("channelId", channelId as Any), ("launchMsgId", launchMsgId as Any), ("winnersCount", winnersCount as Any), ("unclaimedCount", unclaimedCount as Any), ("winners", winners as Any), ("months", months as Any), ("prizeDescription", prizeDescription as Any)])
|
return ("messageMediaGiveawayResults", [("flags", flags as Any), ("channelId", channelId as Any), ("additionalPeersCount", additionalPeersCount as Any), ("launchMsgId", launchMsgId as Any), ("winnersCount", winnersCount as Any), ("unclaimedCount", unclaimedCount as Any), ("winners", winners as Any), ("months", months as Any), ("prizeDescription", prizeDescription as Any), ("untilDate", untilDate as Any)])
|
||||||
case .messageMediaInvoice(let flags, let title, let description, let photo, let receiptMsgId, let currency, let totalAmount, let startParam, let extendedMedia):
|
case .messageMediaInvoice(let flags, let title, let description, let photo, let receiptMsgId, let currency, let totalAmount, let startParam, let extendedMedia):
|
||||||
return ("messageMediaInvoice", [("flags", flags as Any), ("title", title as Any), ("description", description as Any), ("photo", photo as Any), ("receiptMsgId", receiptMsgId as Any), ("currency", currency as Any), ("totalAmount", totalAmount as Any), ("startParam", startParam as Any), ("extendedMedia", extendedMedia as Any)])
|
return ("messageMediaInvoice", [("flags", flags as Any), ("title", title as Any), ("description", description as Any), ("photo", photo as Any), ("receiptMsgId", receiptMsgId as Any), ("currency", currency as Any), ("totalAmount", totalAmount as Any), ("startParam", startParam as Any), ("extendedMedia", extendedMedia as Any)])
|
||||||
case .messageMediaPhoto(let flags, let photo, let ttlSeconds):
|
case .messageMediaPhoto(let flags, let photo, let ttlSeconds):
|
||||||
@ -1056,29 +1058,35 @@ public extension Api {
|
|||||||
var _2: Int64?
|
var _2: Int64?
|
||||||
_2 = reader.readInt64()
|
_2 = reader.readInt64()
|
||||||
var _3: Int32?
|
var _3: Int32?
|
||||||
_3 = reader.readInt32()
|
if Int(_1!) & Int(1 << 3) != 0 {_3 = reader.readInt32() }
|
||||||
var _4: Int32?
|
var _4: Int32?
|
||||||
_4 = reader.readInt32()
|
_4 = reader.readInt32()
|
||||||
var _5: Int32?
|
var _5: Int32?
|
||||||
_5 = reader.readInt32()
|
_5 = reader.readInt32()
|
||||||
var _6: [Int64]?
|
var _6: Int32?
|
||||||
|
_6 = reader.readInt32()
|
||||||
|
var _7: [Int64]?
|
||||||
if let _ = reader.readInt32() {
|
if let _ = reader.readInt32() {
|
||||||
_6 = Api.parseVector(reader, elementSignature: 570911930, elementType: Int64.self)
|
_7 = Api.parseVector(reader, elementSignature: 570911930, elementType: Int64.self)
|
||||||
}
|
}
|
||||||
var _7: Int32?
|
var _8: Int32?
|
||||||
_7 = reader.readInt32()
|
_8 = reader.readInt32()
|
||||||
var _8: String?
|
var _9: String?
|
||||||
if Int(_1!) & Int(1 << 1) != 0 {_8 = parseString(reader) }
|
if Int(_1!) & Int(1 << 1) != 0 {_9 = parseString(reader) }
|
||||||
|
var _10: Int32?
|
||||||
|
_10 = reader.readInt32()
|
||||||
let _c1 = _1 != nil
|
let _c1 = _1 != nil
|
||||||
let _c2 = _2 != nil
|
let _c2 = _2 != nil
|
||||||
let _c3 = _3 != nil
|
let _c3 = (Int(_1!) & Int(1 << 3) == 0) || _3 != nil
|
||||||
let _c4 = _4 != nil
|
let _c4 = _4 != nil
|
||||||
let _c5 = _5 != nil
|
let _c5 = _5 != nil
|
||||||
let _c6 = _6 != nil
|
let _c6 = _6 != nil
|
||||||
let _c7 = _7 != nil
|
let _c7 = _7 != nil
|
||||||
let _c8 = (Int(_1!) & Int(1 << 1) == 0) || _8 != nil
|
let _c8 = _8 != nil
|
||||||
if _c1 && _c2 && _c3 && _c4 && _c5 && _c6 && _c7 && _c8 {
|
let _c9 = (Int(_1!) & Int(1 << 1) == 0) || _9 != nil
|
||||||
return Api.MessageMedia.messageMediaGiveawayResults(flags: _1!, channelId: _2!, launchMsgId: _3!, winnersCount: _4!, unclaimedCount: _5!, winners: _6!, months: _7!, prizeDescription: _8)
|
let _c10 = _10 != nil
|
||||||
|
if _c1 && _c2 && _c3 && _c4 && _c5 && _c6 && _c7 && _c8 && _c9 && _c10 {
|
||||||
|
return Api.MessageMedia.messageMediaGiveawayResults(flags: _1!, channelId: _2!, additionalPeersCount: _3, launchMsgId: _4!, winnersCount: _5!, unclaimedCount: _6!, winners: _7!, months: _8!, prizeDescription: _9, untilDate: _10!)
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
return nil
|
return nil
|
||||||
|
@ -244,7 +244,7 @@ func apiMessagePeerIds(_ message: Api.Message) -> [PeerId] {
|
|||||||
}
|
}
|
||||||
case let .messageActionRequestedPeer(_, peer):
|
case let .messageActionRequestedPeer(_, peer):
|
||||||
result.append(peer.peerId)
|
result.append(peer.peerId)
|
||||||
case let .messageActionGiftCode(_, boostPeer, _, _):
|
case let .messageActionGiftCode(_, boostPeer, _, _, _, _, _, _):
|
||||||
if let boostPeer = boostPeer {
|
if let boostPeer = boostPeer {
|
||||||
result.append(boostPeer.peerId)
|
result.append(boostPeer.peerId)
|
||||||
}
|
}
|
||||||
@ -428,12 +428,15 @@ func textMediaAndExpirationTimerFromApiMedia(_ media: Api.MessageMedia?, _ peerI
|
|||||||
flags.insert(.onlyNewSubscribers)
|
flags.insert(.onlyNewSubscribers)
|
||||||
}
|
}
|
||||||
return (TelegramMediaGiveaway(flags: flags, channelPeerIds: channels.map { PeerId(namespace: Namespaces.Peer.CloudChannel, id: PeerId.Id._internalFromInt64Value($0)) }, countries: countries ?? [], quantity: quantity, months: months, untilDate: untilDate, prizeDescription: prizeDescription), nil, nil, nil, nil)
|
return (TelegramMediaGiveaway(flags: flags, channelPeerIds: channels.map { PeerId(namespace: Namespaces.Peer.CloudChannel, id: PeerId.Id._internalFromInt64Value($0)) }, countries: countries ?? [], quantity: quantity, months: months, untilDate: untilDate, prizeDescription: prizeDescription), nil, nil, nil, nil)
|
||||||
case let .messageMediaGiveawayResults(apiFlags, channelId, launchMsgId, winnersCount, unclaimedCount, winners, months, prizeDescription):
|
case let .messageMediaGiveawayResults(apiFlags, channelId, additionalPeersCount, launchMsgId, winnersCount, unclaimedCount, winners, months, prizeDescription, untilDate):
|
||||||
var flags: TelegramMediaGiveawayResults.Flags = []
|
var flags: TelegramMediaGiveawayResults.Flags = []
|
||||||
if (apiFlags & (1 << 0)) != 0 {
|
if (apiFlags & (1 << 0)) != 0 {
|
||||||
|
flags.insert(.onlyNewSubscribers)
|
||||||
|
}
|
||||||
|
if (apiFlags & (1 << 2)) != 0 {
|
||||||
flags.insert(.refunded)
|
flags.insert(.refunded)
|
||||||
}
|
}
|
||||||
return (TelegramMediaGiveawayResults(flags: flags, launchMessageId: MessageId(peerId: PeerId(namespace: Namespaces.Peer.CloudChannel, id: PeerId.Id._internalFromInt64Value(channelId)), namespace: Namespaces.Message.Cloud, id: launchMsgId), winnersPeerIds: winners.map { PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt64Value($0)) }, winnersCount: winnersCount, unclaimedCount: unclaimedCount, months: months, prizeDescription: prizeDescription), nil, nil, nil, nil)
|
return (TelegramMediaGiveawayResults(flags: flags, launchMessageId: MessageId(peerId: PeerId(namespace: Namespaces.Peer.CloudChannel, id: PeerId.Id._internalFromInt64Value(channelId)), namespace: Namespaces.Message.Cloud, id: launchMsgId), additionalChannelsCount: additionalPeersCount ?? 0, winnersPeerIds: winners.map { PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt64Value($0)) }, winnersCount: winnersCount, unclaimedCount: unclaimedCount, months: months, untilDate: untilDate, prizeDescription: prizeDescription), nil, nil, nil, nil)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -129,8 +129,8 @@ func telegramMediaActionFromApiAction(_ action: Api.MessageAction) -> TelegramMe
|
|||||||
} else {
|
} else {
|
||||||
return TelegramMediaAction(action: .setChatWallpaper(wallpaper: TelegramWallpaper(apiWallpaper: wallpaper), forBoth: (flags & (1 << 1)) != 0))
|
return TelegramMediaAction(action: .setChatWallpaper(wallpaper: TelegramWallpaper(apiWallpaper: wallpaper), forBoth: (flags & (1 << 1)) != 0))
|
||||||
}
|
}
|
||||||
case let .messageActionGiftCode(flags, boostPeer, months, slug):
|
case let .messageActionGiftCode(flags, boostPeer, months, slug, currency, amount, cryptoCurrency, cryptoAmount):
|
||||||
return TelegramMediaAction(action: .giftCode(slug: slug, fromGiveaway: (flags & (1 << 0)) != 0, isUnclaimed: (flags & (1 << 2)) != 0, boostPeerId: boostPeer?.peerId, months: months))
|
return TelegramMediaAction(action: .giftCode(slug: slug, fromGiveaway: (flags & (1 << 0)) != 0, isUnclaimed: (flags & (1 << 2)) != 0, boostPeerId: boostPeer?.peerId, months: months, currency: currency, amount: amount, cryptoCurrency: cryptoCurrency, cryptoAmount: cryptoAmount))
|
||||||
case .messageActionGiveawayLaunch:
|
case .messageActionGiveawayLaunch:
|
||||||
return TelegramMediaAction(action: .giveawayLaunched)
|
return TelegramMediaAction(action: .giveawayLaunched)
|
||||||
case let .messageActionGiveawayResults(winners, unclaimed):
|
case let .messageActionGiveawayResults(winners, unclaimed):
|
||||||
|
@ -109,7 +109,7 @@ public enum TelegramMediaActionType: PostboxCoding, Equatable {
|
|||||||
case requestedPeer(buttonId: Int32, peerId: PeerId)
|
case requestedPeer(buttonId: Int32, peerId: PeerId)
|
||||||
case setChatWallpaper(wallpaper: TelegramWallpaper, forBoth: Bool)
|
case setChatWallpaper(wallpaper: TelegramWallpaper, forBoth: Bool)
|
||||||
case setSameChatWallpaper(wallpaper: TelegramWallpaper)
|
case setSameChatWallpaper(wallpaper: TelegramWallpaper)
|
||||||
case giftCode(slug: String, fromGiveaway: Bool, isUnclaimed: Bool, boostPeerId: PeerId?, months: Int32)
|
case giftCode(slug: String, fromGiveaway: Bool, isUnclaimed: Bool, boostPeerId: PeerId?, months: Int32, currency: String?, amount: Int64?, cryptoCurrency: String?, cryptoAmount: Int64?)
|
||||||
case giveawayLaunched
|
case giveawayLaunched
|
||||||
case joinedChannel
|
case joinedChannel
|
||||||
case giveawayResults(winners: Int32, unclaimed: Int32)
|
case giveawayResults(winners: Int32, unclaimed: Int32)
|
||||||
@ -208,7 +208,7 @@ public enum TelegramMediaActionType: PostboxCoding, Equatable {
|
|||||||
case 35:
|
case 35:
|
||||||
self = .botAppAccessGranted(appName: decoder.decodeOptionalStringForKey("app"), type: decoder.decodeOptionalInt32ForKey("atp").flatMap { BotSendMessageAccessGrantedType(rawValue: $0) })
|
self = .botAppAccessGranted(appName: decoder.decodeOptionalStringForKey("app"), type: decoder.decodeOptionalInt32ForKey("atp").flatMap { BotSendMessageAccessGrantedType(rawValue: $0) })
|
||||||
case 36:
|
case 36:
|
||||||
self = .giftCode(slug: decoder.decodeStringForKey("slug", orElse: ""), fromGiveaway: decoder.decodeBoolForKey("give", orElse: false), isUnclaimed: decoder.decodeBoolForKey("unclaimed", orElse: false), boostPeerId: PeerId(decoder.decodeInt64ForKey("pi", orElse: 0)), months: decoder.decodeInt32ForKey("months", orElse: 0))
|
self = .giftCode(slug: decoder.decodeStringForKey("slug", orElse: ""), fromGiveaway: decoder.decodeBoolForKey("give", orElse: false), isUnclaimed: decoder.decodeBoolForKey("unclaimed", orElse: false), boostPeerId: PeerId(decoder.decodeInt64ForKey("pi", orElse: 0)), months: decoder.decodeInt32ForKey("months", orElse: 0), currency: decoder.decodeOptionalStringForKey("currency"), amount: decoder.decodeOptionalInt64ForKey("amount"), cryptoCurrency: decoder.decodeOptionalStringForKey("cryptoCurrency"), cryptoAmount: decoder.decodeOptionalInt64ForKey("cryptoAmount"))
|
||||||
case 37:
|
case 37:
|
||||||
self = .giveawayLaunched
|
self = .giveawayLaunched
|
||||||
case 38:
|
case 38:
|
||||||
@ -395,7 +395,7 @@ public enum TelegramMediaActionType: PostboxCoding, Equatable {
|
|||||||
} else {
|
} else {
|
||||||
encoder.encodeNil(forKey: "atp")
|
encoder.encodeNil(forKey: "atp")
|
||||||
}
|
}
|
||||||
case let .giftCode(slug, fromGiveaway, unclaimed, boostPeerId, months):
|
case let .giftCode(slug, fromGiveaway, unclaimed, boostPeerId, months, currency, amount, cryptoCurrency, cryptoAmount):
|
||||||
encoder.encodeInt32(36, forKey: "_rawValue")
|
encoder.encodeInt32(36, forKey: "_rawValue")
|
||||||
encoder.encodeString(slug, forKey: "slug")
|
encoder.encodeString(slug, forKey: "slug")
|
||||||
encoder.encodeBool(fromGiveaway, forKey: "give")
|
encoder.encodeBool(fromGiveaway, forKey: "give")
|
||||||
@ -406,6 +406,26 @@ public enum TelegramMediaActionType: PostboxCoding, Equatable {
|
|||||||
encoder.encodeNil(forKey: "pi")
|
encoder.encodeNil(forKey: "pi")
|
||||||
}
|
}
|
||||||
encoder.encodeInt32(months, forKey: "months")
|
encoder.encodeInt32(months, forKey: "months")
|
||||||
|
if let currency = currency {
|
||||||
|
encoder.encodeString(currency, forKey: "currency")
|
||||||
|
} else {
|
||||||
|
encoder.encodeNil(forKey: "currency")
|
||||||
|
}
|
||||||
|
if let amount = amount {
|
||||||
|
encoder.encodeInt64(amount, forKey: "amount")
|
||||||
|
} else {
|
||||||
|
encoder.encodeNil(forKey: "amount")
|
||||||
|
}
|
||||||
|
if let cryptoCurrency = cryptoCurrency {
|
||||||
|
encoder.encodeString(cryptoCurrency, forKey: "cryptoCurrency")
|
||||||
|
} else {
|
||||||
|
encoder.encodeNil(forKey: "cryptoCurrency")
|
||||||
|
}
|
||||||
|
if let cryptoAmount = cryptoAmount {
|
||||||
|
encoder.encodeInt64(cryptoAmount, forKey: "cryptoAmount")
|
||||||
|
} else {
|
||||||
|
encoder.encodeNil(forKey: "cryptoAmount")
|
||||||
|
}
|
||||||
case .giveawayLaunched:
|
case .giveawayLaunched:
|
||||||
encoder.encodeInt32(37, forKey: "_rawValue")
|
encoder.encodeInt32(37, forKey: "_rawValue")
|
||||||
case .joinedChannel:
|
case .joinedChannel:
|
||||||
@ -435,7 +455,7 @@ public enum TelegramMediaActionType: PostboxCoding, Equatable {
|
|||||||
return peerIds
|
return peerIds
|
||||||
case let .requestedPeer(_, peerId):
|
case let .requestedPeer(_, peerId):
|
||||||
return [peerId]
|
return [peerId]
|
||||||
case let .giftCode(_, _, _, boostPeerId, _):
|
case let .giftCode(_, _, _, boostPeerId, _, _, _, _, _):
|
||||||
return boostPeerId.flatMap { [$0] } ?? []
|
return boostPeerId.flatMap { [$0] } ?? []
|
||||||
default:
|
default:
|
||||||
return []
|
return []
|
||||||
|
@ -9,6 +9,7 @@ public final class TelegramMediaGiveawayResults: Media, Equatable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static let refunded = Flags(rawValue: 1 << 0)
|
public static let refunded = Flags(rawValue: 1 << 0)
|
||||||
|
public static let onlyNewSubscribers = Flags(rawValue: 1 << 1)
|
||||||
}
|
}
|
||||||
|
|
||||||
public var id: MediaId? {
|
public var id: MediaId? {
|
||||||
@ -20,29 +21,35 @@ public final class TelegramMediaGiveawayResults: Media, Equatable {
|
|||||||
|
|
||||||
public let flags: Flags
|
public let flags: Flags
|
||||||
public let launchMessageId: MessageId
|
public let launchMessageId: MessageId
|
||||||
|
public let additionalChannelsCount: Int32
|
||||||
public let winnersPeerIds: [PeerId]
|
public let winnersPeerIds: [PeerId]
|
||||||
public let winnersCount: Int32
|
public let winnersCount: Int32
|
||||||
public let unclaimedCount: Int32
|
public let unclaimedCount: Int32
|
||||||
public let months: Int32
|
public let months: Int32
|
||||||
|
public let untilDate: Int32
|
||||||
public let prizeDescription: String?
|
public let prizeDescription: String?
|
||||||
|
|
||||||
public init(flags: Flags, launchMessageId: MessageId, winnersPeerIds: [PeerId], winnersCount: Int32, unclaimedCount: Int32, months: Int32, prizeDescription: String?) {
|
public init(flags: Flags, launchMessageId: MessageId, additionalChannelsCount: Int32, winnersPeerIds: [PeerId], winnersCount: Int32, unclaimedCount: Int32, months: Int32, untilDate: Int32, prizeDescription: String?) {
|
||||||
self.flags = flags
|
self.flags = flags
|
||||||
self.launchMessageId = launchMessageId
|
self.launchMessageId = launchMessageId
|
||||||
|
self.additionalChannelsCount = additionalChannelsCount
|
||||||
self.winnersPeerIds = winnersPeerIds
|
self.winnersPeerIds = winnersPeerIds
|
||||||
self.winnersCount = winnersCount
|
self.winnersCount = winnersCount
|
||||||
self.unclaimedCount = unclaimedCount
|
self.unclaimedCount = unclaimedCount
|
||||||
self.months = months
|
self.months = months
|
||||||
|
self.untilDate = untilDate
|
||||||
self.prizeDescription = prizeDescription
|
self.prizeDescription = prizeDescription
|
||||||
}
|
}
|
||||||
|
|
||||||
public init(decoder: PostboxDecoder) {
|
public init(decoder: PostboxDecoder) {
|
||||||
self.flags = Flags(rawValue: decoder.decodeInt32ForKey("flg", orElse: 0))
|
self.flags = Flags(rawValue: decoder.decodeInt32ForKey("flg", orElse: 0))
|
||||||
self.launchMessageId = MessageId(peerId: PeerId(decoder.decodeInt64ForKey("msgp", orElse: 0)), namespace: Namespaces.Message.Cloud, id: decoder.decodeInt32ForKey("msgi", orElse: 0))
|
self.launchMessageId = MessageId(peerId: PeerId(decoder.decodeInt64ForKey("msgp", orElse: 0)), namespace: Namespaces.Message.Cloud, id: decoder.decodeInt32ForKey("msgi", orElse: 0))
|
||||||
|
self.additionalChannelsCount = decoder.decodeInt32ForKey("chn", orElse: 0)
|
||||||
self.winnersPeerIds = decoder.decodeInt64ArrayForKey("wnr").map { PeerId($0) }
|
self.winnersPeerIds = decoder.decodeInt64ArrayForKey("wnr").map { PeerId($0) }
|
||||||
self.winnersCount = decoder.decodeInt32ForKey("wnc", orElse: 0)
|
self.winnersCount = decoder.decodeInt32ForKey("wnc", orElse: 0)
|
||||||
self.unclaimedCount = decoder.decodeInt32ForKey("unc", orElse: 0)
|
self.unclaimedCount = decoder.decodeInt32ForKey("unc", orElse: 0)
|
||||||
self.months = decoder.decodeInt32ForKey("mts", orElse: 0)
|
self.months = decoder.decodeInt32ForKey("mts", orElse: 0)
|
||||||
|
self.untilDate = decoder.decodeInt32ForKey("unt", orElse: 0)
|
||||||
self.prizeDescription = decoder.decodeOptionalStringForKey("des")
|
self.prizeDescription = decoder.decodeOptionalStringForKey("des")
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -50,10 +57,12 @@ public final class TelegramMediaGiveawayResults: Media, Equatable {
|
|||||||
encoder.encodeInt32(self.flags.rawValue, forKey: "flg")
|
encoder.encodeInt32(self.flags.rawValue, forKey: "flg")
|
||||||
encoder.encodeInt64(self.launchMessageId.peerId.toInt64(), forKey: "msgp")
|
encoder.encodeInt64(self.launchMessageId.peerId.toInt64(), forKey: "msgp")
|
||||||
encoder.encodeInt32(self.launchMessageId.id, forKey: "msgi")
|
encoder.encodeInt32(self.launchMessageId.id, forKey: "msgi")
|
||||||
|
encoder.encodeInt32(self.additionalChannelsCount, forKey: "chn")
|
||||||
encoder.encodeInt64Array(self.winnersPeerIds.map { $0.toInt64() }, forKey: "wnr")
|
encoder.encodeInt64Array(self.winnersPeerIds.map { $0.toInt64() }, forKey: "wnr")
|
||||||
encoder.encodeInt32(self.winnersCount, forKey: "wnc")
|
encoder.encodeInt32(self.winnersCount, forKey: "wnc")
|
||||||
encoder.encodeInt32(self.unclaimedCount, forKey: "unc")
|
encoder.encodeInt32(self.unclaimedCount, forKey: "unc")
|
||||||
encoder.encodeInt32(self.months, forKey: "mts")
|
encoder.encodeInt32(self.months, forKey: "mts")
|
||||||
|
encoder.encodeInt32(self.untilDate, forKey: "unt")
|
||||||
if let prizeDescription = self.prizeDescription {
|
if let prizeDescription = self.prizeDescription {
|
||||||
encoder.encodeString(prizeDescription, forKey: "des")
|
encoder.encodeString(prizeDescription, forKey: "des")
|
||||||
} else {
|
} else {
|
||||||
@ -75,6 +84,9 @@ public final class TelegramMediaGiveawayResults: Media, Equatable {
|
|||||||
if self.launchMessageId != other.launchMessageId {
|
if self.launchMessageId != other.launchMessageId {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
if self.additionalChannelsCount != other.additionalChannelsCount {
|
||||||
|
return false
|
||||||
|
}
|
||||||
if self.winnersPeerIds != other.winnersPeerIds {
|
if self.winnersPeerIds != other.winnersPeerIds {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
@ -87,6 +99,9 @@ public final class TelegramMediaGiveawayResults: Media, Equatable {
|
|||||||
if self.months != other.months {
|
if self.months != other.months {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
if self.untilDate != other.untilDate {
|
||||||
|
return false
|
||||||
|
}
|
||||||
if self.prizeDescription != other.prizeDescription {
|
if self.prizeDescription != other.prizeDescription {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
@ -252,7 +252,7 @@ public class ChatMessageGiftBubbleContentNode: ChatMessageBubbleContentNode {
|
|||||||
case let .giftPremium(_, _, monthsValue, _, _):
|
case let .giftPremium(_, _, monthsValue, _, _):
|
||||||
months = monthsValue
|
months = monthsValue
|
||||||
text = item.presentationData.strings.Notification_PremiumGift_Subtitle(item.presentationData.strings.Notification_PremiumGift_Months(months)).string
|
text = item.presentationData.strings.Notification_PremiumGift_Subtitle(item.presentationData.strings.Notification_PremiumGift_Months(months)).string
|
||||||
case let .giftCode(_, fromGiveaway, unclaimed, channelId, monthsValue):
|
case let .giftCode(_, fromGiveaway, unclaimed, channelId, monthsValue, _, _, _, _):
|
||||||
giftSize.width += 34.0
|
giftSize.width += 34.0
|
||||||
textSpacing += 13.0
|
textSpacing += 13.0
|
||||||
|
|
||||||
|
@ -958,7 +958,7 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G
|
|||||||
let controller = PremiumIntroScreen(context: strongSelf.context, source: .gift(from: fromPeerId, to: toPeerId, duration: duration))
|
let controller = PremiumIntroScreen(context: strongSelf.context, source: .gift(from: fromPeerId, to: toPeerId, duration: duration))
|
||||||
strongSelf.push(controller)
|
strongSelf.push(controller)
|
||||||
return true
|
return true
|
||||||
case let .giftCode(slug, _, _, _, _):
|
case let .giftCode(slug, _, _, _, _, _, _, _, _):
|
||||||
strongSelf.openResolved(result: .premiumGiftCode(slug: slug), sourceMessageId: message.id, progress: params.progress)
|
strongSelf.openResolved(result: .premiumGiftCode(slug: slug), sourceMessageId: message.id, progress: params.progress)
|
||||||
return true
|
return true
|
||||||
case let .suggestedProfilePhoto(image):
|
case let .suggestedProfilePhoto(image):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user