mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-12-24 07:05:35 +00:00
Update API
This commit is contained in:
@@ -109,7 +109,7 @@ public enum TelegramMediaActionType: PostboxCoding, Equatable {
|
||||
case requestedPeer(buttonId: Int32, peerId: PeerId)
|
||||
case setChatWallpaper(wallpaper: TelegramWallpaper, forBoth: Bool)
|
||||
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 joinedChannel
|
||||
case giveawayResults(winners: Int32, unclaimed: Int32)
|
||||
@@ -208,7 +208,7 @@ public enum TelegramMediaActionType: PostboxCoding, Equatable {
|
||||
case 35:
|
||||
self = .botAppAccessGranted(appName: decoder.decodeOptionalStringForKey("app"), type: decoder.decodeOptionalInt32ForKey("atp").flatMap { BotSendMessageAccessGrantedType(rawValue: $0) })
|
||||
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:
|
||||
self = .giveawayLaunched
|
||||
case 38:
|
||||
@@ -395,7 +395,7 @@ public enum TelegramMediaActionType: PostboxCoding, Equatable {
|
||||
} else {
|
||||
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.encodeString(slug, forKey: "slug")
|
||||
encoder.encodeBool(fromGiveaway, forKey: "give")
|
||||
@@ -406,6 +406,26 @@ public enum TelegramMediaActionType: PostboxCoding, Equatable {
|
||||
encoder.encodeNil(forKey: "pi")
|
||||
}
|
||||
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:
|
||||
encoder.encodeInt32(37, forKey: "_rawValue")
|
||||
case .joinedChannel:
|
||||
@@ -435,7 +455,7 @@ public enum TelegramMediaActionType: PostboxCoding, Equatable {
|
||||
return peerIds
|
||||
case let .requestedPeer(_, peerId):
|
||||
return [peerId]
|
||||
case let .giftCode(_, _, _, boostPeerId, _):
|
||||
case let .giftCode(_, _, _, boostPeerId, _, _, _, _, _):
|
||||
return boostPeerId.flatMap { [$0] } ?? []
|
||||
default:
|
||||
return []
|
||||
|
||||
@@ -9,6 +9,7 @@ public final class TelegramMediaGiveawayResults: Media, Equatable {
|
||||
}
|
||||
|
||||
public static let refunded = Flags(rawValue: 1 << 0)
|
||||
public static let onlyNewSubscribers = Flags(rawValue: 1 << 1)
|
||||
}
|
||||
|
||||
public var id: MediaId? {
|
||||
@@ -20,29 +21,35 @@ public final class TelegramMediaGiveawayResults: Media, Equatable {
|
||||
|
||||
public let flags: Flags
|
||||
public let launchMessageId: MessageId
|
||||
public let additionalChannelsCount: Int32
|
||||
public let winnersPeerIds: [PeerId]
|
||||
public let winnersCount: Int32
|
||||
public let unclaimedCount: Int32
|
||||
public let months: Int32
|
||||
public let untilDate: Int32
|
||||
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.launchMessageId = launchMessageId
|
||||
self.additionalChannelsCount = additionalChannelsCount
|
||||
self.winnersPeerIds = winnersPeerIds
|
||||
self.winnersCount = winnersCount
|
||||
self.unclaimedCount = unclaimedCount
|
||||
self.months = months
|
||||
self.untilDate = untilDate
|
||||
self.prizeDescription = prizeDescription
|
||||
}
|
||||
|
||||
public init(decoder: PostboxDecoder) {
|
||||
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.additionalChannelsCount = decoder.decodeInt32ForKey("chn", orElse: 0)
|
||||
self.winnersPeerIds = decoder.decodeInt64ArrayForKey("wnr").map { PeerId($0) }
|
||||
self.winnersCount = decoder.decodeInt32ForKey("wnc", orElse: 0)
|
||||
self.unclaimedCount = decoder.decodeInt32ForKey("unc", orElse: 0)
|
||||
self.months = decoder.decodeInt32ForKey("mts", orElse: 0)
|
||||
self.untilDate = decoder.decodeInt32ForKey("unt", orElse: 0)
|
||||
self.prizeDescription = decoder.decodeOptionalStringForKey("des")
|
||||
}
|
||||
|
||||
@@ -50,10 +57,12 @@ public final class TelegramMediaGiveawayResults: Media, Equatable {
|
||||
encoder.encodeInt32(self.flags.rawValue, forKey: "flg")
|
||||
encoder.encodeInt64(self.launchMessageId.peerId.toInt64(), forKey: "msgp")
|
||||
encoder.encodeInt32(self.launchMessageId.id, forKey: "msgi")
|
||||
encoder.encodeInt32(self.additionalChannelsCount, forKey: "chn")
|
||||
encoder.encodeInt64Array(self.winnersPeerIds.map { $0.toInt64() }, forKey: "wnr")
|
||||
encoder.encodeInt32(self.winnersCount, forKey: "wnc")
|
||||
encoder.encodeInt32(self.unclaimedCount, forKey: "unc")
|
||||
encoder.encodeInt32(self.months, forKey: "mts")
|
||||
encoder.encodeInt32(self.untilDate, forKey: "unt")
|
||||
if let prizeDescription = self.prizeDescription {
|
||||
encoder.encodeString(prizeDescription, forKey: "des")
|
||||
} else {
|
||||
@@ -75,6 +84,9 @@ public final class TelegramMediaGiveawayResults: Media, Equatable {
|
||||
if self.launchMessageId != other.launchMessageId {
|
||||
return false
|
||||
}
|
||||
if self.additionalChannelsCount != other.additionalChannelsCount {
|
||||
return false
|
||||
}
|
||||
if self.winnersPeerIds != other.winnersPeerIds {
|
||||
return false
|
||||
}
|
||||
@@ -87,6 +99,9 @@ public final class TelegramMediaGiveawayResults: Media, Equatable {
|
||||
if self.months != other.months {
|
||||
return false
|
||||
}
|
||||
if self.untilDate != other.untilDate {
|
||||
return false
|
||||
}
|
||||
if self.prizeDescription != other.prizeDescription {
|
||||
return false
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user