mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-12-22 22:25:57 +00:00
Refactor SyncCore
This commit is contained in:
46
submodules/SyncCore/Sources/InlineBotMessageAttribute.swift
Normal file
46
submodules/SyncCore/Sources/InlineBotMessageAttribute.swift
Normal file
@@ -0,0 +1,46 @@
|
||||
import Foundation
|
||||
#if os(macOS)
|
||||
import PostboxMac
|
||||
#else
|
||||
import Postbox
|
||||
#endif
|
||||
|
||||
public class InlineBotMessageAttribute: MessageAttribute {
|
||||
public let peerId: PeerId?
|
||||
public let title: String?
|
||||
|
||||
public var associatedPeerIds: [PeerId] {
|
||||
if let peerId = self.peerId {
|
||||
return [peerId]
|
||||
} else {
|
||||
return []
|
||||
}
|
||||
}
|
||||
|
||||
public init(peerId: PeerId?, title: String?) {
|
||||
self.peerId = peerId
|
||||
self.title = title
|
||||
}
|
||||
|
||||
required public init(decoder: PostboxDecoder) {
|
||||
if let peerId = decoder.decodeOptionalInt64ForKey("i") {
|
||||
self.peerId = PeerId(peerId)
|
||||
} else {
|
||||
self.peerId = nil
|
||||
}
|
||||
self.title = decoder.decodeOptionalStringForKey("t")
|
||||
}
|
||||
|
||||
public func encode(_ encoder: PostboxEncoder) {
|
||||
if let peerId = self.peerId {
|
||||
encoder.encodeInt64(peerId.toInt64(), forKey: "i")
|
||||
} else {
|
||||
encoder.encodeNil(forKey: "i")
|
||||
}
|
||||
if let title = self.title {
|
||||
encoder.encodeString(title, forKey: "t")
|
||||
} else {
|
||||
encoder.encodeNil(forKey: "t")
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user