mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-12-27 16:38:09 +00:00
Update API
This commit is contained in:
@@ -551,7 +551,7 @@ public final class CachedChannelData: CachedPeerData {
|
||||
var peerIds = Set<PeerId>()
|
||||
|
||||
if let legacyValue = decoder.decodeOptionalInt32ForKey("pcs") {
|
||||
self.peerStatusSettings = PeerStatusSettings(flags: PeerStatusSettings.Flags(rawValue: legacyValue), geoDistance: nil)
|
||||
self.peerStatusSettings = PeerStatusSettings(flags: PeerStatusSettings.Flags(rawValue: legacyValue), geoDistance: nil, managingBot: nil)
|
||||
} else if let peerStatusSettings = decoder.decodeObjectForKey("pss", decoder: { PeerStatusSettings(decoder: $0) }) as? PeerStatusSettings {
|
||||
self.peerStatusSettings = peerStatusSettings
|
||||
} else {
|
||||
|
||||
@@ -203,7 +203,7 @@ public final class CachedGroupData: CachedPeerData {
|
||||
self.exportedInvitation = decoder.decode(ExportedInvitation.self, forKey: "i")
|
||||
self.botInfos = decoder.decodeObjectArrayWithDecoderForKey("b") as [CachedPeerBotInfo]
|
||||
if let legacyValue = decoder.decodeOptionalInt32ForKey("pcs") {
|
||||
self.peerStatusSettings = PeerStatusSettings(flags: PeerStatusSettings.Flags(rawValue: legacyValue), geoDistance: nil)
|
||||
self.peerStatusSettings = PeerStatusSettings(flags: PeerStatusSettings.Flags(rawValue: legacyValue), geoDistance: nil, managingBot: nil)
|
||||
} else if let peerStatusSettings = decoder.decodeObjectForKey("pss", decoder: { PeerStatusSettings(decoder: $0) }) as? PeerStatusSettings {
|
||||
self.peerStatusSettings = peerStatusSettings
|
||||
} else {
|
||||
|
||||
@@ -558,7 +558,7 @@ public final class CachedUserData: CachedPeerData {
|
||||
self.botInfo = decoder.decodeObjectForKey("bi") as? BotInfo
|
||||
self.editableBotInfo = decoder.decodeObjectForKey("ebi") as? EditableBotInfo
|
||||
if let legacyValue = decoder.decodeOptionalInt32ForKey("pcs") {
|
||||
self.peerStatusSettings = PeerStatusSettings(flags: PeerStatusSettings.Flags(rawValue: legacyValue), geoDistance: nil)
|
||||
self.peerStatusSettings = PeerStatusSettings(flags: PeerStatusSettings.Flags(rawValue: legacyValue), geoDistance: nil, managingBot: nil)
|
||||
} else if let peerStatusSettings = decoder.decodeObjectForKey("pss", decoder: { PeerStatusSettings(decoder: $0) }) as? PeerStatusSettings {
|
||||
self.peerStatusSettings = peerStatusSettings
|
||||
} else {
|
||||
|
||||
@@ -19,25 +19,39 @@ public struct PeerStatusSettings: PostboxCoding, Equatable {
|
||||
|
||||
}
|
||||
|
||||
public struct ManagingBot: Codable, Equatable {
|
||||
public var id: PeerId
|
||||
public var manageUrl: String?
|
||||
|
||||
public init(id: PeerId, manageUrl: String?) {
|
||||
self.id = id
|
||||
self.manageUrl = manageUrl
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public var flags: PeerStatusSettings.Flags
|
||||
public var geoDistance: Int32?
|
||||
public var requestChatTitle: String?
|
||||
public var requestChatDate: Int32?
|
||||
public var requestChatIsChannel: Bool?
|
||||
public var managingBot: ManagingBot?
|
||||
|
||||
public init() {
|
||||
self.flags = PeerStatusSettings.Flags()
|
||||
self.geoDistance = nil
|
||||
self.requestChatTitle = nil
|
||||
self.requestChatDate = nil
|
||||
self.managingBot = nil
|
||||
}
|
||||
|
||||
public init(flags: PeerStatusSettings.Flags, geoDistance: Int32? = nil, requestChatTitle: String? = nil, requestChatDate: Int32? = nil, requestChatIsChannel: Bool? = nil) {
|
||||
public init(flags: PeerStatusSettings.Flags, geoDistance: Int32? = nil, requestChatTitle: String? = nil, requestChatDate: Int32? = nil, requestChatIsChannel: Bool? = nil, managingBot: ManagingBot? = nil) {
|
||||
self.flags = flags
|
||||
self.geoDistance = geoDistance
|
||||
self.requestChatTitle = requestChatTitle
|
||||
self.requestChatDate = requestChatDate
|
||||
self.requestChatIsChannel = requestChatIsChannel
|
||||
self.managingBot = managingBot
|
||||
}
|
||||
|
||||
public init(decoder: PostboxDecoder) {
|
||||
@@ -46,6 +60,7 @@ public struct PeerStatusSettings: PostboxCoding, Equatable {
|
||||
self.requestChatTitle = decoder.decodeOptionalStringForKey("requestChatTitle")
|
||||
self.requestChatDate = decoder.decodeOptionalInt32ForKey("requestChatDate")
|
||||
self.requestChatIsChannel = decoder.decodeOptionalBoolForKey("requestChatIsChannel")
|
||||
self.managingBot = decoder.decodeCodable(ManagingBot.self, forKey: "managingBot")
|
||||
}
|
||||
|
||||
public func encode(_ encoder: PostboxEncoder) {
|
||||
@@ -70,6 +85,11 @@ public struct PeerStatusSettings: PostboxCoding, Equatable {
|
||||
} else {
|
||||
encoder.encodeNil(forKey: "requestChatIsChannel")
|
||||
}
|
||||
if let managingBot = self.managingBot {
|
||||
encoder.encodeCodable(managingBot, forKey: "managingBot")
|
||||
} else {
|
||||
encoder.encodeNil(forKey: "managingBot")
|
||||
}
|
||||
}
|
||||
|
||||
public func contains(_ member: PeerStatusSettings.Flags) -> Bool {
|
||||
|
||||
@@ -93,7 +93,7 @@ public final class CachedSecretChatData: CachedPeerData {
|
||||
|
||||
public init(decoder: PostboxDecoder) {
|
||||
if let legacyValue = decoder.decodeOptionalInt32ForKey("pcs") {
|
||||
self.peerStatusSettings = PeerStatusSettings(flags: PeerStatusSettings.Flags(rawValue: legacyValue), geoDistance: nil)
|
||||
self.peerStatusSettings = PeerStatusSettings(flags: PeerStatusSettings.Flags(rawValue: legacyValue), geoDistance: nil, managingBot: nil)
|
||||
} else if let peerStatusSettings = decoder.decodeObjectForKey("pss", decoder: { PeerStatusSettings(decoder: $0) }) as? PeerStatusSettings {
|
||||
self.peerStatusSettings = peerStatusSettings
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user