mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-06-16 05:55:20 +00:00
49 lines
1.7 KiB
Swift
49 lines
1.7 KiB
Swift
import Foundation
|
|
import Postbox
|
|
|
|
public struct OutgoingMessageInfoFlags: OptionSet {
|
|
public var rawValue: Int32
|
|
|
|
public init() {
|
|
self.rawValue = 0
|
|
}
|
|
|
|
public init(rawValue: Int32) {
|
|
self.rawValue = rawValue
|
|
}
|
|
|
|
public static var transformedMedia = OutgoingMessageInfoFlags(rawValue: 1 << 0)
|
|
}
|
|
|
|
public class OutgoingMessageInfoAttribute: MessageAttribute {
|
|
public let uniqueId: Int64
|
|
public let flags: OutgoingMessageInfoFlags
|
|
public let acknowledged: Bool
|
|
|
|
public init(uniqueId: Int64, flags: OutgoingMessageInfoFlags, acknowledged: Bool) {
|
|
self.uniqueId = uniqueId
|
|
self.flags = flags
|
|
self.acknowledged = acknowledged
|
|
}
|
|
|
|
required public init(decoder: PostboxDecoder) {
|
|
self.uniqueId = decoder.decodeInt64ForKey("u", orElse: 0)
|
|
self.flags = OutgoingMessageInfoFlags(rawValue: decoder.decodeInt32ForKey("f", orElse: 0))
|
|
self.acknowledged = decoder.decodeInt32ForKey("ack", orElse: 0) != 0
|
|
}
|
|
|
|
public func encode(_ encoder: PostboxEncoder) {
|
|
encoder.encodeInt64(self.uniqueId, forKey: "u")
|
|
encoder.encodeInt32(self.flags.rawValue, forKey: "f")
|
|
encoder.encodeInt32(self.acknowledged ? 1 : 0, forKey: "ack")
|
|
}
|
|
|
|
public func withUpdatedFlags(_ flags: OutgoingMessageInfoFlags) -> OutgoingMessageInfoAttribute {
|
|
return OutgoingMessageInfoAttribute(uniqueId: self.uniqueId, flags: flags, acknowledged: self.acknowledged)
|
|
}
|
|
|
|
public func withUpdatedAcknowledged(_ acknowledged: Bool) -> OutgoingMessageInfoAttribute {
|
|
return OutgoingMessageInfoAttribute(uniqueId: self.uniqueId, flags: self.flags, acknowledged: acknowledged)
|
|
}
|
|
}
|