mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-12-24 07:05:35 +00:00
Various improvements
This commit is contained in:
@@ -4,23 +4,34 @@ public final class RestrictionRule: PostboxCoding, Equatable {
|
||||
public let platform: String
|
||||
public let reason: String
|
||||
public let text: String
|
||||
public let isSensitive: Bool
|
||||
|
||||
public init(platform: String, reason: String, text: String) {
|
||||
self.platform = platform
|
||||
self.reason = reason
|
||||
self.text = text
|
||||
self.isSensitive = false
|
||||
}
|
||||
|
||||
public init(platform: String) {
|
||||
self.platform = platform
|
||||
self.reason = ""
|
||||
self.text = ""
|
||||
self.isSensitive = true
|
||||
}
|
||||
|
||||
public init(decoder: PostboxDecoder) {
|
||||
self.platform = decoder.decodeStringForKey("p", orElse: "all")
|
||||
self.reason = decoder.decodeStringForKey("r", orElse: "")
|
||||
self.text = decoder.decodeStringForKey("t", orElse: "")
|
||||
self.isSensitive = decoder.decodeBoolForKey("s", orElse: false)
|
||||
}
|
||||
|
||||
public func encode(_ encoder: PostboxEncoder) {
|
||||
encoder.encodeString(self.platform, forKey: "p")
|
||||
encoder.encodeString(self.reason, forKey: "r")
|
||||
encoder.encodeString(self.text, forKey: "t")
|
||||
encoder.encodeBool(self.isSensitive, forKey: "s")
|
||||
}
|
||||
|
||||
public static func ==(lhs: RestrictionRule, rhs: RestrictionRule) -> Bool {
|
||||
@@ -33,6 +44,9 @@ public final class RestrictionRule: PostboxCoding, Equatable {
|
||||
if lhs.text != rhs.text {
|
||||
return false
|
||||
}
|
||||
if lhs.isSensitive != rhs.isSensitive {
|
||||
return false
|
||||
}
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user