mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-08-16 10:30:08 +00:00
38 lines
1.0 KiB
Swift
38 lines
1.0 KiB
Swift
import Foundation
|
|
#if os(macOS)
|
|
import PostboxMac
|
|
#else
|
|
import Postbox
|
|
#endif
|
|
|
|
public struct PeerStatusSettings: OptionSet {
|
|
public var rawValue: Int32
|
|
|
|
public init(rawValue: Int32) {
|
|
self.rawValue = rawValue
|
|
}
|
|
|
|
public static let isHidden = PeerStatusSettings(rawValue: 1 << 0)
|
|
public static let canReport = PeerStatusSettings(rawValue: 1 << 1)
|
|
public static let canShareContact = PeerStatusSettings(rawValue: 1 << 2)
|
|
}
|
|
|
|
extension PeerStatusSettings {
|
|
init(apiSettings: Api.PeerSettings) {
|
|
switch apiSettings {
|
|
case let .peerSettings(flags):
|
|
var result = PeerStatusSettings()
|
|
if (flags & (1 << 1)) != 0 {
|
|
result.insert(.isHidden)
|
|
}
|
|
if (flags & (1 << 0)) != 0 {
|
|
result.insert(.canReport)
|
|
}
|
|
if (flags & (1 << 2)) != 0 {
|
|
result.insert(.canShareContact)
|
|
}
|
|
self = result
|
|
}
|
|
}
|
|
}
|